Issue #4945: Improved the documenting of boolean arguments in the json module.
Based on patch by Gabriel Genellina.
diff --git a/.gitignore b/.gitignore
index c2b4fc7..a946596 100644
--- a/.gitignore
+++ b/.gitignore
@@ -93,3 +93,4 @@
Tools/msi/obj
Tools/ssl/amd64
Tools/ssl/win32
+.vscode/
diff --git a/.hgignore b/.hgignore
index 58c73fc..15279cd 100644
--- a/.hgignore
+++ b/.hgignore
@@ -2,6 +2,7 @@
.purify
.svn/
^.idea/
+^.vscode/
.DS_Store
Makefile$
Makefile.pre$
diff --git a/.hgtags b/.hgtags
index ed4fc92..b7a7ea4 100644
--- a/.hgtags
+++ b/.hgtags
@@ -148,6 +148,7 @@
737efcadf5a678b184e0fa431aae11276bf06648 v3.4.4
3631bb4a2490292ebf81d3e947ae36da145da564 v3.4.5rc1
619b61e505d0e2ccc8516b366e4ddd1971b46a6f v3.4.5
+3631bb4a2490292ebf81d3e947ae36da145da564 v3.4.5rc1
5d4b6a57d5fd7564bf73f3db0e46fe5eeb00bcd8 v3.5.0a1
0337bd7ebcb6559d69679bc7025059ad1ce4f432 v3.5.0a2
82656e28b5e5c4ae48d8dd8b5f0d7968908a82b6 v3.5.0a3
@@ -165,3 +166,5 @@
37a07cee5969e6d3672583187a73cf636ff28e1b v3.5.1
68feec6488b26327a85a634605dd28eca4daa5f1 v3.5.2rc1
4def2a2901a5618ea45bcc8f2a1411ef33af18ad v3.5.2
+5896da372fb044e38595fb74495de1e1e7c8fb3c v3.6.0a1
+37889342355223e2fc1438de3dc7ffcd625c60f7 v3.6.0a2
diff --git a/Doc/Makefile b/Doc/Makefile
index 878685d..202e8e1 100644
--- a/Doc/Makefile
+++ b/Doc/Makefile
@@ -153,7 +153,7 @@
cp -pPR build/epub/Python.epub dist/python-$(DISTVERSION)-docs.epub
check:
- $(PYTHON) tools/rstlint.py -i tools
+ $(PYTHON) tools/rstlint.py -i tools -i venv
serve:
../Tools/scripts/serve.py build/html
diff --git a/Doc/c-api/arg.rst b/Doc/c-api/arg.rst
index 983d113..d15f649 100644
--- a/Doc/c-api/arg.rst
+++ b/Doc/c-api/arg.rst
@@ -206,8 +206,7 @@
:c:func:`PyArg_ParseTuple` will use this location as the buffer and interpret the
initial value of *\*buffer_length* as the buffer size. It will then copy the
encoded data into the buffer and NUL-terminate it. If the buffer is not large
- enough, a :exc:`TypeError` will be set.
- Note: starting from Python 3.6 a :exc:`ValueError` will be set.
+ enough, a :exc:`ValueError` will be set.
In both cases, *\*buffer_length* is set to the length of the encoded data
without the trailing NUL byte.
@@ -407,8 +406,15 @@
.. c:function:: int PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], ...)
Parse the parameters of a function that takes both positional and keyword
- parameters into local variables. Returns true on success; on failure, it
- returns false and raises the appropriate exception.
+ parameters into local variables. The *keywords* argument is a
+ *NULL*-terminated array of keyword parameter names. Empty names denote
+ :ref:`positional-only parameters <positional-only_parameter>`.
+ Returns true on success; on failure, it returns false and raises the
+ appropriate exception.
+
+ .. versionchanged:: 3.6
+ Added support for :ref:`positional-only parameters
+ <positional-only_parameter>`.
.. c:function:: int PyArg_VaParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], va_list vargs)
diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst
index 19cbb3b..226b619 100644
--- a/Doc/c-api/exceptions.rst
+++ b/Doc/c-api/exceptions.rst
@@ -334,6 +334,14 @@
.. versionadded:: 3.2
+.. c:function:: int PyErr_ResourceWarning(PyObject *source, Py_ssize_t stack_level, const char *format, ...)
+
+ Function similar to :c:func:`PyErr_WarnFormat`, but *category* is
+ :exc:`ResourceWarning` and pass *source* to :func:`warnings.WarningMessage`.
+
+ .. versionadded:: 3.6
+
+
Querying the error indicator
============================
diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst
index 639819c..d77836a 100644
--- a/Doc/c-api/init.rst
+++ b/Doc/c-api/init.rst
@@ -25,7 +25,7 @@
triple: module; search; path
single: PySys_SetArgv()
single: PySys_SetArgvEx()
- single: Py_Finalize()
+ single: Py_FinalizeEx()
Initialize the Python interpreter. In an application embedding Python, this
should be called before using any other Python/C API functions; with the
@@ -34,7 +34,7 @@
modules :mod:`builtins`, :mod:`__main__` and :mod:`sys`. It also initializes
the module search path (``sys.path``). It does not set ``sys.argv``; use
:c:func:`PySys_SetArgvEx` for that. This is a no-op when called for a second time
- (without calling :c:func:`Py_Finalize` first). There is no return value; it is a
+ (without calling :c:func:`Py_FinalizeEx` first). There is no return value; it is a
fatal error if the initialization fails.
@@ -48,19 +48,20 @@
.. c:function:: int Py_IsInitialized()
Return true (nonzero) when the Python interpreter has been initialized, false
- (zero) if not. After :c:func:`Py_Finalize` is called, this returns false until
+ (zero) if not. After :c:func:`Py_FinalizeEx` is called, this returns false until
:c:func:`Py_Initialize` is called again.
-.. c:function:: void Py_Finalize()
+.. c:function:: int Py_FinalizeEx()
Undo all initializations made by :c:func:`Py_Initialize` and subsequent use of
Python/C API functions, and destroy all sub-interpreters (see
:c:func:`Py_NewInterpreter` below) that were created and not yet destroyed since
the last call to :c:func:`Py_Initialize`. Ideally, this frees all memory
allocated by the Python interpreter. This is a no-op when called for a second
- time (without calling :c:func:`Py_Initialize` again first). There is no return
- value; errors during finalization are ignored.
+ time (without calling :c:func:`Py_Initialize` again first). Normally the
+ return value is 0. If there were errors during finalization
+ (flushing buffered data), -1 is returned.
This function is provided for a number of reasons. An embedding application
might want to restart Python without having to restart the application itself.
@@ -79,7 +80,15 @@
freed. Some memory allocated by extension modules may not be freed. Some
extensions may not work properly if their initialization routine is called more
than once; this can happen if an application calls :c:func:`Py_Initialize` and
- :c:func:`Py_Finalize` more than once.
+ :c:func:`Py_FinalizeEx` more than once.
+
+ .. versionadded:: 3.6
+
+
+.. c:function:: void Py_Finalize()
+
+ This is a backwards-compatible version of :c:func:`Py_FinalizeEx` that
+ disregards the return value.
Process-wide parameters
@@ -107,7 +116,7 @@
Note that :data:`sys.stderr` always uses the "backslashreplace" error
handler, regardless of this (or any other) setting.
- If :c:func:`Py_Finalize` is called, this function will need to be called
+ If :c:func:`Py_FinalizeEx` is called, this function will need to be called
again in order to affect subsequent calls to :c:func:`Py_Initialize`.
Returns 0 if successful, a nonzero value on error (e.g. calling after the
@@ -918,7 +927,7 @@
entry.)
.. index::
- single: Py_Finalize()
+ single: Py_FinalizeEx()
single: Py_Initialize()
Extension modules are shared between (sub-)interpreters as follows: the first
@@ -928,7 +937,7 @@
and filled with the contents of this copy; the extension's ``init`` function is
not called. Note that this is different from what happens when an extension is
imported after the interpreter has been completely re-initialized by calling
- :c:func:`Py_Finalize` and :c:func:`Py_Initialize`; in that case, the extension's
+ :c:func:`Py_FinalizeEx` and :c:func:`Py_Initialize`; in that case, the extension's
``initmodule`` function *is* called again.
.. index:: single: close() (in module os)
@@ -936,14 +945,14 @@
.. c:function:: void Py_EndInterpreter(PyThreadState *tstate)
- .. index:: single: Py_Finalize()
+ .. index:: single: Py_FinalizeEx()
Destroy the (sub-)interpreter represented by the given thread state. The given
thread state must be the current thread state. See the discussion of thread
states below. When the call returns, the current thread state is *NULL*. All
thread states associated with this interpreter are destroyed. (The global
interpreter lock must be held before calling this function and is still held
- when it returns.) :c:func:`Py_Finalize` will destroy all sub-interpreters that
+ when it returns.) :c:func:`Py_FinalizeEx` will destroy all sub-interpreters that
haven't been explicitly destroyed at that point.
diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst
index bc3a752..74681d2 100644
--- a/Doc/c-api/intro.rst
+++ b/Doc/c-api/intro.rst
@@ -64,9 +64,10 @@
located in the directories :file:`{prefix}/include/pythonversion/` and
:file:`{exec_prefix}/include/pythonversion/`, where :envvar:`prefix` and
:envvar:`exec_prefix` are defined by the corresponding parameters to Python's
-:program:`configure` script and *version* is ``sys.version[:3]``. On Windows,
-the headers are installed in :file:`{prefix}/include`, where :envvar:`prefix` is
-the installation directory specified to the installer.
+:program:`configure` script and *version* is
+``'%d.%d' % sys.version_info[:2]``. On Windows, the headers are installed
+in :file:`{prefix}/include`, where :envvar:`prefix` is the installation
+directory specified to the installer.
To include the headers, place both directories (if different) on your compiler's
search path for includes. Do *not* place the parent directories on the search
@@ -578,9 +579,9 @@
application may want to start over (make another call to
:c:func:`Py_Initialize`) or the application is simply done with its use of
Python and wants to free memory allocated by Python. This can be accomplished
-by calling :c:func:`Py_Finalize`. The function :c:func:`Py_IsInitialized` returns
+by calling :c:func:`Py_FinalizeEx`. The function :c:func:`Py_IsInitialized` returns
true if Python is currently in the initialized state. More information about
-these functions is given in a later chapter. Notice that :c:func:`Py_Finalize`
+these functions is given in a later chapter. Notice that :c:func:`Py_FinalizeEx`
does *not* free all memory allocated by the Python interpreter, e.g. memory
allocated by extension modules currently cannot be released.
diff --git a/Doc/c-api/memory.rst b/Doc/c-api/memory.rst
index 290ef09..3ff5452 100644
--- a/Doc/c-api/memory.rst
+++ b/Doc/c-api/memory.rst
@@ -85,9 +85,12 @@
.. seealso::
+ The :envvar:`PYTHONMALLOC` environment variable can be used to configure
+ the memory allocators used by Python.
+
The :envvar:`PYTHONMALLOCSTATS` environment variable can be used to print
- memory allocation statistics every time a new object arena is created, and
- on shutdown.
+ statistics of the :ref:`pymalloc memory allocator <pymalloc>` every time a
+ new pymalloc object arena is created, and on shutdown.
Raw Memory Interface
@@ -162,15 +165,17 @@
behavior when requesting zero bytes, are available for allocating and releasing
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.
+By default, these functions use :ref:`pymalloc memory allocator <pymalloc>`.
.. warning::
The :term:`GIL <global interpreter lock>` must be held when using these
functions.
+.. versionchanged:: 3.6
+
+ The default allocator is now pymalloc instead of system :c:func:`malloc`.
+
.. c:function:: void* PyMem_Malloc(size_t n)
Allocates *n* bytes and returns a pointer of type :c:type:`void\*` to the
@@ -292,15 +297,32 @@
Enum used to identify an allocator domain. Domains:
- * :c:data:`PYMEM_DOMAIN_RAW`: functions :c:func:`PyMem_RawMalloc`,
- :c:func:`PyMem_RawRealloc`, :c:func:`PyMem_RawCalloc` and
- :c:func:`PyMem_RawFree`
- * :c:data:`PYMEM_DOMAIN_MEM`: functions :c:func:`PyMem_Malloc`,
- :c:func:`PyMem_Realloc`, :c:func:`PyMem_Calloc` and :c:func:`PyMem_Free`
- * :c:data:`PYMEM_DOMAIN_OBJ`: functions :c:func:`PyObject_Malloc`,
- :c:func:`PyObject_Realloc`, :c:func:`PyObject_Calloc` and
- :c:func:`PyObject_Free`
+ .. c:var:: PYMEM_DOMAIN_RAW
+ Functions:
+
+ * :c:func:`PyMem_RawMalloc`
+ * :c:func:`PyMem_RawRealloc`
+ * :c:func:`PyMem_RawCalloc`
+ * :c:func:`PyMem_RawFree`
+
+ .. c:var:: PYMEM_DOMAIN_MEM
+
+ Functions:
+
+ * :c:func:`PyMem_Malloc`,
+ * :c:func:`PyMem_Realloc`
+ * :c:func:`PyMem_Calloc`
+ * :c:func:`PyMem_Free`
+
+ .. c:var:: PYMEM_DOMAIN_OBJ
+
+ Functions:
+
+ * :c:func:`PyObject_Malloc`
+ * :c:func:`PyObject_Realloc`
+ * :c:func:`PyObject_Calloc`
+ * :c:func:`PyObject_Free`
.. c:function:: void PyMem_GetAllocator(PyMemAllocatorDomain domain, PyMemAllocatorEx *allocator)
@@ -325,43 +347,62 @@
.. c:function:: void PyMem_SetupDebugHooks(void)
- Setup hooks to detect bugs in the following Python memory allocator
- functions:
-
- - :c:func:`PyMem_RawMalloc`, :c:func:`PyMem_RawRealloc`,
- :c:func:`PyMem_RawCalloc`, :c:func:`PyMem_RawFree`
- - :c:func:`PyMem_Malloc`, :c:func:`PyMem_Realloc`, :c:func:`PyMem_Calloc`,
- :c:func:`PyMem_Free`
- - :c:func:`PyObject_Malloc`, :c:func:`PyObject_Realloc`,
- :c:func:`PyObject_Calloc`, :c:func:`PyObject_Free`
+ Setup hooks to detect bugs in the Python memory allocator functions.
Newly allocated memory is filled with the byte ``0xCB``, freed memory is
- filled with the byte ``0xDB``. Additional checks:
+ filled with the byte ``0xDB``.
- - detect API violations, ex: :c:func:`PyObject_Free` called on a buffer
+ Runtime checks:
+
+ - Detect API violations, ex: :c:func:`PyObject_Free` called on a buffer
allocated by :c:func:`PyMem_Malloc`
- - detect write before the start of the buffer (buffer underflow)
- - detect write after the end of the buffer (buffer overflow)
+ - Detect write before the start of the buffer (buffer underflow)
+ - Detect write after the end of the buffer (buffer overflow)
+ - Check that the :term:`GIL <global interpreter lock>` is held when
+ allocator functions of :c:data:`PYMEM_DOMAIN_OBJ` (ex:
+ :c:func:`PyObject_Malloc`) and :c:data:`PYMEM_DOMAIN_MEM` (ex:
+ :c:func:`PyMem_Malloc`) domains are called
- The function does nothing if Python is not compiled is debug mode.
+ On error, the debug hooks use the :mod:`tracemalloc` module to get the
+ traceback where a memory block was allocated. The traceback is only
+ displayed if :mod:`tracemalloc` is tracing Python memory allocations and the
+ memory block was traced.
+
+ These hooks are installed by default if Python is compiled in debug
+ mode. The :envvar:`PYTHONMALLOC` environment variable can be used to install
+ debug hooks on a Python compiled in release mode.
+
+ .. versionchanged:: 3.6
+ This function now also works on Python compiled in release mode.
+ On error, the debug hooks now use :mod:`tracemalloc` to get the traceback
+ where a memory block was allocated. The debug hooks now also check
+ if the GIL is held when functions of :c:data:`PYMEM_DOMAIN_OBJ` and
+ :c:data:`PYMEM_DOMAIN_MEM` domains are called.
-Customize PyObject Arena Allocator
-==================================
+.. _pymalloc:
-Python has a *pymalloc* allocator for allocations smaller than 512 bytes. This
-allocator is optimized for small objects with a short lifetime. It uses memory
-mappings called "arenas" with a fixed size of 256 KB. It falls back to
-:c:func:`PyMem_RawMalloc` and :c:func:`PyMem_RawRealloc` for allocations larger
-than 512 bytes. *pymalloc* is the default allocator used by
-:c:func:`PyObject_Malloc`.
+The pymalloc allocator
+======================
-The default arena allocator uses the following functions:
+Python has a *pymalloc* allocator optimized for small objects (smaller or equal
+to 512 bytes) with a short lifetime. It uses memory mappings called "arenas"
+with a fixed size of 256 KB. It falls back to :c:func:`PyMem_RawMalloc` and
+:c:func:`PyMem_RawRealloc` for allocations larger than 512 bytes.
+
+*pymalloc* is the default allocator of the :c:data:`PYMEM_DOMAIN_MEM` (ex:
+:c:func:`PyObject_Malloc`) and :c:data:`PYMEM_DOMAIN_OBJ` (ex:
+:c:func:`PyObject_Malloc`) domains.
+
+The arena allocator uses the following functions:
* :c:func:`VirtualAlloc` and :c:func:`VirtualFree` on Windows,
* :c:func:`mmap` and :c:func:`munmap` if available,
* :c:func:`malloc` and :c:func:`free` otherwise.
+Customize pymalloc Arena Allocator
+----------------------------------
+
.. versionadded:: 3.4
.. c:type:: PyObjectArenaAllocator
diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst
index cc84314..e9e8add 100644
--- a/Doc/c-api/structures.rst
+++ b/Doc/c-api/structures.rst
@@ -150,8 +150,9 @@
The :attr:`ml_flags` field is a bitfield which can include the following flags.
The individual flags indicate either a calling convention or a binding
convention. Of the calling convention flags, only :const:`METH_VARARGS` and
-:const:`METH_KEYWORDS` can be combined. Any of the calling convention flags
-can be combined with a binding flag.
+:const:`METH_KEYWORDS` can be combined (but note that :const:`METH_KEYWORDS`
+alone is equivalent to ``METH_VARARGS | METH_KEYWORDS``). Any of the calling
+convention flags can be combined with a binding flag.
.. data:: METH_VARARGS
diff --git a/Doc/c-api/sys.rst b/Doc/c-api/sys.rst
index 3d83b27..035cdc1 100644
--- a/Doc/c-api/sys.rst
+++ b/Doc/c-api/sys.rst
@@ -5,6 +5,17 @@
Operating System Utilities
==========================
+.. c:function:: PyObject* PyOS_FSPath(PyObject *path)
+
+ Return the file system representation for *path*. If the object is a
+ :class:`str` or :class:`bytes` object, then its reference count is
+ incremented. If the object implements the :class:`os.PathLike` interface,
+ then :meth:`~os.PathLike.__fspath__` is returned as long as it is a
+ :class:`str` or :class:`bytes` object. Otherwise :exc:`TypeError` is raised
+ and ``NULL`` is returned.
+
+ .. versionadded:: 3.6
+
.. c:function:: int Py_FdIsInteractive(FILE *fp, const char *filename)
@@ -212,20 +223,24 @@
.. c:function:: void Py_Exit(int status)
.. index::
- single: Py_Finalize()
+ single: Py_FinalizeEx()
single: exit()
- Exit the current process. This calls :c:func:`Py_Finalize` and then calls the
- standard C library function ``exit(status)``.
+ Exit the current process. This calls :c:func:`Py_FinalizeEx` and then calls the
+ standard C library function ``exit(status)``. If :c:func:`Py_FinalizeEx`
+ indicates an error, the exit status is set to 120.
+
+ .. versionchanged:: 3.6
+ Errors from finalization no longer ignored.
.. c:function:: int Py_AtExit(void (*func) ())
.. index::
- single: Py_Finalize()
+ single: Py_FinalizeEx()
single: cleanup functions
- Register a cleanup function to be called by :c:func:`Py_Finalize`. The cleanup
+ Register a cleanup function to be called by :c:func:`Py_FinalizeEx`. The cleanup
function will be called with no arguments and should return no value. At most
32 cleanup functions can be registered. When the registration is successful,
:c:func:`Py_AtExit` returns ``0``; on failure, it returns ``-1``. The cleanup
diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat
index e388195..8b469f4 100644
--- a/Doc/data/refcounts.dat
+++ b/Doc/data/refcounts.dat
@@ -921,6 +921,9 @@
PyObject_AsFileDescriptor:int:::
PyObject_AsFileDescriptor:PyObject*:o:0:
+PyOS_FSPath:PyObject*::+1:
+PyOS_FSPath:PyObject*:path:0:
+
PyObject_Call:PyObject*::+1:
PyObject_Call:PyObject*:callable_object:0:
PyObject_Call:PyObject*:args:0:
diff --git a/Doc/extending/embedding.rst b/Doc/extending/embedding.rst
index acd60ae..1546b1a 100644
--- a/Doc/extending/embedding.rst
+++ b/Doc/extending/embedding.rst
@@ -67,7 +67,9 @@
Py_Initialize();
PyRun_SimpleString("from time import time,ctime\n"
"print('Today is', ctime(time()))\n");
- Py_Finalize();
+ if (Py_FinalizeEx() < 0) {
+ exit(120);
+ }
PyMem_RawFree(program);
return 0;
}
@@ -76,7 +78,7 @@
:c:func:`Py_Initialize` to inform the interpreter about paths to Python run-time
libraries. Next, the Python interpreter is initialized with
:c:func:`Py_Initialize`, followed by the execution of a hard-coded Python script
-that prints the date and time. Afterwards, the :c:func:`Py_Finalize` call shuts
+that prints the date and time. Afterwards, the :c:func:`Py_FinalizeEx` call shuts
the interpreter down, followed by the end of the program. In a real program,
you may want to get the Python script from another source, perhaps a text-editor
routine, a file, or a database. Getting the Python code from a file can better
diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst
index 694753e..9c5e20d 100644
--- a/Doc/faq/programming.rst
+++ b/Doc/faq/programming.rst
@@ -838,7 +838,8 @@
To convert, e.g., the number 144 to the string '144', use the built-in type
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:`formatstrings` section, e.g. ``"{:04d}".format(144)`` yields
+the :ref:`f-strings` and :ref:`formatstrings` sections,
+e.g. ``"{:04d}".format(144)`` yields
``'0144'`` and ``"{:.3f}".format(1.0/3.0)`` yields ``'0.333'``.
diff --git a/Doc/glossary.rst b/Doc/glossary.rst
index 45b794f..fe17595 100644
--- a/Doc/glossary.rst
+++ b/Doc/glossary.rst
@@ -718,6 +718,8 @@
def func(foo, bar=None): ...
+ .. _positional-only_parameter:
+
* :dfn:`positional-only`: specifies an argument that can be supplied only
by position. Python has no syntax for defining positional-only
parameters. However, some built-in functions have positional-only
@@ -776,6 +778,16 @@
One of the default :term:`meta path finders <meta path finder>` which
searches an :term:`import path` for modules.
+ path-like object
+ An object representing a file system path. A path-like object is either
+ a :class:`str` or :class:`bytes` object representing a path, or an object
+ implementing the :class:`os.PathLike` protocol. An object that supports
+ the :class:`os.PathLike` protocol can be converted to a :class:`str` or
+ :class:`bytes` file system path by calling the :func:`os.fspath` function;
+ :func:`os.fsdecode` and :func:`os.fsencode` can be used to guarantee a
+ :class:`str` or :class:`bytes` result instead, respectively. Introduced
+ by :pep:`519`.
+
portion
A set of files in a single directory (possibly stored in a zip file)
that contribute to a namespace package, as defined in :pep:`420`.
diff --git a/Doc/howto/argparse.rst b/Doc/howto/argparse.rst
index cfe9868..7a60165 100644
--- a/Doc/howto/argparse.rst
+++ b/Doc/howto/argparse.rst
@@ -547,7 +547,8 @@
Traceback (most recent call last):
File "prog.py", line 11, in <module>
if args.verbosity >= 2:
- TypeError: unorderable types: NoneType() >= int()
+ TypeError: '>=' not supported between instances of 'NoneType' and 'int'
+
* First output went well, and fixes the bug we had before.
That is, we want any value >= 2 to be as verbose as possible.
diff --git a/Doc/includes/run-func.c b/Doc/includes/run-func.c
index 986d670..ead7bdd 100644
--- a/Doc/includes/run-func.c
+++ b/Doc/includes/run-func.c
@@ -63,6 +63,8 @@
fprintf(stderr, "Failed to load \"%s\"\n", argv[1]);
return 1;
}
- Py_Finalize();
+ if (Py_FinalizeEx() < 0) {
+ return 120;
+ }
return 0;
}
diff --git a/Doc/includes/test.py b/Doc/includes/test.py
index 7ebf46a..9e9d4a6 100644
--- a/Doc/includes/test.py
+++ b/Doc/includes/test.py
@@ -204,7 +204,7 @@
import os
import sys
from distutils.util import get_platform
-PLAT_SPEC = "%s-%s" % (get_platform(), sys.version[0:3])
+PLAT_SPEC = "%s-%d.%d" % (get_platform(), *sys.version_info[:2])
src = os.path.join("build", "lib.%s" % PLAT_SPEC)
sys.path.append(src)
diff --git a/Doc/library/asynchat.rst b/Doc/library/asynchat.rst
index ae72d26..e02360c 100644
--- a/Doc/library/asynchat.rst
+++ b/Doc/library/asynchat.rst
@@ -58,13 +58,13 @@
The asynchronous output buffer size (default ``4096``).
Unlike :class:`asyncore.dispatcher`, :class:`async_chat` allows you to
- define a first-in-first-out queue (fifo) of *producers*. A producer need
+ define a :abbr:`FIFO (first-in, first-out)` queue of *producers*. A producer need
have only one method, :meth:`more`, which should return data to be
transmitted on the channel.
The producer indicates exhaustion (*i.e.* that it contains no more data) by
having its :meth:`more` method return the empty bytes object. At this point
- the :class:`async_chat` object removes the producer from the fifo and starts
- using the next producer, if any. When the producer fifo is empty the
+ the :class:`async_chat` object removes the producer from the queue and starts
+ using the next producer, if any. When the producer queue is empty the
:meth:`handle_write` method does nothing. You use the channel object's
:meth:`set_terminator` method to describe how to recognize the end of, or
an important breakpoint in, an incoming transmission from the remote
@@ -78,8 +78,8 @@
.. method:: async_chat.close_when_done()
- Pushes a ``None`` on to the producer fifo. When this producer is popped off
- the fifo it causes the channel to be closed.
+ Pushes a ``None`` on to the producer queue. When this producer is popped off
+ the queue it causes the channel to be closed.
.. method:: async_chat.collect_incoming_data(data)
@@ -92,7 +92,7 @@
.. method:: async_chat.discard_buffers()
In emergencies this method will discard any data held in the input and/or
- output buffers and the producer fifo.
+ output buffers and the producer queue.
.. method:: async_chat.found_terminator()
@@ -110,7 +110,7 @@
.. method:: async_chat.push(data)
- Pushes data on to the channel's fifo to ensure its transmission.
+ Pushes data on to the channel's queue to ensure its transmission.
This is all you need to do to have the channel write the data out to the
network, although it is possible to use your own producers in more complex
schemes to implement encryption and chunking, for example.
@@ -118,7 +118,7 @@
.. method:: async_chat.push_with_producer(producer)
- Takes a producer object and adds it to the producer fifo associated with
+ Takes a producer object and adds it to the producer queue associated with
the channel. When all currently-pushed producers have been exhausted the
channel will consume this producer's data by calling its :meth:`more`
method and send the data to the remote endpoint.
diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst
index 7ec3aa1..809a3e7 100644
--- a/Doc/library/asyncio-eventloop.rst
+++ b/Doc/library/asyncio-eventloop.rst
@@ -101,8 +101,9 @@
called after :meth:`call_soon` returns, when control returns to the event
loop.
- This operates as a FIFO queue, callbacks are called in the order in
- which they are registered. Each callback will be called exactly once.
+ This operates as a :abbr:`FIFO (first-in, first-out)` queue, callbacks
+ are called in the order in which they are registered. Each callback
+ will be called exactly once.
Any positional arguments after the callback will be passed to the
callback when it is called.
diff --git a/Doc/library/binascii.rst b/Doc/library/binascii.rst
index 878d8db..4f5f0f2 100644
--- a/Doc/library/binascii.rst
+++ b/Doc/library/binascii.rst
@@ -53,13 +53,14 @@
than one line may be passed at a time.
-.. function:: b2a_base64(data)
+.. function:: b2a_base64(data, \*, newline=True)
Convert binary data to a line of ASCII characters in base64 coding. The return
- value is the converted line, including a newline char. The newline is
- added because the original use case for this function was to feed it a
- series of 57 byte input lines to get output lines that conform to the
- MIME-base64 standard. Otherwise the output conforms to :rfc:`3548`.
+ value is the converted line, including a newline char if *newline* is
+ true. The output of this function conforms to :rfc:`3548`.
+
+ .. versionchanged:: 3.6
+ Added the *newline* parameter.
.. function:: a2b_qp(data, header=False)
diff --git a/Doc/library/collections.abc.rst b/Doc/library/collections.abc.rst
index 61682cc..5b0fb38 100644
--- a/Doc/library/collections.abc.rst
+++ b/Doc/library/collections.abc.rst
@@ -41,12 +41,13 @@
:class:`Hashable` ``__hash__``
:class:`Iterable` ``__iter__``
:class:`Iterator` :class:`Iterable` ``__next__`` ``__iter__``
+:class:`Reversible` :class:`Iterable` ``__reversed__``
:class:`Generator` :class:`Iterator` ``send``, ``throw`` ``close``, ``__iter__``, ``__next__``
:class:`Sized` ``__len__``
:class:`Callable` ``__call__``
:class:`Sequence` :class:`Sized`, ``__getitem__``, ``__contains__``, ``__iter__``, ``__reversed__``,
- :class:`Iterable`, ``__len__`` ``index``, and ``count``
+ :class:`Reversible`, ``__len__`` ``index``, and ``count``
:class:`Container`
:class:`MutableSequence` :class:`Sequence` ``__getitem__``, Inherited :class:`Sequence` methods and
@@ -108,6 +109,12 @@
:meth:`~iterator.__next__` methods. See also the definition of
:term:`iterator`.
+.. class:: Reversible
+
+ ABC for classes that provide the :meth:`__reversed__` method.
+
+ .. versionadded:: 3.6
+
.. class:: Generator
ABC for generator classes that implement the protocol defined in
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
index 4936b3a..1758f32 100644
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -964,6 +964,9 @@
constructor that is convenient for use cases where named tuples are being
subclassed.
+ * :meth:`types.SimpleNamespace` for a mutable namespace based on an underlying
+ dictionary instead of a tuple.
+
:class:`OrderedDict` objects
----------------------------
@@ -985,8 +988,9 @@
.. method:: popitem(last=True)
The :meth:`popitem` method for ordered dictionaries returns and removes a
- (key, value) pair. The pairs are returned in LIFO order if *last* is true
- or FIFO order if false.
+ (key, value) pair. The pairs are returned in
+ :abbr:`LIFO (last-in, first-out)` order if *last* is true
+ or :abbr:`FIFO (first-in, first-out)` order if false.
.. method:: move_to_end(key, last=True)
diff --git a/Doc/library/compileall.rst b/Doc/library/compileall.rst
index 511c581..91bdd18 100644
--- a/Doc/library/compileall.rst
+++ b/Doc/library/compileall.rst
@@ -102,7 +102,8 @@
.. function:: compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, workers=1)
Recursively descend the directory tree named by *dir*, compiling all :file:`.py`
- files along the way.
+ files along the way. Return a true value if all the files compiled successfully,
+ and a false value otherwise.
The *maxlevels* parameter is used to limit the depth of the recursion; it
defaults to ``10``.
@@ -154,7 +155,8 @@
.. function:: compile_file(fullname, ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1)
- Compile the file with path *fullname*.
+ Compile the file with path *fullname*. Return a true value if the file
+ compiled successfully, and a false value otherwise.
If *ddir* is given, it is prepended to the path to the file being compiled
for use in compilation time tracebacks, and is also compiled in to the
@@ -190,8 +192,10 @@
.. function:: compile_path(skip_curdir=True, maxlevels=0, force=False, quiet=0, legacy=False, optimize=-1)
- Byte-compile all the :file:`.py` files found along ``sys.path``. If
- *skip_curdir* is true (the default), the current directory is not included
+ Byte-compile all the :file:`.py` files found along ``sys.path``. Return a
+ true value if all the files compiled successfully, and a false value otherwise.
+
+ If *skip_curdir* is true (the default), the current directory is not included
in the search. All other parameters are passed to the :func:`compile_dir`
function. Note that unlike the other compile functions, ``maxlevels``
defaults to ``0``.
diff --git a/Doc/library/contextlib.rst b/Doc/library/contextlib.rst
index cf85fcd..810cea8 100644
--- a/Doc/library/contextlib.rst
+++ b/Doc/library/contextlib.rst
@@ -18,6 +18,18 @@
Functions and classes provided:
+.. class:: AbstractContextManager
+
+ An :term:`abstract base class` for classes that implement
+ :meth:`object.__enter__` and :meth:`object.__exit__`. A default
+ implementation for :meth:`object.__enter__` is provided which returns
+ ``self`` while :meth:`object.__exit__` is an abstract method which by default
+ returns ``None``. See also the definition of :ref:`typecontextmanager`.
+
+ .. versionadded:: 3.6
+
+
+
.. decorator:: contextmanager
This function is a :term:`decorator` that can be used to define a factory
@@ -447,9 +459,9 @@
acquisition and release functions, along with an optional validation function,
and maps them to the context management protocol::
- from contextlib import contextmanager, ExitStack
+ from contextlib import contextmanager, AbstractContextManager, ExitStack
- class ResourceManager:
+ class ResourceManager(AbstractContextManager):
def __init__(self, acquire_resource, release_resource, check_resource_ok=None):
self.acquire_resource = acquire_resource
diff --git a/Doc/library/crypt.rst b/Doc/library/crypt.rst
index a21c1e7..dbd4274 100644
--- a/Doc/library/crypt.rst
+++ b/Doc/library/crypt.rst
@@ -68,7 +68,7 @@
A list of available password hashing algorithms, as
``crypt.METHOD_*`` objects. This list is sorted from strongest to
- weakest, and is guaranteed to have at least ``crypt.METHOD_CRYPT``.
+ weakest.
Module Functions
diff --git a/Doc/library/crypto.rst b/Doc/library/crypto.rst
index 1eddfdc..ae45549 100644
--- a/Doc/library/crypto.rst
+++ b/Doc/library/crypto.rst
@@ -16,3 +16,4 @@
hashlib.rst
hmac.rst
+ secrets.rst
diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst
index 9254ae8..cd78750 100644
--- a/Doc/library/datetime.rst
+++ b/Doc/library/datetime.rst
@@ -610,7 +610,8 @@
.. method:: date.__format__(format)
Same as :meth:`.date.strftime`. This makes it possible to specify a format
- string for a :class:`.date` object when using :meth:`str.format`. For a
+ string for a :class:`.date` object in :ref:`formatted string
+ literals <f-strings>` and when using :meth:`str.format`. For a
complete list of formatting directives, see
:ref:`strftime-strptime-behavior`.
@@ -1138,7 +1139,7 @@
``self.date().isocalendar()``.
-.. method:: datetime.isoformat(sep='T')
+.. method:: datetime.isoformat(sep='T', timespec='auto')
Return a string representing the date and time in ISO 8601 format,
YYYY-MM-DDTHH:MM:SS.mmmmmm or, if :attr:`microsecond` is 0,
@@ -1159,6 +1160,37 @@
>>> datetime(2002, 12, 25, tzinfo=TZ()).isoformat(' ')
'2002-12-25 00:00:00-06:39'
+ The optional argument *timespec* specifies the number of additional
+ components of the time to include (the default is ``'auto'``).
+ It can be one of the following:
+
+ - ``'auto'``: Same as ``'seconds'`` if :attr:`microsecond` is 0,
+ same as ``'microseconds'`` otherwise.
+ - ``'hours'``: Include the :attr:`hour` in the two-digit HH format.
+ - ``'minutes'``: Include :attr:`hour` and :attr:`minute` in HH:MM format.
+ - ``'seconds'``: Include :attr:`hour`, :attr:`minute`, and :attr:`second`
+ in HH:MM:SS format.
+ - ``'milliseconds'``: Include full time, but truncate fractional second
+ part to milliseconds. HH:MM:SS.sss format.
+ - ``'microseconds'``: Include full time in HH:MM:SS.mmmmmm format.
+
+ .. note::
+
+ Excluded time components are truncated, not rounded.
+
+ :exc:`ValueError` will be raised on an invalid *timespec* argument.
+
+
+ >>> from datetime import datetime
+ >>> datetime.now().isoformat(timespec='minutes')
+ '2002-12-25T00:00'
+ >>> dt = datetime(2015, 1, 1, 12, 30, 59, 0)
+ >>> dt.isoformat(timespec='microseconds')
+ '2015-01-01T12:30:59.000000'
+
+ .. versionadded:: 3.6
+ Added the *timespec* argument.
+
.. method:: datetime.__str__()
@@ -1185,7 +1217,8 @@
.. method:: datetime.__format__(format)
Same as :meth:`.datetime.strftime`. This makes it possible to specify a format
- string for a :class:`.datetime` object when using :meth:`str.format`. For a
+ string for a :class:`.datetime` object in :ref:`formatted string
+ literals <f-strings>` and when using :meth:`str.format`. For a
complete list of formatting directives, see
:ref:`strftime-strptime-behavior`.
@@ -1407,13 +1440,46 @@
aware :class:`.time`, without conversion of the time data.
-.. method:: time.isoformat()
+.. method:: time.isoformat(timespec='auto')
Return a string representing the time in ISO 8601 format, HH:MM:SS.mmmmmm or, if
- self.microsecond is 0, HH:MM:SS If :meth:`utcoffset` does not return ``None``, a
+ :attr:`microsecond` is 0, HH:MM:SS If :meth:`utcoffset` does not return ``None``, a
6-character string is appended, giving the UTC offset in (signed) hours and
minutes: HH:MM:SS.mmmmmm+HH:MM or, if self.microsecond is 0, HH:MM:SS+HH:MM
+ The optional argument *timespec* specifies the number of additional
+ components of the time to include (the default is ``'auto'``).
+ It can be one of the following:
+
+ - ``'auto'``: Same as ``'seconds'`` if :attr:`microsecond` is 0,
+ same as ``'microseconds'`` otherwise.
+ - ``'hours'``: Include the :attr:`hour` in the two-digit HH format.
+ - ``'minutes'``: Include :attr:`hour` and :attr:`minute` in HH:MM format.
+ - ``'seconds'``: Include :attr:`hour`, :attr:`minute`, and :attr:`second`
+ in HH:MM:SS format.
+ - ``'milliseconds'``: Include full time, but truncate fractional second
+ part to milliseconds. HH:MM:SS.sss format.
+ - ``'microseconds'``: Include full time in HH:MM:SS.mmmmmm format.
+
+ .. note::
+
+ Excluded time components are truncated, not rounded.
+
+ :exc:`ValueError` will be raised on an invalid *timespec* argument.
+
+
+ >>> from datetime import time
+ >>> time(hour=12, minute=34, second=56, microsecond=123456).isoformat(timespec='minutes')
+ '12:34'
+ >>> dt = time(hour=12, minute=34, second=56, microsecond=0)
+ >>> dt.isoformat(timespec='microseconds')
+ '12:34:56.000000'
+ >>> dt.isoformat(timespec='auto')
+ '12:34:56'
+
+ .. versionadded:: 3.6
+ Added the *timespec* argument.
+
.. method:: time.__str__()
@@ -1430,7 +1496,8 @@
.. method:: time.__format__(format)
Same as :meth:`.time.strftime`. This makes it possible to specify a format string
- for a :class:`.time` object when using :meth:`str.format`. For a
+ for a :class:`.time` object in :ref:`formatted string
+ literals <f-strings>` and when using :meth:`str.format`. For a
complete list of formatting directives, see
:ref:`strftime-strptime-behavior`.
@@ -1741,10 +1808,7 @@
otherwise :exc:`ValueError` is raised.
The *name* argument is optional. If specified it must be a string that
- is used as the value returned by the ``tzname(dt)`` method. Otherwise,
- ``tzname(dt)`` returns a string 'UTCsHH:MM', where s is the sign of
- *offset*, HH and MM are two digits of ``offset.hours`` and
- ``offset.minutes`` respectively.
+ will be used as the value returned by the :meth:`datetime.tzname` method.
.. versionadded:: 3.2
@@ -1757,11 +1821,19 @@
.. method:: timezone.tzname(dt)
- Return the fixed value specified when the :class:`timezone` instance is
- constructed or a string 'UTCsHH:MM', where s is the sign of
- *offset*, HH and MM are two digits of ``offset.hours`` and
+ Return the fixed value specified when the :class:`timezone` instance
+ is constructed. If *name* is not provided in the constructor, the
+ name returned by ``tzname(dt)`` is generated from the value of the
+ ``offset`` as follows. If *offset* is ``timedelta(0)``, the name
+ is "UTC", otherwise it is a string 'UTC±HH:MM', where ± is the sign
+ of ``offset``, HH and MM are two digits of ``offset.hours`` and
``offset.minutes`` respectively.
+ .. versionchanged:: 3.6
+ Name generated from ``offset=timedelta(0)`` is now plain 'UTC', not
+ 'UTC+00:00'.
+
+
.. method:: timezone.dst(dt)
Always returns ``None``.
@@ -1911,6 +1983,34 @@
| ``%%`` | A literal ``'%'`` character. | % | |
+-----------+--------------------------------+------------------------+-------+
+Several additional directives not required by the C89 standard are included for
+convenience. These parameters all correspond to ISO 8601 date values. These
+may not be available on all platforms when used with the :meth:`strftime`
+method. The ISO 8601 year and ISO 8601 week directives are not interchangeable
+with the year and week number directives above. Calling :meth:`strptime` with
+incomplete or ambiguous ISO 8601 directives will raise a :exc:`ValueError`.
+
++-----------+--------------------------------+------------------------+-------+
+| Directive | Meaning | Example | Notes |
++===========+================================+========================+=======+
+| ``%G`` | ISO 8601 year with century | 0001, 0002, ..., 2013, | \(8) |
+| | representing the year that | 2014, ..., 9998, 9999 | |
+| | contains the greater part of | | |
+| | the ISO week (``%V``). | | |
++-----------+--------------------------------+------------------------+-------+
+| ``%u`` | ISO 8601 weekday as a decimal | 1, 2, ..., 7 | |
+| | number where 1 is Monday. | | |
++-----------+--------------------------------+------------------------+-------+
+| ``%V`` | ISO 8601 week as a decimal | 01, 02, ..., 53 | \(8) |
+| | number with Monday as | | |
+| | the first day of the week. | | |
+| | Week 01 is the week containing | | |
+| | Jan 4. | | |
++-----------+--------------------------------+------------------------+-------+
+
+.. versionadded:: 3.6
+ ``%G``, ``%u`` and ``%V`` were added.
+
Notes:
(1)
@@ -1975,7 +2075,14 @@
(7)
When used with the :meth:`strptime` method, ``%U`` and ``%W`` are only used
- in calculations when the day of the week and the year are specified.
+ in calculations when the day of the week and the calendar year (``%Y``)
+ are specified.
+
+(8)
+ Similar to ``%U`` and ``%W``, ``%V`` is only used in calculations when the
+ day of the week and the ISO year (``%G``) are specified in a
+ :meth:`strptime` format string. Also note that ``%G`` and ``%Y`` are not
+ interchangeable.
.. rubric:: Footnotes
diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst
index 528f97b..9edc696 100644
--- a/Doc/library/decimal.rst
+++ b/Doc/library/decimal.rst
@@ -447,6 +447,19 @@
``Decimal('321e+5').adjusted()`` returns seven. Used for determining the
position of the most significant digit with respect to the decimal point.
+ .. method:: as_integer_ratio()
+
+ Return a pair ``(n, d)`` of integers that represent the given
+ :class:`Decimal` instance as a fraction, in lowest terms and
+ with a positive denominator::
+
+ >>> Decimal('-3.14').as_integer_ratio()
+ (-157, 50)
+
+ The conversion is exact. Raise OverflowError on infinities and ValueError
+ on NaNs.
+
+ .. versionadded:: 3.6
.. method:: as_tuple()
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst
index d2d8ac7..245b4d2 100644
--- a/Doc/library/dis.rst
+++ b/Doc/library/dis.rst
@@ -31,9 +31,9 @@
>>> dis.dis(myfunc)
2 0 LOAD_GLOBAL 0 (len)
- 3 LOAD_FAST 0 (alist)
- 6 CALL_FUNCTION 1
- 9 RETURN_VALUE
+ 2 LOAD_FAST 0 (alist)
+ 4 CALL_FUNCTION 1
+ 6 RETURN_VALUE
(The "2" is a line number).
@@ -682,8 +682,7 @@
.. XXX explain the WHY stuff!
-All of the following opcodes expect arguments. An argument is two bytes, with
-the more significant byte last.
+All of the following opcodes use their arguments.
.. opcode:: STORE_NAME (namei)
@@ -769,6 +768,15 @@
to hold *count* entries.
+.. opcode:: BUILD_CONST_KEY_MAP (count)
+
+ The version of :opcode:`BUILD_MAP` specialized for constant keys. *count*
+ values are consumed from the stack. The top element on the stack contains
+ a tuple of keys.
+
+ .. versionadded:: 3.6
+
+
.. opcode:: LOAD_ATTR (namei)
Replaces TOS with ``getattr(TOS, co_names[namei])``.
@@ -929,27 +937,16 @@
.. opcode:: MAKE_FUNCTION (argc)
Pushes a new function object on the stack. From bottom to top, the consumed
- stack must consist of
+ stack must consist of values if the argument carries a specified flag value
- * ``argc & 0xFF`` default argument objects in positional order
- * ``(argc >> 8) & 0xFF`` pairs of name and default argument, with the name
- just below the object on the stack, for keyword-only parameters
- * ``(argc >> 16) & 0x7FFF`` parameter annotation objects
- * a tuple listing the parameter names for the annotations (only if there are
- ony annotation objects)
+ * ``0x01`` a tuple of default argument objects in positional order
+ * ``0x02`` a dictionary of keyword-only parameters' default values
+ * ``0x04`` an annotation dictionary
+ * ``0x08`` a tuple containing cells for free variables, making a closure
* the code associated with the function (at TOS1)
* the :term:`qualified name` of the function (at TOS)
-.. opcode:: MAKE_CLOSURE (argc)
-
- Creates a new function object, sets its *__closure__* slot, and pushes it on
- the stack. TOS is the :term:`qualified name` of the function, TOS1 is the
- code associated with the function, and TOS2 is the tuple containing cells for
- the closure's free variables. *argc* is interpreted as in ``MAKE_FUNCTION``;
- the annotations and defaults are also in the same order below TOS2.
-
-
.. opcode:: BUILD_SLICE (argc)
.. index:: builtin: slice
@@ -989,6 +986,28 @@
arguments.
+.. opcode:: FORMAT_VALUE (flags)
+
+ Used for implementing formatted literal strings (f-strings). Pops
+ an optional *fmt_spec* from the stack, then a required *value*.
+ *flags* is interpreted as follows:
+
+ * ``(flags & 0x03) == 0x00``: *value* is formatted as-is.
+ * ``(flags & 0x03) == 0x01``: call :func:`str` on *value* before
+ formatting it.
+ * ``(flags & 0x03) == 0x02``: call :func:`repr` on *value* before
+ formatting it.
+ * ``(flags & 0x03) == 0x03``: call :func:`ascii` on *value* before
+ formatting it.
+ * ``(flags & 0x04) == 0x04``: pop *fmt_spec* from the stack and use
+ it, else use an empty *fmt_spec*.
+
+ Formatting is performed using :c:func:`PyObject_Format`. The
+ result is pushed on the stack.
+
+ .. versionadded:: 3.6
+
+
.. opcode:: HAVE_ARGUMENT
This is not really an opcode. It identifies the dividing line between
diff --git a/Doc/library/enum.rst b/Doc/library/enum.rst
index a3d5afc..2111d1c 100644
--- a/Doc/library/enum.rst
+++ b/Doc/library/enum.rst
@@ -558,7 +558,8 @@
4. %-style formatting: `%s` and `%r` call the :class:`Enum` class's
:meth:`__str__` and :meth:`__repr__` respectively; other codes (such as
`%i` or `%h` for IntEnum) treat the enum member as its mixed-in type.
-5. :meth:`str.format` (or :func:`format`) will use the mixed-in
+5. :ref:`Formatted string literals <f-strings>`, :meth:`str.format`,
+ and :func:`format` will use the mixed-in
type's :meth:`__format__`. If the :class:`Enum` class's :func:`str` or
:func:`repr` is desired, use the `!s` or `!r` format codes.
@@ -747,6 +748,15 @@
.. versionchanged:: 3.5
+Boolean evaluation: Enum classes that are mixed with non-Enum types (such as
+:class:`int`, :class:`str`, etc.) are evaluated according to the mixed-in
+type's rules; otherwise, all members evaluate as ``True``. To make your own
+Enum's boolean evaluation depend on the member's value add the following to
+your class::
+
+ def __bool__(self):
+ return bool(self.value)
+
The :attr:`__members__` attribute is only available on the class.
If you give your :class:`Enum` subclass extra methods, like the `Planet`_
diff --git a/Doc/library/faulthandler.rst b/Doc/library/faulthandler.rst
index deedea1..d0c4cd0 100644
--- a/Doc/library/faulthandler.rst
+++ b/Doc/library/faulthandler.rst
@@ -70,6 +70,9 @@
.. versionchanged:: 3.5
Added support for passing file descriptor to this function.
+ .. versionchanged:: 3.6
+ On Windows, a handler for Windows exception is also installed.
+
.. function:: disable()
Disable the fault handler: uninstall the signal handlers installed by
diff --git a/Doc/library/fileinput.rst b/Doc/library/fileinput.rst
index aa4c529..5881fef 100644
--- a/Doc/library/fileinput.rst
+++ b/Doc/library/fileinput.rst
@@ -72,9 +72,8 @@
.. versionchanged:: 3.2
Can be used as a context manager.
- .. versionchanged:: 3.5.2
- The *bufsize* parameter is no longer used.
-
+ .. deprecated-removed:: 3.6 3.8
+ The *bufsize* parameter.
The following functions use the global state created by :func:`fileinput.input`;
if there is no active state, :exc:`RuntimeError` is raised.
@@ -167,8 +166,8 @@
.. deprecated:: 3.4
The ``'rU'`` and ``'U'`` modes.
- .. versionchanged:: 3.5.2
- The *bufsize* parameter is no longer used.
+ .. deprecated-removed:: 3.6 3.8
+ The *bufsize* parameter.
**Optional in-place filtering:** if the keyword argument ``inplace=True`` is
@@ -195,10 +194,14 @@
Usage example: ``fi = fileinput.FileInput(openhook=fileinput.hook_compressed)``
-.. function:: hook_encoded(encoding)
+.. function:: hook_encoded(encoding, errors=None)
Returns a hook which opens each file with :func:`open`, using the given
- *encoding* to read the file.
+ *encoding* and *errors* to read the file.
Usage example: ``fi =
- fileinput.FileInput(openhook=fileinput.hook_encoded("iso-8859-1"))``
+ fileinput.FileInput(openhook=fileinput.hook_encoded("utf-8",
+ "surrogateescape"))``
+
+ .. versionchanged:: 3.6
+ Added the optional *errors* parameter.
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index efa5bd3..7216f1d 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -878,11 +878,11 @@
Open *file* and return a corresponding :term:`file object`. If the file
cannot be opened, an :exc:`OSError` is raised.
- *file* is either a string or bytes object giving the pathname (absolute or
- relative to the current working directory) of the file to be opened or
- an integer file descriptor of the file to be wrapped. (If a file descriptor
- is given, it is closed when the returned I/O object is closed, unless
- *closefd* is set to ``False``.)
+ *file* is either a string, bytes, or :class:`os.PathLike` object giving the
+ pathname (absolute or relative to the current working directory) of the file
+ to be opened or an integer file descriptor of the file to be wrapped. (If a
+ file descriptor is given, it is closed when the returned I/O object is
+ closed, unless *closefd* is set to ``False``.)
*mode* is an optional string that specifies the mode in which the file is
opened. It defaults to ``'r'`` which means open for reading in text mode.
@@ -1077,6 +1077,9 @@
.. versionchanged:: 3.5
The ``'namereplace'`` error handler was added.
+ .. versionchanged:: 3.6
+ Support added to accept objects implementing :class:`os.PathLike`.
+
.. function:: ord(c)
Given a string representing one Unicode character, return an integer
diff --git a/Doc/library/grp.rst b/Doc/library/grp.rst
index a30e622..74de3f9 100644
--- a/Doc/library/grp.rst
+++ b/Doc/library/grp.rst
@@ -43,6 +43,9 @@
Return the group database entry for the given numeric group ID. :exc:`KeyError`
is raised if the entry asked for cannot be found.
+ .. deprecated:: 3.6
+ Since Python 3.6 the support of non-integer arguments like floats or
+ strings in :func:`getgrgid` is deprecated.
.. function:: getgrnam(name)
diff --git a/Doc/library/hashlib.rst b/Doc/library/hashlib.rst
index 30be335..93bcc91 100644
--- a/Doc/library/hashlib.rst
+++ b/Doc/library/hashlib.rst
@@ -39,8 +39,8 @@
---------------
There is one constructor method named for each type of :dfn:`hash`. All return
-a hash object with the same simple interface. For example: use :func:`sha1` to
-create a SHA1 hash object. You can now feed this object with :term:`bytes-like
+a hash object with the same simple interface. For example: use :func:`sha256` to
+create a SHA-256 hash object. You can now feed this object with :term:`bytes-like
objects <bytes-like object>` (normally :class:`bytes`) using the :meth:`update` method.
At any point you can ask it for the :dfn:`digest` of the
concatenation of the data fed to it so far using the :meth:`digest` or
@@ -59,21 +59,23 @@
.. index:: single: OpenSSL; (use in module hashlib)
Constructors for hash algorithms that are always present in this module are
-:func:`md5`, :func:`sha1`, :func:`sha224`, :func:`sha256`, :func:`sha384`,
-and :func:`sha512`. Additional algorithms may also be available depending upon
-the OpenSSL library that Python uses on your platform.
+:func:`sha1`, :func:`sha224`, :func:`sha256`, :func:`sha384`,
+and :func:`sha512`. :func:`md5` is normally available as well, though it
+may be missing if you are using a rare "FIPS compliant" build of Python.
+Additional algorithms may also be available depending upon the OpenSSL
+library that Python uses on your platform.
For example, to obtain the digest of the byte string ``b'Nobody inspects the
spammish repetition'``::
>>> import hashlib
- >>> m = hashlib.md5()
+ >>> m = hashlib.sha256()
>>> m.update(b"Nobody inspects")
>>> m.update(b" the spammish repetition")
>>> m.digest()
- b'\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd9\xde\xc9\xa1\x8d\xf0\xff\xe9'
+ b'\x03\x1e\xdd}Ae\x15\x93\xc5\xfe\\\x00o\xa5u+7\xfd\xdf\xf7\xbcN\x84:\xa6\xaf\x0c\x95\x0fK\x94\x06'
>>> m.digest_size
- 16
+ 32
>>> m.block_size
64
@@ -102,7 +104,9 @@
.. data:: algorithms_guaranteed
A set containing the names of the hash algorithms guaranteed to be supported
- by this module on all platforms.
+ by this module on all platforms. Note that 'md5' is in this list despite
+ some upstream vendors offering an odd "FIPS compliant" Python build that
+ excludes it.
.. versionadded:: 3.2
diff --git a/Doc/library/http.server.rst b/Doc/library/http.server.rst
index 16c4fac..c1ea873 100644
--- a/Doc/library/http.server.rst
+++ b/Doc/library/http.server.rst
@@ -98,8 +98,8 @@
.. attribute:: rfile
- Contains an input stream, positioned at the start of the optional input
- data.
+ An :class:`io.BufferedIOBase` input stream, ready to read from
+ the start of the optional input data.
.. attribute:: wfile
@@ -107,6 +107,9 @@
client. Proper adherence to the HTTP protocol must be used when writing to
this stream.
+ .. versionchanged:: 3.6
+ This is an :class:`io.BufferedIOBase` stream.
+
:class:`BaseHTTPRequestHandler` has the following attributes:
.. attribute:: server_version
@@ -369,10 +372,9 @@
Handler = http.server.SimpleHTTPRequestHandler
- httpd = socketserver.TCPServer(("", PORT), Handler)
-
- print("serving at port", PORT)
- httpd.serve_forever()
+ with socketserver.TCPServer(("", PORT), Handler) as httpd:
+ print("serving at port", PORT)
+ httpd.serve_forever()
.. _http-server-cli:
diff --git a/Doc/library/imaplib.rst b/Doc/library/imaplib.rst
index c25e7d8..b9b3b91 100644
--- a/Doc/library/imaplib.rst
+++ b/Doc/library/imaplib.rst
@@ -500,6 +500,17 @@
M.store(num, '+FLAGS', '\\Deleted')
M.expunge()
+ .. note::
+
+ Creating flags containing ']' (for example: "[test]") violates
+ :rfc:`3501` (the IMAP protocol). However, imaplib has historically
+ allowed creation of such tags, and popular IMAP servers, such as Gmail,
+ accept and produce such flags. There are non-Python programs which also
+ create such tags. Although it is an RFC violation and IMAP clients and
+ servers are supposed to be strict, imaplib nonetheless continues to allow
+ such tags to be created for backward compatibility reasons, and as of
+ python 3.6, handles them if they are sent from the server, since this
+ improves real-world compatibility.
.. method:: IMAP4.subscribe(mailbox)
diff --git a/Doc/library/imp.rst b/Doc/library/imp.rst
index 9828ba6..ccf5f92 100644
--- a/Doc/library/imp.rst
+++ b/Doc/library/imp.rst
@@ -85,7 +85,9 @@
.. 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`.
+ :func:`importlib.find_loader`. For example usage of the former case,
+ see the :ref:`importlib-examples` section of the :mod:`importlib`
+ documentation.
.. function:: load_module(name, file, pathname, description)
@@ -112,9 +114,12 @@
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()``.
+ called :func:`imp.load_module` and related functions directly with file
+ path arguments then use a combination of
+ :func:`importlib.util.spec_from_file_location` and
+ :func:`importlib.util.module_from_spec`. See the :ref:`importlib-examples`
+ section of the :mod:`importlib` documentation for details of the various
+ approaches.
.. function:: new_module(name)
@@ -123,7 +128,7 @@
in ``sys.modules``.
.. deprecated:: 3.4
- Use :class:`types.ModuleType` instead.
+ Use :func:`importlib.util.module_from_spec` instead.
.. function:: reload(module)
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
index ff7cc91..c1c3b12 100644
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -267,7 +267,7 @@
module and *path* will be the value of :attr:`__path__` from the
parent package. If a spec cannot be found, ``None`` is returned.
When passed in, ``target`` is a module object that the finder may
- use to make a more educated about what spec to return.
+ use to make a more educated guess about what spec to return.
.. versionadded:: 3.4
@@ -317,7 +317,7 @@
within the :term:`path entry` to which it is assigned. If a spec
cannot be found, ``None`` is returned. When passed in, ``target``
is a module object that the finder may use to make a more educated
- about what spec to return.
+ guess about what spec to return.
.. versionadded:: 3.4
@@ -379,10 +379,14 @@
An abstract method that executes the module in its own namespace
when a module is imported or reloaded. The module should already
- be initialized when exec_module() is called.
+ be initialized when ``exec_module()`` is called. When this method exists,
+ :meth:`~importlib.abc.Loader.create_module` must be defined.
.. versionadded:: 3.4
+ .. versionchanged:: 3.6
+ :meth:`~importlib.abc.Loader.create_module` must also be defined.
+
.. method:: load_module(fullname)
A legacy method for loading a module. If the module cannot be
@@ -936,6 +940,10 @@
Concrete implementation of :meth:`importlib.abc.Loader.load_module` where
specifying the name of the module to load is optional.
+ .. deprecated:: 3.6
+
+ Use :meth:`importlib.abc.Loader.exec_module` instead.
+
.. class:: SourcelessFileLoader(fullname, path)
@@ -975,6 +983,10 @@
Concrete implementation of :meth:`importlib.abc.Loader.load_module` where
specifying the name of the module to load is optional.
+ .. deprecated:: 3.6
+
+ Use :meth:`importlib.abc.Loader.exec_module` instead.
+
.. class:: ExtensionFileLoader(fullname, path)
@@ -1192,12 +1204,13 @@
.. function:: module_from_spec(spec)
- Create a new module based on **spec** and ``spec.loader.create_module()``.
+ Create a new module based on **spec** and
+ :meth:`spec.loader.create_module <importlib.abc.Loader.create_module>`.
- If ``spec.loader.create_module()`` does not return ``None``, then any
- pre-existing attributes will not be reset. Also, no :exc:`AttributeError`
- will be raised if triggered while accessing **spec** or setting an attribute
- on the module.
+ If :meth:`spec.loader.create_module <importlib.abc.Loader.create_module>`
+ does not return ``None``, then any pre-existing attributes will not be reset.
+ Also, no :exc:`AttributeError` will be raised if triggered while accessing
+ **spec** or setting an attribute on the module.
This function is preferred over using :class:`types.ModuleType` to create a
new module as **spec** is used to set as many import-controlled attributes on
@@ -1259,7 +1272,8 @@
.. decorator:: set_package
- A :term:`decorator` for :meth:`importlib.abc.Loader.load_module` to set the :attr:`__package__` attribute on the returned module. If :attr:`__package__`
+ A :term:`decorator` for :meth:`importlib.abc.Loader.load_module` to set the
+ :attr:`__package__` attribute on the returned module. If :attr:`__package__`
is set and has a value other than ``None`` it will not be changed.
.. deprecated:: 3.4
@@ -1292,13 +1306,12 @@
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 those same reasons, the loader's
- :meth:`~importlib.abc.Loader.create_module` method will be ignored (i.e., the
- loader's method should only return ``None``; this excludes
- :class:`BuiltinImporter` and :class:`ExtensionFileLoader`). 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.
+ :meth:`~importlib.abc.Loader.create_module` method must return ``None`` or a
+ type for which its ``__class__`` attribute can be mutated along with not
+ using :term:`slots <__slots__>`. 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
@@ -1309,6 +1322,11 @@
.. versionadded:: 3.5
+ .. versionchanged:: 3.6
+ Began calling :meth:`~importlib.abc.Loader.create_module`, removing the
+ compatibility warning for :class:`importlib.machinery.BuiltinImporter` and
+ :class:`importlib.machinery.ExtensionFileLoader`.
+
.. classmethod:: factory(loader)
A static method which returns a callable that creates a lazy loader. This
@@ -1320,3 +1338,120 @@
loader = importlib.machinery.SourceFileLoader
lazy_loader = importlib.util.LazyLoader.factory(loader)
finder = importlib.machinery.FileFinder(path, (lazy_loader, suffixes))
+
+.. _importlib-examples:
+
+Examples
+--------
+
+To programmatically import a module, use :func:`importlib.import_module`.
+::
+
+ import importlib
+
+ itertools = importlib.import_module('itertools')
+
+If you need to find out if a module can be imported without actually doing the
+import, then you should use :func:`importlib.util.find_spec`.
+::
+
+ import importlib.util
+ import sys
+
+ # For illustrative purposes.
+ name = 'itertools'
+
+ spec = importlib.util.find_spec(name)
+ if spec is None:
+ print("can't find the itertools module")
+ else:
+ # If you chose to perform the actual import ...
+ module = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(module)
+ # Adding the module to sys.modules is optional.
+ sys.modules[name] = module
+
+To import a Python source file directly, use the following recipe
+(Python 3.4 and newer only)::
+
+ import importlib.util
+ import sys
+
+ # For illustrative purposes.
+ import tokenize
+ file_path = tokenize.__file__
+ module_name = tokenize.__name__
+
+ spec = importlib.util.spec_from_file_location(module_name, file_path)
+ module = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(module)
+ # Optional; only necessary if you want to be able to import the module
+ # by name later.
+ sys.modules[module_name] = module
+
+For deep customizations of import, you typically want to implement an
+:term:`importer`. This means managing both the :term:`finder` and :term:`loader`
+side of things. For finders there are two flavours to choose from depending on
+your needs: a :term:`meta path finder` or a :term:`path entry finder`. The
+former is what you would put on :attr:`sys.meta_path` while the latter is what
+you create using a :term:`path entry hook` on :attr:`sys.path_hooks` which works
+with :attr:`sys.path` entries to potentially create a finder. This example will
+show you how to register your own importers so that import will use them (for
+creating an importer for yourself, read the documentation for the appropriate
+classes defined within this package)::
+
+ import importlib.machinery
+ import sys
+
+ # For illustrative purposes only.
+ SpamMetaPathFinder = importlib.machinery.PathFinder
+ SpamPathEntryFinder = importlib.machinery.FileFinder
+ loader_details = (importlib.machinery.SourceFileLoader,
+ importlib.machinery.SOURCE_SUFFIXES)
+
+ # Setting up a meta path finder.
+ # Make sure to put the finder in the proper location in the list in terms of
+ # priority.
+ sys.meta_path.append(SpamMetaPathFinder)
+
+ # Setting up a path entry finder.
+ # Make sure to put the path hook in the proper location in the list in terms
+ # of priority.
+ sys.path_hooks.append(SpamPathEntryFinder.path_hook(loader_details))
+
+Import itself is implemented in Python code, making it possible to
+expose most of the import machinery through importlib. The following
+helps illustrate the various APIs that importlib exposes by providing an
+approximate implementation of
+:func:`importlib.import_module` (Python 3.4 and newer for the importlib usage,
+Python 3.6 and newer for other parts of the code).
+::
+
+ import importlib.util
+ import sys
+
+ def import_module(name, package=None):
+ """An approximate implementation of import."""
+ absolute_name = importlib.util.resolve_name(name, package)
+ try:
+ return sys.modules[absolute_name]
+ except KeyError:
+ pass
+
+ path = None
+ if '.' in absolute_name:
+ parent_name, _, child_name = absolute_name.rpartition('.')
+ parent_module = import_module(parent_name)
+ path = parent_module.spec.submodule_search_locations
+ for finder in sys.meta_path:
+ spec = finder.find_spec(absolute_name, path)
+ if spec is not None:
+ break
+ else:
+ raise ImportError(f'No module named {absolute_name!r}')
+ module = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(module)
+ sys.modules[absolute_name] = module
+ if path is not None:
+ setattr(parent_module, child_name, module)
+ return module
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
index 8e7ed19..5cb7c22 100644
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -235,24 +235,6 @@
listed in the metaclass' custom :meth:`__dir__`.
-.. function:: getmoduleinfo(path)
-
- Returns a :term:`named tuple` ``ModuleInfo(name, suffix, mode, module_type)``
- of values that describe how Python will interpret the file identified by
- *path* if it is a module, or ``None`` if it would not be identified as a
- module. In that tuple, *name* is the name of the module without the name of
- any enclosing package, *suffix* is the trailing part of the file name (which
- may not be a dot-delimited extension), *mode* is the :func:`open` mode that
- would be used (``'r'`` or ``'rb'``), and *module_type* is an integer giving
- the type of the module. *module_type* will have a value which can be
- compared to the constants defined in the :mod:`imp` module; see the
- documentation for that module for more information on module types.
-
- .. deprecated:: 3.3
- You may check the file path's suffix against the supported suffixes
- listed in :mod:`importlib.machinery` to infer the same information.
-
-
.. function:: getmodulename(path)
Return the name of the module named by the file *path*, without including the
@@ -266,8 +248,7 @@
still return ``None``.
.. versionchanged:: 3.3
- This function is now based directly on :mod:`importlib` rather than the
- deprecated :func:`getmoduleinfo`.
+ The function is based directly on :mod:`importlib`.
.. function:: ismodule(object)
@@ -646,6 +627,16 @@
The name of the parameter as a string. The name must be a valid
Python identifier.
+ .. impl-detail::
+
+ CPython generates implicit parameter names of the form ``.0`` on the
+ code objects used to implement comprehensions and generator
+ expressions.
+
+ .. versionchanged:: 3.6
+ These parameter names are exposed by this module as names like
+ ``implicit0``.
+
.. attribute:: Parameter.default
The default value for the parameter. If the parameter has no default
@@ -854,8 +845,6 @@
from kwonlyargs to defaults. *annotations* is a dictionary mapping argument
names to annotations.
- The first four items in the tuple correspond to :func:`getargspec`.
-
.. versionchanged:: 3.4
This function is now based on :func:`signature`, but still ignores
``__wrapped__`` attributes and includes the already bound first
@@ -884,7 +873,7 @@
.. function:: formatargspec(args[, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations[, formatarg, formatvarargs, formatvarkw, formatvalue, formatreturns, formatannotations]])
Format a pretty argument spec from the values returned by
- :func:`getargspec` or :func:`getfullargspec`.
+ :func:`getfullargspec`.
The first seven arguments are (``args``, ``varargs``, ``varkw``,
``defaults``, ``kwonlyargs``, ``kwonlydefaults``, ``annotations``).
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst
index dfc1ddc..b0d0a8c 100644
--- a/Doc/library/itertools.rst
+++ b/Doc/library/itertools.rst
@@ -591,7 +591,13 @@
.. function:: tee(iterable, n=2)
- Return *n* independent iterators from a single iterable. Roughly equivalent to::
+ Return *n* independent iterators from a single iterable.
+
+ The following Python code helps explain what *tee* does (although the actual
+ implementation is more complex and uses only a single underlying
+ :abbr:`FIFO (first-in, first-out)` queue).
+
+ Roughly equivalent to::
def tee(iterable, n=2):
it = iter(iterable)
diff --git a/Doc/library/json.rst b/Doc/library/json.rst
index ee58266..73824f8 100644
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -126,7 +126,7 @@
Basic Usage
-----------
-.. function:: dump(obj, fp, skipkeys=False, ensure_ascii=True, \
+.. function:: dump(obj, fp, *, skipkeys=False, ensure_ascii=True, \
check_circular=True, allow_nan=True, cls=None, \
indent=None, separators=None, default=None, \
sort_keys=False, **kw)
@@ -187,8 +187,11 @@
:meth:`default` method to serialize additional types), specify it with the
*cls* kwarg; otherwise :class:`JSONEncoder` is used.
+ .. versionchanged:: 3.6
+ All optional parameters are now :ref:`keyword-only <keyword-only_parameter>`.
-.. function:: dumps(obj, skipkeys=False, ensure_ascii=True, \
+
+.. function:: dumps(obj, *, skipkeys=False, ensure_ascii=True, \
check_circular=True, allow_nan=True, cls=None, \
indent=None, separators=None, default=None, \
sort_keys=False, **kw)
@@ -212,7 +215,7 @@
the original one. That is, ``loads(dumps(x)) != x`` if x has non-string
keys.
-.. function:: load(fp, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
+.. function:: load(fp, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
Deserialize *fp* (a ``.read()``-supporting :term:`file-like object`
containing a JSON document) to a Python object using this :ref:`conversion
@@ -260,7 +263,10 @@
If the data being deserialized is not a valid JSON document, a
:exc:`JSONDecodeError` will be raised.
-.. function:: loads(s, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
+ .. versionchanged:: 3.6
+ All optional parameters are now :ref:`keyword-only <keyword-only_parameter>`.
+
+.. function:: loads(s, *, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
Deserialize *s* (a :class:`str` instance containing a JSON document) to a
Python object using this :ref:`conversion table <json-to-py-table>`.
@@ -274,7 +280,7 @@
Encoders and Decoders
---------------------
-.. class:: JSONDecoder(object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)
+.. class:: JSONDecoder(*, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)
Simple JSON decoder.
@@ -344,6 +350,9 @@
If the data being deserialized is not a valid JSON document, a
:exc:`JSONDecodeError` will be raised.
+ .. versionchanged:: 3.6
+ All parameters are now :ref:`keyword-only <keyword-only_parameter>`.
+
.. method:: decode(s)
Return the Python representation of *s* (a :class:`str` instance
@@ -362,7 +371,7 @@
extraneous data at the end.
-.. class:: JSONEncoder(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)
+.. class:: JSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)
Extensible JSON encoder for Python data structures.
@@ -442,6 +451,9 @@
the object or raise a :exc:`TypeError`. If not specified, :exc:`TypeError`
is raised.
+ .. versionchanged:: 3.6
+ All parameters are now :ref:`keyword-only <keyword-only_parameter>`.
+
.. method:: default(o)
diff --git a/Doc/library/logging.handlers.rst b/Doc/library/logging.handlers.rst
index 855adab..4eaea09 100644
--- a/Doc/library/logging.handlers.rst
+++ b/Doc/library/logging.handlers.rst
@@ -161,11 +161,19 @@
first call to :meth:`emit`. By default, the file grows indefinitely.
+ .. method:: reopenIfNeeded()
+
+ Checks to see if the file has changed. If it has, the existing stream is
+ flushed and closed and the file opened again, typically as a precursor to
+ outputting the record to the file.
+
+ .. versionadded:: 3.6
+
+
.. method:: emit(record)
- Outputs the record to the file, but first checks to see if the file has
- changed. If it has, the existing stream is flushed and closed and the
- file opened again, before outputting the record to the file.
+ Outputs the record to the file, but first calls :meth:`reopenIfNeeded` to
+ reopen the file if it has changed.
.. _base-rotating-handler:
diff --git a/Doc/library/mmap.rst b/Doc/library/mmap.rst
index 8f53833..c544c80 100644
--- a/Doc/library/mmap.rst
+++ b/Doc/library/mmap.rst
@@ -264,13 +264,18 @@
.. method:: write(bytes)
Write the bytes in *bytes* into memory at the current position of the
- file pointer; the file position is updated to point after the bytes that
- were written. If the mmap was created with :const:`ACCESS_READ`, then
+ file pointer and return the number of bytes written (never less than
+ ``len(bytes)``, since if the write fails, a :exc:`ValueError` will be
+ raised). The file position is updated to point after the bytes that
+ were written. If the mmap was created with :const:`ACCESS_READ`, then
writing to it will raise a :exc:`TypeError` exception.
.. versionchanged:: 3.5
Writable :term:`bytes-like object` is now accepted.
+ .. versionchanged:: 3.6
+ The number of bytes written is now returned.
+
.. method:: write_byte(byte)
diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst
index d20098f..f886ecb 100644
--- a/Doc/library/multiprocessing.rst
+++ b/Doc/library/multiprocessing.rst
@@ -647,8 +647,9 @@
For passing messages one can use :func:`Pipe` (for a connection between two
processes) or a queue (which allows multiple producers and consumers).
-The :class:`Queue`, :class:`SimpleQueue` and :class:`JoinableQueue` types are multi-producer,
-multi-consumer FIFO queues modelled on the :class:`queue.Queue` class in the
+The :class:`Queue`, :class:`SimpleQueue` and :class:`JoinableQueue` types
+are multi-producer, multi-consumer :abbr:`FIFO (first-in, first-out)`
+queues modelled on the :class:`queue.Queue` class in the
standard library. They differ in that :class:`Queue` lacks the
:meth:`~queue.Queue.task_done` and :meth:`~queue.Queue.join` methods introduced
into Python 2.5's :class:`queue.Queue` class.
@@ -886,8 +887,13 @@
.. function:: cpu_count()
- Return the number of CPUs in the system. May raise
- :exc:`NotImplementedError`.
+ Return the number of CPUs in the system.
+
+ This number is not equivalent to the number of CPUs the current process can
+ use. The number of usable CPUs can be obtained with
+ ``len(os.sched_getaffinity(0))``
+
+ May raise :exc:`NotImplementedError`.
.. seealso::
:func:`os.cpu_count`
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
index e73d8ee..eae7249 100644
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -171,23 +171,60 @@
.. function:: fsencode(filename)
- Encode *filename* to the filesystem encoding with ``'surrogateescape'``
- error handler, or ``'strict'`` on Windows; return :class:`bytes` unchanged.
+ Encode :term:`path-like <path-like object>` *filename* to the filesystem
+ encoding with ``'surrogateescape'`` error handler, or ``'strict'`` on
+ Windows; return :class:`bytes` unchanged.
:func:`fsdecode` is the reverse function.
.. versionadded:: 3.2
+ .. versionchanged:: 3.6
+ Support added to accept objects implementing the :class:`os.PathLike`
+ interface.
+
.. function:: fsdecode(filename)
- Decode *filename* from the filesystem encoding with ``'surrogateescape'``
- error handler, or ``'strict'`` on Windows; return :class:`str` unchanged.
+ Decode the :term:`path-like <path-like object>` *filename* from the
+ filesystem encoding with ``'surrogateescape'`` error handler, or ``'strict'``
+ on Windows; return :class:`str` unchanged.
:func:`fsencode` is the reverse function.
.. versionadded:: 3.2
+ .. versionchanged:: 3.6
+ Support added to accept objects implementing the :class:`os.PathLike`
+ interface.
+
+
+.. function:: fspath(path)
+
+ Return the file system representation of the path.
+
+ If :class:`str` or :class:`bytes` is passed in, it is returned unchanged.
+ Otherwise :meth:`~os.PathLike.__fspath__` is called and its value is
+ returned as long as it is a :class:`str` or :class:`bytes` object.
+ In all other cases, :exc:`TypeError` is raised.
+
+ .. versionadded:: 3.6
+
+
+.. class:: PathLike
+
+ An :term:`abstract base class` for objects representing a file system path,
+ e.g. :class:`pathlib.PurePath`.
+
+ .. versionadded:: 3.6
+
+ .. abstractmethod:: __fspath__()
+
+ Return the file system path representation of the object.
+
+ The method should only return a :class:`str` or :class:`bytes` object,
+ with the preference being for :class:`str`.
+
.. function:: getenv(key, default=None)
@@ -1883,35 +1920,51 @@
.. function:: scandir(path='.')
- Return an iterator of :class:`DirEntry` objects corresponding to the entries
- in the directory given by *path*. The entries are yielded in arbitrary
- order, and the special entries ``'.'`` and ``'..'`` are not included.
+ Return an iterator of :class:`os.DirEntry` objects corresponding to the
+ entries in the directory given by *path*. The entries are yielded in
+ arbitrary order, and the special entries ``'.'`` and ``'..'`` are not
+ included.
Using :func:`scandir` instead of :func:`listdir` can significantly
increase the performance of code that also needs file type or file
- attribute information, because :class:`DirEntry` objects expose this
+ attribute information, because :class:`os.DirEntry` objects expose this
information if the operating system provides it when scanning a directory.
- All :class:`DirEntry` methods may perform a system call, but
- :func:`~DirEntry.is_dir` and :func:`~DirEntry.is_file` usually only
- require a system call for symbolic links; :func:`DirEntry.stat`
+ All :class:`os.DirEntry` methods may perform a system call, but
+ :func:`~os.DirEntry.is_dir` and :func:`~os.DirEntry.is_file` usually only
+ require a system call for symbolic links; :func:`os.DirEntry.stat`
always requires a system call on Unix but only requires one for
symbolic links on Windows.
On Unix, *path* can be of type :class:`str` or :class:`bytes` (use
:func:`~os.fsencode` and :func:`~os.fsdecode` to encode and decode
:class:`bytes` paths). On Windows, *path* must be of type :class:`str`.
- On both sytems, the type of the :attr:`~DirEntry.name` and
- :attr:`~DirEntry.path` attributes of each :class:`DirEntry` will be of
+ On both sytems, the type of the :attr:`~os.DirEntry.name` and
+ :attr:`~os.DirEntry.path` attributes of each :class:`os.DirEntry` will be of
the same type as *path*.
+ The :func:`scandir` iterator supports the :term:`context manager` protocol
+ and has the following method:
+
+ .. method:: scandir.close()
+
+ Close the iterator and free acquired resources.
+
+ This is called automatically when the iterator is exhausted or garbage
+ collected, or when an error happens during iterating. However it
+ is advisable to call it explicitly or use the :keyword:`with`
+ statement.
+
+ .. versionadded:: 3.6
+
The following example shows a simple use of :func:`scandir` to display all
the files (excluding directories) in the given *path* that don't start with
``'.'``. The ``entry.is_file()`` call will generally not make an additional
system call::
- for entry in os.scandir(path):
- if not entry.name.startswith('.') and entry.is_file():
- print(entry.name)
+ with os.scandir(path) as it:
+ for entry in it:
+ if not entry.name.startswith('.') and entry.is_file():
+ print(entry.name)
.. note::
@@ -1927,6 +1980,12 @@
.. versionadded:: 3.5
+ .. versionadded:: 3.6
+ Added support for the :term:`context manager` protocol and the
+ :func:`~scandir.close()` method. If a :func:`scandir` iterator is neither
+ exhausted nor explicitly closed a :exc:`ResourceWarning` will be emitted
+ in its destructor.
+
.. class:: DirEntry
@@ -1935,19 +1994,22 @@
:func:`scandir` will provide as much of this information as possible without
making additional system calls. When a ``stat()`` or ``lstat()`` system call
- is made, the ``DirEntry`` object will cache the result.
+ is made, the ``os.DirEntry`` object will cache the result.
- ``DirEntry`` instances are not intended to be stored in long-lived data
+ ``os.DirEntry`` instances are not intended to be stored in long-lived data
structures; if you know the file metadata has changed or if a long time has
elapsed since calling :func:`scandir`, call ``os.stat(entry.path)`` to fetch
up-to-date information.
- Because the ``DirEntry`` methods can make operating system calls, they may
+ Because the ``os.DirEntry`` methods can make operating system calls, they may
also raise :exc:`OSError`. If you need very fine-grained
control over errors, you can catch :exc:`OSError` when calling one of the
- ``DirEntry`` methods and handle as appropriate.
+ ``os.DirEntry`` methods and handle as appropriate.
- Attributes and methods on a ``DirEntry`` instance are as follows:
+ To be directly usable as a :term:`path-like object`, ``os.DirEntry``
+ implements the :class:`os.PathLike` interface.
+
+ Attributes and methods on a ``os.DirEntry`` instance are as follows:
.. attribute:: name
@@ -1973,8 +2035,9 @@
Return the inode number of the entry.
- The result is cached on the ``DirEntry`` object. Use ``os.stat(entry.path,
- follow_symlinks=False).st_ino`` to fetch up-to-date information.
+ The result is cached on the ``os.DirEntry`` object. Use
+ ``os.stat(entry.path, follow_symlinks=False).st_ino`` to fetch up-to-date
+ information.
On the first, uncached call, a system call is required on Windows but
not on Unix.
@@ -1989,7 +2052,7 @@
is a directory (without following symlinks); return ``False`` if the
entry is any other kind of file or if it doesn't exist anymore.
- The result is cached on the ``DirEntry`` object, with a separate cache
+ The result is cached on the ``os.DirEntry`` object, with a separate cache
for *follow_symlinks* ``True`` and ``False``. Call :func:`os.stat` along
with :func:`stat.S_ISDIR` to fetch up-to-date information.
@@ -2013,8 +2076,8 @@
is a file (without following symlinks); return ``False`` if the entry is
a directory or other non-file entry, or if it doesn't exist anymore.
- The result is cached on the ``DirEntry`` object. Caching, system calls
- made, and exceptions raised are as per :func:`~DirEntry.is_dir`.
+ The result is cached on the ``os.DirEntry`` object. Caching, system calls
+ made, and exceptions raised are as per :func:`~os.DirEntry.is_dir`.
.. method:: is_symlink()
@@ -2022,7 +2085,7 @@
return ``False`` if the entry points to a directory or any kind of file,
or if it doesn't exist anymore.
- The result is cached on the ``DirEntry`` object. Call
+ The result is cached on the ``os.DirEntry`` object. Call
:func:`os.path.islink` to fetch up-to-date information.
On the first, uncached call, no system call is required in most cases.
@@ -2047,17 +2110,21 @@
:class:`stat_result` are always set to zero. Call :func:`os.stat` to
get these attributes.
- The result is cached on the ``DirEntry`` object, with a separate cache
+ The result is cached on the ``os.DirEntry`` object, with a separate cache
for *follow_symlinks* ``True`` and ``False``. Call :func:`os.stat` to
fetch up-to-date information.
Note that there is a nice correspondence between several attributes
- and methods of ``DirEntry`` and of :class:`pathlib.Path`. In
- particular, the ``name`` attribute has the same meaning, as do the
- ``is_dir()``, ``is_file()``, ``is_symlink()`` and ``stat()`` methods.
+ and methods of ``os.DirEntry`` and of :class:`pathlib.Path`. In
+ particular, the ``name`` attribute has the same
+ meaning, as do the ``is_dir()``, ``is_file()``, ``is_symlink()``
+ and ``stat()`` methods.
.. versionadded:: 3.5
+ .. versionchanged:: 3.6
+ Added support for the :class:`os.PathLike` interface.
+
.. function:: stat(path, \*, dir_fd=None, follow_symlinks=True)
@@ -3618,6 +3685,11 @@
Return the number of CPUs in the system. Returns None if undetermined.
+ This number is not equivalent to the number of CPUs the current process can
+ use. The number of usable CPUs can be obtained with
+ ``len(os.sched_getaffinity(0))``
+
+
.. versionadded:: 3.4
diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst
index f803fb6..74c4807 100644
--- a/Doc/library/pathlib.rst
+++ b/Doc/library/pathlib.rst
@@ -35,12 +35,6 @@
accessing the OS. In this case, instantiating one of the pure classes may be
useful since those simply don't have any OS-accessing operations.
-.. note::
- This module has been included in the standard library on a
- :term:`provisional basis <provisional package>`. Backwards incompatible
- changes (up to and including removal of the package) may occur if deemed
- necessary by the core developers.
-
.. seealso::
:pep:`428`: The pathlib module -- object-oriented filesystem paths.
@@ -111,7 +105,8 @@
PurePosixPath('setup.py')
Each element of *pathsegments* can be either a string representing a
- path segment, or another path object::
+ path segment, an object implementing the :class:`os.PathLike` interface
+ which returns a string, or another path object::
>>> PurePath('foo', 'some/path', 'bar')
PurePosixPath('foo/some/path/bar')
@@ -152,6 +147,12 @@
to ``PurePosixPath('bar')``, which is wrong if ``foo`` is a symbolic link
to another directory)
+ Pure path objects implement the :class:`os.PathLike` interface, allowing them
+ to be used anywhere the interface is accepted.
+
+ .. versionchanged:: 3.6
+ Added support for the :class:`os.PathLike` interface.
+
.. class:: PurePosixPath(*pathsegments)
A subclass of :class:`PurePath`, this path flavour represents non-Windows
@@ -199,7 +200,7 @@
>>> PureWindowsPath('foo') < PurePosixPath('foo')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
- TypeError: unorderable types: PureWindowsPath() < PurePosixPath()
+ TypeError: '<' not supported between instances of 'PureWindowsPath' and 'PurePosixPath'
Operators
@@ -216,6 +217,14 @@
>>> '/usr' / q
PurePosixPath('/usr/bin')
+A path object can be used anywhere an object implementing :class:`os.PathLike`
+is accepted::
+
+ >>> import os
+ >>> p = PurePath('/etc')
+ >>> os.fspath(p)
+ '/etc'
+
The string representation of a path is the raw filesystem path itself
(in native form, e.g. with backslashes under Windows), which you can
pass to any function taking a file path as a string::
diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst
index 0d64191..6e8430f 100644
--- a/Doc/library/pickle.rst
+++ b/Doc/library/pickle.rst
@@ -492,7 +492,7 @@
.. method:: object.__getnewargs_ex__()
- In protocols 4 and newer, classes that implements the
+ In protocols 2 and newer, classes that implements the
:meth:`__getnewargs_ex__` method can dictate the values passed to the
:meth:`__new__` method upon unpickling. The method must return a pair
``(args, kwargs)`` where *args* is a tuple of positional arguments
@@ -504,15 +504,22 @@
class requires keyword-only arguments. Otherwise, it is recommended for
compatibility to implement :meth:`__getnewargs__`.
+ .. versionchanged:: 3.6
+ :meth:`__getnewargs_ex__` is now used in protocols 2 and 3.
+
.. method:: object.__getnewargs__()
- This method serve a similar purpose as :meth:`__getnewargs_ex__` but
- for protocols 2 and newer. It must return a tuple of arguments ``args``
- which will be passed to the :meth:`__new__` method upon unpickling.
+ This method serve a similar purpose as :meth:`__getnewargs_ex__`, but
+ supports only positional arguments. It must return a tuple of arguments
+ ``args`` which will be passed to the :meth:`__new__` method upon unpickling.
- In protocols 4 and newer, :meth:`__getnewargs__` will not be called if
- :meth:`__getnewargs_ex__` is defined.
+ :meth:`__getnewargs__` will not be called if :meth:`__getnewargs_ex__` is
+ defined.
+
+ .. versionchanged:: 3.6
+ Before Python 3.6, :meth:`__getnewargs__` was called instead of
+ :meth:`__getnewargs_ex__` in protocols 2 and 3.
.. method:: object.__getstate__()
diff --git a/Doc/library/queue.rst b/Doc/library/queue.rst
index 1cb0935..e3eaa3f 100644
--- a/Doc/library/queue.rst
+++ b/Doc/library/queue.rst
@@ -16,8 +16,9 @@
module.
The module implements three types of queue, which differ only in the order in
-which the entries are retrieved. In a FIFO queue, the first tasks added are
-the first retrieved. In a LIFO queue, the most recently added entry is
+which the entries are retrieved. In a :abbr:`FIFO (first-in, first-out)`
+queue, the first tasks added are the first retrieved. In a
+:abbr:`LIFO (last-in, first-out)` queue, the most recently added entry is
the first retrieved (operating like a stack). With a priority queue,
the entries are kept sorted (using the :mod:`heapq` module) and the
lowest valued entry is retrieved first.
@@ -27,14 +28,16 @@
.. class:: Queue(maxsize=0)
- Constructor for a FIFO queue. *maxsize* is an integer that sets the upperbound
+ Constructor for a :abbr:`FIFO (first-in, first-out)` queue. *maxsize* is
+ an integer that sets the upperbound
limit on the number of items that can be placed in the queue. Insertion will
block once this size has been reached, until queue items are consumed. If
*maxsize* is less than or equal to zero, the queue size is infinite.
.. class:: LifoQueue(maxsize=0)
- Constructor for a LIFO queue. *maxsize* is an integer that sets the upperbound
+ Constructor for a :abbr:`LIFO (last-in, first-out)` queue. *maxsize* is
+ an integer that sets the upperbound
limit on the number of items that can be placed in the queue. Insertion will
block once this size has been reached, until queue items are consumed. If
*maxsize* is less than or equal to zero, the queue size is infinite.
diff --git a/Doc/library/random.rst b/Doc/library/random.rst
index df502a0..e7b81ad 100644
--- a/Doc/library/random.rst
+++ b/Doc/library/random.rst
@@ -46,7 +46,8 @@
.. warning::
The pseudo-random generators of this module should not be used for
- security purposes.
+ security purposes. For security or cryptographic uses, see the
+ :mod:`secrets` module.
Bookkeeping functions:
diff --git a/Doc/library/re.rst b/Doc/library/re.rst
index 569b522..dfbedd4 100644
--- a/Doc/library/re.rst
+++ b/Doc/library/re.rst
@@ -321,8 +321,9 @@
The special sequences consist of ``'\'`` and a character from the list below.
-If the ordinary character is not on the list, then the resulting RE will match
-the second character. For example, ``\$`` matches the character ``'$'``.
+If the ordinary character is not an ASCII digit or an ASCII letter, then the
+resulting RE will match the second character. For example, ``\$`` matches the
+character ``'$'``.
``\number``
Matches the contents of the group of the same number. Groups are numbered
@@ -442,9 +443,8 @@
.. versionchanged:: 3.3
The ``'\u'`` and ``'\U'`` escape sequences have been added.
-.. deprecated-removed:: 3.5 3.6
- Unknown escapes consisting of ``'\'`` and ASCII letter now raise a
- deprecation warning and will be forbidden in Python 3.6.
+.. versionchanged:: 3.6
+ Unknown escapes consisting of ``'\'`` and an ASCII letter now are errors.
.. seealso::
@@ -532,11 +532,11 @@
current locale. The use of this flag is discouraged as the locale mechanism
is very unreliable, and it only handles one "culture" at a time anyway;
you should use Unicode matching instead, which is the default in Python 3
- for Unicode (str) patterns. This flag makes sense only with bytes patterns.
+ for Unicode (str) patterns. This flag can be used only with bytes patterns.
- .. deprecated-removed:: 3.5 3.6
- Deprecated the use of :const:`re.LOCALE` with string patterns or
- :const:`re.ASCII`.
+ .. versionchanged:: 3.6
+ :const:`re.LOCALE` can be used only with bytes patterns and is
+ not compatible with :const:`re.ASCII`.
.. data:: M
@@ -742,9 +742,8 @@
.. versionchanged:: 3.5
Unmatched groups are replaced with an empty string.
- .. deprecated-removed:: 3.5 3.6
- Unknown escapes consist of ``'\'`` and ASCII letter now raise a
- deprecation warning and will be forbidden in Python 3.6.
+ .. versionchanged:: 3.6
+ Unknown escapes consisting of ``'\'`` and an ASCII letter now are errors.
.. function:: subn(pattern, repl, string, count=0, flags=0)
diff --git a/Doc/library/readline.rst b/Doc/library/readline.rst
index 4d3c099..37e400e 100644
--- a/Doc/library/readline.rst
+++ b/Doc/library/readline.rst
@@ -167,6 +167,20 @@
This calls :c:func:`add_history` in the underlying library.
+.. function:: set_auto_history(enabled)
+
+ Enable or disable automatic calls to :c:func:`add_history` when reading
+ input via readline. The *enabled* argument should be a Boolean value
+ that when true, enables auto history, and that when False, disables
+ auto history.
+
+ .. versionadded:: 3.6
+
+ .. impl-detail::
+ Auto history is enabled by default, and changes to this do not persist
+ across multiple sessions.
+
+
Startup hooks
-------------
diff --git a/Doc/library/secrets.rst b/Doc/library/secrets.rst
new file mode 100644
index 0000000..9bf848f
--- /dev/null
+++ b/Doc/library/secrets.rst
@@ -0,0 +1,198 @@
+:mod:`secrets` --- Generate secure random numbers for managing secrets
+======================================================================
+
+.. module:: secrets
+ :synopsis: Generate secure random numbers for managing secrets.
+
+.. moduleauthor:: Steven D'Aprano <steve+python@pearwood.info>
+.. sectionauthor:: Steven D'Aprano <steve+python@pearwood.info>
+.. versionadded:: 3.6
+
+.. testsetup::
+
+ from secrets import *
+ __name__ = '<doctest>'
+
+**Source code:** :source:`Lib/secrets.py`
+
+-------------
+
+The :mod:`secrets` module is used for generating cryptographically strong
+random numbers suitable for managing data such as passwords, account
+authentication, security tokens, and related secrets.
+
+In particularly, :mod:`secrets` should be used in preference to the
+default pseudo-random number generator in the :mod:`random` module, which
+is designed for modelling and simulation, not security or cryptography.
+
+.. seealso::
+
+ :pep:`506`
+
+
+Random numbers
+--------------
+
+The :mod:`secrets` module provides access to the most secure source of
+randomness that your operating system provides.
+
+.. class:: SystemRandom
+
+ A class for generating random numbers using the highest-quality
+ sources provided by the operating system. See
+ :class:`random.SystemRandom` for additional details.
+
+.. function:: choice(sequence)
+
+ Return a randomly-chosen element from a non-empty sequence.
+
+.. function:: randbelow(n)
+
+ Return a random int in the range [0, *n*).
+
+.. function:: randbits(k)
+
+ Return an int with *k* random bits.
+
+
+Generating tokens
+-----------------
+
+The :mod:`secrets` module provides functions for generating secure
+tokens, suitable for applications such as password resets,
+hard-to-guess URLs, and similar.
+
+.. function:: token_bytes([nbytes=None])
+
+ Return a random byte string containing *nbytes* number of bytes.
+ If *nbytes* is ``None`` or not supplied, a reasonable default is
+ used.
+
+ .. doctest::
+
+ >>> token_bytes(16) #doctest:+SKIP
+ b'\xebr\x17D*t\xae\xd4\xe3S\xb6\xe2\xebP1\x8b'
+
+
+.. function:: token_hex([nbytes=None])
+
+ Return a random text string, in hexadecimal. The string has *nbytes*
+ random bytes, each byte converted to two hex digits. If *nbytes* is
+ ``None`` or not supplied, a reasonable default is used.
+
+ .. doctest::
+
+ >>> token_hex(16) #doctest:+SKIP
+ 'f9bf78b9a18ce6d46a0cd2b0b86df9da'
+
+.. function:: token_urlsafe([nbytes=None])
+
+ Return a random URL-safe text string, containing *nbytes* random
+ bytes. The text is Base64 encoded, so on average each byte results
+ in approximately 1.3 characters. If *nbytes* is ``None`` or not
+ supplied, a reasonable default is used.
+
+ .. doctest::
+
+ >>> token_urlsafe(16) #doctest:+SKIP
+ 'Drmhze6EPcv0fN_81Bj-nA'
+
+
+How many bytes should tokens use?
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+To be secure against
+`brute-force attacks <https://en.wikipedia.org/wiki/Brute-force_attack>`_,
+tokens need to have sufficient randomness. Unfortunately, what is
+considered sufficient will necessarily increase as computers get more
+powerful and able to make more guesses in a shorter period. As of 2015,
+it is believed that 32 bytes (256 bits) of randomness is sufficient for
+the typical use-case expected for the :mod:`secrets` module.
+
+For those who want to manage their own token length, you can explicitly
+specify how much randomness is used for tokens by giving an :class:`int`
+argument to the various ``token_*`` functions. That argument is taken
+as the number of bytes of randomness to use.
+
+Otherwise, if no argument is provided, or if the argument is ``None``,
+the ``token_*`` functions will use a reasonable default instead.
+
+.. note::
+
+ That default is subject to change at any time, including during
+ maintenance releases.
+
+
+Other functions
+---------------
+
+.. function:: compare_digest(a, b)
+
+ Return ``True`` if strings *a* and *b* are equal, otherwise ``False``,
+ in such a way as to reduce the risk of
+ `timing attacks <http://codahale.com/a-lesson-in-timing-attacks/>`_.
+ See :func:`hmac.compare_digest` for additional details.
+
+
+Recipes and best practices
+--------------------------
+
+This section shows recipes and best practices for using :mod:`secrets`
+to manage a basic level of security.
+
+Generate an eight-character alphanumeric password:
+
+.. testcode::
+
+ import string
+ alphabet = string.ascii_letters + string.digits
+ password = ''.join(choice(alphabet) for i in range(8))
+
+
+.. note::
+
+ Applications should not
+ `store passwords in a recoverable format <http://cwe.mitre.org/data/definitions/257.html>`_,
+ whether plain text or encrypted. They should be salted and hashed
+ using a cryptographically-strong one-way (irreversible) hash function.
+
+
+Generate a ten-character alphanumeric password with at least one
+lowercase character, at least one uppercase character, and at least
+three digits:
+
+.. testcode::
+
+ import string
+ alphabet = string.ascii_letters + string.digits
+ while True:
+ password = ''.join(choice(alphabet) for i in range(10))
+ if (any(c.islower() for c in password)
+ and any(c.isupper() for c in password)
+ and sum(c.isdigit() for c in password) >= 3):
+ break
+
+
+Generate an `XKCD-style passphrase <http://xkcd.com/936/>`_:
+
+.. testcode::
+
+ # On standard Linux systems, use a convenient dictionary file.
+ # Other platforms may need to provide their own word-list.
+ with open('/usr/share/dict/words') as f:
+ words = [word.strip() for word in f]
+ password = ' '.join(choice(words) for i in range(4))
+
+
+Generate a hard-to-guess temporary URL containing a security token
+suitable for password recovery applications:
+
+.. testcode::
+
+ url = 'https://mydomain.com/reset=' + token_urlsafe()
+
+
+
+..
+ # This modeline must appear within the last ten lines of the file.
+ kate: indent-width 3; remove-trailing-space on; replace-tabs on; encoding utf-8;
diff --git a/Doc/library/site.rst b/Doc/library/site.rst
index 0a73f5a..43daf79 100644
--- a/Doc/library/site.rst
+++ b/Doc/library/site.rst
@@ -52,7 +52,8 @@
A path configuration file is a file whose name has the form :file:`{name}.pth`
and exists in one of the four directories mentioned above; its contents are
additional items (one per line) to be added to ``sys.path``. Non-existing items
-are never added to ``sys.path``. No item is added to ``sys.path`` more than
+are never added to ``sys.path``, and no check is made that the item refers to a
+directory rather than a file. No item is added to ``sys.path`` more than
once. Blank lines and lines beginning with ``#`` are skipped. Lines starting
with ``import`` (followed by space or tab) are executed.
diff --git a/Doc/library/smtpd.rst b/Doc/library/smtpd.rst
index 977f9a8..ad6bd3c 100644
--- a/Doc/library/smtpd.rst
+++ b/Doc/library/smtpd.rst
@@ -29,7 +29,7 @@
.. class:: SMTPServer(localaddr, remoteaddr, data_size_limit=33554432,\
- map=None, enable_SMTPUTF8=False, decode_data=True)
+ map=None, enable_SMTPUTF8=False, decode_data=False)
Create a new :class:`SMTPServer` object, which binds to local address
*localaddr*. It will treat *remoteaddr* as an upstream SMTP relayer. It
@@ -45,20 +45,19 @@
global socket map is used.
*enable_SMTPUTF8* determins whether the ``SMTPUTF8`` extension (as defined
- in :RFC:`6531`) should be enabled. The default is ``False``. If set to
- ``True``, *decode_data* must be ``False`` (otherwise an error is raised).
+ in :RFC:`6531`) should be enabled. The default is ``False``.
When ``True``, ``SMTPUTF8`` is accepted as a parameter to the ``MAIL``
command and when present is passed to :meth:`process_message` in the
- ``kwargs['mail_options']`` list.
+ ``kwargs['mail_options']`` list. *decode_data* and *enable_SMTPUTF8*
+ cannot be set to ``True`` at the same time.
*decode_data* specifies whether the data portion of the SMTP transaction
- should be decoded using UTF-8. The default is ``True`` for backward
- compatibility reasons, but will change to ``False`` in Python 3.6; specify
- the keyword value explicitly to avoid the :exc:`DeprecationWarning`. When
- *decode_data* is set to ``False`` the server advertises the ``8BITMIME``
+ should be decoded using UTF-8. When *decode_data* is ``False`` (the
+ default), the server advertises the ``8BITMIME``
extension (:rfc:`6152`), accepts the ``BODY=8BITMIME`` parameter to
the ``MAIL`` command, and when present passes it to :meth:`process_message`
- in the ``kwargs['mail_options']`` list.
+ in the ``kwargs['mail_options']`` list. *decode_data* and *enable_SMTPUTF8*
+ cannot be set to ``True`` at the same time.
.. method:: process_message(peer, mailfrom, rcpttos, data, **kwargs)
@@ -75,9 +74,8 @@
will be a bytes object.
*kwargs* is a dictionary containing additional information. It is empty
- unless at least one of ``decode_data=False`` or ``enable_SMTPUTF8=True``
- was given as an init parameter, in which case it contains the following
- keys:
+ if ``decode_data=True`` was given as an init argument, otherwise
+ it contains the following keys:
*mail_options*:
a list of all received parameters to the ``MAIL``
@@ -108,9 +106,12 @@
*localaddr* and *remoteaddr* may now contain IPv6 addresses.
.. versionadded:: 3.5
- the *decode_data* and *enable_SMTPUTF8* constructor arguments, and the
- *kwargs* argument to :meth:`process_message` when one or more of these is
- specified.
+ The *decode_data* and *enable_SMTPUTF8* constructor parameters, and the
+ *kwargs* parameter to :meth:`process_message` when *decode_data* is
+ ``False``.
+
+ .. versionchanged:: 3.6
+ *decode_data* is now ``False`` by default.
DebuggingServer Objects
@@ -150,7 +151,7 @@
-------------------
.. class:: SMTPChannel(server, conn, addr, data_size_limit=33554432,\
- map=None, enable_SMTPUTF8=False, decode_data=True)
+ map=None, enable_SMTPUTF8=False, decode_data=False)
Create a new :class:`SMTPChannel` object which manages the communication
between the server and a single SMTP client.
@@ -162,22 +163,25 @@
limit.
*enable_SMTPUTF8* determins whether the ``SMTPUTF8`` extension (as defined
- in :RFC:`6531`) should be enabled. The default is ``False``. A
- :exc:`ValueError` is raised if both *enable_SMTPUTF8* and *decode_data* are
- set to ``True`` at the same time.
+ in :RFC:`6531`) should be enabled. The default is ``False``.
+ *decode_data* and *enable_SMTPUTF8* cannot be set to ``True`` at the same
+ time.
A dictionary can be specified in *map* to avoid using a global socket map.
*decode_data* specifies whether the data portion of the SMTP transaction
- should be decoded using UTF-8. The default is ``True`` for backward
- compatibility reasons, but will change to ``False`` in Python 3.6. Specify
- the keyword value explicitly to avoid the :exc:`DeprecationWarning`.
+ should be decoded using UTF-8. The default is ``False``.
+ *decode_data* and *enable_SMTPUTF8* cannot be set to ``True`` at the same
+ time.
To use a custom SMTPChannel implementation you need to override the
:attr:`SMTPServer.channel_class` of your :class:`SMTPServer`.
.. versionchanged:: 3.5
- the *decode_data* and *enable_SMTPUTF8* arguments were added.
+ The *decode_data* and *enable_SMTPUTF8* parameters were added.
+
+ .. versionchanged:: 3.6
+ *decode_data* is now ``False`` by default.
The :class:`SMTPChannel` has the following instance variables:
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
index 48311c5..c63c73a 100644
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -329,12 +329,17 @@
.. versionadded:: 3.3
-.. data:: SIO_*
+.. data:: SIO_RCVALL
+ SIO_KEEPALIVE_VALS
+ SIO_LOOPBACK_FAST_PATH
RCVALL_*
Constants for Windows' WSAIoctl(). The constants are used as arguments to the
:meth:`~socket.socket.ioctl` method of socket objects.
+ .. versionchanged:: 3.6
+ ``SIO_LOOPBACK_FAST_PATH`` was added.
+
.. data:: TIPC_*
@@ -872,6 +877,10 @@
it is recommended to :meth:`close` them explicitly, or to use a
:keyword:`with` statement around them.
+ .. versionchanged:: 3.6
+ :exc:`OSError` is now raised if an error occurs when the underlying
+ :c:func:`close` call is made.
+
.. note::
:meth:`close()` releases the resource associated with a connection but
@@ -992,6 +1001,12 @@
On other platforms, the generic :func:`fcntl.fcntl` and :func:`fcntl.ioctl`
functions may be used; they accept a socket object as their first argument.
+ Currently only the following control codes are supported:
+ ``SIO_RCVALL``, ``SIO_KEEPALIVE_VALS``, and ``SIO_LOOPBACK_FAST_PATH``.
+
+ .. versionchanged:: 3.6
+ ``SIO_LOOPBACK_FAST_PATH`` was added.
+
.. method:: socket.listen([backlog])
Enable a server to accept connections. If *backlog* is specified, it must
diff --git a/Doc/library/socketserver.rst b/Doc/library/socketserver.rst
index 98d2c46..3eb27e3 100644
--- a/Doc/library/socketserver.rst
+++ b/Doc/library/socketserver.rst
@@ -52,11 +52,12 @@
overriding its :meth:`~BaseRequestHandler.handle` method;
this method will process incoming
requests. Second, you must instantiate one of the server classes, passing it
-the server's address and the request handler class. Then call the
+the server's address and the request handler class. It is recommended to use
+the server in a :keyword:`with` statement. Then call the
:meth:`~BaseServer.handle_request` or
:meth:`~BaseServer.serve_forever` method of the server object to
process one or many requests. Finally, call :meth:`~BaseServer.server_close`
-to close the socket.
+to close the socket (unless you used a :keyword:`with` statement).
When inheriting from :class:`ThreadingMixIn` for threaded connection behavior,
you should explicitly declare how you want your threads to behave on an abrupt
@@ -111,6 +112,8 @@
:class:`UDPServer`. Setting the various attributes also changes the
behavior of the underlying server mechanism.
+ :class:`ForkingMixIn` and the Forking classes mentioned below are
+ only available on POSIX platforms that support :func:`~os.fork`.
.. class:: ForkingTCPServer
ForkingUDPServer
@@ -304,7 +307,11 @@
This function is called if the :meth:`~BaseRequestHandler.handle`
method of a :attr:`RequestHandlerClass` instance raises
an exception. The default action is to print the traceback to
- standard output and continue handling further requests.
+ standard error and continue handling further requests.
+
+ .. versionchanged:: 3.6
+ Now only called for exceptions derived from the :exc:`Exception`
+ class.
.. method:: handle_timeout()
@@ -349,6 +356,11 @@
default implementation always returns :const:`True`.
+ .. versionchanged:: 3.6
+ Support for the :term:`context manager` protocol was added. Exiting the
+ context manager is equivalent to calling :meth:`server_close`.
+
+
Request Handler Objects
-----------------------
@@ -397,6 +409,15 @@
read or written, respectively, to get the request data or return data
to the client.
+ The :attr:`rfile` attributes of both classes support the
+ :class:`io.BufferedIOBase` readable interface, and
+ :attr:`DatagramRequestHandler.wfile` supports the
+ :class:`io.BufferedIOBase` writable interface.
+
+ .. versionchanged:: 3.6
+ :attr:`StreamRequestHandler.wfile` also supports the
+ :class:`io.BufferedIOBase` writable interface.
+
Examples
--------
@@ -429,11 +450,10 @@
HOST, PORT = "localhost", 9999
# Create the server, binding to localhost on port 9999
- server = socketserver.TCPServer((HOST, PORT), MyTCPHandler)
-
- # Activate the server; this will keep running until you
- # interrupt the program with Ctrl-C
- server.serve_forever()
+ with socketserver.TCPServer((HOST, PORT), MyTCPHandler) as server:
+ # Activate the server; this will keep running until you
+ # interrupt the program with Ctrl-C
+ server.serve_forever()
An alternative request handler class that makes use of streams (file-like
objects that simplify communication by providing the standard file interface)::
@@ -521,8 +541,8 @@
if __name__ == "__main__":
HOST, PORT = "localhost", 9999
- server = socketserver.UDPServer((HOST, PORT), MyUDPHandler)
- server.serve_forever()
+ with socketserver.UDPServer((HOST, PORT), MyUDPHandler) as server:
+ server.serve_forever()
This is the client side::
@@ -581,22 +601,22 @@
HOST, PORT = "localhost", 0
server = ThreadedTCPServer((HOST, PORT), ThreadedTCPRequestHandler)
- ip, port = server.server_address
+ with server:
+ ip, port = server.server_address
- # Start a thread with the server -- that thread will then start one
- # more thread for each request
- server_thread = threading.Thread(target=server.serve_forever)
- # Exit the server thread when the main thread terminates
- server_thread.daemon = True
- server_thread.start()
- print("Server loop running in thread:", server_thread.name)
+ # Start a thread with the server -- that thread will then start one
+ # more thread for each request
+ server_thread = threading.Thread(target=server.serve_forever)
+ # Exit the server thread when the main thread terminates
+ server_thread.daemon = True
+ server_thread.start()
+ print("Server loop running in thread:", server_thread.name)
- client(ip, port, "Hello World 1")
- client(ip, port, "Hello World 2")
- client(ip, port, "Hello World 3")
+ client(ip, port, "Hello World 1")
+ client(ip, port, "Hello World 2")
+ client(ip, port, "Hello World 3")
- server.shutdown()
- server.server_close()
+ server.shutdown()
The output of the example should look something like this::
@@ -610,3 +630,5 @@
The :class:`ForkingMixIn` class is used in the same way, except that the server
will spawn a new process for each request.
+Available only on POSIX platforms that support :func:`~os.fork`.
+
diff --git a/Doc/library/spwd.rst b/Doc/library/spwd.rst
index fd3c9ad..c6cad2a 100644
--- a/Doc/library/spwd.rst
+++ b/Doc/library/spwd.rst
@@ -55,6 +55,9 @@
Return the shadow password database entry for the given user name.
+ .. versionchanged:: 3.6
+ Raises a :exc:`PermissionError` instead of :exc:`KeyError` if the user
+ doesn't have privileges.
.. function:: getspall()
diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst
index 605d8d3..2cd823e 100644
--- a/Doc/library/sqlite3.rst
+++ b/Doc/library/sqlite3.rst
@@ -629,9 +629,16 @@
.. attribute:: lastrowid
This read-only attribute provides the rowid of the last modified row. It is
- only set if you issued an ``INSERT`` statement using the :meth:`execute`
- method. For operations other than ``INSERT`` or when :meth:`executemany` is
- called, :attr:`lastrowid` is set to :const:`None`.
+ only set if you issued an ``INSERT`` or a ``REPLACE`` statement using the
+ :meth:`execute` method. For operations other than ``INSERT`` or
+ ``REPLACE`` or when :meth:`executemany` is called, :attr:`lastrowid` is
+ set to :const:`None`.
+
+ If the ``INSERT`` or ``REPLACE`` statement failed to insert the previous
+ successful rowid is returned.
+
+ .. versionchanged:: 3.6
+ Added support for the ``REPLACE`` statement.
.. attribute:: description
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index db1c2d0..0ade172 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -1453,8 +1453,8 @@
For more information on the ``str`` class and its methods, see
:ref:`textseq` and the :ref:`string-methods` section below. To output
- formatted strings, see the :ref:`formatstrings` section. In addition,
- see the :ref:`stringservices` section.
+ formatted strings, see the :ref:`f-strings` and :ref:`formatstrings`
+ sections. In addition, see the :ref:`stringservices` section.
.. index::
@@ -2056,8 +2056,8 @@
.. index::
single: formatting, string (%)
single: interpolation, string (%)
- single: string; formatting
- single: string; interpolation
+ single: string; formatting, printf
+ single: string; interpolation, printf
single: printf-style formatting
single: sprintf-style formatting
single: % formatting
@@ -2067,9 +2067,10 @@
The formatting operations described here exhibit a variety of quirks that
lead to a number of common errors (such as failing to display tuples and
- dictionaries correctly). Using the newer :meth:`str.format` interface
- helps avoid these errors, and also provides a generally more powerful,
- flexible and extensible approach to formatting text.
+ dictionaries correctly). Using the newer :ref:`formatted
+ string literals <f-strings>` or the :meth:`str.format` interface
+ helps avoid these errors. These alternatives also provide more powerful,
+ flexible and extensible approaches to formatting text.
String objects have one unique built-in operation: the ``%`` operator (modulo).
This is also known as the string *formatting* or *interpolation* operator.
diff --git a/Doc/library/string.rst b/Doc/library/string.rst
index d5d2430..c421c72 100644
--- a/Doc/library/string.rst
+++ b/Doc/library/string.rst
@@ -188,7 +188,9 @@
The :meth:`str.format` method and the :class:`Formatter` class share the same
syntax for format strings (although in the case of :class:`Formatter`,
-subclasses can define their own format string syntax).
+subclasses can define their own format string syntax). The syntax is
+related to that of :ref:`formatted string literals <f-strings>`, but
+there are differences.
Format strings contain "replacement fields" surrounded by curly braces ``{}``.
Anything that is not contained in braces is considered literal text, which is
@@ -283,7 +285,8 @@
"Format specifications" are used within replacement fields contained within a
format string to define how individual values are presented (see
-:ref:`formatstrings`). They can also be passed directly to the built-in
+:ref:`formatstrings` and :ref:`f-strings`).
+They can also be passed directly to the built-in
:func:`format` function. Each formattable type may define how the format
specification is to be interpreted.
@@ -308,7 +311,8 @@
If a valid *align* value is specified, it can be preceded by a *fill*
character that can be any character and defaults to a space if omitted.
It is not possible to use a literal curly brace ("``{``" or "``}``") as
-the *fill* character when using the :meth:`str.format`
+the *fill* character in a :ref:`formatted string literal
+<f-strings>` or when using the :meth:`str.format`
method. However, it is possible to insert a curly brace
with a nested replacement field. This limitation doesn't
affect the :func:`format` function.
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst
index f469107..3da4574 100644
--- a/Doc/library/subprocess.rst
+++ b/Doc/library/subprocess.rst
@@ -502,6 +502,10 @@
.. versionchanged:: 3.2
Added context manager support.
+ .. versionchanged:: 3.6
+ Popen destructor now emits a :exc:`ResourceWarning` warning if the child
+ process is still running.
+
Exceptions
^^^^^^^^^^
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst
index 9f70a13..ae7af7c 100644
--- a/Doc/library/sys.rst
+++ b/Doc/library/sys.rst
@@ -256,7 +256,7 @@
(defaulting to zero), or another type of object. If it is an integer, zero
is considered "successful termination" and any nonzero value is considered
"abnormal termination" by shells and the like. Most systems require it to be
- in the range 0-127, and produce undefined results otherwise. Some systems
+ in the range 0--127, and produce undefined results otherwise. Some systems
have a convention for assigning specific meanings to specific exit codes, but
these are generally underdeveloped; Unix programs generally use 2 for command
line syntax errors and 1 for all other kind of errors. If another type of
@@ -269,6 +269,11 @@
the process when called from the main thread, and the exception is not
intercepted.
+ .. versionchanged:: 3.6
+ If an error occurs in the cleanup after the Python interpreter
+ has caught :exc:`SystemExit` (such as an error flushing buffered data
+ in the standard streams), the exit status is changed to 120.
+
.. data:: flags
diff --git a/Doc/library/sysconfig.rst b/Doc/library/sysconfig.rst
index 0b0df9b..a115bea 100644
--- a/Doc/library/sysconfig.rst
+++ b/Doc/library/sysconfig.rst
@@ -164,7 +164,7 @@
.. function:: get_python_version()
Return the ``MAJOR.MINOR`` Python version number as a string. Similar to
- ``sys.version[:3]``.
+ ``'%d.%d' % sys.version_info[:2]``.
.. function:: get_platform()
diff --git a/Doc/library/telnetlib.rst b/Doc/library/telnetlib.rst
index b950e41..f9c5153 100644
--- a/Doc/library/telnetlib.rst
+++ b/Doc/library/telnetlib.rst
@@ -43,6 +43,17 @@
:exc:`EOFError` when the end of the connection is read, because they can return
an empty string for other reasons. See the individual descriptions below.
+ A :class:`Telnet` object is a context manager and can be used in a
+ :keyword:`with` statement. When the :keyword:`with` block ends, the
+ :meth:`close` method is called::
+
+ >>> from telnetlib import Telnet
+ >>> with Telnet('localhost', 23) as tn:
+ ... tn.interact()
+ ...
+
+ .. versionchanged:: 3.6 Context manager support added
+
.. seealso::
diff --git a/Doc/library/test.rst b/Doc/library/test.rst
index 2ea9c27..7114cdf 100644
--- a/Doc/library/test.rst
+++ b/Doc/library/test.rst
@@ -582,6 +582,48 @@
.. versionadded:: 3.5
+.. function:: check__all__(test_case, module, name_of_module=None, extra=(), blacklist=())
+
+ Assert that the ``__all__`` variable of *module* contains all public names.
+
+ The module's public names (its API) are detected automatically
+ based on whether they match the public name convention and were defined in
+ *module*.
+
+ The *name_of_module* argument can specify (as a string or tuple thereof) what
+ module(s) an API could be defined in in order to be detected as a public
+ API. One case for this is when *module* imports part of its public API from
+ other modules, possibly a C backend (like ``csv`` and its ``_csv``).
+
+ The *extra* argument can be a set of names that wouldn't otherwise be automatically
+ detected as "public", like objects without a proper ``__module__``
+ attribute. If provided, it will be added to the automatically detected ones.
+
+ The *blacklist* argument can be a set of names that must not be treated as part of
+ the public API even though their names indicate otherwise.
+
+ Example use::
+
+ import bar
+ import foo
+ import unittest
+ from test import support
+
+ class MiscTestCase(unittest.TestCase):
+ def test__all__(self):
+ support.check__all__(self, foo)
+
+ class OtherTestCase(unittest.TestCase):
+ def test__all__(self):
+ extra = {'BAR_CONST', 'FOO_CONST'}
+ blacklist = {'baz'} # Undocumented name.
+ # bar imports part of its API from _bar.
+ support.check__all__(self, bar, ('bar', '_bar'),
+ extra=extra, blacklist=blacklist)
+
+ .. versionadded:: 3.6
+
+
The :mod:`test.support` module defines the following classes:
.. class:: TransientResource(exc, **kwargs)
diff --git a/Doc/library/time.rst b/Doc/library/time.rst
index e6626f2..7c81ce7 100644
--- a/Doc/library/time.rst
+++ b/Doc/library/time.rst
@@ -637,11 +637,11 @@
it is possible to refer to February 29.
:samp:`M{m}.{n}.{d}`
- The *d*'th day (0 <= *d* <= 6) or week *n* of month *m* of the year (1
+ The *d*'th day (0 <= *d* <= 6) of week *n* of month *m* of the year (1
<= *n* <= 5, 1 <= *m* <= 12, where week 5 means "the last *d* day in
month *m*" which may occur in either the fourth or the fifth
week). Week 1 is the first week in which the *d*'th day occurs. Day
- zero is Sunday.
+ zero is a Sunday.
``time`` has the same format as ``offset`` except that no leading sign
('-' or '+') is allowed. The default, if time is not given, is 02:00:00.
diff --git a/Doc/library/tracemalloc.rst b/Doc/library/tracemalloc.rst
index 3a0b1e0..f56f27b 100644
--- a/Doc/library/tracemalloc.rst
+++ b/Doc/library/tracemalloc.rst
@@ -359,10 +359,32 @@
See also the :func:`get_object_traceback` function.
+DomainFilter
+^^^^^^^^^^^^
+
+.. class:: DomainFilter(inclusive: bool, domain: int)
+
+ Filter traces of memory blocks by their address space (domain).
+
+ .. versionadded:: 3.6
+
+ .. attribute:: inclusive
+
+ If *inclusive* is ``True`` (include), match memory blocks allocated
+ in the address space :attr:`domain`.
+
+ If *inclusive* is ``False`` (exclude), match memory blocks not allocated
+ in the address space :attr:`domain`.
+
+ .. attribute:: domain
+
+ Address space of a memory block (``int``). Read-only property.
+
+
Filter
^^^^^^
-.. class:: Filter(inclusive: bool, filename_pattern: str, lineno: int=None, all_frames: bool=False)
+.. class:: Filter(inclusive: bool, filename_pattern: str, lineno: int=None, all_frames: bool=False, domain: int=None)
Filter on traces of memory blocks.
@@ -382,9 +404,17 @@
.. versionchanged:: 3.5
The ``'.pyo'`` file extension is no longer replaced with ``'.py'``.
+ .. versionchanged:: 3.6
+ Added the :attr:`domain` attribute.
+
+
+ .. attribute:: domain
+
+ Address space of a memory block (``int`` or ``None``).
+
.. attribute:: inclusive
- If *inclusive* is ``True`` (include), only trace memory blocks allocated
+ If *inclusive* is ``True`` (include), only match memory blocks allocated
in a file with a name matching :attr:`filename_pattern` at line number
:attr:`lineno`.
@@ -399,7 +429,7 @@
.. attribute:: filename_pattern
- Filename pattern of the filter (``str``).
+ Filename pattern of the filter (``str``). Read-only property.
.. attribute:: all_frames
@@ -462,14 +492,17 @@
.. method:: filter_traces(filters)
Create a new :class:`Snapshot` instance with a filtered :attr:`traces`
- sequence, *filters* is a list of :class:`Filter` instances. If *filters*
- is an empty list, return a new :class:`Snapshot` instance with a copy of
- the traces.
+ sequence, *filters* is a list of :class:`DomainFilter` and
+ :class:`Filter` instances. If *filters* is an empty list, return a new
+ :class:`Snapshot` instance with a copy of the traces.
All inclusive filters are applied at once, a trace is ignored if no
inclusive filters match it. A trace is ignored if at least one exclusive
filter matches it.
+ .. versionchanged:: 3.6
+ :class:`DomainFilter` instances are now also accepted in *filters*.
+
.. classmethod:: load(filename)
diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst
index 317229d..9fa543c 100644
--- a/Doc/library/typing.rst
+++ b/Doc/library/typing.rst
@@ -347,11 +347,15 @@
.. class:: Iterable(Generic[T_co])
- A generic version of the :class:`collections.abc.Iterable`.
+ A generic version of :class:`collections.abc.Iterable`.
.. class:: Iterator(Iterable[T_co])
- A generic version of the :class:`collections.abc.Iterator`.
+ A generic version of :class:`collections.abc.Iterator`.
+
+.. class:: Reversible(Iterable[T_co])
+
+ A generic version of :class:`collections.abc.Reversible`.
.. class:: SupportsInt
@@ -371,11 +375,6 @@
An ABC with one abstract method ``__round__``
that is covariant in its return type.
-.. class:: Reversible
-
- An ABC with one abstract method ``__reversed__`` returning
- an ``Iterator[T_co]``.
-
.. class:: Container(Generic[T_co])
A generic version of :class:`collections.abc.Container`.
@@ -396,7 +395,7 @@
A generic version of :class:`collections.abc.MutableMapping`.
-.. class:: Sequence(Sized, Iterable[T_co], Container[T_co])
+.. class:: Sequence(Sized, Reversible[T_co], Container[T_co])
A generic version of :class:`collections.abc.Sequence`.
@@ -451,6 +450,12 @@
A generic version of :class:`collections.abc.ValuesView`.
+.. class:: ContextManager(Generic[T_co])
+
+ A generic version of :class:`contextlib.AbstractContextManager`.
+
+ .. versionadded:: 3.6
+
.. class:: Dict(dict, MutableMapping[KT, VT])
A generic version of :class:`dict`.
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
index 5c9177a..f559d71 100644
--- a/Doc/library/unittest.mock.rst
+++ b/Doc/library/unittest.mock.rst
@@ -262,6 +262,34 @@
used to set attributes on the mock after it is created. See the
:meth:`configure_mock` method for details.
+ .. method:: assert_called(*args, **kwargs)
+
+ Assert that the mock was called at least once.
+
+ >>> mock = Mock()
+ >>> mock.method()
+ <Mock name='mock.method()' id='...'>
+ >>> mock.method.assert_called()
+
+ .. versionadded:: 3.6
+
+ .. method:: assert_called_once(*args, **kwargs)
+
+ Assert that the mock was called exactly once.
+
+ >>> mock = Mock()
+ >>> mock.method()
+ <Mock name='mock.method()' id='...'>
+ >>> mock.method.assert_called_once()
+ >>> mock.method()
+ <Mock name='mock.method()' id='...'>
+ >>> mock.method.assert_called_once()
+ Traceback (most recent call last):
+ ...
+ AssertionError: Expected 'method' to have been called once. Called 2 times.
+
+ .. versionadded:: 3.6
+
.. method:: assert_called_with(*args, **kwargs)
@@ -339,7 +367,7 @@
.. versionadded:: 3.5
- .. method:: reset_mock()
+ .. method:: reset_mock(*, return_value=False, side_effect=False)
The reset_mock method resets all the call attributes on a mock object:
@@ -351,12 +379,20 @@
>>> mock.called
False
+ .. versionchanged:: 3.6
+ Added two keyword only argument to the reset_mock function.
+
This can be useful where you want to make a series of assertions that
reuse the same object. Note that :meth:`reset_mock` *doesn't* clear the
return value, :attr:`side_effect` or any child attributes you have
- set using normal assignment. Child mocks and the return value mock
+ set using normal assignment by default. In case you want to reset
+ *return_value* or :attr:`side_effect`, then pass the corresponding
+ parameter as ``True``. Child mocks and the return value mock
(if any) are reset as well.
+ .. note:: *return_value*, and :attr:`side_effect` are keyword only
+ argument.
+
.. method:: mock_add_spec(spec, spec_set=False)
diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst
index 0fc02c4..1d5f869 100644
--- a/Doc/library/unittest.rst
+++ b/Doc/library/unittest.rst
@@ -1393,9 +1393,9 @@
Add a function to be called after :meth:`tearDown` to cleanup resources
used during the test. Functions will be called in reverse order to the
- order they are added (LIFO). They are called with any arguments and
- keyword arguments passed into :meth:`addCleanup` when they are
- added.
+ order they are added (:abbr:`LIFO (last-in, first-out)`). They
+ are called with any arguments and keyword arguments passed into
+ :meth:`addCleanup` when they are added.
If :meth:`setUp` fails, meaning that :meth:`tearDown` is not called,
then any cleanup functions added will still be called.
diff --git a/Doc/library/urllib.parse.rst b/Doc/library/urllib.parse.rst
index c6de230..d79d8f0 100644
--- a/Doc/library/urllib.parse.rst
+++ b/Doc/library/urllib.parse.rst
@@ -114,8 +114,9 @@
| | | if present | |
+------------------+-------+--------------------------+----------------------+
- See section :ref:`urlparse-result-object` for more information on the result
- object.
+ Reading the :attr:`port` attribute will raise a :exc:`ValueError` if
+ an invalid port is specified in the URL. See section
+ :ref:`urlparse-result-object` for more information on the result object.
.. versionchanged:: 3.2
Added IPv6 URL parsing capabilities.
@@ -125,6 +126,10 @@
false), in accordance with :rfc:`3986`. Previously, a whitelist of
schemes that support fragments existed.
+ .. versionchanged:: 3.6
+ Out-of-range port numbers now raise :exc:`ValueError`, instead of
+ returning :const:`None`.
+
.. function:: parse_qs(qs, keep_blank_values=False, strict_parsing=False, encoding='utf-8', errors='replace')
@@ -227,8 +232,13 @@
| | | if present | |
+------------------+-------+-------------------------+----------------------+
- See section :ref:`urlparse-result-object` for more information on the result
- object.
+ Reading the :attr:`port` attribute will raise a :exc:`ValueError` if
+ an invalid port is specified in the URL. See section
+ :ref:`urlparse-result-object` for more information on the result object.
+
+ .. versionchanged:: 3.6
+ Out-of-range port numbers now raise :exc:`ValueError`, instead of
+ returning :const:`None`.
.. function:: urlunsplit(parts)
diff --git a/Doc/library/urllib.robotparser.rst b/Doc/library/urllib.robotparser.rst
index ba701c3..7d31932 100644
--- a/Doc/library/urllib.robotparser.rst
+++ b/Doc/library/urllib.robotparser.rst
@@ -57,15 +57,41 @@
Sets the time the ``robots.txt`` file was last fetched to the current
time.
+ .. method:: crawl_delay(useragent)
-The following example demonstrates basic use of the RobotFileParser class.
+ Returns the value of the ``Crawl-delay`` parameter from ``robots.txt``
+ for the *useragent* in question. If there is no such parameter or it
+ doesn't apply to the *useragent* specified or the ``robots.txt`` entry
+ for this parameter has invalid syntax, return ``None``.
+
+ .. versionadded:: 3.6
+
+ .. method:: request_rate(useragent)
+
+ Returns the contents of the ``Request-rate`` parameter from
+ ``robots.txt`` in the form of a :func:`~collections.namedtuple`
+ ``(requests, seconds)``. If there is no such parameter or it doesn't
+ apply to the *useragent* specified or the ``robots.txt`` entry for this
+ parameter has invalid syntax, return ``None``.
+
+ .. versionadded:: 3.6
+
+
+The following example demonstrates basic use of the :class:`RobotFileParser`
+class::
>>> import urllib.robotparser
>>> rp = urllib.robotparser.RobotFileParser()
>>> rp.set_url("http://www.musi-cal.com/robots.txt")
>>> rp.read()
+ >>> rrate = rp.request_rate("*")
+ >>> rrate.requests
+ 3
+ >>> rrate.seconds
+ 20
+ >>> rp.crawl_delay("*")
+ 6
>>> rp.can_fetch("*", "http://www.musi-cal.com/cgi-bin/search?city=San+Francisco")
False
>>> rp.can_fetch("*", "http://www.musi-cal.com/")
True
-
diff --git a/Doc/library/warnings.rst b/Doc/library/warnings.rst
index 5212131..fa47965 100644
--- a/Doc/library/warnings.rst
+++ b/Doc/library/warnings.rst
@@ -300,7 +300,7 @@
-------------------
-.. function:: warn(message, category=None, stacklevel=1)
+.. function:: warn(message, category=None, stacklevel=1, source=None)
Issue a warning, or maybe ignore it or raise an exception. The *category*
argument, if given, must be a warning category class (see above); it defaults to
@@ -318,8 +318,14 @@
source of :func:`deprecation` itself (since the latter would defeat the purpose
of the warning message).
+ *source*, if supplied, is the destroyed object which emitted a
+ :exc:`ResourceWarning`.
-.. function:: warn_explicit(message, category, filename, lineno, module=None, registry=None, module_globals=None)
+ .. versionchanged:: 3.6
+ Added *source* parameter.
+
+
+.. function:: warn_explicit(message, category, filename, lineno, module=None, registry=None, module_globals=None, source=None)
This is a low-level interface to the functionality of :func:`warn`, passing in
explicitly the message, category, filename and line number, and optionally the
@@ -335,6 +341,12 @@
source for modules found in zipfiles or other non-filesystem import
sources).
+ *source*, if supplied, is the destroyed object which emitted a
+ :exc:`ResourceWarning`.
+
+ .. versionchanged:: 3.6
+ Add the *source* parameter.
+
.. function:: showwarning(message, category, filename, lineno, file=None, line=None)
diff --git a/Doc/library/winreg.rst b/Doc/library/winreg.rst
index 52d591a..48bdf14 100644
--- a/Doc/library/winreg.rst
+++ b/Doc/library/winreg.rst
@@ -635,7 +635,7 @@
.. data:: REG_DWORD_LITTLE_ENDIAN
- A 32-bit number in little-endian format.
+ A 32-bit number in little-endian format. Equivalent to :const:`REG_DWORD`.
.. data:: REG_DWORD_BIG_ENDIAN
@@ -659,6 +659,18 @@
No defined value type.
+.. data:: REG_QWORD
+
+ A 64-bit number.
+
+ .. versionadded:: 3.6
+
+.. data:: REG_QWORD_LITTLE_ENDIAN
+
+ A 64-bit number in little-endian format. Equivalent to :const:`REG_QWORD`.
+
+ .. versionadded:: 3.6
+
.. data:: REG_RESOURCE_LIST
A device-driver resource list.
diff --git a/Doc/library/wsgiref.rst b/Doc/library/wsgiref.rst
index aad27a8..a1d4469 100644
--- a/Doc/library/wsgiref.rst
+++ b/Doc/library/wsgiref.rst
@@ -133,9 +133,9 @@
for key, value in environ.items()]
return ret
- httpd = make_server('', 8000, simple_app)
- print("Serving on port 8000...")
- httpd.serve_forever()
+ with make_server('', 8000, simple_app) as httpd:
+ print("Serving on port 8000...")
+ httpd.serve_forever()
In addition to the environment functions above, the :mod:`wsgiref.util` module
@@ -285,14 +285,14 @@
from wsgiref.simple_server import make_server, demo_app
- httpd = make_server('', 8000, demo_app)
- print("Serving HTTP on port 8000...")
+ with make_server('', 8000, demo_app) as httpd:
+ print("Serving HTTP on port 8000...")
- # Respond to requests until process is killed
- httpd.serve_forever()
+ # Respond to requests until process is killed
+ httpd.serve_forever()
- # Alternative: serve one request, then exit
- httpd.handle_request()
+ # Alternative: serve one request, then exit
+ httpd.handle_request()
.. function:: demo_app(environ, start_response)
@@ -432,9 +432,9 @@
# This is the application wrapped in a validator
validator_app = validator(simple_app)
- httpd = make_server('', 8000, validator_app)
- print("Listening on port 8000....")
- httpd.serve_forever()
+ with make_server('', 8000, validator_app) as httpd:
+ print("Listening on port 8000....")
+ httpd.serve_forever()
:mod:`wsgiref.handlers` -- server/gateway base classes
@@ -774,8 +774,8 @@
# The returned object is going to be printed
return [b"Hello World"]
- httpd = make_server('', 8000, hello_world_app)
- print("Serving on port 8000...")
+ with make_server('', 8000, hello_world_app) as httpd:
+ print("Serving on port 8000...")
- # Serve until process is killed
- httpd.serve_forever()
+ # Serve until process is killed
+ httpd.serve_forever()
diff --git a/Doc/library/xmlrpc.server.rst b/Doc/library/xmlrpc.server.rst
index ad1e812..2b9107f 100644
--- a/Doc/library/xmlrpc.server.rst
+++ b/Doc/library/xmlrpc.server.rst
@@ -148,29 +148,29 @@
rpc_paths = ('/RPC2',)
# Create server
- server = SimpleXMLRPCServer(("localhost", 8000),
- requestHandler=RequestHandler)
- server.register_introspection_functions()
+ with SimpleXMLRPCServer(("localhost", 8000),
+ requestHandler=RequestHandler) as server:
+ server.register_introspection_functions()
- # Register pow() function; this will use the value of
- # pow.__name__ as the name, which is just 'pow'.
- server.register_function(pow)
+ # Register pow() function; this will use the value of
+ # pow.__name__ as the name, which is just 'pow'.
+ server.register_function(pow)
- # Register a function under a different name
- def adder_function(x,y):
- return x + y
- server.register_function(adder_function, 'add')
+ # Register a function under a different name
+ def adder_function(x,y):
+ return x + y
+ server.register_function(adder_function, 'add')
- # Register an instance; all the methods of the instance are
- # published as XML-RPC methods (in this case, just 'mul').
- class MyFuncs:
- def mul(self, x, y):
- return x * y
+ # Register an instance; all the methods of the instance are
+ # published as XML-RPC methods (in this case, just 'mul').
+ class MyFuncs:
+ def mul(self, x, y):
+ return x * y
- server.register_instance(MyFuncs())
+ server.register_instance(MyFuncs())
- # Run the server's main loop
- server.serve_forever()
+ # Run the server's main loop
+ server.serve_forever()
The following client code will call the methods made available by the preceding
server::
@@ -207,18 +207,17 @@
def getCurrentTime():
return datetime.datetime.now()
- server = SimpleXMLRPCServer(("localhost", 8000))
- server.register_function(pow)
- server.register_function(lambda x,y: x+y, 'add')
- server.register_instance(ExampleService(), allow_dotted_names=True)
- server.register_multicall_functions()
- print('Serving XML-RPC on localhost port 8000')
- try:
- server.serve_forever()
- except KeyboardInterrupt:
- print("\nKeyboard interrupt received, exiting.")
- server.server_close()
- sys.exit(0)
+ with SimpleXMLRPCServer(("localhost", 8000)) as server:
+ server.register_function(pow)
+ server.register_function(lambda x,y: x+y, 'add')
+ server.register_instance(ExampleService(), allow_dotted_names=True)
+ server.register_multicall_functions()
+ print('Serving XML-RPC on localhost port 8000')
+ try:
+ server.serve_forever()
+ except KeyboardInterrupt:
+ print("\nKeyboard interrupt received, exiting.")
+ sys.exit(0)
This ExampleService demo can be invoked from the command line::
diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst
index abe38c4..6c9d207 100644
--- a/Doc/library/zipfile.rst
+++ b/Doc/library/zipfile.rst
@@ -205,18 +205,13 @@
Return a list of archive members by name.
-.. index::
- single: universal newlines; zipfile.ZipFile.open method
+.. method:: ZipFile.open(name, mode='r', pwd=None, *, force_zip64=False)
-.. method:: ZipFile.open(name, mode='r', pwd=None)
-
- Extract a member from the archive as a file-like object (ZipExtFile). *name*
- is the name of the file in the archive, or a :class:`ZipInfo` object. The
- *mode* parameter, if included, must be one of the following: ``'r'`` (the
- default), ``'U'``, or ``'rU'``. Choosing ``'U'`` or ``'rU'`` will enable
- :term:`universal newlines` support in the read-only object. *pwd* is the
- password used for encrypted files. Calling :meth:`.open` on a closed
- ZipFile will raise a :exc:`RuntimeError`.
+ Access a member of the archive as a binary file-like object. *name*
+ can be either the name of a file within the archive or a :class:`ZipInfo`
+ object. The *mode* parameter, if included, must be ``'r'`` (the default)
+ or ``'w'``. *pwd* is the password used to decrypt encrypted ZIP files.
+ Calling :meth:`.open` on a closed ZipFile will raise a :exc:`RuntimeError`.
:meth:`~ZipFile.open` is also a context manager and therefore supports the
:keyword:`with` statement::
@@ -225,17 +220,23 @@
with myzip.open('eggs.txt') as myfile:
print(myfile.read())
- .. note::
+ With *mode* ``'r'`` the file-like object
+ (``ZipExtFile``) is read-only and provides the following methods:
+ :meth:`~io.BufferedIOBase.read`, :meth:`~io.IOBase.readline`,
+ :meth:`~io.IOBase.readlines`, :meth:`__iter__`,
+ :meth:`~iterator.__next__`. These objects can operate independently of
+ the ZipFile.
- The file-like object is read-only and provides the following methods:
- :meth:`~io.BufferedIOBase.read`, :meth:`~io.IOBase.readline`,
- :meth:`~io.IOBase.readlines`, :meth:`__iter__`,
- :meth:`~iterator.__next__`.
+ With ``mode='w'``, a writable file handle is returned, which supports the
+ :meth:`~io.BufferedIOBase.write` method. While a writable file handle is open,
+ attempting to read or write other files in the ZIP file will raise a
+ :exc:`RuntimeError`.
- .. note::
-
- Objects returned by :meth:`.open` can operate independently of the
- ZipFile.
+ When writing a file, if the file size is not known in advance but may exceed
+ 2 GiB, pass ``force_zip64=True`` to ensure that the header format is
+ capable of supporting large files. If the file size is known in advance,
+ construct a :class:`ZipInfo` object with :attr:`~ZipInfo.file_size` set, and
+ use that as the *name* parameter.
.. note::
@@ -243,10 +244,14 @@
or a :class:`ZipInfo` object. You will appreciate this when trying to read a
ZIP file that contains members with duplicate names.
- .. deprecated-removed:: 3.4 3.6
- The ``'U'`` or ``'rU'`` mode. Use :class:`io.TextIOWrapper` for reading
+ .. versionchanged:: 3.6
+ Removed support of ``mode='U'``. Use :class:`io.TextIOWrapper` for reading
compressed text files in :term:`universal newlines` mode.
+ .. versionchanged:: 3.6
+ :meth:`open` can now be used to write files into the archive with the
+ ``mode='w'`` option.
+
.. method:: ZipFile.extract(member, path=None, pwd=None)
Extract a member from the archive to the current working directory; *member*
@@ -465,7 +470,31 @@
:meth:`.infolist` methods of :class:`ZipFile` objects. Each object stores
information about a single member of the ZIP archive.
-Instances have the following attributes:
+There is one classmethod to make a :class:`ZipInfo` instance for a filesystem
+file:
+
+.. classmethod:: ZipInfo.from_file(filename, arcname=None)
+
+ Construct a :class:`ZipInfo` instance for a file on the filesystem, in
+ preparation for adding it to a zip file.
+
+ *filename* should be the path to a file or directory on the filesystem.
+
+ If *arcname* is specified, it is used as the name within the archive.
+ If *arcname* is not specified, the name will be the same as *filename*, but
+ with any drive letter and leading path separators removed.
+
+ .. versionadded:: 3.6
+
+Instances have the following methods and attributes:
+
+.. method:: ZipInfo.is_dir()
+
+ Return True if this archive member is a directory.
+
+ This uses the entry's name: directories should always end with ``/``.
+
+ .. versionadded:: 3.6
.. attribute:: ZipInfo.filename
@@ -574,4 +603,5 @@
Size of the uncompressed file.
+
.. _PKZIP Application Note: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
diff --git a/Doc/library/zlib.rst b/Doc/library/zlib.rst
index 1de7bae..846020c 100644
--- a/Doc/library/zlib.rst
+++ b/Doc/library/zlib.rst
@@ -47,14 +47,19 @@
platforms, use ``adler32(data) & 0xffffffff``.
-.. function:: compress(data[, level])
+.. function:: compress(data, level=-1)
Compresses the bytes in *data*, returning a bytes object containing compressed data.
- *level* is an integer from ``0`` to ``9`` controlling the level of compression;
+ *level* is an integer from ``0`` to ``9`` or ``-1`` controlling the level of compression;
``1`` is fastest and produces the least compression, ``9`` is slowest and
- produces the most. ``0`` is no compression. The default value is ``6``.
+ produces the most. ``0`` is no compression. The default value is ``-1``
+ (Z_DEFAULT_COMPRESSION). Z_DEFAULT_COMPRESSION represents a default
+ compromise between speed and compression (currently equivalent to level 6).
Raises the :exc:`error` exception if any error occurs.
+ .. versionchanged:: 3.6
+ *level* can now be used as a keyword parameter.
+
.. function:: compressobj(level=-1, method=DEFLATED, wbits=15, memLevel=8, strategy=Z_DEFAULT_STRATEGY[, zdict])
diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst
index 2469422..e1a7f57 100644
--- a/Doc/reference/compound_stmts.rst
+++ b/Doc/reference/compound_stmts.rst
@@ -471,10 +471,10 @@
decorators: `decorator`+
decorator: "@" `dotted_name` ["(" [`argument_list` [","]] ")"] NEWLINE
dotted_name: `identifier` ("." `identifier`)*
- parameter_list: (`defparameter` ",")*
- : | "*" [`parameter`] ("," `defparameter`)* ["," "**" `parameter`]
- : | "**" `parameter`
- : | `defparameter` [","] )
+ parameter_list: `defparameter` ("," `defparameter`)* ["," [`parameter_list_starargs`]]
+ : | `parameter_list_starargs`
+ parameter_list_starargs: "*" [`parameter`] ("," `defparameter`)* ["," ["**" `parameter` [","]]]
+ : | "**" `parameter` [","]
parameter: `identifier` [":" `expression`]
defparameter: `parameter` ["=" `expression`]
funcname: `identifier`
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index f97eb08..4c88e38 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -1233,8 +1233,9 @@
.. method:: object.__format__(self, format_spec)
- Called by the :func:`format` built-in function (and by extension, the
- :meth:`str.format` method of class :class:`str`) to produce a "formatted"
+ Called by the :func:`format` built-in function,
+ and by extension, evaluation of :ref:`formatted string literals
+ <f-strings>` and the :meth:`str.format` method, to produce a "formatted"
string representation of an object. The ``format_spec`` argument is
a string that contains a description of the formatting options desired.
The interpretation of the ``format_spec`` argument is up to the type
diff --git a/Doc/reference/import.rst b/Doc/reference/import.rst
index 2144c1f..56049ce 100644
--- a/Doc/reference/import.rst
+++ b/Doc/reference/import.rst
@@ -554,19 +554,30 @@
details.
This attribute is used instead of ``__name__`` to calculate explicit
- relative imports for main modules, as defined in :pep:`366`.
+ relative imports for main modules, as defined in :pep:`366`. It is
+ expected to have the same value as ``__spec__.parent``.
+
+ .. versionchanged:: 3.6
+ The value of ``__package__`` is expected to be the same as
+ ``__spec__.parent``.
.. attribute:: __spec__
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__``
+ used when importing the module. Setting ``__spec__``
appropriately applies equally to :ref:`modules initialized during
interpreter startup <programs>`. The one exception is ``__main__``,
where ``__spec__`` is :ref:`set to None in some cases <main_spec>`.
+ When ``__package__`` is not defined, ``__spec__.parent`` is used as
+ a fallback.
+
.. versionadded:: 3.4
+ .. versionchanged:: 3.6
+ ``__spec__.parent`` is used as a fallback when ``__package__`` is
+ not defined.
+
.. attribute:: __path__
If the module is a package (either regular or namespace), the module
diff --git a/Doc/reference/lexical_analysis.rst b/Doc/reference/lexical_analysis.rst
index 71964d7..7af1b28 100644
--- a/Doc/reference/lexical_analysis.rst
+++ b/Doc/reference/lexical_analysis.rst
@@ -405,7 +405,8 @@
.. productionlist::
stringliteral: [`stringprefix`](`shortstring` | `longstring`)
- stringprefix: "r" | "u" | "R" | "U"
+ stringprefix: "r" | "u" | "R" | "U" | "f" | "F"
+ : | "fr" | "Fr" | "fR" | "FR" | "rf" | "rF" | "Rf" | "RF"
shortstring: "'" `shortstringitem`* "'" | '"' `shortstringitem`* '"'
longstring: "'''" `longstringitem`* "'''" | '"""' `longstringitem`* '"""'
shortstringitem: `shortstringchar` | `stringescapeseq`
@@ -464,6 +465,11 @@
to simplify the maintenance of dual Python 2.x and 3.x codebases.
See :pep:`414` for more information.
+A string literal with ``'f'`` or ``'F'`` in its prefix is a
+:dfn:`formatted string literal`; see :ref:`f-strings`. The ``'f'`` may be
+combined with ``'r'``, but not with ``'b'`` or ``'u'``, therefore raw
+formatted strings are possible, but formatted bytes literals are not.
+
In triple-quoted literals, unescaped newlines and quotes are allowed (and are
retained), except that three unescaped quotes in a row terminate the literal. (A
"quote" is the character used to open the literal, i.e. either ``'`` or ``"``.)
@@ -583,7 +589,106 @@
Note that this feature is defined at the syntactical level, but implemented at
compile time. The '+' operator must be used to concatenate string expressions
at run time. Also note that literal concatenation can use different quoting
-styles for each component (even mixing raw strings and triple quoted strings).
+styles for each component (even mixing raw strings and triple quoted strings),
+and formatted string literals may be concatenated with plain string literals.
+
+
+.. index::
+ single: formatted string literal
+ single: interpolated string literal
+ single: string; formatted literal
+ single: string; interpolated literal
+ single: f-string
+.. _f-strings:
+
+Formatted string literals
+-------------------------
+
+.. versionadded:: 3.6
+
+A :dfn:`formatted string literal` or :dfn:`f-string` is a string literal
+that is prefixed with ``'f'`` or ``'F'``. These strings may contain
+replacement fields, which are expressions delimited by curly braces ``{}``.
+While other string literals always have a constant value, formatted strings
+are really expressions evaluated at run time.
+
+Escape sequences are decoded like in ordinary string literals (except when
+a literal is also marked as a raw string). After decoding, the grammar
+for the contents of the string is:
+
+.. productionlist::
+ f_string: (`literal_char` | "{{" | "}}" | `replacement_field`)*
+ replacement_field: "{" `f_expression` ["!" `conversion`] [":" `format_spec`] "}"
+ f_expression: (`conditional_expression` | "*" `or_expr`)
+ : ("," `conditional_expression` | "," "*" `or_expr`)* [","]
+ : | `yield_expression`
+ conversion: "s" | "r" | "a"
+ format_spec: (`literal_char` | NULL | `replacement_field`)*
+ literal_char: <any code point except "{", "}" or NULL>
+
+The parts of the string outside curly braces are treated literally,
+except that any doubled curly braces ``'{{'`` or ``'}}'`` are replaced
+with the corresponding single curly brace. A single opening curly
+bracket ``'{'`` marks a replacement field, which starts with a
+Python expression. After the expression, there may be a conversion field,
+introduced by an exclamation point ``'!'``. A format specifier may also
+be appended, introduced by a colon ``':'``. A replacement field ends
+with a closing curly bracket ``'}'``.
+
+Expressions in formatted string literals are treated like regular
+Python expressions surrounded by parentheses, with a few exceptions.
+An empty expression is not allowed, and a :keyword:`lambda` expression
+must be surrounded by explicit parentheses. Replacement expressions
+can contain line breaks (e.g. in triple-quoted strings), but they
+cannot contain comments. Each expression is evaluated in the context
+where the formatted string literal appears, in order from left to right.
+
+If a conversion is specified, the result of evaluating the expression
+is converted before formatting. Conversion ``'!s'`` calls :func:`str` on
+the result, ``'!r'`` calls :func:`repr`, and ``'!a'`` calls :func:`ascii`.
+
+The result is then formatted using the :func:`format` protocol. The
+format specifier is passed to the :meth:`__format__` method of the
+expression or conversion result. An empty string is passed when the
+format specifier is omitted. The formatted result is then included in
+the final value of the whole string.
+
+Top-level format specifiers may include nested replacement fields.
+These nested fields may include their own conversion fields and
+format specifiers, but may not include more deeply-nested replacement fields.
+
+Formatted string literals may be concatenated, but replacement fields
+cannot be split across literals.
+
+Some examples of formatted string literals::
+
+ >>> name = "Fred"
+ >>> f"He said his name is {name!r}."
+ "He said his name is 'Fred'."
+ >>> f"He said his name is {repr(name)}." # repr() is equivalent to !r
+ "He said his name is 'Fred'."
+ >>> width = 10
+ >>> precision = 4
+ >>> value = decimal.Decimal("12.34567")
+ >>> f"result: {value:{width}.{precision}}" # nested fields
+ 'result: 12.35'
+
+A consequence of sharing the same syntax as regular string literals is
+that characters in the replacement fields must not conflict with the
+quoting used in the outer formatted string literal. Also, escape
+sequences normally apply to the outer formatted string literal,
+rather than inner string literals::
+
+ f"abc {a["x"]} def" # error: outer string literal ended prematurely
+ f"abc {a[\"x\"]} def" # workaround: escape the inner quotes
+ f"abc {a['x']} def" # workaround: use different quoting
+
+ f"newline: {ord('\n')}" # error: literal line break in inner string
+ f"newline: {ord('\\n')}" # workaround: double escaping
+ fr"newline: {ord('\n')}" # workaround: raw outer string
+
+See also :pep:`498` for the proposal that added formatted string literals,
+and :meth:`str.format`, which uses a related format string mechanism.
.. _numbers:
diff --git a/Doc/reference/simple_stmts.rst b/Doc/reference/simple_stmts.rst
index d403c4d..eee3f43 100644
--- a/Doc/reference/simple_stmts.rst
+++ b/Doc/reference/simple_stmts.rst
@@ -84,7 +84,7 @@
assignment_stmt: (`target_list` "=")+ (`starred_expression` | `yield_expression`)
target_list: `target` ("," `target`)* [","]
target: `identifier`
- : | "(" `target_list` ")"
+ : | "(" [`target_list`] ")"
: | "[" [`target_list`] "]"
: | `attributeref`
: | `subscription`
diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py
index 6311283..7986017 100644
--- a/Doc/tools/extensions/pyspecific.py
+++ b/Doc/tools/extensions/pyspecific.py
@@ -34,7 +34,7 @@
ISSUE_URI = 'https://bugs.python.org/issue%s'
-SOURCE_URI = 'https://hg.python.org/cpython/file/3.5/%s'
+SOURCE_URI = 'https://hg.python.org/cpython/file/default/%s'
# monkey-patch reST parser to disable alphabetic and roman enumerated lists
from docutils.parsers.rst.states import Body
diff --git a/Doc/tools/susp-ignored.csv b/Doc/tools/susp-ignored.csv
index dba93bf..4d3ecda 100644
--- a/Doc/tools/susp-ignored.csv
+++ b/Doc/tools/susp-ignored.csv
@@ -272,6 +272,7 @@
whatsnew/3.2,,:gz,">>> with tarfile.open(name='myarchive.tar.gz', mode='w:gz') as tf:"
whatsnew/3.2,,:location,zope9-location = ${zope9:location}
whatsnew/3.2,,:prefix,zope-conf = ${custom:prefix}/etc/zope.conf
+whatsnew/changelog,,:version,import sys; I = version[:version.index(' ')]
whatsnew/changelog,,:gz,": TarFile opened with external fileobj and ""w:gz"" mode didn't"
whatsnew/changelog,,::,": Use ""127.0.0.1"" or ""::1"" instead of ""localhost"" as much as"
library/tarfile,149,:xz,'x:xz'
diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst
index ddc0855..b03b553 100644
--- a/Doc/tutorial/controlflow.rst
+++ b/Doc/tutorial/controlflow.rst
@@ -78,6 +78,9 @@
>>> words
['defenestrate', 'cat', 'window', 'defenestrate']
+With ``for w in words:``, the example would attempt to create an infinite list,
+inserting ``defenestrate`` over and over again.
+
.. _tut-range:
diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst
index dd9c7cd..beeaac3 100644
--- a/Doc/tutorial/inputoutput.rst
+++ b/Doc/tutorial/inputoutput.rst
@@ -25,7 +25,8 @@
concatenation operations you can create any layout you can imagine. The
string type has some methods that perform useful operations for padding
strings to a given column width; these will be discussed shortly. The second
-way is to use the :meth:`str.format` method.
+way is to use :ref:`formatted string literals <f-strings>`, or the
+:meth:`str.format` method.
The :mod:`string` module contains a :class:`~string.Template` class which offers
yet another way to substitute values into strings.
diff --git a/Doc/tutorial/interpreter.rst b/Doc/tutorial/interpreter.rst
index e966085..c89fae3 100644
--- a/Doc/tutorial/interpreter.rst
+++ b/Doc/tutorial/interpreter.rst
@@ -10,13 +10,13 @@
Invoking the Interpreter
========================
-The Python interpreter is usually installed as :file:`/usr/local/bin/python3.5`
+The Python interpreter is usually installed as :file:`/usr/local/bin/python3.6`
on those machines where it is available; putting :file:`/usr/local/bin` in your
Unix shell's search path makes it possible to start it by typing the command:
.. code-block:: text
- python3.5
+ python3.6
to the shell. [#]_ Since the choice of the directory where the interpreter lives
is an installation option, other places are possible; check with your local
@@ -24,11 +24,11 @@
popular alternative location.)
On Windows machines, the Python installation is usually placed in
-:file:`C:\\Python35`, though you can change this when you're running the
+:file:`C:\\Python36`, though you can change this when you're running the
installer. To add this directory to your path, you can type the following
command into the command prompt in a DOS box::
- set path=%path%;C:\python35
+ set path=%path%;C:\python36
Typing an end-of-file character (:kbd:`Control-D` on Unix, :kbd:`Control-Z` on
Windows) at the primary prompt causes the interpreter to exit with a zero exit
@@ -96,8 +96,8 @@
prints a welcome message stating its version number and a copyright notice
before printing the first prompt::
- $ python3.5
- Python 3.5 (default, Sep 16 2015, 09:25:04)
+ $ python3.6
+ Python 3.6 (default, Sep 16 2015, 09:25:04)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst
index 2140329..7e8ee3e 100644
--- a/Doc/tutorial/introduction.rst
+++ b/Doc/tutorial/introduction.rst
@@ -352,6 +352,9 @@
Strings support a large number of methods for
basic transformations and searching.
+ :ref:`f-strings`
+ String literals that have embedded expressions.
+
:ref:`formatstrings`
Information about string formatting with :meth:`str.format`.
diff --git a/Doc/tutorial/stdlib.rst b/Doc/tutorial/stdlib.rst
index 52ffdbe..1dd06c2 100644
--- a/Doc/tutorial/stdlib.rst
+++ b/Doc/tutorial/stdlib.rst
@@ -15,7 +15,7 @@
>>> import os
>>> os.getcwd() # Return the current working directory
- 'C:\\Python35'
+ 'C:\\Python36'
>>> os.chdir('/server/accesslogs') # Change current working directory
>>> os.system('mkdir today') # Run the command mkdir in the system shell
0
diff --git a/Doc/tutorial/stdlib2.rst b/Doc/tutorial/stdlib2.rst
index 3714384..bf4cf87 100644
--- a/Doc/tutorial/stdlib2.rst
+++ b/Doc/tutorial/stdlib2.rst
@@ -278,7 +278,7 @@
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
d['primary'] # entry was automatically removed
- File "C:/python35/lib/weakref.py", line 46, in __getitem__
+ File "C:/python36/lib/weakref.py", line 46, in __getitem__
o = self.data[key]()
KeyError: 'primary'
diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst
index ec744a3..49fe3a0 100644
--- a/Doc/using/cmdline.rst
+++ b/Doc/using/cmdline.rst
@@ -621,6 +621,54 @@
.. versionadded:: 3.4
+.. envvar:: PYTHONMALLOC
+
+ Set the Python memory allocators and/or install debug hooks.
+
+ Set the family of memory allocators used by Python:
+
+ * ``malloc``: use the :c:func:`malloc` function of the C library
+ for all domains (:c:data:`PYMEM_DOMAIN_RAW`, :c:data:`PYMEM_DOMAIN_MEM`,
+ :c:data:`PYMEM_DOMAIN_OBJ`).
+ * ``pymalloc``: use the :ref:`pymalloc allocator <pymalloc>` for
+ :c:data:`PYMEM_DOMAIN_MEM` and :c:data:`PYMEM_DOMAIN_OBJ` domains and use
+ the :c:func:`malloc` function for the :c:data:`PYMEM_DOMAIN_RAW` domain.
+
+ Install debug hooks:
+
+ * ``debug``: install debug hooks on top of the default memory allocator
+ * ``malloc_debug``: same as ``malloc`` but also install debug hooks
+ * ``pymalloc_debug``: same as ``pymalloc`` but also install debug hooks
+
+ When Python is compiled in release mode, the default is ``pymalloc``. When
+ compiled in debug mode, the default is ``pymalloc_debug`` and the debug hooks
+ are used automatically.
+
+ If Python is configured without ``pymalloc`` support, ``pymalloc`` and
+ ``pymalloc_debug`` are not available, the default is ``malloc`` in release
+ mode and ``malloc_debug`` in debug mode.
+
+ See the :c:func:`PyMem_SetupDebugHooks` function for debug hooks on Python
+ memory allocators.
+
+ .. versionadded:: 3.6
+
+
+.. envvar:: PYTHONMALLOCSTATS
+
+ If set to a non-empty string, Python will print statistics of the
+ :ref:`pymalloc memory allocator <pymalloc>` every time a new pymalloc object
+ arena is created, and on shutdown.
+
+ This variable is ignored if the :envvar:`PYTHONMALLOC` environment variable
+ is used to force the :c:func:`malloc` allocator of the C library, or if
+ Python is configured without ``pymalloc`` support.
+
+ .. versionchanged:: 3.6
+ This variable can now also be used on Python compiled in release mode.
+ It now has no effect if set to an empty string.
+
+
Debug-mode variables
~~~~~~~~~~~~~~~~~~~~
@@ -636,9 +684,3 @@
If set, Python will dump objects and reference counts still alive after
shutting down the interpreter.
-
-
-.. envvar:: PYTHONMALLOCSTATS
-
- If set, Python will print memory allocation statistics every time a new
- object arena is created, and on shutdown.
diff --git a/Doc/using/mac.rst b/Doc/using/mac.rst
index 05c91bb..8f1ac3f 100644
--- a/Doc/using/mac.rst
+++ b/Doc/using/mac.rst
@@ -25,7 +25,7 @@
What you get after installing is a number of things:
-* A :file:`MacPython 3.5` folder in your :file:`Applications` folder. In here
+* A :file:`MacPython 3.6` folder in your :file:`Applications` folder. In here
you find IDLE, the development environment that is a standard part of official
Python distributions; PythonLauncher, which handles double-clicking Python
scripts from the Finder; and the "Build Applet" tool, which allows you to
@@ -93,7 +93,7 @@
anything that has a GUI) need to be run in a special way. Use :program:`pythonw`
instead of :program:`python` to start such scripts.
-With Python 3.5, you can use either :program:`python` or :program:`pythonw`.
+With Python 3.6, you can use either :program:`python` or :program:`pythonw`.
Configuration
@@ -159,7 +159,7 @@
Distributing Python Applications on the Mac
===========================================
-The "Build Applet" tool that is placed in the MacPython 3.5 folder is fine for
+The "Build Applet" tool that is placed in the MacPython 3.6 folder is fine for
packaging small Python scripts on your own machine to run as a standard Mac
application. This tool, however, is not robust enough to distribute Python
applications to other users.
diff --git a/Doc/using/windows.rst b/Doc/using/windows.rst
index 7520d60..2399278 100644
--- a/Doc/using/windows.rst
+++ b/Doc/using/windows.rst
@@ -418,6 +418,8 @@
From the command-line
^^^^^^^^^^^^^^^^^^^^^
+.. versionchanged:: 3.6
+
System-wide installations of Python 3.3 and later will put the launcher on your
:envvar:`PATH`. The launcher is compatible with all available versions of
Python, so it does not matter which version is installed. To check that the
@@ -427,25 +429,26 @@
py
-You should find that the latest version of Python 2.x you have installed is
+You should find that the latest version of Python you have installed is
started - it can be exited as normal, and any additional command-line
arguments specified will be sent directly to Python.
-If you have multiple versions of Python 2.x installed (e.g., 2.6 and 2.7) you
-will have noticed that Python 2.7 was started - to launch Python 2.6, try the
+If you have multiple versions of Python installed (e.g., 2.7 and 3.6) you
+will have noticed that Python 3.6 was started - to launch Python 2.7, try the
command:
::
- py -2.6
+ py -2.7
-If you have a Python 3.x installed, try the command:
+If you want the latest version of Python 2.x you have installed, try the
+command:
::
- py -3
+ py -2
-You should find the latest version of Python 3.x starts.
+You should find the latest version of Python 2.x starts.
If you see the following error, you do not have the launcher installed:
@@ -500,6 +503,11 @@
first line to ``#! python2.6`` and you should find the 2.6 version
information printed.
+Note that unlike interactive use, a bare "python" will use the latest
+version of Python 2.x that you have installed. This is for backward
+compatibility and for compatibility with Unix, where the command ``python``
+typically refers to Python 2.
+
From file associations
^^^^^^^^^^^^^^^^^^^^^^
diff --git a/Doc/whatsnew/2.1.rst b/Doc/whatsnew/2.1.rst
index 06366b8..6aae726 100644
--- a/Doc/whatsnew/2.1.rst
+++ b/Doc/whatsnew/2.1.rst
@@ -367,7 +367,7 @@
This version works for simple things such as integers, but it has a side effect;
the ``_cache`` dictionary holds a reference to the return values, so they'll
-never be deallocated until the Python process exits and cleans up This isn't
+never be deallocated until the Python process exits and cleans up. This isn't
very noticeable for integers, but if :func:`f` returns an object, or a data
structure that takes up a lot of memory, this can be a problem.
diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst
new file mode 100644
index 0000000..a8802a4
--- /dev/null
+++ b/Doc/whatsnew/3.6.rst
@@ -0,0 +1,738 @@
+****************************
+ What's New In Python 3.6
+****************************
+
+:Release: |release|
+:Date: |today|
+
+.. Rules for maintenance:
+
+ * Anyone can add text to this document. Do not spend very much time
+ on the wording of your changes, because your text will probably
+ get rewritten to some degree.
+
+ * The maintainer will go through Misc/NEWS periodically and add
+ changes; it's therefore more important to add your changes to
+ Misc/NEWS than to this file.
+
+ * This is not a complete list of every single change; completeness
+ is the purpose of Misc/NEWS. Some changes I consider too small
+ or esoteric to include. If such a change is added to the text,
+ I'll just remove it. (This is another reason you shouldn't spend
+ too much time on writing your addition.)
+
+ * If you want to draw your new text to the attention of the
+ maintainer, add 'XXX' to the beginning of the paragraph or
+ section.
+
+ * It's OK to just add a fragmentary note about a change. For
+ example: "XXX Describe the transmogrify() function added to the
+ socket module." The maintainer will research the change and
+ write the necessary text.
+
+ * You can comment out your additions if you like, but it's not
+ necessary (especially when a final release is some months away).
+
+ * Credit the author of a patch or bugfix. Just the name is
+ sufficient; the e-mail address isn't necessary.
+
+ * It's helpful to add the bug/patch number as a comment:
+
+ XXX Describe the transmogrify() function added to the socket
+ module.
+ (Contributed by P.Y. Developer in :issue:`12345`.)
+
+ This saves the maintainer the effort of going through the Mercurial log
+ when researching a change.
+
+This article explains the new features in Python 3.6, compared to 3.5.
+
+For full details, see the :source:`Misc/NEWS` file.
+
+.. note::
+
+ Prerelease users should be aware that this document is currently in draft
+ form. It will be updated substantially as Python 3.6 moves towards release,
+ so it's worth checking back even after reading earlier versions.
+
+
+Summary -- Release highlights
+=============================
+
+.. This section singles out the most important changes in Python 3.6.
+ Brevity is key.
+
+New syntax features:
+
+* PEP 498: :ref:`Formatted string literals <whatsnew-fstrings>`
+
+Windows improvements:
+
+* The ``py.exe`` launcher, when used interactively, no longer prefers
+ Python 2 over Python 3 when the user doesn't specify a version (via
+ command line arguments or a config file). Handling of shebang lines
+ remains unchanged - "python" refers to Python 2 in that case.
+
+.. PEP-sized items next.
+
+.. _pep-4XX:
+
+.. PEP 4XX: Virtual Environments
+.. =============================
+
+
+.. (Implemented by Foo Bar.)
+
+.. .. seealso::
+
+ :pep:`4XX` - Python Virtual Environments
+ PEP written by Carl Meyer
+
+
+New Features
+============
+
+.. _whatsnew-fstrings:
+
+PEP 498: Formatted string literals
+----------------------------------
+
+Formatted string literals are a new kind of string literal, prefixed
+with ``'f'``. They are similar to the format strings accepted by
+:meth:`str.format`. They contain replacement fields surrounded by
+curly braces. The replacement fields are expressions, which are
+evaluated at run time, and then formatted using the :func:`format` protocol.
+
+ >>> name = "Fred"
+ >>> f"He said his name is {name}."
+ 'He said his name is Fred.'
+
+See :pep:`498` and the main documentation at :ref:`f-strings`.
+
+
+PYTHONMALLOC environment variable
+---------------------------------
+
+The new :envvar:`PYTHONMALLOC` environment variable allows setting the Python
+memory allocators and/or install debug hooks.
+
+It is now possible to install debug hooks on Python memory allocators on Python
+compiled in release mode using ``PYTHONMALLOC=debug``. Effects of debug hooks:
+
+* Newly allocated memory is filled with the byte ``0xCB``
+* Freed memory is filled with the byte ``0xDB``
+* Detect violations of Python memory allocator API. For example,
+ :c:func:`PyObject_Free` called on a memory block allocated by
+ :c:func:`PyMem_Malloc`.
+* Detect write before the start of the buffer (buffer underflow)
+* Detect write after the end of the buffer (buffer overflow)
+* Check that the :term:`GIL <global interpreter lock>` is held when allocator
+ functions of :c:data:`PYMEM_DOMAIN_OBJ` (ex: :c:func:`PyObject_Malloc`) and
+ :c:data:`PYMEM_DOMAIN_MEM` (ex: :c:func:`PyMem_Malloc`) domains are called.
+
+Checking if the GIL is held is also a new feature of Python 3.6.
+
+See the :c:func:`PyMem_SetupDebugHooks` function for debug hooks on Python
+memory allocators.
+
+It is now also possible to force the usage of the :c:func:`malloc` allocator of
+the C library for all Python memory allocations using ``PYTHONMALLOC=malloc``.
+It helps to use external memory debuggers like Valgrind on a Python compiled in
+release mode.
+
+On error, the debug hooks on Python memory allocators now use the
+:mod:`tracemalloc` module to get the traceback where a memory block was
+allocated.
+
+Example of fatal error on buffer overflow using
+``python3.6 -X tracemalloc=5`` (store 5 frames in traces)::
+
+ Debug memory block at address p=0x7fbcd41666f8: API 'o'
+ 4 bytes originally requested
+ The 7 pad bytes at p-7 are FORBIDDENBYTE, as expected.
+ The 8 pad bytes at tail=0x7fbcd41666fc are not all FORBIDDENBYTE (0xfb):
+ at tail+0: 0x02 *** OUCH
+ at tail+1: 0xfb
+ at tail+2: 0xfb
+ at tail+3: 0xfb
+ at tail+4: 0xfb
+ at tail+5: 0xfb
+ at tail+6: 0xfb
+ at tail+7: 0xfb
+ The block was made by call #1233329 to debug malloc/realloc.
+ Data at p: 1a 2b 30 00
+
+ Memory block allocated at (most recent call first):
+ File "test/test_bytes.py", line 323
+ File "unittest/case.py", line 600
+ File "unittest/case.py", line 648
+ File "unittest/suite.py", line 122
+ File "unittest/suite.py", line 84
+
+ Fatal Python error: bad trailing pad byte
+
+ Current thread 0x00007fbcdbd32700 (most recent call first):
+ File "test/test_bytes.py", line 323 in test_hex
+ File "unittest/case.py", line 600 in run
+ File "unittest/case.py", line 648 in __call__
+ File "unittest/suite.py", line 122 in run
+ File "unittest/suite.py", line 84 in __call__
+ File "unittest/suite.py", line 122 in run
+ File "unittest/suite.py", line 84 in __call__
+ ...
+
+(Contributed by Victor Stinner in :issue:`26516` and :issue:`26564`.)
+
+
+Other Language Changes
+======================
+
+* None yet.
+
+
+New Modules
+===========
+
+* None yet.
+
+
+Improved Modules
+================
+
+
+asyncio
+-------
+
+Since the :mod:`asyncio` module is :term:`provisional <provisional api>`,
+all changes introduced in Python 3.6 have also been backported to Python
+3.5.x.
+
+Notable changes in the :mod:`asyncio` module since Python 3.5.0:
+
+* The :func:`~asyncio.ensure_future` function and all functions that
+ use it, such as :meth:`loop.run_until_complete() <asyncio.BaseEventLoop.run_until_complete>`,
+ now accept all kinds of :term:`awaitable objects <awaitable>`.
+ (Contributed by Yury Selivanov.)
+
+* New :func:`~asyncio.run_coroutine_threadsafe` function to submit
+ coroutines to event loops from other threads.
+ (Contributed by Vincent Michel.)
+
+* New :meth:`Transport.is_closing() <asyncio.BaseTransport.is_closing>`
+ method to check if the transport is closing or closed.
+ (Contributed by Yury Selivanov.)
+
+* The :meth:`loop.create_server() <asyncio.BaseEventLoop.create_server>`
+ method can now accept a list of hosts.
+ (Contributed by Yann Sionneau.)
+
+* New :meth:`loop.create_future() <asyncio.BaseEventLoop.create_future>`
+ method to create Future objects. This allows alternative event
+ loop implementations, such as
+ `uvloop <https://github.com/MagicStack/uvloop>`_, to provide a faster
+ :class:`asyncio.Future` implementation.
+ (Contributed by Yury Selivanov.)
+
+* New :meth:`loop.get_exception_handler() <asyncio.BaseEventLoop.get_exception_handler>`
+ method to get the current exception handler.
+ (Contributed by Yury Selivanov.)
+
+* New :func:`~asyncio.timeout` context manager to simplify timeouts
+ handling code.
+ (Contributed by Andrew Svetlov.)
+
+* New :meth:`StreamReader.readuntil() <asyncio.StreamReader.readuntil>`
+ method to read data from the stream until a separator bytes
+ sequence appears.
+ (Contributed by Mark Korenberg.)
+
+* The :meth:`loop.getaddrinfo() <asyncio.BaseEventLoop.getaddrinfo>`
+ method is optimized to avoid calling the system ``getaddrinfo``
+ function if the address is already resolved.
+ (Contributed by A. Jesse Jiryu Davis.)
+
+
+contextlib
+----------
+
+The :class:`contextlib.AbstractContextManager` class has been added to
+provide an abstract base class for context managers. It provides a
+sensible default implementation for `__enter__()` which returns
+``self`` and leaves `__exit__()` an abstract method. A matching
+class has been added to the :mod:`typing` module as
+:class:`typing.ContextManager`.
+(Contributed by Brett Cannon in :issue:`25609`.)
+
+
+datetime
+--------
+
+The :meth:`datetime.strftime() <datetime.datetime.strftime>` and
+:meth:`date.strftime() <datetime.date.strftime>` methods now support ISO 8601 date
+directives ``%G``, ``%u`` and ``%V``.
+(Contributed by Ashley Anderson in :issue:`12006`.)
+
+
+faulthandler
+------------
+
+On Windows, the :mod:`faulthandler` module now installs a handler for Windows
+exceptions: see :func:`faulthandler.enable`. (Contributed by Victor Stinner in
+:issue:`23848`.)
+
+
+idlelib and IDLE
+----------------
+
+The idlelib package is being modernized and refactored to make IDLE look and work better and to make the code easier to understand, test, and improve. Part of making IDLE look better, especially on Linux and Mac, is using ttk widgets, mostly in the dialogs. As a result, IDLE no longer runs with tcl/tk 8.4. It now requires tcl/tk 8.5 or 8.6. We recommend running the latest release of either.
+
+'Modernizing' includes renaming and consolidation of idlelib modules. The renaming of files with partial uppercase names is similar to the renaming of, for instance, Tkinter and TkFont to tkinter and tkinter.font in 3.0. As a result, imports of idlelib files that worked in 3.5 will usually not work in 3.6. At least a module name change will be needed (see idlelib/README.txt), sometimes more. (Name changes contributed by Al Swiegart and Terry Reedy in :issue:`24225`. Most idlelib patches since have been and will be part of the process.)
+
+In compensation, the eventual result with be that some idlelib classes will be easier to use, with better APIs and docstrings explaining them. Additional useful information will be added to idlelib when available.
+
+
+importlib
+---------
+
+:class:`importlib.util.LazyLoader` now calls
+:meth:`~importlib.abc.Loader.create_module` on the wrapped loader, removing the
+restriction that :class:`importlib.machinery.BuiltinImporter` and
+:class:`importlib.machinery.ExtensionFileLoader` couldn't be used with
+:class:`importlib.util.LazyLoader`.
+
+
+os
+--
+
+A new :meth:`~os.scandir.close` method allows explicitly closing a
+:func:`~os.scandir` iterator. The :func:`~os.scandir` iterator now
+supports the :term:`context manager` protocol. If a :func:`scandir`
+iterator is neither exhausted nor explicitly closed a :exc:`ResourceWarning`
+will be emitted in its destructor.
+(Contributed by Serhiy Storchaka in :issue:`25994`.)
+
+
+pickle
+------
+
+Objects that need calling ``__new__`` with keyword arguments can now be pickled
+using :ref:`pickle protocols <pickle-protocols>` older than protocol version 4.
+Protocol version 4 already supports this case. (Contributed by Serhiy
+Storchaka in :issue:`24164`.)
+
+
+readline
+--------
+
+Added :func:`~readline.set_auto_history` to enable or disable
+automatic addition of input to the history list. (Contributed by
+Tyler Crompton in :issue:`26870`.)
+
+
+rlcompleter
+-----------
+
+Private and special attribute names now are omitted unless the prefix starts
+with underscores. A space or a colon is added after some completed keywords.
+(Contributed by Serhiy Storchaka in :issue:`25011` and :issue:`25209`.)
+
+Names of most attributes listed by :func:`dir` are now completed.
+Previously, names of properties and slots which were not yet created on
+an instance were excluded. (Contributed by Martin Panter in :issue:`25590`.)
+
+
+site
+----
+
+When specifying paths to add to :attr:`sys.path` in a `.pth` file,
+you may now specify file paths on top of directories (e.g. zip files).
+(Contributed by Wolfgang Langner in :issue:`26587`).
+
+
+sqlite3
+-------
+
+* :attr:`sqlite3.Cursor.lastrowid` now supports the ``REPLACE`` statement.
+ (Contributed by Alex LordThorsen in :issue:`16864`.)
+
+
+socket
+------
+
+The :func:`~socket.socket.ioctl` function now supports the :data:`~socket.SIO_LOOPBACK_FAST_PATH`
+control code.
+(Contributed by Daniel Stokes in :issue:`26536`.)
+
+
+socketserver
+------------
+
+Servers based on the :mod:`socketserver` module, including those
+defined in :mod:`http.server`, :mod:`xmlrpc.server` and
+:mod:`wsgiref.simple_server`, now support the :term:`context manager`
+protocol.
+(Contributed by Aviv Palivoda in :issue:`26404`.)
+
+The :attr:`~socketserver.StreamRequestHandler.wfile` attribute of
+:class:`~socketserver.StreamRequestHandler` classes now implements
+the :class:`io.BufferedIOBase` writable interface. In particular,
+calling :meth:`~io.BufferedIOBase.write` is now guaranteed to send the
+data in full. (Contributed by Martin Panter in :issue:`26721`.)
+
+
+subprocess
+----------
+
+:class:`subprocess.Popen` destructor now emits a :exc:`ResourceWarning` warning
+if the child process is still running. Use the context manager protocol (``with
+proc: ...``) or call explicitly the :meth:`~subprocess.Popen.wait` method to
+read the exit status of the child process (Contributed by Victor Stinner in
+:issue:`26741`).
+
+
+telnetlib
+---------
+
+:class:`~telnetlib.Telnet` is now a context manager (contributed by
+Stéphane Wirtel in :issue:`25485`).
+
+
+tkinter
+-------
+
+Added methods :meth:`~tkinter.Variable.trace_add`,
+:meth:`~tkinter.Variable.trace_remove` and :meth:`~tkinter.Variable.trace_info`
+in the :class:`tkinter.Variable` class. They replace old methods
+:meth:`~tkinter.Variable.trace_variable`, :meth:`~tkinter.Variable.trace`,
+:meth:`~tkinter.Variable.trace_vdelete` and
+:meth:`~tkinter.Variable.trace_vinfo` that use obsolete Tcl commands and might
+not work in future versions of Tcl.
+(Contributed by Serhiy Storchaka in :issue:`22115`).
+
+
+typing
+------
+
+The :class:`typing.ContextManager` class has been added for
+representing :class:`contextlib.AbstractContextManager`.
+(Contributed by Brett Cannon in :issue:`25609`.)
+
+
+unittest.mock
+-------------
+
+The :class:`~unittest.mock.Mock` class has the following improvements:
+
+* Two new methods, :meth:`Mock.assert_called()
+ <unittest.mock.Mock.assert_called>` and :meth:`Mock.assert_called_once()
+ <unittest.mock.Mock.assert_called_once>` to check if the mock object
+ was called.
+ (Contributed by Amit Saha in :issue:`26323`.)
+
+
+urllib.robotparser
+------------------
+
+:class:`~urllib.robotparser.RobotFileParser` now supports the ``Crawl-delay`` and
+``Request-rate`` extensions.
+(Contributed by Nikolay Bogoychev in :issue:`16099`.)
+
+
+warnings
+--------
+
+A new optional *source* parameter has been added to the
+:func:`warnings.warn_explicit` function: the destroyed object which emitted a
+:exc:`ResourceWarning`. A *source* attribute has also been added to
+:class:`warnings.WarningMessage` (contributed by Victor Stinner in
+:issue:`26568` and :issue:`26567`).
+
+When a :exc:`ResourceWarning` warning is logged, the :mod:`tracemalloc` is now
+used to try to retrieve the traceback where the detroyed object was allocated.
+
+Example with the script ``example.py``::
+
+ import warnings
+
+ def func():
+ return open(__file__)
+
+ f = func()
+ f = None
+
+Output of the command ``python3.6 -Wd -X tracemalloc=5 example.py``::
+
+ example.py:7: ResourceWarning: unclosed file <_io.TextIOWrapper name='example.py' mode='r' encoding='UTF-8'>
+ f = None
+ Object allocated at (most recent call first):
+ File "example.py", lineno 4
+ return open(__file__)
+ File "example.py", lineno 6
+ f = func()
+
+The "Object allocated at" traceback is new and only displayed if
+:mod:`tracemalloc` is tracing Python memory allocations and if the
+:mod:`warnings` was already imported.
+
+
+winreg
+------
+
+Added the 64-bit integer type :data:`REG_QWORD <winreg.REG_QWORD>`.
+(Contributed by Clement Rouault in :issue:`23026`.)
+
+
+zipfile
+-------
+
+A new :meth:`ZipInfo.from_file() <zipfile.ZipInfo.from_file>` class method
+allows making a :class:`~zipfile.ZipInfo` instance from a filesystem file.
+A new :meth:`ZipInfo.is_dir() <zipfile.ZipInfo.is_dir>` method can be used
+to check if the :class:`~zipfile.ZipInfo` instance represents a directory.
+(Contributed by Thomas Kluyver in :issue:`26039`.)
+
+The :meth:`ZipFile.open() <zipfile.ZipFile.open>` method can now be used to
+write data into a ZIP file, as well as for extracting data.
+(Contributed by Thomas Kluyver in :issue:`26039`.)
+
+
+zlib
+----
+
+The :func:`~zlib.compress` function now accepts keyword arguments.
+(Contributed by Aviv Palivoda in :issue:`26243`.)
+
+
+fileinput
+---------
+
+:func:`~fileinput.hook_encoded` now supports the *errors* argument.
+(Contributed by Joseph Hackman in :issue:`25788`.)
+
+
+Optimizations
+=============
+
+* The ASCII decoder is now up to 60 times as fast for error handlers
+ ``surrogateescape``, ``ignore`` and ``replace`` (Contributed
+ by Victor Stinner in :issue:`24870`).
+
+* The ASCII and the Latin1 encoders are now up to 3 times as fast for the
+ error handler ``surrogateescape`` (Contributed by Victor Stinner in :issue:`25227`).
+
+* The UTF-8 encoder is now up to 75 times as fast for error handlers
+ ``ignore``, ``replace``, ``surrogateescape``, ``surrogatepass`` (Contributed
+ by Victor Stinner in :issue:`25267`).
+
+* The UTF-8 decoder is now up to 15 times as fast for error handlers
+ ``ignore``, ``replace`` and ``surrogateescape`` (Contributed
+ by Victor Stinner in :issue:`25301`).
+
+* ``bytes % args`` is now up to 2 times faster. (Contributed by Victor Stinner
+ in :issue:`25349`).
+
+* ``bytearray % args`` is now between 2.5 and 5 times faster. (Contributed by
+ Victor Stinner in :issue:`25399`).
+
+* Optimize :meth:`bytes.fromhex` and :meth:`bytearray.fromhex`: they are now
+ between 2x and 3.5x faster. (Contributed by Victor Stinner in :issue:`25401`).
+
+* Optimize ``bytes.replace(b'', b'.')`` and ``bytearray.replace(b'', b'.')``:
+ up to 80% faster. (Contributed by Josh Snider in :issue:`26574`).
+
+* Allocator functions of the :c:func:`PyMem_Malloc` domain
+ (:c:data:`PYMEM_DOMAIN_MEM`) now use the :ref:`pymalloc memory allocator
+ <pymalloc>` instead of :c:func:`malloc` function of the C library. The
+ pymalloc allocator is optimized for objects smaller or equal to 512 bytes
+ with a short lifetime, and use :c:func:`malloc` for larger memory blocks.
+ (Contributed by Victor Stinner in :issue:`26249`).
+
+* :func:`pickle.load` and :func:`pickle.loads` are now up to 10% faster when
+ deserializing many small objects (Contributed by Victor Stinner in
+ :issue:`27056`).
+
+Build and C API Changes
+=======================
+
+* New :c:func:`Py_FinalizeEx` API which indicates if flushing buffered data
+ failed (:issue:`5319`).
+
+* :c:func:`PyArg_ParseTupleAndKeywords` now supports :ref:`positional-only
+ parameters <positional-only_parameter>`. Positional-only parameters are
+ defined by empty names.
+ (Contributed by Serhit Storchaka in :issue:`26282`).
+
+
+Deprecated
+==========
+
+New Keywords
+------------
+
+``async`` and ``await`` are not recommended to be used as variable, class,
+function or module names. Introduced by :pep:`492` in Python 3.5, they will
+become proper keywords in Python 3.7.
+
+
+Deprecated Python modules, functions and methods
+------------------------------------------------
+
+* :meth:`importlib.machinery.SourceFileLoader.load_module` and
+ :meth:`importlib.machinery.SourcelessFileLoader.load_module` are now
+ deprecated. They were the only remaining implementations of
+ :meth:`importlib.abc.Loader.load_module` in :mod:`importlib` that had not
+ been deprecated in previous versions of Python in favour of
+ :meth:`importlib.abc.Loader.exec_module`.
+
+
+Deprecated functions and types of the C API
+-------------------------------------------
+
+* None yet.
+
+
+Deprecated features
+-------------------
+
+* The ``pyvenv`` script has been deprecated in favour of ``python3 -m venv``.
+ This prevents confusion as to what Python interpreter ``pyvenv`` is
+ connected to and thus what Python interpreter will be used by the virtual
+ environment. (Contributed by Brett Cannon in :issue:`25154`.)
+
+* When performing a relative import, falling back on ``__name__`` and
+ ``__path__`` from the calling module when ``__spec__`` or
+ ``__package__`` are not defined now raises an :exc:`ImportWarning`.
+ (Contributed by Rose Ames in :issue:`25791`.)
+
+
+Deprecated Python behavior
+--------------------------
+
+* Raising the :exc:`StopIteration` exception inside a generator will now generate a
+ :exc:`DeprecationWarning`, and will trigger a :exc:`RuntimeError` in Python 3.7.
+ See :ref:`whatsnew-pep-479` for details.
+
+
+Removed
+=======
+
+API and Feature Removals
+------------------------
+
+* ``inspect.getmoduleinfo()`` was removed (was deprecated since CPython 3.3).
+ :func:`inspect.getmodulename` should be used for obtaining the module
+ name for a given path.
+
+* ``traceback.Ignore`` class and ``traceback.usage``, ``traceback.modname``,
+ ``traceback.fullmodname``, ``traceback.find_lines_from_code``,
+ ``traceback.find_lines``, ``traceback.find_strings``,
+ ``traceback.find_executable_lines`` methods were removed from the
+ :mod:`traceback` module. They were undocumented methods deprecated since
+ Python 3.2 and equivalent functionality is available from private methods.
+
+* The ``tk_menuBar()`` and ``tk_bindForTraversal()`` dummy methods in
+ :mod:`tkinter` widget classes were removed (corresponding Tk commands
+ were obsolete since Tk 4.0).
+
+* The :meth:`~zipfile.ZipFile.open` method of the :class:`zipfile.ZipFile`
+ class no longer supports the ``'U'`` mode (was deprecated since Python 3.4).
+ Use :class:`io.TextIOWrapper` for reading compressed text files in
+ :term:`universal newlines` mode.
+
+
+Porting to Python 3.6
+=====================
+
+This section lists previously described changes and other bugfixes
+that may require changes to your code.
+
+Changes in the Python API
+-------------------------
+
+* When :meth:`importlib.abc.Loader.exec_module` is defined,
+ :meth:`importlib.abc.Loader.create_module` must also be defined.
+
+* The format of the ``co_lnotab`` attribute of code objects changed to support
+ negative line number delta. By default, Python does not emit bytecode with
+ negative line number delta. Functions using ``frame.f_lineno``,
+ ``PyFrame_GetLineNumber()`` or ``PyCode_Addr2Line()`` are not affected.
+ Functions decoding directly ``co_lnotab`` should be updated to use a signed
+ 8-bit integer type for the line number delta, but it's only required to
+ support applications using negative line number delta. See
+ ``Objects/lnotab_notes.txt`` for the ``co_lnotab`` format and how to decode
+ it, and see the :pep:`511` for the rationale.
+
+* The functions in the :mod:`compileall` module now return booleans instead
+ of ``1`` or ``0`` to represent success or failure, respectively. Thanks to
+ booleans being a subclass of integers, this should only be an issue if you
+ were doing identity checks for ``1`` or ``0``. See :issue:`25768`.
+
+* Reading the :attr:`~urllib.parse.SplitResult.port` attribute of
+ :func:`urllib.parse.urlsplit` and :func:`~urllib.parse.urlparse` results
+ now raises :exc:`ValueError` for out-of-range values, rather than
+ returning :const:`None`. See :issue:`20059`.
+
+* The :mod:`imp` module now raises a :exc:`DeprecationWarning` instead of
+ :exc:`PendingDeprecationWarning`.
+
+* The following modules have had missing APIs added to their :attr:`__all__`
+ attributes to match the documented APIs:
+ :mod:`calendar`, :mod:`cgi`, :mod:`csv`,
+ :mod:`~xml.etree.ElementTree`, :mod:`enum`,
+ :mod:`fileinput`, :mod:`ftplib`, :mod:`logging`, :mod:`mailbox`,
+ :mod:`mimetypes`, :mod:`optparse`, :mod:`plistlib`, :mod:`smtpd`,
+ :mod:`subprocess`, :mod:`tarfile`, :mod:`threading` and
+ :mod:`wave`. This means they will export new symbols when ``import *``
+ is used. See :issue:`23883`.
+
+* When performing a relative import, if ``__package__`` does not compare equal
+ to ``__spec__.parent`` then :exc:`ImportWarning` is raised.
+ (Contributed by Brett Cannon in :issue:`25791`.)
+
+* When a relative import is performed and no parent package is known, then
+ :exc:`ImportError` will be raised. Previously, :exc:`SystemError` could be
+ raised. (Contributed by Brett Cannon in :issue:`18018`.)
+
+* Servers based on the :mod:`socketserver` module, including those
+ defined in :mod:`http.server`, :mod:`xmlrpc.server` and
+ :mod:`wsgiref.simple_server`, now only catch exceptions derived
+ from :exc:`Exception`. Therefore if a request handler raises
+ an exception like :exc:`SystemExit` or :exc:`KeyboardInterrupt`,
+ :meth:`~socketserver.BaseServer.handle_error` is no longer called, and
+ the exception will stop a single-threaded server. (Contributed by
+ Martin Panter in :issue:`23430`.)
+
+* :func:`spwd.getspnam` now raises a :exc:`PermissionError` instead of
+ :exc:`KeyError` if the user doesn't have privileges.
+
+* The :meth:`socket.socket.close` method now raises an exception if
+ an error (e.g. EBADF) was reported by the underlying system call.
+ See :issue:`26685`.
+
+* The *decode_data* argument for :class:`smtpd.SMTPChannel` and
+ :class:`smtpd.SMTPServer` constructors is now ``False`` by default.
+ This means that the argument passed to
+ :meth:`~smtpd.SMTPServer.process_message` is now a bytes object by
+ default, and ``process_message()`` will be passed keyword arguments.
+ Code that has already been updated in accordance with the deprecation
+ warning generated by 3.5 will not be affected.
+
+* All optional parameters of the :func:`~json.dump`, :func:`~json.dumps`,
+ :func:`~json.load` and :func:`~json.loads` functions and
+ :class:`~json.JSONEncoder` and :class:`~json.JSONDecoder` class
+ constructors in the :mod:`json` module are now :ref:`keyword-only
+ <keyword-only_parameter>`.
+ (Contributed by Serhiy Storchaka in :issue:`18726`.)
+
+
+Changes in the C API
+--------------------
+
+* :c:func:`PyMem_Malloc` allocator family now uses the :ref:`pymalloc allocator
+ <pymalloc>` rather than system :c:func:`malloc`. Applications calling
+ :c:func:`PyMem_Malloc` without holding the GIL can now crash. Set the
+ :envvar:`PYTHONMALLOC` environment variable to ``debug`` to validate the
+ usage of memory allocators in your application. See :issue:`26249`.
+
+* :c:func:`Py_Exit` (and the main interpreter) now override the exit status
+ with 120 if flushing buffered data failed. See :issue:`5319`.
diff --git a/Doc/whatsnew/index.rst b/Doc/whatsnew/index.rst
index edb5502..7c92524 100644
--- a/Doc/whatsnew/index.rst
+++ b/Doc/whatsnew/index.rst
@@ -11,6 +11,7 @@
.. toctree::
:maxdepth: 2
+ 3.6.rst
3.5.rst
3.4.rst
3.3.rst
diff --git a/Grammar/Grammar b/Grammar/Grammar
index 99fcea0..14bdecd 100644
--- a/Grammar/Grammar
+++ b/Grammar/Grammar
@@ -27,13 +27,18 @@
funcdef: 'def' NAME parameters ['->' test] ':' suite
parameters: '(' [typedargslist] ')'
-typedargslist: (tfpdef ['=' test] (',' tfpdef ['=' test])* [','
- ['*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef]]
- | '*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef)
+typedargslist: (tfpdef ['=' test] (',' tfpdef ['=' test])* [',' [
+ '*' [tfpdef] (',' tfpdef ['=' test])* [',' ['**' tfpdef [',']]]
+ | '**' tfpdef [',']]]
+ | '*' [tfpdef] (',' tfpdef ['=' test])* [',' ['**' tfpdef [',']]]
+ | '**' tfpdef [','])
tfpdef: NAME [':' test]
-varargslist: (vfpdef ['=' test] (',' vfpdef ['=' test])* [','
- ['*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef]]
- | '*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef)
+varargslist: (vfpdef ['=' test] (',' vfpdef ['=' test])* [',' [
+ '*' [vfpdef] (',' vfpdef ['=' test])* [',' ['**' vfpdef [',']]]
+ | '**' vfpdef [',']]]
+ | '*' [vfpdef] (',' vfpdef ['=' test])* [',' ['**' vfpdef [',']]]
+ | '**' vfpdef [',']
+)
vfpdef: NAME
stmt: simple_stmt | compound_stmt
diff --git a/Include/Python-ast.h b/Include/Python-ast.h
index 2d3eacb..1ab376a 100644
--- a/Include/Python-ast.h
+++ b/Include/Python-ast.h
@@ -201,9 +201,10 @@
SetComp_kind=9, DictComp_kind=10, GeneratorExp_kind=11,
Await_kind=12, Yield_kind=13, YieldFrom_kind=14,
Compare_kind=15, Call_kind=16, Num_kind=17, Str_kind=18,
- Bytes_kind=19, NameConstant_kind=20, Ellipsis_kind=21,
- Attribute_kind=22, Subscript_kind=23, Starred_kind=24,
- Name_kind=25, List_kind=26, Tuple_kind=27};
+ FormattedValue_kind=19, JoinedStr_kind=20, Bytes_kind=21,
+ NameConstant_kind=22, Ellipsis_kind=23, Constant_kind=24,
+ Attribute_kind=25, Subscript_kind=26, Starred_kind=27,
+ Name_kind=28, List_kind=29, Tuple_kind=30};
struct _expr {
enum _expr_kind kind;
union {
@@ -297,6 +298,16 @@
} Str;
struct {
+ expr_ty value;
+ int conversion;
+ expr_ty format_spec;
+ } FormattedValue;
+
+ struct {
+ asdl_seq *values;
+ } JoinedStr;
+
+ struct {
bytes s;
} Bytes;
@@ -305,6 +316,10 @@
} NameConstant;
struct {
+ constant value;
+ } Constant;
+
+ struct {
expr_ty value;
identifier attr;
expr_context_ty ctx;
@@ -543,6 +558,12 @@
expr_ty _Py_Num(object n, int lineno, int col_offset, PyArena *arena);
#define Str(a0, a1, a2, a3) _Py_Str(a0, a1, a2, a3)
expr_ty _Py_Str(string s, int lineno, int col_offset, PyArena *arena);
+#define FormattedValue(a0, a1, a2, a3, a4, a5) _Py_FormattedValue(a0, a1, a2, a3, a4, a5)
+expr_ty _Py_FormattedValue(expr_ty value, int conversion, expr_ty format_spec,
+ int lineno, int col_offset, PyArena *arena);
+#define JoinedStr(a0, a1, a2, a3) _Py_JoinedStr(a0, a1, a2, a3)
+expr_ty _Py_JoinedStr(asdl_seq * values, int lineno, int col_offset, PyArena
+ *arena);
#define Bytes(a0, a1, a2, a3) _Py_Bytes(a0, a1, a2, a3)
expr_ty _Py_Bytes(bytes s, int lineno, int col_offset, PyArena *arena);
#define NameConstant(a0, a1, a2, a3) _Py_NameConstant(a0, a1, a2, a3)
@@ -550,6 +571,9 @@
*arena);
#define Ellipsis(a0, a1, a2) _Py_Ellipsis(a0, a1, a2)
expr_ty _Py_Ellipsis(int lineno, int col_offset, PyArena *arena);
+#define Constant(a0, a1, a2, a3) _Py_Constant(a0, a1, a2, a3)
+expr_ty _Py_Constant(constant value, int lineno, int col_offset, PyArena
+ *arena);
#define Attribute(a0, a1, a2, a3, a4, a5) _Py_Attribute(a0, a1, a2, a3, a4, a5)
expr_ty _Py_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
lineno, int col_offset, PyArena *arena);
diff --git a/Include/Python.h b/Include/Python.h
index 858dbd1..4c7c9a4 100644
--- a/Include/Python.h
+++ b/Include/Python.h
@@ -116,6 +116,7 @@
#include "pylifecycle.h"
#include "ceval.h"
#include "sysmodule.h"
+#include "osmodule.h"
#include "intrcheck.h"
#include "import.h"
diff --git a/Include/asdl.h b/Include/asdl.h
index 495153c..35e9fa1 100644
--- a/Include/asdl.h
+++ b/Include/asdl.h
@@ -6,6 +6,7 @@
typedef PyObject * bytes;
typedef PyObject * object;
typedef PyObject * singleton;
+typedef PyObject * constant;
/* It would be nice if the code generated by asdl_c.py was completely
independent of Python, but it is a goal the requires too much work
diff --git a/Include/bytes_methods.h b/Include/bytes_methods.h
index 11d5f42..7fa7540 100644
--- a/Include/bytes_methods.h
+++ b/Include/bytes_methods.h
@@ -17,9 +17,18 @@
/* These store their len sized answer in the given preallocated *result arg. */
extern void _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len);
extern void _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len);
-extern void _Py_bytes_title(char *result, char *s, Py_ssize_t len);
-extern void _Py_bytes_capitalize(char *result, char *s, Py_ssize_t len);
-extern void _Py_bytes_swapcase(char *result, char *s, Py_ssize_t len);
+extern void _Py_bytes_title(char *result, const char *s, Py_ssize_t len);
+extern void _Py_bytes_capitalize(char *result, const char *s, Py_ssize_t len);
+extern void _Py_bytes_swapcase(char *result, const char *s, Py_ssize_t len);
+
+extern PyObject *_Py_bytes_find(const char *str, Py_ssize_t len, PyObject *args);
+extern PyObject *_Py_bytes_index(const char *str, Py_ssize_t len, PyObject *args);
+extern PyObject *_Py_bytes_rfind(const char *str, Py_ssize_t len, PyObject *args);
+extern PyObject *_Py_bytes_rindex(const char *str, Py_ssize_t len, PyObject *args);
+extern PyObject *_Py_bytes_count(const char *str, Py_ssize_t len, PyObject *args);
+extern int _Py_bytes_contains(const char *str, Py_ssize_t len, PyObject *arg);
+extern PyObject *_Py_bytes_startswith(const char *str, Py_ssize_t len, PyObject *args);
+extern PyObject *_Py_bytes_endswith(const char *str, Py_ssize_t len, PyObject *args);
/* The maketrans() static method. */
extern PyObject* _Py_bytes_maketrans(Py_buffer *frm, Py_buffer *to);
@@ -37,7 +46,19 @@
extern const char _Py_title__doc__[];
extern const char _Py_capitalize__doc__[];
extern const char _Py_swapcase__doc__[];
+extern const char _Py_count__doc__[];
+extern const char _Py_find__doc__[];
+extern const char _Py_index__doc__[];
+extern const char _Py_rfind__doc__[];
+extern const char _Py_rindex__doc__[];
+extern const char _Py_startswith__doc__[];
+extern const char _Py_endswith__doc__[];
extern const char _Py_maketrans__doc__[];
+extern const char _Py_expandtabs__doc__[];
+extern const char _Py_ljust__doc__[];
+extern const char _Py_rjust__doc__[];
+extern const char _Py_center__doc__[];
+extern const char _Py_zfill__doc__[];
/* this is needed because some docs are shared from the .o, not static */
#define PyDoc_STRVAR_shared(name,str) const char name[] = PyDoc_STR(str)
diff --git a/Include/bytesobject.h b/Include/bytesobject.h
index 6c1e0c3..4578069 100644
--- a/Include/bytesobject.h
+++ b/Include/bytesobject.h
@@ -62,7 +62,14 @@
PyAPI_FUNC(void) PyBytes_ConcatAndDel(PyObject **, PyObject *);
#ifndef Py_LIMITED_API
PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t);
-PyAPI_FUNC(PyObject *) _PyBytes_Format(PyObject *, PyObject *);
+PyAPI_FUNC(PyObject*) _PyBytes_FormatEx(
+ const char *format,
+ Py_ssize_t format_len,
+ PyObject *args,
+ int use_bytearray);
+PyAPI_FUNC(PyObject*) _PyBytes_FromHex(
+ PyObject *string,
+ int use_bytearray);
#endif
PyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t,
const char *, Py_ssize_t,
@@ -123,6 +130,87 @@
#define F_ALT (1<<3)
#define F_ZERO (1<<4)
+#ifndef Py_LIMITED_API
+/* The _PyBytesWriter structure is big: it contains an embeded "stack buffer".
+ A _PyBytesWriter variable must be declared at the end of variables in a
+ function to optimize the memory allocation on the stack. */
+typedef struct {
+ /* bytes, bytearray or NULL (when the small buffer is used) */
+ PyObject *buffer;
+
+ /* Number of allocated size. */
+ Py_ssize_t allocated;
+
+ /* Minimum number of allocated bytes,
+ incremented by _PyBytesWriter_Prepare() */
+ Py_ssize_t min_size;
+
+ /* If non-zero, use a bytearray instead of a bytes object for buffer. */
+ int use_bytearray;
+
+ /* If non-zero, overallocate the buffer (default: 0).
+ This flag must be zero if use_bytearray is non-zero. */
+ int overallocate;
+
+ /* Stack buffer */
+ int use_small_buffer;
+ char small_buffer[512];
+} _PyBytesWriter;
+
+/* Initialize a bytes writer
+
+ By default, the overallocation is disabled. Set the overallocate attribute
+ to control the allocation of the buffer. */
+PyAPI_FUNC(void) _PyBytesWriter_Init(_PyBytesWriter *writer);
+
+/* Get the buffer content and reset the writer.
+ Return a bytes object, or a bytearray object if use_bytearray is non-zero.
+ Raise an exception and return NULL on error. */
+PyAPI_FUNC(PyObject *) _PyBytesWriter_Finish(_PyBytesWriter *writer,
+ void *str);
+
+/* Deallocate memory of a writer (clear its internal buffer). */
+PyAPI_FUNC(void) _PyBytesWriter_Dealloc(_PyBytesWriter *writer);
+
+/* Allocate the buffer to write size bytes.
+ Return the pointer to the beginning of buffer data.
+ Raise an exception and return NULL on error. */
+PyAPI_FUNC(void*) _PyBytesWriter_Alloc(_PyBytesWriter *writer,
+ Py_ssize_t size);
+
+/* Ensure that the buffer is large enough to write *size* bytes.
+ Add size to the writer minimum size (min_size attribute).
+
+ str is the current pointer inside the buffer.
+ Return the updated current pointer inside the buffer.
+ Raise an exception and return NULL on error. */
+PyAPI_FUNC(void*) _PyBytesWriter_Prepare(_PyBytesWriter *writer,
+ void *str,
+ Py_ssize_t size);
+
+/* Resize the buffer to make it larger.
+ The new buffer may be larger than size bytes because of overallocation.
+ Return the updated current pointer inside the buffer.
+ Raise an exception and return NULL on error.
+
+ Note: size must be greater than the number of allocated bytes in the writer.
+
+ This function doesn't use the writer minimum size (min_size attribute).
+
+ See also _PyBytesWriter_Prepare().
+ */
+PyAPI_FUNC(void*) _PyBytesWriter_Resize(_PyBytesWriter *writer,
+ void *str,
+ Py_ssize_t size);
+
+/* Write bytes.
+ Raise an exception and return NULL on error. */
+PyAPI_FUNC(void*) _PyBytesWriter_WriteBytes(_PyBytesWriter *writer,
+ void *str,
+ const void *bytes,
+ Py_ssize_t size);
+#endif /* Py_LIMITED_API */
+
#ifdef __cplusplus
}
#endif
diff --git a/Include/ceval.h b/Include/ceval.h
index b5373a9..d194044 100644
--- a/Include/ceval.h
+++ b/Include/ceval.h
@@ -206,6 +206,14 @@
PyAPI_FUNC(void) _PyEval_SignalAsyncExc(void);
#endif
+/* Masks and values used by FORMAT_VALUE opcode. */
+#define FVC_MASK 0x3
+#define FVC_NONE 0x0
+#define FVC_STR 0x1
+#define FVC_REPR 0x2
+#define FVC_ASCII 0x3
+#define FVS_MASK 0x4
+#define FVS_HAVE_SPEC 0x4
#ifdef __cplusplus
}
diff --git a/Include/code.h b/Include/code.h
index 8ecf38a..a300ead 100644
--- a/Include/code.h
+++ b/Include/code.h
@@ -126,7 +126,7 @@
#endif
PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts,
- PyObject *names, PyObject *lineno_obj);
+ PyObject *names, PyObject *lnotab);
#ifdef __cplusplus
}
diff --git a/Include/longobject.h b/Include/longobject.h
index aed59ce..eaf7a7e 100644
--- a/Include/longobject.h
+++ b/Include/longobject.h
@@ -65,7 +65,8 @@
# error "void* different in size from int, long and long long"
#endif /* SIZEOF_VOID_P */
-/* Used by Python/mystrtoul.c. */
+/* Used by Python/mystrtoul.c, _PyBytes_FromHex(),
+ _PyBytes_DecodeEscapeRecode(), etc. */
#ifndef Py_LIMITED_API
PyAPI_DATA(unsigned char) _PyLong_DigitValue[256];
#endif
@@ -182,6 +183,13 @@
int base,
int alternate);
+PyAPI_FUNC(char*) _PyLong_FormatBytesWriter(
+ _PyBytesWriter *writer,
+ char *str,
+ PyObject *obj,
+ int base,
+ int alternate);
+
/* Format the object based on the format_spec, as defined in PEP 3101
(Advanced String Formatting). */
PyAPI_FUNC(int) _PyLong_FormatAdvancedWriter(
diff --git a/Include/object.h b/Include/object.h
index 50d9747..0c88603 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -785,7 +785,7 @@
--(_py_decref_tmp)->ob_refcnt != 0) \
_Py_CHECK_REFCNT(_py_decref_tmp) \
else \
- _Py_Dealloc(_py_decref_tmp); \
+ _Py_Dealloc(_py_decref_tmp); \
} while (0)
/* Safely decref `op` and set `op` to NULL, especially useful in tp_clear
diff --git a/Include/opcode.h b/Include/opcode.h
index 3f917fb..171aae7 100644
--- a/Include/opcode.h
+++ b/Include/opcode.h
@@ -102,7 +102,6 @@
#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
@@ -122,6 +121,8 @@
#define BUILD_TUPLE_UNPACK 152
#define BUILD_SET_UNPACK 153
#define SETUP_ASYNC_WITH 154
+#define FORMAT_VALUE 155
+#define BUILD_CONST_KEY_MAP 156
/* 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
diff --git a/Include/osmodule.h b/Include/osmodule.h
new file mode 100644
index 0000000..7146757
--- /dev/null
+++ b/Include/osmodule.h
@@ -0,0 +1,15 @@
+
+/* os module interface */
+
+#ifndef Py_OSMODULE_H
+#define Py_OSMODULE_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+PyAPI_FUNC(PyObject *) PyOS_FSPath(PyObject *path);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_OSMODULE_H */
diff --git a/Include/patchlevel.h b/Include/patchlevel.h
index 45e5736..4164ff3 100644
--- a/Include/patchlevel.h
+++ b/Include/patchlevel.h
@@ -17,13 +17,13 @@
/* Version parsed out into numeric values */
/*--start constants--*/
#define PY_MAJOR_VERSION 3
-#define PY_MINOR_VERSION 5
-#define PY_MICRO_VERSION 2
-#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL
-#define PY_RELEASE_SERIAL 0
+#define PY_MINOR_VERSION 6
+#define PY_MICRO_VERSION 0
+#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA
+#define PY_RELEASE_SERIAL 2
/* Version as a string */
-#define PY_VERSION "3.5.2+"
+#define PY_VERSION "3.6.0a2+"
/*--end constants--*/
/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.
diff --git a/Include/py_curses.h b/Include/py_curses.h
index f2c08f6..3c21697 100644
--- a/Include/py_curses.h
+++ b/Include/py_curses.h
@@ -103,8 +103,8 @@
#endif
/* general error messages */
-static char *catchall_ERR = "curses function returned ERR";
-static char *catchall_NULL = "curses function returned NULL";
+static const char catchall_ERR[] = "curses function returned ERR";
+static const char catchall_NULL[] = "curses function returned NULL";
/* Function Prototype Macros - They are ugly but very, very useful. ;-)
diff --git a/Include/pylifecycle.h b/Include/pylifecycle.h
index ccdebe2..e96eb70 100644
--- a/Include/pylifecycle.h
+++ b/Include/pylifecycle.h
@@ -27,6 +27,7 @@
PyAPI_FUNC(void) _Py_InitializeEx_Private(int, int);
#endif
PyAPI_FUNC(void) Py_Finalize(void);
+PyAPI_FUNC(int) Py_FinalizeEx(void);
PyAPI_FUNC(int) Py_IsInitialized(void);
PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void);
PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *);
diff --git a/Include/pymacro.h b/Include/pymacro.h
index 3f6f5dc..49929e5 100644
--- a/Include/pymacro.h
+++ b/Include/pymacro.h
@@ -36,6 +36,10 @@
#define Py_BUILD_ASSERT_EXPR(cond) \
(sizeof(char [1 - 2*!(cond)]) - 1)
+#define Py_BUILD_ASSERT(cond) do { \
+ (void)Py_BUILD_ASSERT_EXPR(cond); \
+ } while(0)
+
/* Get the number of elements in a visible array
This does not work on pointers, or arrays declared as [], or function
diff --git a/Include/pymath.h b/Include/pymath.h
index 1ea9ac1..ed76053 100644
--- a/Include/pymath.h
+++ b/Include/pymath.h
@@ -169,7 +169,7 @@
#pragma float_control (pop)
#define Py_NAN __icc_nan()
#else /* ICC_NAN_RELAXED as default for Intel Compiler */
- static union { unsigned char buf[8]; double __icc_nan; } __nan_store = {0,0,0,0,0,0,0xf8,0x7f};
+ static const union { unsigned char buf[8]; double __icc_nan; } __nan_store = {0,0,0,0,0,0,0xf8,0x7f};
#define Py_NAN (__nan_store.__icc_nan)
#endif /* ICC_NAN_STRICT */
#endif /* __INTEL_COMPILER */
diff --git a/Include/pymem.h b/Include/pymem.h
index 043db64..431e5b6 100644
--- a/Include/pymem.h
+++ b/Include/pymem.h
@@ -16,8 +16,51 @@
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);
+
+/* Configure the Python memory allocators. Pass NULL to use default
+ allocators. */
+PyAPI_FUNC(int) _PyMem_SetupAllocators(const char *opt);
+
+#ifdef WITH_PYMALLOC
+PyAPI_FUNC(int) _PyMem_PymallocEnabled(void);
#endif
+/* Identifier of an address space (domain) in tracemalloc */
+typedef unsigned int _PyTraceMalloc_domain_t;
+
+/* Track an allocated memory block in the tracemalloc module.
+ Return 0 on success, return -1 on error (failed to allocate memory to store
+ the trace).
+
+ Return -2 if tracemalloc is disabled.
+
+ If memory block is already tracked, update the existing trace. */
+PyAPI_FUNC(int) _PyTraceMalloc_Track(
+ _PyTraceMalloc_domain_t domain,
+ Py_uintptr_t ptr,
+ size_t size);
+
+/* Untrack an allocated memory block in the tracemalloc module.
+ Do nothing if the block was not tracked.
+
+ Return -2 if tracemalloc is disabled, otherwise return 0. */
+PyAPI_FUNC(int) _PyTraceMalloc_Untrack(
+ _PyTraceMalloc_domain_t domain,
+ Py_uintptr_t ptr);
+
+/* Get the traceback where a memory block was allocated.
+
+ Return a tuple of (filename: str, lineno: int) tuples.
+
+ Return None if the tracemalloc module is disabled or if the memory block
+ is not tracked by tracemalloc.
+
+ Raise an exception and return NULL on error. */
+PyAPI_FUNC(PyObject*) _PyTraceMalloc_GetTraceback(
+ _PyTraceMalloc_domain_t domain,
+ Py_uintptr_t ptr);
+#endif /* !Py_LIMITED_API */
+
/* BEWARE:
diff --git a/Include/pyport.h b/Include/pyport.h
index 66e00d4..8b0a89f 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -897,4 +897,8 @@
#endif /* _MSC_VER >= 1900 */
#endif /* Py_BUILD_CORE */
+#ifdef __ANDROID__
+#include <android/api-level.h>
+#endif
+
#endif /* Py_PYPORT_H */
diff --git a/Include/pystate.h b/Include/pystate.h
index 0499a74..d69d4c9 100644
--- a/Include/pystate.h
+++ b/Include/pystate.h
@@ -241,11 +241,23 @@
*/
PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void);
-/* Helper/diagnostic function - return 1 if the current thread
- * currently holds the GIL, 0 otherwise
- */
#ifndef Py_LIMITED_API
+/* Issue #26558: Flag to disable PyGILState_Check().
+ If set to non-zero, PyGILState_Check() always return 1. */
+PyAPI_DATA(int) _PyGILState_check_enabled;
+
+/* Helper/diagnostic function - return 1 if the current thread
+ currently holds the GIL, 0 otherwise.
+
+ The function returns 1 if _PyGILState_check_enabled is non-zero. */
PyAPI_FUNC(int) PyGILState_Check(void);
+
+/* Unsafe function to get the single PyInterpreterState used by this process'
+ GILState implementation.
+
+ Return NULL before _PyGILState_Init() is called and after _PyGILState_Fini()
+ is called. */
+PyAPI_FUNC(PyInterpreterState *) _PyGILState_GetInterpreterStateUnsafe(void);
#endif
#endif /* #ifdef WITH_THREAD */
diff --git a/Include/pythonrun.h b/Include/pythonrun.h
index 9c2e813..cfa0a9f 100644
--- a/Include/pythonrun.h
+++ b/Include/pythonrun.h
@@ -66,8 +66,8 @@
const char *filename, /* decoded from the filesystem encoding */
const char* enc,
int start,
- char *ps1,
- char *ps2,
+ const char *ps1,
+ const char *ps2,
PyCompilerFlags *flags,
int *errcode,
PyArena *arena);
@@ -76,8 +76,8 @@
PyObject *filename,
const char* enc,
int start,
- char *ps1,
- char *ps2,
+ const char *ps1,
+ const char *ps2,
PyCompilerFlags *flags,
int *errcode,
PyArena *arena);
diff --git a/Include/pytime.h b/Include/pytime.h
index 494322c..98612e1 100644
--- a/Include/pytime.h
+++ b/Include/pytime.h
@@ -30,7 +30,10 @@
_PyTime_ROUND_FLOOR=0,
/* Round towards infinity (+inf).
For example, used for timeout to wait "at least" N seconds. */
- _PyTime_ROUND_CEILING
+ _PyTime_ROUND_CEILING=1,
+ /* Round to nearest with ties going to nearest even integer.
+ For example, used to round from a Python float. */
+ _PyTime_ROUND_HALF_EVEN
} _PyTime_round_t;
/* Convert a time_t to a PyLong. */
diff --git a/Include/setobject.h b/Include/setobject.h
index f17bc1b..87ec1c8 100644
--- a/Include/setobject.h
+++ b/Include/setobject.h
@@ -10,12 +10,13 @@
/* There are three kinds of entries in the table:
-1. Unused: key == NULL
-2. Active: key != NULL and key != dummy
-3. Dummy: key == dummy
+1. Unused: key == NULL and hash == 0
+2. Dummy: key == dummy and hash == -1
+3. Active: key != NULL and key != dummy and hash != -1
-The hash field of Unused slots have no meaning.
-The hash field of Dummny slots are set to -1
+The hash field of Unused slots is always zero.
+
+The hash field of Dummy slots are set to -1
meaning that dummy entries can be detected by
either entry->key==dummy or by entry->hash==-1.
*/
diff --git a/Include/traceback.h b/Include/traceback.h
index c3ecbe2..dbc769b 100644
--- a/Include/traceback.h
+++ b/Include/traceback.h
@@ -53,19 +53,63 @@
PyThreadState *tstate);
/* Write the traceback of all threads into the file 'fd'. current_thread can be
- NULL. Return NULL on success, or an error message on error.
+ NULL.
+
+ Return NULL on success, or an error message on error.
This function is written for debug purpose only. It calls
_Py_DumpTraceback() for each thread, and so has the same limitations. It
only write the traceback of the first 100 threads: write "..." if there are
more threads.
+ If current_tstate is NULL, the function tries to get the Python thread state
+ of the current thread. It is not an error if the function is unable to get
+ the current Python thread state.
+
+ If interp is NULL, the function tries to get the interpreter state from
+ the current Python thread state, or from
+ _PyGILState_GetInterpreterStateUnsafe() in last resort.
+
+ It is better to pass NULL to interp and current_tstate, the function tries
+ different options to retrieve these informations.
+
This function is signal safe. */
PyAPI_FUNC(const char*) _Py_DumpTracebackThreads(
- int fd, PyInterpreterState *interp,
- PyThreadState *current_thread);
+ int fd,
+ PyInterpreterState *interp,
+ PyThreadState *current_tstate);
+#ifndef Py_LIMITED_API
+
+/* Write a Unicode object into the file descriptor fd. Encode the string to
+ ASCII using the backslashreplace error handler.
+
+ Do nothing if text is not a Unicode object. The function accepts Unicode
+ string which is not ready (PyUnicode_WCHAR_KIND).
+
+ This function is signal safe. */
+PyAPI_FUNC(void) _Py_DumpASCII(int fd, PyObject *text);
+
+/* Format an integer as decimal into the file descriptor fd.
+
+ This function is signal safe. */
+PyAPI_FUNC(void) _Py_DumpDecimal(
+ int fd,
+ unsigned long value);
+
+/* Format an integer as hexadecimal into the file descriptor fd with at least
+ width digits.
+
+ The maximum width is sizeof(unsigned long)*2 digits.
+
+ This function is signal safe. */
+PyAPI_FUNC(void) _Py_DumpHexadecimal(
+ int fd,
+ unsigned long value,
+ Py_ssize_t width);
+
+#endif /* !Py_LIMITED_API */
#ifdef __cplusplus
}
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
index 533dd75..1af620d 100644
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -900,7 +900,7 @@
/* minimum character (default: 127, ASCII) */
Py_UCS4 min_char;
- /* If non-zero, overallocate the buffer by 25% (default: 0). */
+ /* If non-zero, overallocate the buffer (default: 0). */
unsigned char overallocate;
/* If readonly is 1, buffer is a shared string (cannot be modified)
@@ -934,6 +934,23 @@
_PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter *writer,
Py_ssize_t length, Py_UCS4 maxchar);
+/* Prepare the buffer to have at least the kind KIND.
+ For example, kind=PyUnicode_2BYTE_KIND ensures that the writer will
+ support characters in range U+000-U+FFFF.
+
+ Return 0 on success, raise an exception and return -1 on error. */
+#define _PyUnicodeWriter_PrepareKind(WRITER, KIND) \
+ (assert((KIND) != PyUnicode_WCHAR_KIND), \
+ (KIND) <= (WRITER)->kind \
+ ? 0 \
+ : _PyUnicodeWriter_PrepareKindInternal((WRITER), (KIND)))
+
+/* Don't call this function directly, use the _PyUnicodeWriter_PrepareKind()
+ macro instead. */
+PyAPI_FUNC(int)
+_PyUnicodeWriter_PrepareKindInternal(_PyUnicodeWriter *writer,
+ enum PyUnicode_Kind kind);
+
/* Append a Unicode character.
Return 0 on success, raise an exception and return -1 on error. */
PyAPI_FUNC(int)
@@ -2253,6 +2270,10 @@
/* Clear all static strings. */
PyAPI_FUNC(void) _PyUnicode_ClearStaticStrings(void);
+/* Fast equality check when the inputs are known to be exact unicode types
+ and where the hash values are equal (i.e. a very probable match) */
+PyAPI_FUNC(int) _PyUnicode_EQ(PyObject *, PyObject *);
+
#ifdef __cplusplus
}
#endif
diff --git a/Include/warnings.h b/Include/warnings.h
index effb9fad..c1c6992 100644
--- a/Include/warnings.h
+++ b/Include/warnings.h
@@ -17,6 +17,13 @@
Py_ssize_t stack_level,
const char *format, /* ASCII-encoded string */
...);
+
+/* Emit a ResourceWarning warning */
+PyAPI_FUNC(int) PyErr_ResourceWarning(
+ PyObject *source,
+ Py_ssize_t stack_level,
+ const char *format, /* ASCII-encoded string */
+ ...);
#ifndef Py_LIMITED_API
PyAPI_FUNC(int) PyErr_WarnExplicitObject(
PyObject *category,
diff --git a/Lib/_collections_abc.py b/Lib/_collections_abc.py
index fc9c9f1..ffee385 100644
--- a/Lib/_collections_abc.py
+++ b/Lib/_collections_abc.py
@@ -10,7 +10,7 @@
import sys
__all__ = ["Awaitable", "Coroutine", "AsyncIterable", "AsyncIterator",
- "Hashable", "Iterable", "Iterator", "Generator",
+ "Hashable", "Iterable", "Iterator", "Generator", "Reversible",
"Sized", "Container", "Callable",
"Set", "MutableSet",
"Mapping", "MutableMapping",
@@ -240,6 +240,25 @@
Iterator.register(zip_iterator)
+class Reversible(Iterable):
+
+ __slots__ = ()
+
+ @abstractmethod
+ def __reversed__(self):
+ return NotImplemented
+
+ @classmethod
+ def __subclasshook__(cls, C):
+ if cls is Reversible:
+ for B in C.__mro__:
+ if "__reversed__" in B.__dict__:
+ if B.__dict__["__reversed__"] is not None:
+ return True
+ break
+ return NotImplemented
+
+
class Generator(Iterator):
__slots__ = ()
@@ -670,7 +689,7 @@
except KeyError:
return False
else:
- return v == value
+ return v is value or v == value
def __iter__(self):
for key in self._mapping:
@@ -685,7 +704,8 @@
def __contains__(self, value):
for key in self._mapping:
- if value == self._mapping[key]:
+ v = self._mapping[key]
+ if v is value or v == value:
return True
return False
@@ -794,7 +814,7 @@
### SEQUENCES ###
-class Sequence(Sized, Iterable, Container):
+class Sequence(Sized, Reversible, Container):
"""All the operations on a read-only sequence.
@@ -820,7 +840,7 @@
def __contains__(self, value):
for v in self:
- if v == value:
+ if v is value or v == value:
return True
return False
diff --git a/Lib/_pydecimal.py b/Lib/_pydecimal.py
index c719424..7bcf75f 100644
--- a/Lib/_pydecimal.py
+++ b/Lib/_pydecimal.py
@@ -148,7 +148,7 @@
__name__ = 'decimal' # For pickling
__version__ = '1.70' # Highest version of the spec this complies with
# See http://speleotrove.com/decimal/
-__libmpdec_version__ = "2.4.1" # compatible libmpdec version
+__libmpdec_version__ = "2.4.2" # compatible libmpdec version
import math as _math
import numbers as _numbers
@@ -1010,6 +1010,56 @@
"""
return DecimalTuple(self._sign, tuple(map(int, self._int)), self._exp)
+ def as_integer_ratio(self):
+ """Express a finite Decimal instance in the form n / d.
+
+ Returns a pair (n, d) of integers. When called on an infinity
+ or NaN, raises OverflowError or ValueError respectively.
+
+ >>> Decimal('3.14').as_integer_ratio()
+ (157, 50)
+ >>> Decimal('-123e5').as_integer_ratio()
+ (-12300000, 1)
+ >>> Decimal('0.00').as_integer_ratio()
+ (0, 1)
+
+ """
+ if self._is_special:
+ if self.is_nan():
+ raise ValueError("cannot convert NaN to integer ratio")
+ else:
+ raise OverflowError("cannot convert Infinity to integer ratio")
+
+ if not self:
+ return 0, 1
+
+ # Find n, d in lowest terms such that abs(self) == n / d;
+ # we'll deal with the sign later.
+ n = int(self._int)
+ if self._exp >= 0:
+ # self is an integer.
+ n, d = n * 10**self._exp, 1
+ else:
+ # Find d2, d5 such that abs(self) = n / (2**d2 * 5**d5).
+ d5 = -self._exp
+ while d5 > 0 and n % 5 == 0:
+ n //= 5
+ d5 -= 1
+
+ # (n & -n).bit_length() - 1 counts trailing zeros in binary
+ # representation of n (provided n is nonzero).
+ d2 = -self._exp
+ shift2 = min((n & -n).bit_length() - 1, d2)
+ if shift2:
+ n >>= shift2
+ d2 -= shift2
+
+ d = 5**d5 << d2
+
+ if self._sign:
+ n = -n
+ return n, d
+
def __repr__(self):
"""Represents the number as an instance of Decimal."""
# Invariant: eval(repr(d)) == d
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index 0d98b74..d0947f0 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -6,7 +6,6 @@
import abc
import codecs
import errno
-import array
import stat
import sys
# Import _thread instead of threading to reduce startup cost
@@ -161,6 +160,8 @@
opened in a text mode, and for bytes a BytesIO can be used like a file
opened in a binary mode.
"""
+ if not isinstance(file, int):
+ file = os.fspath(file)
if not isinstance(file, (str, bytes, int)):
raise TypeError("invalid file: %r" % file)
if not isinstance(mode, str):
@@ -182,8 +183,8 @@
text = "t" in modes
binary = "b" in modes
if "U" in modes:
- if creating or writing or appending:
- raise ValueError("can't use U and writing mode at once")
+ if creating or writing or appending or updating:
+ raise ValueError("mode U cannot be combined with 'x', 'w', 'a', or '+'")
import warnings
warnings.warn("'U' mode is deprecated",
DeprecationWarning, 2)
@@ -1516,7 +1517,7 @@
if self._fd >= 0 and self._closefd and not self.closed:
import warnings
warnings.warn('unclosed file %r' % (self,), ResourceWarning,
- stacklevel=2)
+ stacklevel=2, source=self)
self.close()
def __getstate__(self):
diff --git a/Lib/_strptime.py b/Lib/_strptime.py
index f84227b..fe94361 100644
--- a/Lib/_strptime.py
+++ b/Lib/_strptime.py
@@ -199,12 +199,15 @@
'f': r"(?P<f>[0-9]{1,6})",
'H': r"(?P<H>2[0-3]|[0-1]\d|\d)",
'I': r"(?P<I>1[0-2]|0[1-9]|[1-9])",
+ 'G': r"(?P<G>\d\d\d\d)",
'j': r"(?P<j>36[0-6]|3[0-5]\d|[1-2]\d\d|0[1-9]\d|00[1-9]|[1-9]\d|0[1-9]|[1-9])",
'm': r"(?P<m>1[0-2]|0[1-9]|[1-9])",
'M': r"(?P<M>[0-5]\d|\d)",
'S': r"(?P<S>6[0-1]|[0-5]\d|\d)",
'U': r"(?P<U>5[0-3]|[0-4]\d|\d)",
'w': r"(?P<w>[0-6])",
+ 'u': r"(?P<u>[1-7])",
+ 'V': r"(?P<V>5[0-3]|0[1-9]|[1-4]\d|\d)",
# W is set below by using 'U'
'y': r"(?P<y>\d\d)",
#XXX: Does 'Y' need to worry about having less or more than
@@ -299,6 +302,22 @@
return 1 + days_to_week + day_of_week
+def _calc_julian_from_V(iso_year, iso_week, iso_weekday):
+ """Calculate the Julian day based on the ISO 8601 year, week, and weekday.
+ ISO weeks start on Mondays, with week 01 being the week containing 4 Jan.
+ ISO week days range from 1 (Monday) to 7 (Sunday).
+ """
+ correction = datetime_date(iso_year, 1, 4).isoweekday() + 3
+ ordinal = (iso_week * 7) + iso_weekday - correction
+ # ordinal may be negative or 0 now, which means the date is in the previous
+ # calendar year
+ if ordinal < 1:
+ ordinal += datetime_date(iso_year, 1, 1).toordinal()
+ iso_year -= 1
+ ordinal -= datetime_date(iso_year, 1, 1).toordinal()
+ return iso_year, ordinal
+
+
def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
"""Return a 2-tuple consisting of a time struct and an int containing
the number of microseconds based on the input string and the
@@ -345,15 +364,15 @@
raise ValueError("unconverted data remains: %s" %
data_string[found.end():])
- year = None
+ iso_year = year = None
month = day = 1
hour = minute = second = fraction = 0
tz = -1
tzoffset = None
# Default to -1 to signify that values not known; not critical to have,
# though
- week_of_year = -1
- week_of_year_start = -1
+ iso_week = week_of_year = None
+ week_of_year_start = None
# weekday and julian defaulted to None so as to signal need to calculate
# values
weekday = julian = None
@@ -375,6 +394,8 @@
year += 1900
elif group_key == 'Y':
year = int(found_dict['Y'])
+ elif group_key == 'G':
+ iso_year = int(found_dict['G'])
elif group_key == 'm':
month = int(found_dict['m'])
elif group_key == 'B':
@@ -420,6 +441,9 @@
weekday = 6
else:
weekday -= 1
+ elif group_key == 'u':
+ weekday = int(found_dict['u'])
+ weekday -= 1
elif group_key == 'j':
julian = int(found_dict['j'])
elif group_key in ('U', 'W'):
@@ -430,6 +454,8 @@
else:
# W starts week on Monday.
week_of_year_start = 0
+ elif group_key == 'V':
+ iso_week = int(found_dict['V'])
elif group_key == 'z':
z = found_dict['z']
tzoffset = int(z[1:3]) * 60 + int(z[3:5])
@@ -450,32 +476,61 @@
else:
tz = value
break
+ # Deal with the cases where ambiguities arize
+ # don't assume default values for ISO week/year
+ if year is None and iso_year is not None:
+ if iso_week is None or weekday is None:
+ raise ValueError("ISO year directive '%G' must be used with "
+ "the ISO week directive '%V' and a weekday "
+ "directive ('%A', '%a', '%w', or '%u').")
+ if julian is not None:
+ raise ValueError("Day of the year directive '%j' is not "
+ "compatible with ISO year directive '%G'. "
+ "Use '%Y' instead.")
+ elif week_of_year is None and iso_week is not None:
+ if weekday is None:
+ raise ValueError("ISO week directive '%V' must be used with "
+ "the ISO year directive '%G' and a weekday "
+ "directive ('%A', '%a', '%w', or '%u').")
+ else:
+ raise ValueError("ISO week directive '%V' is incompatible with "
+ "the year directive '%Y'. Use the ISO year '%G' "
+ "instead.")
+
leap_year_fix = False
if year is None and month == 2 and day == 29:
year = 1904 # 1904 is first leap year of 20th century
leap_year_fix = True
elif year is None:
year = 1900
+
+
# If we know the week of the year and what day of that week, we can figure
# out the Julian day of the year.
- if julian is None and week_of_year != -1 and weekday is not None:
- week_starts_Mon = True if week_of_year_start == 0 else False
- julian = _calc_julian_from_U_or_W(year, week_of_year, weekday,
- week_starts_Mon)
- if julian <= 0:
+ if julian is None and weekday is not None:
+ if week_of_year is not None:
+ week_starts_Mon = True if week_of_year_start == 0 else False
+ julian = _calc_julian_from_U_or_W(year, week_of_year, weekday,
+ week_starts_Mon)
+ elif iso_year is not None and iso_week is not None:
+ year, julian = _calc_julian_from_V(iso_year, iso_week, weekday + 1)
+ if julian is not None and julian <= 0:
year -= 1
yday = 366 if calendar.isleap(year) else 365
julian += yday
- # Cannot pre-calculate datetime_date() since can change in Julian
- # calculation and thus could have different value for the day of the week
- # calculation.
+
if julian is None:
+ # Cannot pre-calculate datetime_date() since can change in Julian
+ # calculation and thus could have different value for the day of
+ # the week calculation.
# Need to add 1 to result since first day of the year is 1, not 0.
julian = datetime_date(year, month, day).toordinal() - \
datetime_date(year, 1, 1).toordinal() + 1
- else: # Assume that if they bothered to include Julian day it will
- # be accurate.
- datetime_result = datetime_date.fromordinal((julian - 1) + datetime_date(year, 1, 1).toordinal())
+ else: # Assume that if they bothered to include Julian day (or if it was
+ # calculated above with year/week/weekday) it will be accurate.
+ datetime_result = datetime_date.fromordinal(
+ (julian - 1) +
+ datetime_date(year, 1, 1).toordinal())
year = datetime_result.year
month = datetime_result.month
day = datetime_result.day
diff --git a/Lib/aifc.py b/Lib/aifc.py
index 7ebdbeb..692d0bf 100644
--- a/Lib/aifc.py
+++ b/Lib/aifc.py
@@ -257,6 +257,15 @@
_aifc_params = namedtuple('_aifc_params',
'nchannels sampwidth framerate nframes comptype compname')
+_aifc_params.nchannels.__doc__ = 'Number of audio channels (1 for mono, 2 for stereo)'
+_aifc_params.sampwidth.__doc__ = 'Sample width in bytes'
+_aifc_params.framerate.__doc__ = 'Sampling frequency'
+_aifc_params.nframes.__doc__ = 'Number of audio frames'
+_aifc_params.comptype.__doc__ = 'Compression type ("NONE" for AIFF files)'
+_aifc_params.compname.__doc__ = ("""\
+A human-readable version of the compression type
+('not compressed' for AIFF files)""")
+
class Aifc_read:
# Variables used in this class:
diff --git a/Lib/argparse.py b/Lib/argparse.py
index 9a06719..209b4e9 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -118,10 +118,16 @@
def __repr__(self):
type_name = type(self).__name__
arg_strings = []
+ star_args = {}
for arg in self._get_args():
arg_strings.append(repr(arg))
for name, value in self._get_kwargs():
- arg_strings.append('%s=%r' % (name, value))
+ if name.isidentifier():
+ arg_strings.append('%s=%r' % (name, value))
+ else:
+ star_args[name] = value
+ if star_args:
+ arg_strings.append('**%s' % repr(star_args))
return '%s(%s)' % (type_name, ', '.join(arg_strings))
def _get_kwargs(self):
@@ -204,8 +210,6 @@
if self.parent is not None:
self.formatter._indent()
join = self.formatter._join_parts
- for func, args in self.items:
- func(*args)
item_help = join([func(*args) for func, args in self.items])
if self.parent is not None:
self.formatter._dedent()
diff --git a/Lib/ast.py b/Lib/ast.py
index 0170472..156a1f2 100644
--- a/Lib/ast.py
+++ b/Lib/ast.py
@@ -35,6 +35,8 @@
return compile(source, filename, mode, PyCF_ONLY_AST)
+_NUM_TYPES = (int, float, complex)
+
def literal_eval(node_or_string):
"""
Safely evaluate an expression node or a string containing a Python
@@ -47,7 +49,9 @@
if isinstance(node_or_string, Expression):
node_or_string = node_or_string.body
def _convert(node):
- if isinstance(node, (Str, Bytes)):
+ if isinstance(node, Constant):
+ return node.value
+ elif isinstance(node, (Str, Bytes)):
return node.s
elif isinstance(node, Num):
return node.n
@@ -62,24 +66,21 @@
in zip(node.keys, node.values))
elif isinstance(node, NameConstant):
return node.value
- elif isinstance(node, UnaryOp) and \
- isinstance(node.op, (UAdd, USub)) and \
- isinstance(node.operand, (Num, UnaryOp, BinOp)):
+ elif isinstance(node, UnaryOp) and isinstance(node.op, (UAdd, USub)):
operand = _convert(node.operand)
- if isinstance(node.op, UAdd):
- return + operand
- else:
- return - operand
- elif isinstance(node, BinOp) and \
- isinstance(node.op, (Add, Sub)) and \
- isinstance(node.right, (Num, UnaryOp, BinOp)) and \
- isinstance(node.left, (Num, UnaryOp, BinOp)):
+ if isinstance(operand, _NUM_TYPES):
+ if isinstance(node.op, UAdd):
+ return + operand
+ else:
+ return - operand
+ elif isinstance(node, BinOp) and isinstance(node.op, (Add, Sub)):
left = _convert(node.left)
right = _convert(node.right)
- if isinstance(node.op, Add):
- return left + right
- else:
- return left - right
+ if isinstance(left, _NUM_TYPES) and isinstance(right, _NUM_TYPES):
+ if isinstance(node.op, Add):
+ return left + right
+ else:
+ return left - right
raise ValueError('malformed node or string: ' + repr(node))
return _convert(node_or_string)
@@ -196,12 +197,19 @@
"""
if not isinstance(node, (AsyncFunctionDef, FunctionDef, ClassDef, Module)):
raise TypeError("%r can't have docstrings" % node.__class__.__name__)
- if node.body and isinstance(node.body[0], Expr) and \
- isinstance(node.body[0].value, Str):
- if clean:
- import inspect
- return inspect.cleandoc(node.body[0].value.s)
- return node.body[0].value.s
+ if not(node.body and isinstance(node.body[0], Expr)):
+ return
+ node = node.body[0].value
+ if isinstance(node, Str):
+ text = node.s
+ elif isinstance(node, Constant) and isinstance(node.value, str):
+ text = node.value
+ else:
+ return
+ if clean:
+ import inspect
+ text = inspect.cleandoc(text)
+ return text
def walk(node):
diff --git a/Lib/asynchat.py b/Lib/asynchat.py
index f728d1b..fc1146a 100644
--- a/Lib/asynchat.py
+++ b/Lib/asynchat.py
@@ -285,35 +285,6 @@
return result
-class fifo:
- def __init__(self, list=None):
- import warnings
- warnings.warn('fifo class will be removed in Python 3.6',
- DeprecationWarning, stacklevel=2)
- if not list:
- self.list = deque()
- else:
- self.list = deque(list)
-
- def __len__(self):
- return len(self.list)
-
- def is_empty(self):
- return not self.list
-
- def first(self):
- return self.list[0]
-
- def push(self, data):
- self.list.append(data)
-
- def pop(self):
- if self.list:
- return (1, self.list.popleft())
- else:
- return (0, None)
-
-
# Given 'haystack', see if any prefix of 'needle' is at its end. This
# assumes an exact match has already been checked. Return the number of
# characters matched.
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 172a463..f55a36e 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -426,7 +426,8 @@
if compat.PY34:
def __del__(self):
if not self.is_closed():
- warnings.warn("unclosed event loop %r" % self, ResourceWarning)
+ warnings.warn("unclosed event loop %r" % self, ResourceWarning,
+ source=self)
if not self.is_running():
self.close()
diff --git a/Lib/asyncio/base_subprocess.py b/Lib/asyncio/base_subprocess.py
index 8fc253c..fb8c2ba 100644
--- a/Lib/asyncio/base_subprocess.py
+++ b/Lib/asyncio/base_subprocess.py
@@ -122,7 +122,8 @@
if compat.PY34:
def __del__(self):
if not self._closed:
- warnings.warn("unclosed transport %r" % self, ResourceWarning)
+ warnings.warn("unclosed transport %r" % self, ResourceWarning,
+ source=self)
self.close()
def get_pid(self):
diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py
index 3ac314c..4b6067a 100644
--- a/Lib/asyncio/proactor_events.py
+++ b/Lib/asyncio/proactor_events.py
@@ -86,7 +86,8 @@
if compat.PY34:
def __del__(self):
if self._sock is not None:
- warnings.warn("unclosed transport %r" % self, ResourceWarning)
+ warnings.warn("unclosed transport %r" % self, ResourceWarning,
+ source=self)
self.close()
def _fatal_error(self, exc, message='Fatal error on pipe transport'):
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py
index ed2b4d7..34cce6b 100644
--- a/Lib/asyncio/selector_events.py
+++ b/Lib/asyncio/selector_events.py
@@ -579,7 +579,8 @@
if compat.PY34:
def __del__(self):
if self._sock is not None:
- warnings.warn("unclosed transport %r" % self, ResourceWarning)
+ warnings.warn("unclosed transport %r" % self, ResourceWarning,
+ source=self)
self._sock.close()
def _fatal_error(self, exc, message='Fatal error on transport'):
diff --git a/Lib/asyncio/sslproto.py b/Lib/asyncio/sslproto.py
index 33d5de2..f0f642e 100644
--- a/Lib/asyncio/sslproto.py
+++ b/Lib/asyncio/sslproto.py
@@ -325,7 +325,8 @@
if compat.PY34:
def __del__(self):
if not self._closed:
- warnings.warn("unclosed transport %r" % self, ResourceWarning)
+ warnings.warn("unclosed transport %r" % self, ResourceWarning,
+ source=self)
self.close()
def pause_reading(self):
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index d712749..ce49c4f 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -381,7 +381,8 @@
if compat.PY34:
def __del__(self):
if self._pipe is not None:
- warnings.warn("unclosed transport %r" % self, ResourceWarning)
+ warnings.warn("unclosed transport %r" % self, ResourceWarning,
+ source=self)
self._pipe.close()
def _fatal_error(self, exc, message='Fatal error on pipe transport'):
@@ -573,7 +574,8 @@
if compat.PY34:
def __del__(self):
if self._pipe is not None:
- warnings.warn("unclosed transport %r" % self, ResourceWarning)
+ warnings.warn("unclosed transport %r" % self, ResourceWarning,
+ source=self)
self._pipe.close()
def abort(self):
diff --git a/Lib/asyncio/windows_utils.py b/Lib/asyncio/windows_utils.py
index 870cd13..7c63fb9 100644
--- a/Lib/asyncio/windows_utils.py
+++ b/Lib/asyncio/windows_utils.py
@@ -159,7 +159,8 @@
def __del__(self):
if self._handle is not None:
- warnings.warn("unclosed %r" % self, ResourceWarning)
+ warnings.warn("unclosed %r" % self, ResourceWarning,
+ source=self)
self.close()
def __enter__(self):
diff --git a/Lib/asyncore.py b/Lib/asyncore.py
index 3b51f0f..4b046d6 100644
--- a/Lib/asyncore.py
+++ b/Lib/asyncore.py
@@ -595,7 +595,8 @@
def __del__(self):
if self.fd >= 0:
- warnings.warn("unclosed file %r" % self, ResourceWarning)
+ warnings.warn("unclosed file %r" % self, ResourceWarning,
+ source=self)
self.close()
def recv(self, *args):
diff --git a/Lib/base64.py b/Lib/base64.py
index adaec1d..67e54f0 100755
--- a/Lib/base64.py
+++ b/Lib/base64.py
@@ -55,8 +55,7 @@
alternative alphabet for the '+' and '/' characters. This allows an
application to e.g. generate url or filesystem safe Base64 strings.
"""
- # Strip off the trailing newline
- encoded = binascii.b2a_base64(s)[:-1]
+ encoded = binascii.b2a_base64(s, newline=False)
if altchars is not None:
assert len(altchars) == 2, repr(altchars)
return encoded.translate(bytes.maketrans(b'+/', altchars))
diff --git a/Lib/calendar.py b/Lib/calendar.py
index 5244b8d..85baf2e 100644
--- a/Lib/calendar.py
+++ b/Lib/calendar.py
@@ -12,7 +12,9 @@
__all__ = ["IllegalMonthError", "IllegalWeekdayError", "setfirstweekday",
"firstweekday", "isleap", "leapdays", "weekday", "monthrange",
"monthcalendar", "prmonth", "month", "prcal", "calendar",
- "timegm", "month_name", "month_abbr", "day_name", "day_abbr"]
+ "timegm", "month_name", "month_abbr", "day_name", "day_abbr",
+ "Calendar", "TextCalendar", "HTMLCalendar", "LocaleTextCalendar",
+ "LocaleHTMLCalendar", "weekheader"]
# Exception raised for bad input (with string parameter for details)
error = ValueError
@@ -605,51 +607,63 @@
def main(args):
- import optparse
- parser = optparse.OptionParser(usage="usage: %prog [options] [year [month]]")
- parser.add_option(
+ import argparse
+ parser = argparse.ArgumentParser()
+ textgroup = parser.add_argument_group('text only arguments')
+ htmlgroup = parser.add_argument_group('html only arguments')
+ textgroup.add_argument(
"-w", "--width",
- dest="width", type="int", default=2,
- help="width of date column (default 2, text only)"
+ type=int, default=2,
+ help="width of date column (default 2)"
)
- parser.add_option(
+ textgroup.add_argument(
"-l", "--lines",
- dest="lines", type="int", default=1,
- help="number of lines for each week (default 1, text only)"
+ type=int, default=1,
+ help="number of lines for each week (default 1)"
)
- parser.add_option(
+ textgroup.add_argument(
"-s", "--spacing",
- dest="spacing", type="int", default=6,
- help="spacing between months (default 6, text only)"
+ type=int, default=6,
+ help="spacing between months (default 6)"
)
- parser.add_option(
+ textgroup.add_argument(
"-m", "--months",
- dest="months", type="int", default=3,
- help="months per row (default 3, text only)"
+ type=int, default=3,
+ help="months per row (default 3)"
)
- parser.add_option(
+ htmlgroup.add_argument(
"-c", "--css",
- dest="css", default="calendar.css",
- help="CSS to use for page (html only)"
+ default="calendar.css",
+ help="CSS to use for page"
)
- parser.add_option(
+ parser.add_argument(
"-L", "--locale",
- dest="locale", default=None,
+ default=None,
help="locale to be used from month and weekday names"
)
- parser.add_option(
+ parser.add_argument(
"-e", "--encoding",
- dest="encoding", default=None,
- help="Encoding to use for output."
+ default=None,
+ help="encoding to use for output"
)
- parser.add_option(
+ parser.add_argument(
"-t", "--type",
- dest="type", default="text",
+ default="text",
choices=("text", "html"),
help="output type (text or html)"
)
+ parser.add_argument(
+ "year",
+ nargs='?', type=int,
+ help="year number (1-9999)"
+ )
+ parser.add_argument(
+ "month",
+ nargs='?', type=int,
+ help="month number (1-12, text only)"
+ )
- (options, args) = parser.parse_args(args)
+ options = parser.parse_args(args[1:])
if options.locale and not options.encoding:
parser.error("if --locale is specified --encoding is required")
@@ -667,10 +681,10 @@
encoding = sys.getdefaultencoding()
optdict = dict(encoding=encoding, css=options.css)
write = sys.stdout.buffer.write
- if len(args) == 1:
+ if options.year is None:
write(cal.formatyearpage(datetime.date.today().year, **optdict))
- elif len(args) == 2:
- write(cal.formatyearpage(int(args[1]), **optdict))
+ elif options.month is None:
+ write(cal.formatyearpage(options.year, **optdict))
else:
parser.error("incorrect number of arguments")
sys.exit(1)
@@ -680,18 +694,15 @@
else:
cal = TextCalendar()
optdict = dict(w=options.width, l=options.lines)
- if len(args) != 3:
+ if options.month is None:
optdict["c"] = options.spacing
optdict["m"] = options.months
- if len(args) == 1:
+ if options.year is None:
result = cal.formatyear(datetime.date.today().year, **optdict)
- elif len(args) == 2:
- result = cal.formatyear(int(args[1]), **optdict)
- elif len(args) == 3:
- result = cal.formatmonth(int(args[1]), int(args[2]), **optdict)
+ elif options.month is None:
+ result = cal.formatyear(options.year, **optdict)
else:
- parser.error("incorrect number of arguments")
- sys.exit(1)
+ result = cal.formatmonth(options.year, options.month, **optdict)
write = sys.stdout.write
if options.encoding:
result = result.encode(options.encoding)
diff --git a/Lib/cgi.py b/Lib/cgi.py
index 189c6d5..233a496 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -45,7 +45,7 @@
__all__ = ["MiniFieldStorage", "FieldStorage",
"parse", "parse_qs", "parse_qsl", "parse_multipart",
- "parse_header", "print_exception", "print_environ",
+ "parse_header", "test", "print_exception", "print_environ",
"print_form", "print_directory", "print_arguments",
"print_environ_usage", "escape"]
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
index ebe8ee7..b941950 100644
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -842,7 +842,7 @@
########################################################################
-### ChainMap (helper for configparser and string.Template)
+### ChainMap
########################################################################
class ChainMap(MutableMapping):
@@ -969,7 +969,7 @@
dict = kwargs.pop('dict')
import warnings
warnings.warn("Passing 'dict' as keyword argument is deprecated",
- PendingDeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
else:
dict = None
self.data = {}
diff --git a/Lib/compileall.py b/Lib/compileall.py
index 0cc0c1d..67c5f5a 100644
--- a/Lib/compileall.py
+++ b/Lib/compileall.py
@@ -68,7 +68,7 @@
"""
files = _walk_dir(dir, quiet=quiet, maxlevels=maxlevels,
ddir=ddir)
- success = 1
+ success = True
if workers is not None and workers != 1 and ProcessPoolExecutor is not None:
if workers < 0:
raise ValueError('workers must be greater or equal to 0')
@@ -81,12 +81,12 @@
legacy=legacy,
optimize=optimize),
files)
- success = min(results, default=1)
+ success = min(results, default=True)
else:
for file in files:
if not compile_file(file, ddir, force, rx, quiet,
legacy, optimize):
- success = 0
+ success = False
return success
def compile_file(fullname, ddir=None, force=False, rx=None, quiet=0,
@@ -104,7 +104,7 @@
legacy: if True, produce legacy pyc paths instead of PEP 3147 paths
optimize: optimization level or -1 for level of the interpreter
"""
- success = 1
+ success = True
name = os.path.basename(fullname)
if ddir is not None:
dfile = os.path.join(ddir, name)
@@ -144,7 +144,7 @@
ok = py_compile.compile(fullname, cfile, dfile, True,
optimize=optimize)
except py_compile.PyCompileError as err:
- success = 0
+ success = False
if quiet >= 2:
return success
elif quiet:
@@ -157,7 +157,7 @@
msg = msg.decode(sys.stdout.encoding)
print(msg)
except (SyntaxError, UnicodeError, OSError) as e:
- success = 0
+ success = False
if quiet >= 2:
return success
elif quiet:
@@ -167,7 +167,7 @@
print(e.__class__.__name__ + ':', e)
else:
if ok == 0:
- success = 0
+ success = False
return success
def compile_path(skip_curdir=1, maxlevels=0, force=False, quiet=0,
@@ -183,7 +183,7 @@
legacy: as for compile_dir() (default False)
optimize: as for compile_dir() (default -1)
"""
- success = 1
+ success = True
for dir in sys.path:
if (not dir or dir == os.curdir) and skip_curdir:
if quiet < 2:
diff --git a/Lib/contextlib.py b/Lib/contextlib.py
index d44edd6..7d94a57 100644
--- a/Lib/contextlib.py
+++ b/Lib/contextlib.py
@@ -1,11 +1,34 @@
"""Utilities for with-statement contexts. See PEP 343."""
-
+import abc
import sys
from collections import deque
from functools import wraps
-__all__ = ["contextmanager", "closing", "ContextDecorator", "ExitStack",
- "redirect_stdout", "redirect_stderr", "suppress"]
+__all__ = ["contextmanager", "closing", "AbstractContextManager",
+ "ContextDecorator", "ExitStack", "redirect_stdout",
+ "redirect_stderr", "suppress"]
+
+
+class AbstractContextManager(abc.ABC):
+
+ """An abstract base class for context managers."""
+
+ def __enter__(self):
+ """Return `self` upon entering the runtime context."""
+ return self
+
+ @abc.abstractmethod
+ def __exit__(self, exc_type, exc_value, traceback):
+ """Raise any exception triggered within the runtime context."""
+ return None
+
+ @classmethod
+ def __subclasshook__(cls, C):
+ if cls is AbstractContextManager:
+ if (any("__enter__" in B.__dict__ for B in C.__mro__) and
+ any("__exit__" in B.__dict__ for B in C.__mro__)):
+ return True
+ return NotImplemented
class ContextDecorator(object):
@@ -31,7 +54,7 @@
return inner
-class _GeneratorContextManager(ContextDecorator):
+class _GeneratorContextManager(ContextDecorator, AbstractContextManager):
"""Helper for @contextmanager decorator."""
def __init__(self, func, args, kwds):
@@ -137,7 +160,7 @@
return helper
-class closing(object):
+class closing(AbstractContextManager):
"""Context to automatically close something at the end of a block.
Code like this:
@@ -162,7 +185,7 @@
self.thing.close()
-class _RedirectStream:
+class _RedirectStream(AbstractContextManager):
_stream = None
@@ -202,7 +225,7 @@
_stream = "stderr"
-class suppress:
+class suppress(AbstractContextManager):
"""Context manager to suppress specified exceptions
After the exception is suppressed, execution proceeds with the next
@@ -233,7 +256,7 @@
# Inspired by discussions on http://bugs.python.org/issue13585
-class ExitStack(object):
+class ExitStack(AbstractContextManager):
"""Context manager for dynamic management of a stack of exit callbacks
For example:
@@ -312,9 +335,6 @@
"""Immediately unwind the context stack"""
self.__exit__(None, None, None)
- def __enter__(self):
- return self
-
def __exit__(self, *exc_details):
received_exc = exc_details[0] is not None
diff --git a/Lib/copy.py b/Lib/copy.py
index 972b94a..f86040a 100644
--- a/Lib/copy.py
+++ b/Lib/copy.py
@@ -51,7 +51,6 @@
import types
import weakref
from copyreg import dispatch_table
-import builtins
class Error(Exception):
pass
@@ -102,37 +101,33 @@
else:
raise Error("un(shallow)copyable object of type %s" % cls)
- return _reconstruct(x, rv, 0)
+ if isinstance(rv, str):
+ return x
+ return _reconstruct(x, None, *rv)
_copy_dispatch = d = {}
def _copy_immutable(x):
return x
-for t in (type(None), int, float, bool, str, tuple,
- bytes, frozenset, type, range,
- types.BuiltinFunctionType, type(Ellipsis),
+for t in (type(None), int, float, bool, complex, str, tuple,
+ bytes, frozenset, type, range, slice,
+ types.BuiltinFunctionType, type(Ellipsis), type(NotImplemented),
types.FunctionType, weakref.ref):
d[t] = _copy_immutable
t = getattr(types, "CodeType", None)
if t is not None:
d[t] = _copy_immutable
-for name in ("complex", "unicode"):
- t = getattr(builtins, name, None)
- if t is not None:
- d[t] = _copy_immutable
-def _copy_with_constructor(x):
- return type(x)(x)
-for t in (list, dict, set):
- d[t] = _copy_with_constructor
+d[list] = list.copy
+d[dict] = dict.copy
+d[set] = set.copy
+d[bytearray] = bytearray.copy
-def _copy_with_copy_method(x):
- return x.copy()
if PyStringMap is not None:
- d[PyStringMap] = _copy_with_copy_method
+ d[PyStringMap] = PyStringMap.copy
-del d
+del d, t
def deepcopy(x, memo=None, _nil=[]):
"""Deep copy operation on arbitrary Python objects.
@@ -179,7 +174,10 @@
else:
raise Error(
"un(deep)copyable object of type %s" % cls)
- y = _reconstruct(x, rv, 1, memo)
+ if isinstance(rv, str):
+ y = x
+ else:
+ y = _reconstruct(x, memo, *rv)
# If is its own copy, don't memoize.
if y is not x:
@@ -193,13 +191,11 @@
return x
d[type(None)] = _deepcopy_atomic
d[type(Ellipsis)] = _deepcopy_atomic
+d[type(NotImplemented)] = _deepcopy_atomic
d[int] = _deepcopy_atomic
d[float] = _deepcopy_atomic
d[bool] = _deepcopy_atomic
-try:
- d[complex] = _deepcopy_atomic
-except NameError:
- pass
+d[complex] = _deepcopy_atomic
d[bytes] = _deepcopy_atomic
d[str] = _deepcopy_atomic
try:
@@ -211,15 +207,16 @@
d[types.FunctionType] = _deepcopy_atomic
d[weakref.ref] = _deepcopy_atomic
-def _deepcopy_list(x, memo):
+def _deepcopy_list(x, memo, deepcopy=deepcopy):
y = []
memo[id(x)] = y
+ append = y.append
for a in x:
- y.append(deepcopy(a, memo))
+ append(deepcopy(a, memo))
return y
d[list] = _deepcopy_list
-def _deepcopy_tuple(x, memo):
+def _deepcopy_tuple(x, memo, deepcopy=deepcopy):
y = [deepcopy(a, memo) for a in x]
# 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.
@@ -236,7 +233,7 @@
return y
d[tuple] = _deepcopy_tuple
-def _deepcopy_dict(x, memo):
+def _deepcopy_dict(x, memo, deepcopy=deepcopy):
y = {}
memo[id(x)] = y
for key, value in x.items():
@@ -248,7 +245,9 @@
def _deepcopy_method(x, memo): # Copy instance methods
return type(x)(x.__func__, deepcopy(x.__self__, memo))
-_deepcopy_dispatch[types.MethodType] = _deepcopy_method
+d[types.MethodType] = _deepcopy_method
+
+del d
def _keep_alive(x, memo):
"""Keeps a reference to the object x in the memo.
@@ -266,31 +265,15 @@
# aha, this is the first one :-)
memo[id(memo)]=[x]
-def _reconstruct(x, info, deep, memo=None):
- if isinstance(info, str):
- return x
- assert isinstance(info, tuple)
- if memo is None:
- memo = {}
- n = len(info)
- assert n in (2, 3, 4, 5)
- callable, args = info[:2]
- if n > 2:
- state = info[2]
- else:
- state = None
- if n > 3:
- listiter = info[3]
- else:
- listiter = None
- if n > 4:
- dictiter = info[4]
- else:
- dictiter = None
+def _reconstruct(x, memo, func, args,
+ state=None, listiter=None, dictiter=None,
+ deepcopy=deepcopy):
+ deep = memo is not None
+ if deep and args:
+ args = (deepcopy(arg, memo) for arg in args)
+ y = func(*args)
if deep:
- args = deepcopy(args, memo)
- y = callable(*args)
- memo[id(x)] = y
+ memo[id(x)] = y
if state is not None:
if deep:
@@ -309,22 +292,22 @@
setattr(y, key, value)
if listiter is not None:
- for item in listiter:
- if deep:
+ if deep:
+ for item in listiter:
item = deepcopy(item, memo)
- y.append(item)
+ y.append(item)
+ else:
+ for item in listiter:
+ y.append(item)
if dictiter is not None:
- for key, value in dictiter:
- if deep:
+ if deep:
+ for key, value in dictiter:
key = deepcopy(key, memo)
value = deepcopy(value, memo)
- y[key] = value
+ y[key] = value
+ else:
+ for key, value in dictiter:
+ y[key] = value
return y
-del d
-
-del types
-
-# Helper for instance creation without calling __init__
-class _EmptyClass:
- pass
+del types, weakref, PyStringMap
diff --git a/Lib/crypt.py b/Lib/crypt.py
index 49ab96e..fbc5f4c 100644
--- a/Lib/crypt.py
+++ b/Lib/crypt.py
@@ -54,9 +54,8 @@
METHOD_SHA512 = _Method('SHA512', '6', 16, 106)
methods = []
-for _method in (METHOD_SHA512, METHOD_SHA256, METHOD_MD5):
+for _method in (METHOD_SHA512, METHOD_SHA256, METHOD_MD5, METHOD_CRYPT):
_result = crypt('', _method)
if _result and len(_result) == _method.total_size:
methods.append(_method)
-methods.append(METHOD_CRYPT)
del _result, _method
diff --git a/Lib/csv.py b/Lib/csv.py
index ca40e5e..90461db 100644
--- a/Lib/csv.py
+++ b/Lib/csv.py
@@ -13,11 +13,12 @@
from io import StringIO
-__all__ = [ "QUOTE_MINIMAL", "QUOTE_ALL", "QUOTE_NONNUMERIC", "QUOTE_NONE",
- "Error", "Dialect", "__doc__", "excel", "excel_tab",
- "field_size_limit", "reader", "writer",
- "register_dialect", "get_dialect", "list_dialects", "Sniffer",
- "unregister_dialect", "__version__", "DictReader", "DictWriter" ]
+__all__ = ["QUOTE_MINIMAL", "QUOTE_ALL", "QUOTE_NONNUMERIC", "QUOTE_NONE",
+ "Error", "Dialect", "__doc__", "excel", "excel_tab",
+ "field_size_limit", "reader", "writer",
+ "register_dialect", "get_dialect", "list_dialects", "Sniffer",
+ "unregister_dialect", "__version__", "DictReader", "DictWriter",
+ "unix_dialect"]
class Dialect:
"""Describe a CSV dialect.
diff --git a/Lib/ctypes/test/test_bitfields.py b/Lib/ctypes/test/test_bitfields.py
index b39d82c..0eb09fb 100644
--- a/Lib/ctypes/test/test_bitfields.py
+++ b/Lib/ctypes/test/test_bitfields.py
@@ -3,7 +3,6 @@
import unittest
import os
-import ctypes
import _ctypes_test
class BITS(Structure):
diff --git a/Lib/ctypes/test/test_objects.py b/Lib/ctypes/test/test_objects.py
index ef7b20b..19e3dc1 100644
--- a/Lib/ctypes/test/test_objects.py
+++ b/Lib/ctypes/test/test_objects.py
@@ -54,7 +54,7 @@
'''
-import unittest, doctest, sys
+import unittest, doctest
import ctypes.test.test_objects
diff --git a/Lib/ctypes/test/test_parameters.py b/Lib/ctypes/test/test_parameters.py
index e56bccf..363f586 100644
--- a/Lib/ctypes/test/test_parameters.py
+++ b/Lib/ctypes/test/test_parameters.py
@@ -1,4 +1,4 @@
-import unittest, sys
+import unittest
from ctypes.test import need_symbol
class SimpleTypesTestCase(unittest.TestCase):
@@ -49,7 +49,7 @@
# XXX Replace by c_char_p tests
def test_cstrings(self):
- from ctypes import c_char_p, byref
+ from ctypes import c_char_p
# c_char_p.from_param on a Python String packs the string
# into a cparam object
@@ -68,7 +68,7 @@
@need_symbol('c_wchar_p')
def test_cw_strings(self):
- from ctypes import byref, c_wchar_p
+ from ctypes import c_wchar_p
c_wchar_p.from_param("123")
@@ -98,7 +98,7 @@
def test_byref_pointer(self):
# The from_param class method of POINTER(typ) classes accepts what is
# returned by byref(obj), it type(obj) == typ
- from ctypes import c_short, c_uint, c_int, c_long, pointer, POINTER, byref
+ from ctypes import c_short, c_uint, c_int, c_long, POINTER, byref
LPINT = POINTER(c_int)
LPINT.from_param(byref(c_int(42)))
diff --git a/Lib/ctypes/test/test_pep3118.py b/Lib/ctypes/test/test_pep3118.py
index 32f802c..d68397e 100644
--- a/Lib/ctypes/test/test_pep3118.py
+++ b/Lib/ctypes/test/test_pep3118.py
@@ -1,6 +1,6 @@
import unittest
from ctypes import *
-import re, struct, sys
+import re, sys
if sys.byteorder == "little":
THIS_ENDIAN = "<"
diff --git a/Lib/ctypes/test/test_returnfuncptrs.py b/Lib/ctypes/test/test_returnfuncptrs.py
index 93eba6b..1974f40 100644
--- a/Lib/ctypes/test/test_returnfuncptrs.py
+++ b/Lib/ctypes/test/test_returnfuncptrs.py
@@ -1,6 +1,5 @@
import unittest
from ctypes import *
-import os
import _ctypes_test
diff --git a/Lib/ctypes/test/test_sizes.py b/Lib/ctypes/test/test_sizes.py
index f9b5e97..4ceacbc 100644
--- a/Lib/ctypes/test/test_sizes.py
+++ b/Lib/ctypes/test/test_sizes.py
@@ -2,7 +2,6 @@
from ctypes import *
-import sys
import unittest
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py
index d998c27..94a86ea 100644
--- a/Lib/ctypes/test/test_structures.py
+++ b/Lib/ctypes/test/test_structures.py
@@ -320,17 +320,14 @@
cls, msg = self.get_except(Person, b"Someone", (1, 2))
self.assertEqual(cls, RuntimeError)
- self.assertEqual(msg,
- "(Phone) <class 'TypeError'>: "
- "expected bytes, int found")
+ self.assertRegex(msg,
+ r"\(Phone\) <class 'TypeError' at 0x.+>: "
+ r"expected bytes, int found")
cls, msg = self.get_except(Person, b"Someone", (b"a", b"b", b"c"))
self.assertEqual(cls, RuntimeError)
- if issubclass(Exception, object):
- self.assertEqual(msg,
- "(Phone) <class 'TypeError'>: too many initializers")
- else:
- self.assertEqual(msg, "(Phone) TypeError: too many initializers")
+ self.assertRegex(msg,
+ r"\(Phone\) <class 'TypeError' at 0x.+>: too many initializers")
def test_huge_field_name(self):
# issue12881: segfault with large structure field names
diff --git a/Lib/ctypes/test/test_values.py b/Lib/ctypes/test/test_values.py
index 5a3a47f..e71b480 100644
--- a/Lib/ctypes/test/test_values.py
+++ b/Lib/ctypes/test/test_values.py
@@ -79,9 +79,9 @@
continue
items.append((entry.name.decode("ascii"), entry.size))
- expected = [("__hello__", 161),
- ("__phello__", -161),
- ("__phello__.spam", 161),
+ expected = [("__hello__", 139),
+ ("__phello__", -139),
+ ("__phello__.spam", 139),
]
self.assertEqual(items, expected, "PyImport_FrozenModules example "
"in Doc/library/ctypes.rst may be out of date")
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
index 7684eab..e25a886 100644
--- a/Lib/ctypes/util.py
+++ b/Lib/ctypes/util.py
@@ -271,8 +271,8 @@
abi_type = mach_map.get(machine, 'libc6')
# XXX assuming GLIBC's ldconfig (with option -p)
- regex = os.fsencode(
- '\s+(lib%s\.[^\s]+)\s+\(%s' % (re.escape(name), abi_type))
+ regex = r'\s+(lib%s\.[^\s]+)\s+\(%s'
+ regex = os.fsencode(regex % (re.escape(name), abi_type))
try:
with subprocess.Popen(['/sbin/ldconfig', '-p'],
stdin=subprocess.DEVNULL,
diff --git a/Lib/datetime.py b/Lib/datetime.py
index 2f94218..b1321a3 100644
--- a/Lib/datetime.py
+++ b/Lib/datetime.py
@@ -152,12 +152,26 @@
dnum = _days_before_month(y, m) + d
return _time.struct_time((y, m, d, hh, mm, ss, wday, dnum, dstflag))
-def _format_time(hh, mm, ss, us):
- # Skip trailing microseconds when us==0.
- result = "%02d:%02d:%02d" % (hh, mm, ss)
- if us:
- result += ".%06d" % us
- return result
+def _format_time(hh, mm, ss, us, timespec='auto'):
+ specs = {
+ 'hours': '{:02d}',
+ 'minutes': '{:02d}:{:02d}',
+ 'seconds': '{:02d}:{:02d}:{:02d}',
+ 'milliseconds': '{:02d}:{:02d}:{:02d}.{:03d}',
+ 'microseconds': '{:02d}:{:02d}:{:02d}.{:06d}'
+ }
+
+ if timespec == 'auto':
+ # Skip trailing microseconds when us==0.
+ timespec = 'microseconds' if us else 'seconds'
+ elif timespec == 'milliseconds':
+ us //= 1000
+ try:
+ fmt = specs[timespec]
+ except KeyError:
+ raise ValueError('Unknown timespec value')
+ else:
+ return fmt.format(hh, mm, ss, us)
# Correctly substitute for %z and %Z escapes in strftime formats.
def _wrap_strftime(object, format, timetuple):
@@ -240,7 +254,7 @@
raise ValueError("tzinfo.%s() must return a whole number "
"of minutes, got %s" % (name, offset))
if not -timedelta(1) < offset < timedelta(1):
- raise ValueError("%s()=%s, must be must be strictly between "
+ raise ValueError("%s()=%s, must be strictly between "
"-timedelta(hours=24) and timedelta(hours=24)" %
(name, offset))
@@ -316,6 +330,7 @@
return q
+
class timedelta:
"""Represent the difference between two datetime objects.
@@ -1193,14 +1208,17 @@
s = s[:-1] + ", tzinfo=%r" % self._tzinfo + ")"
return s
- def isoformat(self):
+ def isoformat(self, timespec='auto'):
"""Return the time formatted according to ISO.
- This is 'HH:MM:SS.mmmmmm+zz:zz', or 'HH:MM:SS+zz:zz' if
- self.microsecond == 0.
+ The full format is 'HH:MM:SS.mmmmmm+zz:zz'. By default, the fractional
+ part is omitted if self.microsecond == 0.
+
+ The optional argument timespec specifies the number of additional
+ terms of the time to include.
"""
s = _format_time(self._hour, self._minute, self._second,
- self._microsecond)
+ self._microsecond, timespec)
tz = self._tzstr()
if tz:
s += tz
@@ -1549,21 +1567,25 @@
self._hour, self._minute, self._second,
self._year)
- def isoformat(self, sep='T'):
+ def isoformat(self, sep='T', timespec='auto'):
"""Return the time formatted according to ISO.
- This is 'YYYY-MM-DD HH:MM:SS.mmmmmm', or 'YYYY-MM-DD HH:MM:SS' if
- self.microsecond == 0.
+ The full format looks like 'YYYY-MM-DD HH:MM:SS.mmmmmm'.
+ By default, the fractional part is omitted if self.microsecond == 0.
If self.tzinfo is not None, the UTC offset is also attached, giving
- 'YYYY-MM-DD HH:MM:SS.mmmmmm+HH:MM' or 'YYYY-MM-DD HH:MM:SS+HH:MM'.
+ giving a full format of 'YYYY-MM-DD HH:MM:SS.mmmmmm+HH:MM'.
Optional argument sep specifies the separator between date and
time, default 'T'.
+
+ The optional argument timespec specifies the number of additional
+ terms of the time to include.
"""
s = ("%04d-%02d-%02d%c" % (self._year, self._month, self._day, sep) +
_format_time(self._hour, self._minute, self._second,
- self._microsecond))
+ self._microsecond, timespec))
+
off = self.utcoffset()
if off is not None:
if off.days < 0:
@@ -1913,6 +1935,8 @@
@staticmethod
def _name_from_offset(delta):
+ if not delta:
+ return 'UTC'
if delta < timedelta(0):
sign = '-'
delta = -delta
diff --git a/Lib/dis.py b/Lib/dis.py
index f7e3c7f..59886f1 100644
--- a/Lib/dis.py
+++ b/Lib/dis.py
@@ -163,6 +163,15 @@
_Instruction = collections.namedtuple("_Instruction",
"opname opcode arg argval argrepr offset starts_line is_jump_target")
+_Instruction.opname.__doc__ = "Human readable name for operation"
+_Instruction.opcode.__doc__ = "Numeric code for operation"
+_Instruction.arg.__doc__ = "Numeric argument to operation (if any), otherwise None"
+_Instruction.argval.__doc__ = "Resolved arg value (if known), otherwise same as arg"
+_Instruction.argrepr.__doc__ = "Human readable description of operation argument"
+_Instruction.offset.__doc__ = "Start index of operation within bytecode sequence"
+_Instruction.starts_line.__doc__ = "Line started by this opcode (if any), otherwise None"
+_Instruction.is_jump_target.__doc__ = "True if other code jumps to here, otherwise False"
+
class Instruction(_Instruction):
"""Details for a bytecode operation
@@ -276,7 +285,6 @@
"""
labels = findlabels(code)
starts_line = None
- free = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
@@ -296,7 +304,7 @@
elif op in hasname:
argval, argrepr = _get_name_info(arg, names)
elif op in hasjrel:
- argval = offset + 3 + arg
+ argval = offset + 2 + arg
argrepr = "to " + repr(argval)
elif op in haslocal:
argval, argrepr = _get_name_info(arg, varnames)
@@ -343,23 +351,15 @@
disco = disassemble # XXX For backwards compatibility
def _unpack_opargs(code):
- # enumerate() is not an option, since we sometimes process
- # multiple elements on a single pass through the loop
extended_arg = 0
- n = len(code)
- i = 0
- while i < n:
+ for i in range(0, len(code), 2):
op = code[i]
- offset = i
- i = i+1
- arg = None
if op >= HAVE_ARGUMENT:
- arg = code[i] + code[i+1]*256 + extended_arg
- extended_arg = 0
- i = i+2
- if op == EXTENDED_ARG:
- extended_arg = arg*65536
- yield (offset, op, arg)
+ arg = code[i+1] | extended_arg
+ extended_arg = (arg << 8) if op == EXTENDED_ARG else 0
+ else:
+ arg = None
+ yield (i, op, arg)
def findlabels(code):
"""Detect all offsets in a byte code which are jump targets.
@@ -370,14 +370,14 @@
labels = []
for offset, op, arg in _unpack_opargs(code):
if arg is not None:
- label = -1
if op in hasjrel:
- label = offset + 3 + arg
+ label = offset + 2 + arg
elif op in hasjabs:
label = arg
- if label >= 0:
- if label not in labels:
- labels.append(label)
+ else:
+ continue
+ if label not in labels:
+ labels.append(label)
return labels
def findlinestarts(code):
@@ -386,8 +386,8 @@
Generate pairs (offset, lineno) as described in Python/compile.c.
"""
- byte_increments = list(code.co_lnotab[0::2])
- line_increments = list(code.co_lnotab[1::2])
+ byte_increments = code.co_lnotab[0::2]
+ line_increments = code.co_lnotab[1::2]
lastlineno = None
lineno = code.co_firstlineno
@@ -398,6 +398,9 @@
yield (addr, lineno)
lastlineno = lineno
addr += byte_incr
+ if line_incr >= 0x80:
+ # line_increments is an array of 8-bit signed integers
+ line_incr -= 0x100
lineno += line_incr
if lineno != lastlineno:
yield (addr, lineno)
diff --git a/Lib/distutils/command/bdist_msi.py b/Lib/distutils/command/bdist_msi.py
index b3cfe9c..f6c21ae 100644
--- a/Lib/distutils/command/bdist_msi.py
+++ b/Lib/distutils/command/bdist_msi.py
@@ -199,7 +199,7 @@
target_version = self.target_version
if not target_version:
assert self.skip_build, "Should have already checked this"
- target_version = sys.version[0:3]
+ target_version = '%d.%d' % sys.version_info[:2]
plat_specifier = ".%s-%s" % (self.plat_name, target_version)
build = self.get_finalized_command('build')
build.build_lib = os.path.join(build.build_base,
diff --git a/Lib/distutils/command/bdist_wininst.py b/Lib/distutils/command/bdist_wininst.py
index 0c0e2c1..d3e1d3a 100644
--- a/Lib/distutils/command/bdist_wininst.py
+++ b/Lib/distutils/command/bdist_wininst.py
@@ -141,7 +141,7 @@
target_version = self.target_version
if not target_version:
assert self.skip_build, "Should have already checked this"
- target_version = sys.version[0:3]
+ target_version = '%d.%d' % sys.version_info[:2]
plat_specifier = ".%s-%s" % (self.plat_name, target_version)
build = self.get_finalized_command('build')
build.build_lib = os.path.join(build.build_base,
diff --git a/Lib/distutils/command/build.py b/Lib/distutils/command/build.py
index 337dd0b..c6f52e6 100644
--- a/Lib/distutils/command/build.py
+++ b/Lib/distutils/command/build.py
@@ -81,7 +81,7 @@
"--plat-name only supported on Windows (try "
"using './configure --help' on your platform)")
- plat_specifier = ".%s-%s" % (self.plat_name, sys.version[0:3])
+ plat_specifier = ".%s-%d.%d" % (self.plat_name, *sys.version_info[:2])
# Make it so Python 2.x and Python 2.x with --with-pydebug don't
# share the same build directories. Doing so confuses the build
@@ -114,7 +114,7 @@
'temp' + plat_specifier)
if self.build_scripts is None:
self.build_scripts = os.path.join(self.build_base,
- 'scripts-' + sys.version[0:3])
+ 'scripts-%d.%d' % sys.version_info[:2])
if self.executable is None:
self.executable = os.path.normpath(sys.executable)
diff --git a/Lib/distutils/command/config.py b/Lib/distutils/command/config.py
index 847e858..b1fd09e 100644
--- a/Lib/distutils/command/config.py
+++ b/Lib/distutils/command/config.py
@@ -9,7 +9,7 @@
this header file lives".
"""
-import sys, os, re
+import os, re
from distutils.core import Command
from distutils.errors import DistutilsExecError
diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
index 67db007..9474e9c 100644
--- a/Lib/distutils/command/install.py
+++ b/Lib/distutils/command/install.py
@@ -290,8 +290,8 @@
'dist_version': self.distribution.get_version(),
'dist_fullname': self.distribution.get_fullname(),
'py_version': py_version,
- 'py_version_short': py_version[0:3],
- 'py_version_nodot': py_version[0] + py_version[2],
+ 'py_version_short': '%d.%d' % sys.version_info[:2],
+ 'py_version_nodot': '%d%d' % sys.version_info[:2],
'sys_prefix': prefix,
'prefix': prefix,
'sys_exec_prefix': exec_prefix,
diff --git a/Lib/distutils/command/install_egg_info.py b/Lib/distutils/command/install_egg_info.py
index c2a7d64..0ddc736 100644
--- a/Lib/distutils/command/install_egg_info.py
+++ b/Lib/distutils/command/install_egg_info.py
@@ -21,10 +21,10 @@
def finalize_options(self):
self.set_undefined_options('install_lib',('install_dir','install_dir'))
- basename = "%s-%s-py%s.egg-info" % (
+ basename = "%s-%s-py%d.%d.egg-info" % (
to_filename(safe_name(self.distribution.get_name())),
to_filename(safe_version(self.distribution.get_version())),
- sys.version[:3]
+ *sys.version_info[:2]
)
self.target = os.path.join(self.install_dir, basename)
self.outputs = [self.target]
diff --git a/Lib/distutils/command/register.py b/Lib/distutils/command/register.py
index 86343c8..456d50d 100644
--- a/Lib/distutils/command/register.py
+++ b/Lib/distutils/command/register.py
@@ -5,7 +5,7 @@
# created 2002/10/21, Richard Jones
-import os, string, getpass
+import getpass
import io
import urllib.parse, urllib.request
from warnings import warn
diff --git a/Lib/distutils/command/sdist.py b/Lib/distutils/command/sdist.py
index 7ea3d5f..35a06eb 100644
--- a/Lib/distutils/command/sdist.py
+++ b/Lib/distutils/command/sdist.py
@@ -3,7 +3,6 @@
Implements the Distutils 'sdist' command (create a source distribution)."""
import os
-import string
import sys
from types import *
from glob import glob
diff --git a/Lib/distutils/core.py b/Lib/distutils/core.py
index f05b34b..d603d4a 100644
--- a/Lib/distutils/core.py
+++ b/Lib/distutils/core.py
@@ -204,16 +204,15 @@
global _setup_stop_after, _setup_distribution
_setup_stop_after = stop_after
- save_argv = sys.argv
+ save_argv = sys.argv.copy()
g = {'__file__': script_name}
- l = {}
try:
try:
sys.argv[0] = script_name
if script_args is not None:
sys.argv[1:] = script_args
with open(script_name, 'rb') as f:
- exec(f.read(), g, l)
+ exec(f.read(), g)
finally:
sys.argv = save_argv
_setup_stop_after = None
diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py
index ffb33ff..62a2451 100644
--- a/Lib/distutils/dist.py
+++ b/Lib/distutils/dist.py
@@ -1018,8 +1018,7 @@
"maintainer", "maintainer_email", "url",
"license", "description", "long_description",
"keywords", "platforms", "fullname", "contact",
- "contact_email", "license", "classifiers",
- "download_url",
+ "contact_email", "classifiers", "download_url",
# PEP 314
"provides", "requires", "obsoletes",
)
diff --git a/Lib/distutils/extension.py b/Lib/distutils/extension.py
index 7efbb74..c507da3 100644
--- a/Lib/distutils/extension.py
+++ b/Lib/distutils/extension.py
@@ -4,7 +4,6 @@
modules in setup scripts."""
import os
-import sys
import warnings
# This class is really only used by the "build_ext" command, so it might
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
index 573724d..f72b7f5 100644
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -70,7 +70,7 @@
leaving off the patchlevel. Sample return values could be '1.5'
or '2.2'.
"""
- return sys.version[:3]
+ return '%d.%d' % sys.version_info[:2]
def get_python_inc(plat_specific=0, prefix=None):
@@ -242,6 +242,8 @@
return os.path.join(_sys_home or project_base, "Makefile")
lib_dir = get_python_lib(plat_specific=0, standard_lib=1)
config_file = 'config-{}{}'.format(get_python_version(), build_flags)
+ if hasattr(sys.implementation, '_multiarch'):
+ config_file += '-%s' % sys.implementation._multiarch
return os.path.join(lib_dir, config_file, 'Makefile')
@@ -415,38 +417,13 @@
def _init_posix():
"""Initialize the module as appropriate for POSIX systems."""
- g = {}
- # load the installed Makefile:
- try:
- filename = get_makefile_filename()
- parse_makefile(filename, g)
- except OSError as msg:
- my_msg = "invalid Python installation: unable to open %s" % filename
- if hasattr(msg, "strerror"):
- my_msg = my_msg + " (%s)" % msg.strerror
-
- raise DistutilsPlatformError(my_msg)
-
- # load the installed pyconfig.h:
- try:
- filename = get_config_h_filename()
- with open(filename) as file:
- parse_config_h(file, g)
- except OSError as msg:
- my_msg = "invalid Python installation: unable to open %s" % filename
- if hasattr(msg, "strerror"):
- my_msg = my_msg + " (%s)" % msg.strerror
-
- raise DistutilsPlatformError(my_msg)
-
- # On AIX, there are wrong paths to the linker scripts in the Makefile
- # -- these paths are relative to the Python source, but when installed
- # the scripts are in another directory.
- if python_build:
- g['LDSHARED'] = g['BLDSHARED']
-
+ # _sysconfigdata is generated at build time, see the sysconfig module
+ name = '_sysconfigdata_' + sys.abiflags
+ _temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
+ build_time_vars = _temp.build_time_vars
global _config_vars
- _config_vars = g
+ _config_vars = {}
+ _config_vars.update(build_time_vars)
def _init_nt():
diff --git a/Lib/distutils/tests/test_bdist_rpm.py b/Lib/distutils/tests/test_bdist_rpm.py
index 25c14ab..c1a2a04 100644
--- a/Lib/distutils/tests/test_bdist_rpm.py
+++ b/Lib/distutils/tests/test_bdist_rpm.py
@@ -3,16 +3,12 @@
import unittest
import sys
import os
-import tempfile
-import shutil
from test.support import run_unittest
from distutils.core import Distribution
from distutils.command.bdist_rpm import bdist_rpm
from distutils.tests import support
from distutils.spawn import find_executable
-from distutils import spawn
-from distutils.errors import DistutilsExecError
SETUP_PY = """\
from distutils.core import setup
diff --git a/Lib/distutils/tests/test_build.py b/Lib/distutils/tests/test_build.py
index 3391f36..b020a5b 100644
--- a/Lib/distutils/tests/test_build.py
+++ b/Lib/distutils/tests/test_build.py
@@ -27,7 +27,7 @@
# build_platlib is 'build/lib.platform-x.x[-pydebug]'
# examples:
# build/lib.macosx-10.3-i386-2.7
- plat_spec = '.%s-%s' % (cmd.plat_name, sys.version[0:3])
+ plat_spec = '.%s-%d.%d' % (cmd.plat_name, *sys.version_info[:2])
if hasattr(sys, 'gettotalrefcount'):
self.assertTrue(cmd.build_platlib.endswith('-pydebug'))
plat_spec += '-pydebug'
@@ -42,7 +42,8 @@
self.assertEqual(cmd.build_temp, wanted)
# build_scripts is build/scripts-x.x
- wanted = os.path.join(cmd.build_base, 'scripts-' + sys.version[0:3])
+ wanted = os.path.join(cmd.build_base,
+ 'scripts-%d.%d' % sys.version_info[:2])
self.assertEqual(cmd.build_scripts, wanted)
# executable is os.path.normpath(sys.executable)
diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py
index 8f62b1a..55db5a8 100644
--- a/Lib/distutils/tests/test_build_ext.py
+++ b/Lib/distutils/tests/test_build_ext.py
@@ -166,7 +166,6 @@
cmd = self.build_ext(dist)
cmd.finalize_options()
- from distutils import sysconfig
py_include = sysconfig.get_python_inc()
self.assertIn(py_include, cmd.include_dirs)
diff --git a/Lib/distutils/tests/test_clean.py b/Lib/distutils/tests/test_clean.py
index b64f300..c605afd 100644
--- a/Lib/distutils/tests/test_clean.py
+++ b/Lib/distutils/tests/test_clean.py
@@ -1,8 +1,6 @@
"""Tests for distutils.command.clean."""
-import sys
import os
import unittest
-import getpass
from distutils.command.clean import clean
from distutils.tests import support
diff --git a/Lib/distutils/tests/test_config.py b/Lib/distutils/tests/test_config.py
index 3dd92d6..af21671 100644
--- a/Lib/distutils/tests/test_config.py
+++ b/Lib/distutils/tests/test_config.py
@@ -1,8 +1,6 @@
"""Tests for distutils.pypirc.pypirc."""
-import sys
import os
import unittest
-import tempfile
from distutils.core import PyPIRCCommand
from distutils.core import Distribution
diff --git a/Lib/distutils/tests/test_core.py b/Lib/distutils/tests/test_core.py
index 654227c..27ce732 100644
--- a/Lib/distutils/tests/test_core.py
+++ b/Lib/distutils/tests/test_core.py
@@ -29,6 +29,21 @@
setup()
"""
+setup_does_nothing = """\
+from distutils.core import setup
+setup()
+"""
+
+
+setup_defines_subclass = """\
+from distutils.core import setup
+from distutils.command.install import install as _install
+
+class install(_install):
+ sub_commands = _install.sub_commands + ['cmd']
+
+setup(cmdclass={'install': install})
+"""
class CoreTestCase(support.EnvironGuard, unittest.TestCase):
@@ -67,6 +82,21 @@
distutils.core.run_setup(
self.write_setup(setup_using___file__))
+ def test_run_setup_preserves_sys_argv(self):
+ # Make sure run_setup does not clobber sys.argv
+ argv_copy = sys.argv.copy()
+ distutils.core.run_setup(
+ self.write_setup(setup_does_nothing))
+ self.assertEqual(sys.argv, argv_copy)
+
+ def test_run_setup_defines_subclass(self):
+ # Make sure the script can use __file__; if that's missing, the test
+ # setup.py script will raise NameError.
+ dist = distutils.core.run_setup(
+ self.write_setup(setup_defines_subclass))
+ install = dist.get_command_obj('install')
+ self.assertIn('cmd', install.sub_commands)
+
def test_run_setup_uses_current_dir(self):
# This tests that the setup script is run with the current directory
# as its own current directory; this was temporarily broken by a
diff --git a/Lib/distutils/tests/test_cygwinccompiler.py b/Lib/distutils/tests/test_cygwinccompiler.py
index 8569216..9dc869d 100644
--- a/Lib/distutils/tests/test_cygwinccompiler.py
+++ b/Lib/distutils/tests/test_cygwinccompiler.py
@@ -3,11 +3,10 @@
import sys
import os
from io import BytesIO
-import subprocess
from test.support import run_unittest
from distutils import cygwinccompiler
-from distutils.cygwinccompiler import (CygwinCCompiler, check_config_h,
+from distutils.cygwinccompiler import (check_config_h,
CONFIG_H_OK, CONFIG_H_NOTOK,
CONFIG_H_UNCERTAIN, get_versions,
get_msvcr)
diff --git a/Lib/distutils/tests/test_dep_util.py b/Lib/distutils/tests/test_dep_util.py
index 3e1c366..c6fae39 100644
--- a/Lib/distutils/tests/test_dep_util.py
+++ b/Lib/distutils/tests/test_dep_util.py
@@ -1,7 +1,6 @@
"""Tests for distutils.dep_util."""
import unittest
import os
-import time
from distutils.dep_util import newer, newer_pairwise, newer_group
from distutils.errors import DistutilsFileError
diff --git a/Lib/distutils/tests/test_file_util.py b/Lib/distutils/tests/test_file_util.py
index a6d04f0..03040af 100644
--- a/Lib/distutils/tests/test_file_util.py
+++ b/Lib/distutils/tests/test_file_util.py
@@ -1,7 +1,6 @@
"""Tests for distutils.file_util."""
import unittest
import os
-import shutil
import errno
from unittest.mock import patch
diff --git a/Lib/distutils/tests/test_install_data.py b/Lib/distutils/tests/test_install_data.py
index 4d8c00a..32ab296 100644
--- a/Lib/distutils/tests/test_install_data.py
+++ b/Lib/distutils/tests/test_install_data.py
@@ -1,8 +1,6 @@
"""Tests for distutils.command.install_data."""
-import sys
import os
import unittest
-import getpass
from distutils.command.install_data import install_data
from distutils.tests import support
diff --git a/Lib/distutils/tests/test_install_headers.py b/Lib/distutils/tests/test_install_headers.py
index d953157..2217b32 100644
--- a/Lib/distutils/tests/test_install_headers.py
+++ b/Lib/distutils/tests/test_install_headers.py
@@ -1,8 +1,6 @@
"""Tests for distutils.command.install_headers."""
-import sys
import os
import unittest
-import getpass
from distutils.command.install_headers import install_headers
from distutils.tests import support
diff --git a/Lib/distutils/tests/test_spawn.py b/Lib/distutils/tests/test_spawn.py
index 6c7eb20..f507ef7 100644
--- a/Lib/distutils/tests/test_spawn.py
+++ b/Lib/distutils/tests/test_spawn.py
@@ -1,11 +1,10 @@
"""Tests for distutils.spawn."""
import unittest
import os
-import time
-from test.support import captured_stdout, run_unittest
+from test.support import run_unittest
from distutils.spawn import _nt_quote_args
-from distutils.spawn import spawn, find_executable
+from distutils.spawn import spawn
from distutils.errors import DistutilsExecError
from distutils.tests import support
diff --git a/Lib/distutils/tests/test_unixccompiler.py b/Lib/distutils/tests/test_unixccompiler.py
index e171ee9..efba27e 100644
--- a/Lib/distutils/tests/test_unixccompiler.py
+++ b/Lib/distutils/tests/test_unixccompiler.py
@@ -1,5 +1,4 @@
"""Tests for distutils.unixccompiler."""
-import os
import sys
import unittest
from test.support import EnvironmentVarGuard, run_unittest
diff --git a/Lib/distutils/text_file.py b/Lib/distutils/text_file.py
index 478336f..93abad3 100644
--- a/Lib/distutils/text_file.py
+++ b/Lib/distutils/text_file.py
@@ -4,7 +4,7 @@
that (optionally) takes care of stripping comments, ignoring blank
lines, and joining lines with backslashes."""
-import sys, os, io
+import sys, io
class TextFile:
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
index e423325..fdcf6fa 100644
--- a/Lib/distutils/util.py
+++ b/Lib/distutils/util.py
@@ -7,8 +7,8 @@
import os
import re
import importlib.util
-import sys
import string
+import sys
from distutils.errors import DistutilsPlatformError
from distutils.dep_util import newer
from distutils.spawn import spawn
@@ -350,6 +350,11 @@
generated in indirect mode; unless you know what you're doing, leave
it set to None.
"""
+
+ # Late import to fix a bootstrap issue: _posixsubprocess is built by
+ # setup.py, but setup.py uses distutils.
+ import subprocess
+
# nothing is done if sys.dont_write_bytecode is True
if sys.dont_write_bytecode:
raise DistutilsByteCompileError('byte-compiling is disabled.')
@@ -412,11 +417,9 @@
script.close()
- cmd = [sys.executable, script_name]
- if optimize == 1:
- cmd.insert(1, "-O")
- elif optimize == 2:
- cmd.insert(1, "-OO")
+ cmd = [sys.executable]
+ cmd.extend(subprocess._optim_args_from_interpreter_flags())
+ cmd.append(script_name)
spawn(cmd, dry_run=dry_run)
execute(os.remove, (script_name,), "removing %s" % script_name,
dry_run=dry_run)
diff --git a/Lib/doctest.py b/Lib/doctest.py
index 38fdd80..5630220 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -381,12 +381,15 @@
sys.stdout = save_stdout
# [XX] Normalize with respect to os.path.pardir?
-def _module_relative_path(module, path):
+def _module_relative_path(module, test_path):
if not inspect.ismodule(module):
raise TypeError('Expected a module: %r' % module)
- if path.startswith('/'):
+ if test_path.startswith('/'):
raise ValueError('Module-relative files may not have absolute paths')
+ # Normalize the path. On Windows, replace "/" with "\".
+ test_path = os.path.join(*(test_path.split('/')))
+
# Find the base directory for the path.
if hasattr(module, '__file__'):
# A normal module/package
@@ -398,13 +401,19 @@
else:
basedir = os.curdir
else:
+ if hasattr(module, '__path__'):
+ for directory in module.__path__:
+ fullpath = os.path.join(directory, test_path)
+ if os.path.exists(fullpath):
+ return fullpath
+
# A module w/o __file__ (this includes builtins)
raise ValueError("Can't resolve paths relative to the module "
"%r (it has no __file__)"
% module.__name__)
- # Combine the base directory and the path.
- return os.path.join(basedir, *(path.split('/')))
+ # Combine the base directory and the test path.
+ return os.path.join(basedir, test_path)
######################################################################
## 2. Example & DocTest
diff --git a/Lib/enum.py b/Lib/enum.py
index b8787d1..99db9e6 100644
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -1,8 +1,14 @@
import sys
-from collections import OrderedDict
from types import MappingProxyType, DynamicClassAttribute
-__all__ = ['Enum', 'IntEnum', 'unique']
+# try _collections first to reduce startup cost
+try:
+ from _collections import OrderedDict
+except ImportError:
+ from collections import OrderedDict
+
+
+__all__ = ['EnumMeta', 'Enum', 'IntEnum', 'unique']
def _is_descriptor(obj):
@@ -544,8 +550,14 @@
source = vars(source)
else:
source = module_globals
- members = {name: value for name, value in source.items()
- if filter(name)}
+ # We use an OrderedDict of sorted source keys so that the
+ # _value2member_map is populated in the same order every time
+ # for a consistent reverse mapping of number to name when there
+ # are multiple names for the same number rather than varying
+ # between runs due to hash randomization of the module dictionary.
+ members = OrderedDict((name, source[name])
+ for name in sorted(source.keys())
+ if filter(name))
cls = cls(name, members, module=module)
cls.__reduce_ex__ = _reduce_ex_by_name
module_globals.update(cls.__members__)
diff --git a/Lib/fileinput.py b/Lib/fileinput.py
index d2b5206..721fe9c 100644
--- a/Lib/fileinput.py
+++ b/Lib/fileinput.py
@@ -75,13 +75,11 @@
import sys, os
__all__ = ["input", "close", "nextfile", "filename", "lineno", "filelineno",
- "isfirstline", "isstdin", "FileInput"]
+ "fileno", "isfirstline", "isstdin", "FileInput", "hook_compressed",
+ "hook_encoded"]
_state = None
-# No longer used
-DEFAULT_BUFSIZE = 8*1024
-
def input(files=None, inplace=False, backup="", bufsize=0,
mode="r", openhook=None):
"""Return an instance of the FileInput class, which can be iterated.
@@ -201,6 +199,10 @@
self._files = files
self._inplace = inplace
self._backup = backup
+ if bufsize:
+ import warnings
+ warnings.warn('bufsize is deprecated and ignored',
+ DeprecationWarning, stacklevel=2)
self._savestdout = None
self._output = None
self._filename = None
@@ -398,9 +400,9 @@
return open(filename, mode)
-def hook_encoded(encoding):
+def hook_encoded(encoding, errors=None):
def openhook(filename, mode):
- return open(filename, mode, encoding=encoding)
+ return open(filename, mode, encoding=encoding, errors=errors)
return openhook
diff --git a/Lib/fractions.py b/Lib/fractions.py
index 60b0728..64d746b 100644
--- a/Lib/fractions.py
+++ b/Lib/fractions.py
@@ -125,17 +125,9 @@
self._denominator = numerator.denominator
return self
- elif isinstance(numerator, float):
- # Exact conversion from float
- value = Fraction.from_float(numerator)
- self._numerator = value._numerator
- self._denominator = value._denominator
- return self
-
- elif isinstance(numerator, Decimal):
- value = Fraction.from_decimal(numerator)
- self._numerator = value._numerator
- self._denominator = value._denominator
+ elif isinstance(numerator, (float, Decimal)):
+ # Exact conversion
+ self._numerator, self._denominator = numerator.as_integer_ratio()
return self
elif isinstance(numerator, str):
@@ -210,10 +202,6 @@
elif not isinstance(f, float):
raise TypeError("%s.from_float() only takes floats, not %r (%s)" %
(cls.__name__, f, type(f).__name__))
- if math.isnan(f):
- raise ValueError("Cannot convert %r to %s." % (f, cls.__name__))
- if math.isinf(f):
- raise OverflowError("Cannot convert %r to %s." % (f, cls.__name__))
return cls(*f.as_integer_ratio())
@classmethod
@@ -226,19 +214,7 @@
raise TypeError(
"%s.from_decimal() only takes Decimals, not %r (%s)" %
(cls.__name__, dec, type(dec).__name__))
- if dec.is_infinite():
- raise OverflowError(
- "Cannot convert %s to %s." % (dec, cls.__name__))
- if dec.is_nan():
- raise ValueError("Cannot convert %s to %s." % (dec, cls.__name__))
- sign, digits, exp = dec.as_tuple()
- digits = int(''.join(map(str, digits)))
- if sign:
- digits = -digits
- if exp >= 0:
- return cls(digits * 10 ** exp)
- else:
- return cls(digits, 10 ** -exp)
+ return cls(*dec.as_integer_ratio())
def limit_denominator(self, max_denominator=1000000):
"""Closest Fraction to self with denominator at most max_denominator.
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index c416d85..2ab1d56 100644
--- a/Lib/ftplib.py
+++ b/Lib/ftplib.py
@@ -36,13 +36,12 @@
# Modified by Giampaolo Rodola' to add TLS support.
#
-import os
import sys
import socket
-import warnings
from socket import _GLOBAL_DEFAULT_TIMEOUT
-__all__ = ["FTP"]
+__all__ = ["FTP", "error_reply", "error_temp", "error_perm", "error_proto",
+ "all_errors"]
# Magic number from <socket.h>
MSG_OOB = 0x1 # Process data out of band
diff --git a/Lib/http/client.py b/Lib/http/client.py
index 350313e..763e1ef 100644
--- a/Lib/http/client.py
+++ b/Lib/http/client.py
@@ -420,6 +420,7 @@
self.fp.flush()
def readable(self):
+ """Always returns True"""
return True
# End of "raw stream" methods
@@ -467,6 +468,10 @@
return s
def readinto(self, b):
+ """Read up to len(b) bytes into bytearray b and return the number
+ of bytes read.
+ """
+
if self.fp is None:
return 0
@@ -706,6 +711,17 @@
return self.fp.fileno()
def getheader(self, name, default=None):
+ '''Returns the value of the header matching *name*.
+
+ If there are multiple matching headers, the values are
+ combined into a single string separated by commas and spaces.
+
+ If no matching header is found, returns *default* or None if
+ the *default* is not specified.
+
+ If the headers are unknown, raises http.client.ResponseNotReady.
+
+ '''
if self.headers is None:
raise ResponseNotReady()
headers = self.headers.get_all(name) or default
@@ -728,12 +744,45 @@
# For compatibility with old-style urllib responses.
def info(self):
+ '''Returns an instance of the class mimetools.Message containing
+ meta-information associated with the URL.
+
+ When the method is HTTP, these headers are those returned by
+ the server at the head of the retrieved HTML page (including
+ Content-Length and Content-Type).
+
+ When the method is FTP, a Content-Length header will be
+ present if (as is now usual) the server passed back a file
+ length in response to the FTP retrieval request. A
+ Content-Type header will be present if the MIME type can be
+ guessed.
+
+ When the method is local-file, returned headers will include
+ a Date representing the file's last-modified time, a
+ Content-Length giving file size, and a Content-Type
+ containing a guess at the file's type. See also the
+ description of the mimetools module.
+
+ '''
return self.headers
def geturl(self):
+ '''Return the real URL of the page.
+
+ In some cases, the HTTP server redirects a client to another
+ URL. The urlopen() function handles this transparently, but in
+ some cases the caller needs to know which URL the client was
+ redirected to. The geturl() method can be used to get at this
+ redirected URL.
+
+ '''
return self.url
def getcode(self):
+ '''Return the HTTP status code that was sent with the response,
+ or None if the URL is not an HTTP URL.
+
+ '''
return self.status
class HTTPConnection:
diff --git a/Lib/http/server.py b/Lib/http/server.py
index 00620d1..e12e45b 100644
--- a/Lib/http/server.py
+++ b/Lib/http/server.py
@@ -87,6 +87,7 @@
"SimpleHTTPRequestHandler", "CGIHTTPRequestHandler",
]
+import email.utils
import html
import http.client
import io
@@ -126,9 +127,6 @@
DEFAULT_ERROR_CONTENT_TYPE = "text/html;charset=utf-8"
-def _quote_html(html):
- return html.replace("&", "&").replace("<", "<").replace(">", ">")
-
class HTTPServer(socketserver.TCPServer):
allow_reuse_address = 1 # Seems to make sense in testing environment
@@ -136,7 +134,7 @@
def server_bind(self):
"""Override server_bind to store the server name."""
socketserver.TCPServer.server_bind(self)
- host, port = self.socket.getsockname()[:2]
+ host, port = self.server_address[:2]
self.server_name = socket.getfqdn(host)
self.server_port = port
@@ -282,12 +280,9 @@
words = requestline.split()
if len(words) == 3:
command, path, version = words
- if version[:5] != 'HTTP/':
- self.send_error(
- HTTPStatus.BAD_REQUEST,
- "Bad request version (%r)" % version)
- return False
try:
+ if version[:5] != 'HTTP/':
+ raise ValueError
base_version_number = version.split('/', 1)[1]
version_number = base_version_number.split(".")
# RFC 2145 section 3.1 says there can be only one "." and
@@ -309,7 +304,7 @@
if version_number >= (2, 0):
self.send_error(
HTTPStatus.HTTP_VERSION_NOT_SUPPORTED,
- "Invalid HTTP Version (%s)" % base_version_number)
+ "Invalid HTTP version (%s)" % base_version_number)
return False
elif len(words) == 2:
command, path = words
@@ -332,10 +327,11 @@
try:
self.headers = http.client.parse_headers(self.rfile,
_class=self.MessageClass)
- except http.client.LineTooLong:
+ except http.client.LineTooLong as err:
self.send_error(
- HTTPStatus.BAD_REQUEST,
- "Line too long")
+ HTTPStatus.REQUEST_HEADER_FIELDS_TOO_LARGE,
+ "Line too long",
+ str(err))
return False
except http.client.HTTPException as err:
self.send_error(
@@ -465,8 +461,8 @@
# (see bug #1100201)
content = (self.error_message_format % {
'code': code,
- 'message': _quote_html(message),
- 'explain': _quote_html(explain)
+ 'message': html.escape(message, quote=False),
+ 'explain': html.escape(explain, quote=False)
})
body = content.encode('UTF-8', 'replace')
self.send_header("Content-Type", self.error_content_type)
@@ -491,12 +487,12 @@
def send_response_only(self, code, message=None):
"""Send the response header only."""
- if message is None:
- if code in self.responses:
- message = self.responses[code][0]
- else:
- message = ''
if self.request_version != 'HTTP/0.9':
+ if message is None:
+ if code in self.responses:
+ message = self.responses[code][0]
+ else:
+ message = ''
if not hasattr(self, '_headers_buffer'):
self._headers_buffer = []
self._headers_buffer.append(("%s %d %s\r\n" %
@@ -583,12 +579,7 @@
"""Return the current date and time formatted for a message header."""
if timestamp is None:
timestamp = time.time()
- year, month, day, hh, mm, ss, wd, y, z = time.gmtime(timestamp)
- s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (
- self.weekdayname[wd],
- day, self.monthname[month], year,
- hh, mm, ss)
- return s
+ return email.utils.formatdate(timestamp, usegmt=True)
def log_date_time_string(self):
"""Return the current time formatted for logging."""
@@ -726,7 +717,7 @@
errors='surrogatepass')
except UnicodeDecodeError:
displaypath = urllib.parse.unquote(path)
- displaypath = html.escape(displaypath)
+ displaypath = html.escape(displaypath, quote=False)
enc = sys.getfilesystemencoding()
title = 'Directory listing for %s' % displaypath
r.append('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" '
@@ -750,7 +741,7 @@
r.append('<li><a href="%s">%s</a></li>'
% (urllib.parse.quote(linkname,
errors='surrogatepass'),
- html.escape(displayname)))
+ html.escape(displayname, quote=False)))
r.append('</ul>\n<hr>\n</body>\n</html>\n')
encoded = '\n'.join(r).encode(enc, 'surrogateescape')
f = io.BytesIO()
@@ -1191,16 +1182,15 @@
server_address = (bind, port)
HandlerClass.protocol_version = protocol
- httpd = ServerClass(server_address, HandlerClass)
-
- sa = httpd.socket.getsockname()
- print("Serving HTTP on", sa[0], "port", sa[1], "...")
- try:
- httpd.serve_forever()
- except KeyboardInterrupt:
- print("\nKeyboard interrupt received, exiting.")
- httpd.server_close()
- sys.exit(0)
+ with ServerClass(server_address, HandlerClass) as httpd:
+ sa = httpd.socket.getsockname()
+ serve_message = "Serving HTTP on {host} port {port} (http://{host}:{port}/) ..."
+ print(serve_message.format(host=sa[0], port=sa[1]))
+ try:
+ httpd.serve_forever()
+ except KeyboardInterrupt:
+ print("\nKeyboard interrupt received, exiting.")
+ sys.exit(0)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt
index 6ef2aa5..4a69249 100644
--- a/Lib/idlelib/NEWS.txt
+++ b/Lib/idlelib/NEWS.txt
@@ -1,6 +1,8 @@
-What's New in IDLE 3.5.3?
-=========================
-*Release date: 2017-01-01?*
+What's New in IDLE 3.6.0?
+===========================
+*Release date: 2016-09-??*
+
+- Issue #27372: Test_idle no longer changes the locale.
- Issue #27365: Allow non-ascii chars in IDLE NEWS.txt, for contributor names.
@@ -8,19 +10,31 @@
Previously, when IDLE was started from a console or by import, a cascade
of warnings was emitted. Patch by Serhiy Storchaka.
+- Issue #24137: Run IDLE, test_idle, and htest with tkinter default root disabled.
+ Fix code and tests that fail with this restriction.
+ Fix htests to not create a second and redundant root and mainloop.
-What's New in IDLE 3.5.2?
-=========================
-*Release date: 2016-06-26*
+- Issue #27310: Fix IDLE.app failure to launch on OS X due to vestigial import.
- Issue #5124: Paste with text selected now replaces the selection on X11.
This matches how paste works on Windows, Mac, most modern Linux apps,
and ttk widgets. Original patch by Serhiy Storchaka.
+- Issue #24750: Switch all scrollbars in IDLE to ttk versions.
+ Where needed, minimal tests are added to cover changes.
+
+- Issue #24759: IDLE requires tk 8.5 and availability ttk widgets.
+ Delete now unneeded tk version tests and code for older versions.
+ Add test for IDLE syntax colorizer.
+
+- Issue #27239: idlelib.macosx.isXyzTk functions initialize as needed.
+
+- Issue #27262: move Aqua unbinding code, which enable context menus, to maxosx.
+
- Issue #24759: Make clear in idlelib.idle_test.__init__ that the directory
is a private implementation of test.test_idle and tool for maintainers.
-- Issue #27196: Stop 'ThemeChangef' warnings when running IDLE tests.
+- Issue #27196: Stop 'ThemeChanged' warnings when running IDLE tests.
These persisted after other warnings were suppressed in #20567.
Apply Serhiy Storchaka's update_idletasks solution to four test files.
Record this additional advice in idle_test/README.txt
@@ -28,9 +42,26 @@
- Issue #20567: Revise idle_test/README.txt with advice about avoiding
tk warning messages from tests. Apply advice to several IDLE tests.
+- Issue # 24225: Update idlelib/README.txt with new file names
+ and event handlers.
+
+- Issue #27156: Remove obsolete code not used by IDLE. Replacements:
+ 1. help.txt, replaced by help.html, is out-of-date and should not be used.
+ Its dedicated viewer has be replaced by the html viewer in help.py.
+ 2. 'import idlever; I = idlever.IDLE_VERSION' is the same as
+ 'import sys; I = version[:version.index(' ')]'
+ 3. After 'ob = stackviewer.VariablesTreeItem(*args)',
+ 'ob.keys()' == 'list(ob.object.keys).
+ 4. In macosc, runningAsOSXAPP == isAquaTk; idCarbonAquaTk == isCarbonTk
+
- Issue #27117: Make colorizer htest and turtledemo work with dark themes.
Move code for configuring text widget colors to a new function.
+- Issue #24225: Rename many idlelib/*.py and idle_test/test_*.py files.
+ Edit files to replace old names with new names when the old name
+ referred to the module rather than the class it contained.
+ See the issue and IDLE section in What's New in 3.6 for more.
+
- Issue #26673: When tk reports font size as 0, change to size 10.
Such fonts on Linux prevented the configuration dialog from opening.
@@ -43,8 +74,8 @@
- Issue #18410: Add test for IDLE's search dialog.
Original patch by Westley Martínez.
-- Issue #21703: Add test for undo delegator.
- Original patch by Saimadhav Heblikar .
+- Issue #21703: Add test for undo delegator. Patch mostly by
+ Saimadhav Heblikar .
- Issue #27044: Add ConfigDialog.remove_var_callbacks to stop memory leaks.
@@ -63,11 +94,6 @@
MARK in README.txt and open this and NEWS.txt with 'ascii'.
Re-encode CREDITS.txt to utf-8 and open it with 'utf-8'.
-
-What's New in IDLE 3.5.1?
-=========================
-*Release date: 2015-12-06*
-
- Issue 15348: Stop the debugger engine (normally in a user process)
before closing the debugger window (running in the IDLE process).
This prevents the RuntimeErrors that were being caught and ignored.
@@ -345,6 +371,11 @@
- Use of 'filter' in keybindingDialog.py was causing custom key assignment to
fail. Patch 5707 amaury.forgeotdarc.
+
+What's New in IDLE 3.1a1?
+=========================
+*Release date: 07-Mar-09*
+
- Issue #4815: Offer conversion to UTF-8 if source files have
no encoding declaration and are not encoded in UTF-8.
@@ -384,6 +415,11 @@
- Issue #3549: On MacOS the preferences menu was not present
+
+What's New in IDLE 3.0?
+=======================
+*Release date: 03-Dec-2008*
+
- IDLE would print a "Unhandled server exception!" message when internal
debugging is enabled.
diff --git a/Lib/idlelib/README.txt b/Lib/idlelib/README.txt
index 7bf74c0..e1d682e 100644
--- a/Lib/idlelib/README.txt
+++ b/Lib/idlelib/README.txt
@@ -29,61 +29,61 @@
Implementation
--------------
-AutoComplete.py # Complete attribute names or filenames.
-AutoCompleteWindow.py # Display completions.
-AutoExpand.py # Expand word with previous word in file.
-Bindings.py # Define most of IDLE menu.
-CallTipWindow.py # Display calltip.
-CallTips.py # Create calltip text.
-ClassBrowser.py # Create module browser window.
-CodeContext.py # Show compound statement headers otherwise not visible.
-ColorDelegator.py # Colorize text (nim).
-Debugger.py # Debug code run from editor; show window.
-Delegator.py # Define base class for delegators (nim).
-EditorWindow.py # Define most of editor and utility functions.
-FileList.py # Open files and manage list of open windows (nim).
-FormatParagraph.py# Re-wrap multiline strings and comments.
-GrepDialog.py # Find all occurrences of pattern in multiple files.
-HyperParser.py # Parse code around a given index.
-IOBinding.py # Open, read, and write files
-IdleHistory.py # Get previous or next user input in shell (nim)
-MultiCall.py # Wrap tk widget to allow multiple calls per event (nim).
-MultiStatusBar.py # Define status bar for windows (nim).
-ObjectBrowser.py # Define class used in StackViewer (nim).
-OutputWindow.py # Create window for grep output.
-ParenMatch.py # Match fenceposts: (), [], and {}.
-PathBrowser.py # Create path browser window.
-Percolator.py # Manage delegator stack (nim).
-PyParse.py # Give information on code indentation
-PyShell.py # Start IDLE, manage shell, complete editor window
-RemoteDebugger.py # Debug code run in remote process.
-RemoteObjectBrowser.py # Communicate objects between processes with rpc (nim).
-ReplaceDialog.py # Search and replace pattern in text.
-RstripExtension.py# Strip trailing whitespace
-ScriptBinding.py # Check and run user code.
-ScrolledList.py # Define ScrolledList widget for IDLE (nim).
-SearchDialog.py # Search for pattern in text.
-SearchDialogBase.py # Define base for search, replace, and grep dialogs.
-SearchEngine.py # Define engine for all 3 search dialogs.
-StackViewer.py # View stack after exception.
-TreeWidget.py # Define tree widger, used in browsers (nim).
-UndoDelegator.py # Manage undo stack.
-WidgetRedirector.py # Intercept widget subcommands (for percolator) (nim).
-WindowList.py # Manage window list and define listed top level.
-ZoomHeight.py # Zoom window to full height of screen.
-aboutDialog.py # Display About IDLE dialog.
-configDialog.py # Display user configuration dialogs.
-configHandler.py # Load, fetch, and save configuration (nim).
-configHelpSourceEdit.py # Specify help source.
-configSectionNameDialog.py # Spefify user config section name
-dynOptionMenuWidget.py # define mutable OptionMenu widget (nim).
+autocomplete.py # Complete attribute names or filenames.
+autocomplete_w.py # Display completions.
+autoexpand.py # Expand word with previous word in file.
+browser.py # Create module browser window.
+calltip_w.py # Display calltip.
+calltips.py # Create calltip text.
+codecontext.py # Show compound statement headers otherwise not visible.
+colorizer.py # Colorize text (nim)
+config.py # Load, fetch, and save configuration (nim).
+configdialog.py # Display user configuration dialogs.
+config_help.py # Specify help source in configdialog.
+config_key.py # Change keybindings.
+config_sec.py # Spefify user config section name
+dynoption.py # Define mutable OptionMenu widget (nim).
+debugobj.py # Define class used in stackviewer.
+debugobj_r.py # Communicate objects between processes with rpc (nim).
+debugger.py # Debug code run from shell or editor; show window.
+debugger_r.py # Debug code run in remote process.
+delegator.py # Define base class for delegators (nim).
+editor.py # Define most of editor and utility functions.
+filelist.py # Open files and manage list of open windows (nim).
+grep.py # Find all occurrences of pattern in multiple files.
help.py # Display IDLE's html doc.
-keybindingDialog.py # Change keybindings.
-macosxSupport.py # Help IDLE run on Macs (nim).
+help_about.py # Display About IDLE dialog.
+history.py # Get previous or next user input in shell (nim)
+hyperparser.py # Parse code around a given index.
+iomenu.py # Open, read, and write files
+macosx.py # Help IDLE run on Macs (nim).
+mainmenu.py # Define most of IDLE menu.
+multicall.py # Wrap tk widget to allow multiple calls per event (nim).
+outwin.py # Create window for grep output.
+paragraph.py # Re-wrap multiline strings and comments.
+parenmatch.py # Match fenceposts: (), [], and {}.
+pathbrowser.py # Create path browser window.
+percolator.py # Manage delegator stack (nim).
+pyparse.py # Give information on code indentation
+pyshell.py # Start IDLE, manage shell, complete editor window
+redirector.py # Intercept widget subcommands (for percolator) (nim).
+replace.py # Search and replace pattern in text.
rpc.py # Commuicate between idle and user processes (nim).
+rstrip.py # Strip trailing whitespace.
run.py # Manage user code execution subprocess.
+runscript.py # Check and run user code.
+scrolledlist.py # Define scrolledlist widget for IDLE (nim).
+search.py # Search for pattern in text.
+searchbase.py # Define base for search, replace, and grep dialogs.
+searchengine.py # Define engine for all 3 search dialogs.
+stackviewer.py # View stack after exception.
+statusbar.py # Define status bar for windows (nim).
tabbedpages.py # Define tabbed pages widget (nim).
-textView.py # Define read-only text widget (nim).
+textview.py # Define read-only text widget (nim).
+tree.py # Define tree widger, used in browsers (nim).
+undo.py # Manage undo stack.
+windows.py # Manage window list and define listed top level.
+zoomheight.py # Zoom window to full height of screen.
Configuration
-------------
@@ -104,126 +104,128 @@
Subdirectories
--------------
-Icons # small image files
-idle_test # files for human test and automated unit tests
+Icons # small image files
+idle_test # files for human test and automated unit tests
Unused and Deprecated files and objects (nim)
---------------------------------------------
-EditorWindow.py: Helpdialog and helpDialog
-ToolTip.py: unused.
-help.txt
-idlever.py
+tooltip.py # unused
+
IDLE MENUS
-Top level items and most submenu items are defined in Bindings.
+Top level items and most submenu items are defined in mainmenu.
Extenstions add submenu items when active. The names given are
found, quoted, in one of these modules, paired with a '<<pseudoevent>>'.
Each pseudoevent is bound to an event handler. Some event handlers
call another function that does the actual work. The annotations below
are intended to at least give the module where the actual work is done.
+'eEW' = editor.EditorWindow
-File # IOBindig except as noted
- New File
- Open... # IOBinding.open
- Open Module
+File
+ New File # eEW.new_callback
+ Open... # iomenu.open
+ Open Module # eEw.open_module
Recent Files
- Class Browser # Class Browser
- Path Browser # Path Browser
+ Class Browser # eEW.open_class_browser, browser.ClassBrowser
+ Path Browser # eEW.open_path_browser, pathbrowser
---
- Save # IDBinding.save
- Save As... # IOBinding.save_as
- Save Copy As... # IOBindling.save_a_copy
+ Save # iomenu.save
+ Save As... # iomenu.save_as
+ Save Copy As... # iomenu.save_a_copy
---
- Print Window # IOBinding.print_window
+ Print Window # iomenu.print_window
---
- Close
- Exit
+ Close # eEW.close_event
+ Exit # flist.close_all_callback (bound in eEW)
Edit
- Undo # undoDelegator
- Redo # undoDelegator
- ---
- Cut
- Copy
- Paste
- Select All
- --- # Next 5 items use SearchEngine; dialogs use SearchDialogBase
- Find # Search Dialog
- Find Again
- Find Selection
- Find in Files... # GrepDialog
- Replace... # ReplaceDialog
- Go to Line
- Show Completions # AutoComplete extension and AutoCompleteWidow (&HP)
- Expand Word # AutoExpand extension
- Show call tip # Calltips extension and CalltipWindow (& Hyperparser)
- Show surrounding parens # ParenMatch (& Hyperparser)
+ Undo # undodelegator
+ Redo # undodelegator
+ --- # eEW.right_menu_event
+ Cut # eEW.cut
+ Copy # eEW.copy
+ Paste # eEW.past
+ Select All # eEW.select_all (+ see eEW.remove_selection)
+ --- # Next 5 items use searchengine; dialogs use searchbase
+ Find # eEW.find_event, search.SearchDialog.find
+ Find Again # eEW.find_again_event, sSD.find_again
+ Find Selection # eEW.find_selection_event, sSD.find_selection
+ Find in Files... # eEW.find_in_files_event, grep
+ Replace... # eEW.replace_event, replace.ReplaceDialog.replace
+ Go to Line # eEW.goto_line_event
+ Show Completions # autocomplete extension and autocompleteWidow (&HP)
+ Expand Word # autoexpand extension
+ Show call tip # Calltips extension and CalltipWindow (& Hyperparser)
+ Show surrounding parens # parenmatch (& Hyperparser)
-Shell # PyShell
- View Last Restart # PyShell.?
- Restart Shell # PyShell.?
+Shell # pyshell
+ View Last Restart# pyshell.?
+ Restart Shell # pyshell.?
Debug (Shell only)
Go to File/Line
- Debugger # Debugger, RemoteDebugger
- Stack Viewer # StackViewer
- Auto-open Stack Viewer # StackViewer
+ debugger # debugger, debugger_r
+ Stack Viewer # stackviewer
+ Auto-open Stack Viewer # stackviewer
Format (Editor only)
- Indent Region
- Dedent Region
- Comment Out Region
- Uncomment Region
- Tabify Region
- Untabify Region
- Toggle Tabs
- New Indent Width
- Format Paragraph # FormatParagraph extension
+ Indent Region # eEW.indent_region_event
+ Dedent Region # eEW.dedent_region_event
+ Comment Out Reg. # eEW.comment_region_event
+ Uncomment Region # eEW.uncomment_region_event
+ Tabify Region # eEW.tabify_region_event
+ Untabify Region # eEW.untabify_region_event
+ Toggle Tabs # eEW.toggle_tabs_event
+ New Indent Width # eEW.change_indentwidth_event
+ Format Paragraph # paragraph extension
---
- Strip tailing whitespace # RstripExtension extension
+ Strip tailing whitespace # rstrip extension
Run (Editor only)
- Python Shell # PyShell
+ Python Shell # pyshell
---
- Check Module # ScriptBinding
- Run Module # ScriptBinding
+ Check Module # runscript
+ Run Module # runscript
Options
- Configure IDLE # configDialog
+ Configure IDLE # eEW.config_dialog, configdialog
(tabs in the dialog)
- Font tab # onfig-main.def
- Highlight tab # configSectionNameDialog, config-highlight.def
- Keys tab # keybindingDialog, configSectionNameDialog, onfig-keus.def
- General tab # configHelpSourceEdit, config-main.def
- Configure Extensions # configDialog
- Xyz tab # xyz.py, config-extensions.def
+ Font tab # config-main.def
+ Highlight tab # config_sec, config-highlight.def
+ Keys tab # config_key, configconfig_secg-keus.def
+ General tab # config_help, config-main.def
+ Extensions tab # config-extensions.def, corresponding .py
---
- Code Context (editor only) # CodeContext extension
+ Code Context (ed)# codecontext extension
Window
- Zoomheight # ZoomHeight extension
+ Zoomheight # zoomheight extension
---
- <open windows> # WindowList
+ <open windows> # windows
Help
- About IDLE # aboutDialog
+ About IDLE # eEW.about_dialog, help_about.AboutDialog
---
- IDLE Help # help
- Python Doc
- Turtle Demo
+ IDLE Help # eEW.help_dialog, helpshow_idlehelp
+ Python Doc # eEW.python_docs
+ Turtle Demo # eEW.open_turtle_demo
---
<other help sources>
<Context Menu> (right click)
-Defined in EditorWindow, PyShell, Output
- Cut
- Copy
- Paste
- ---
- Go to file/line (shell and output only)
- Set Breakpoint (editor only)
- Clear Breakpoint (editor only)
- Defined in Debugger
- Go to source line
- Show stack frame
+ Defined in editor, PyShelpyshellut
+ Cut
+ Copy
+ Paste
+ ---
+ Go to file/line (shell and output only)
+ Set Breakpoint (editor only)
+ Clear Breakpoint (editor only)
+ Defined in debugger
+ Go to source line
+ Show stack frame
+
+<No menu>
+Center Insert # eEW.center_insert_event
+
diff --git a/Lib/idlelib/__init__.py b/Lib/idlelib/__init__.py
index 711f61b..791ddea 100644
--- a/Lib/idlelib/__init__.py
+++ b/Lib/idlelib/__init__.py
@@ -1,8 +1,10 @@
"""The idlelib package implements the Idle application.
Idle includes an interactive shell and editor.
+Starting with Python 3.6, IDLE requires tcl/tk 8.5 or later.
Use the files named idle.* to start Idle.
The other files are private implementations. Their details are subject to
change. See PEP 434 for more. Import them at your own risk.
"""
+testing = False # Set True by test.test_idle.
diff --git a/Lib/idlelib/__main__.py b/Lib/idlelib/__main__.py
index 2edf5f7..6349ec7 100644
--- a/Lib/idlelib/__main__.py
+++ b/Lib/idlelib/__main__.py
@@ -3,6 +3,6 @@
Run IDLE as python -m idlelib
"""
-import idlelib.PyShell
-idlelib.PyShell.main()
+import idlelib.pyshell
+idlelib.pyshell.main()
# This file does not work for 2.7; See issue 24212.
diff --git a/Lib/idlelib/AutoComplete.py b/Lib/idlelib/autocomplete.py
similarity index 97%
rename from Lib/idlelib/AutoComplete.py
rename to Lib/idlelib/autocomplete.py
index ff085d5..5ba8dc5 100644
--- a/Lib/idlelib/AutoComplete.py
+++ b/Lib/idlelib/autocomplete.py
@@ -1,4 +1,4 @@
-"""AutoComplete.py - An IDLE extension for automatically completing names.
+"""autocomplete.py - An IDLE extension for automatically completing names.
This extension can complete either attribute names or file names. It can pop
a window with all available names, for the user to select from.
@@ -7,7 +7,7 @@
import sys
import string
-from idlelib.configHandler import idleConf
+from idlelib.config import idleConf
# This string includes all chars that may be in an identifier
ID_CHARS = string.ascii_letters + string.digits + "_"
@@ -15,8 +15,8 @@
# These constants represent the two different types of completions
COMPLETE_ATTRIBUTES, COMPLETE_FILES = range(1, 2+1)
-from idlelib import AutoCompleteWindow
-from idlelib.HyperParser import HyperParser
+from idlelib import autocomplete_w
+from idlelib.hyperparser import HyperParser
import __main__
@@ -49,7 +49,7 @@
self._delayed_completion_index = None
def _make_autocomplete_window(self):
- return AutoCompleteWindow.AutoCompleteWindow(self.text)
+ return autocomplete_w.AutoCompleteWindow(self.text)
def _remove_autocomplete_window(self, event=None):
if self.autocompletewindow:
diff --git a/Lib/idlelib/AutoCompleteWindow.py b/Lib/idlelib/autocomplete_w.py
similarity index 97%
rename from Lib/idlelib/AutoCompleteWindow.py
rename to Lib/idlelib/autocomplete_w.py
index 2ee6878..38f8601 100644
--- a/Lib/idlelib/AutoCompleteWindow.py
+++ b/Lib/idlelib/autocomplete_w.py
@@ -1,9 +1,10 @@
"""
-An auto-completion window for IDLE, used by the AutoComplete extension
+An auto-completion window for IDLE, used by the autocomplete extension
"""
from tkinter import *
-from idlelib.MultiCall import MC_SHIFT
-from idlelib.AutoComplete import COMPLETE_FILES, COMPLETE_ATTRIBUTES
+from tkinter.ttk import Scrollbar
+from idlelib.multicall import MC_SHIFT
+from idlelib.autocomplete import COMPLETE_FILES, COMPLETE_ATTRIBUTES
HIDE_VIRTUAL_EVENT_NAME = "<<autocompletewindow-hide>>"
HIDE_SEQUENCES = ("<FocusOut>", "<ButtonPress>")
@@ -34,8 +35,8 @@
self.completions = None
# A list with more completions, or None
self.morecompletions = None
- # The completion mode. Either AutoComplete.COMPLETE_ATTRIBUTES or
- # AutoComplete.COMPLETE_FILES
+ # The completion mode. Either autocomplete.COMPLETE_ATTRIBUTES or
+ # autocomplete.COMPLETE_FILES
self.mode = None
# The current completion start, on the text box (a string)
self.start = None
diff --git a/Lib/idlelib/AutoExpand.py b/Lib/idlelib/autoexpand.py
similarity index 100%
rename from Lib/idlelib/AutoExpand.py
rename to Lib/idlelib/autoexpand.py
diff --git a/Lib/idlelib/ClassBrowser.py b/Lib/idlelib/browser.py
similarity index 94%
rename from Lib/idlelib/ClassBrowser.py
rename to Lib/idlelib/browser.py
index d09c52f..9968333 100644
--- a/Lib/idlelib/ClassBrowser.py
+++ b/Lib/idlelib/browser.py
@@ -14,13 +14,13 @@
import sys
import pyclbr
-from idlelib import PyShell
-from idlelib.WindowList import ListedToplevel
-from idlelib.TreeWidget import TreeNode, TreeItem, ScrolledCanvas
-from idlelib.configHandler import idleConf
+from idlelib import pyshell
+from idlelib.windows import ListedToplevel
+from idlelib.tree import TreeNode, TreeItem, ScrolledCanvas
+from idlelib.config import idleConf
file_open = None # Method...Item and Class...Item use this.
-# Normally PyShell.flist.open, but there is no PyShell.flist for htest.
+# Normally pyshell.flist.open, but there is no pyshell.flist for htest.
class ClassBrowser:
@@ -32,7 +32,7 @@
"""
global file_open
if not _htest:
- file_open = PyShell.flist.open
+ file_open = pyshell.flist.open
self.name = name
self.file = os.path.join(path[0], self.name + ".py")
self._htest = _htest
@@ -95,7 +95,7 @@
return
if not os.path.exists(self.file):
return
- PyShell.flist.open(self.file)
+ pyshell.flist.open(self.file)
def IsExpandable(self):
return os.path.normcase(self.file[-3:]) == ".py"
@@ -226,7 +226,7 @@
file = sys.argv[0]
dir, file = os.path.split(file)
name = os.path.splitext(file)[0]
- flist = PyShell.PyShellFileList(parent)
+ flist = pyshell.PyShellFileList(parent)
global file_open
file_open = flist.open
ClassBrowser(flist, name, [dir], _htest=True)
diff --git a/Lib/idlelib/CallTipWindow.py b/Lib/idlelib/calltip_w.py
similarity index 98%
rename from Lib/idlelib/CallTipWindow.py
rename to Lib/idlelib/calltip_w.py
index 8e68a76..9f6cdc1 100644
--- a/Lib/idlelib/CallTipWindow.py
+++ b/Lib/idlelib/calltip_w.py
@@ -1,7 +1,7 @@
"""A CallTip window class for Tkinter/IDLE.
-After ToolTip.py, which uses ideas gleaned from PySol
-Used by the CallTips IDLE extension.
+After tooltip.py, which uses ideas gleaned from PySol
+Used by the calltips IDLE extension.
"""
from tkinter import Toplevel, Label, LEFT, SOLID, TclError
diff --git a/Lib/idlelib/CallTips.py b/Lib/idlelib/calltips.py
similarity index 96%
rename from Lib/idlelib/CallTips.py
rename to Lib/idlelib/calltips.py
index 81bd5f1..3a9b1c6 100644
--- a/Lib/idlelib/CallTips.py
+++ b/Lib/idlelib/calltips.py
@@ -1,4 +1,4 @@
-"""CallTips.py - An IDLE Extension to Jog Your Memory
+"""calltips.py - An IDLE Extension to Jog Your Memory
Call Tips are floating windows which display function, class, and method
parameter and docstring information when you type an opening parenthesis, and
@@ -12,8 +12,8 @@
import textwrap
import types
-from idlelib import CallTipWindow
-from idlelib.HyperParser import HyperParser
+from idlelib import calltip_w
+from idlelib.hyperparser import HyperParser
class CallTips:
@@ -37,7 +37,7 @@
def _make_tk_calltip_window(self):
# See __init__ for usage
- return CallTipWindow.CallTip(self.text)
+ return calltip_w.CallTip(self.text)
def _remove_calltip_window(self, event=None):
if self.active_calltip:
diff --git a/Lib/idlelib/CodeContext.py b/Lib/idlelib/codecontext.py
similarity index 97%
rename from Lib/idlelib/CodeContext.py
rename to Lib/idlelib/codecontext.py
index 7d25ada..2a21a1f 100644
--- a/Lib/idlelib/CodeContext.py
+++ b/Lib/idlelib/codecontext.py
@@ -1,11 +1,11 @@
-"""CodeContext - Extension to display the block context above the edit window
+"""codecontext - Extension to display the block context above the edit window
Once code has scrolled off the top of a window, it can be difficult to
determine which block you are in. This extension implements a pane at the top
of each IDLE edit window which provides block structure hints. These hints are
the lines which contain the block opening keywords, e.g. 'if', for the
enclosing block. The number of hint lines is determined by the numlines
-variable in the CodeContext section of config-extensions.def. Lines which do
+variable in the codecontext section of config-extensions.def. Lines which do
not open blocks are not shown in the context hints pane.
"""
@@ -13,7 +13,7 @@
from tkinter.constants import TOP, LEFT, X, W, SUNKEN
import re
from sys import maxsize as INFINITY
-from idlelib.configHandler import idleConf
+from idlelib.config import idleConf
BLOCKOPENERS = {"class", "def", "elif", "else", "except", "finally", "for",
"if", "try", "while", "with"}
diff --git a/Lib/idlelib/ColorDelegator.py b/Lib/idlelib/colorizer.py
similarity index 96%
rename from Lib/idlelib/ColorDelegator.py
rename to Lib/idlelib/colorizer.py
index 02eac47..5b6dc67 100644
--- a/Lib/idlelib/ColorDelegator.py
+++ b/Lib/idlelib/colorizer.py
@@ -2,9 +2,8 @@
import re
import keyword
import builtins
-from tkinter import TkVersion
-from idlelib.Delegator import Delegator
-from idlelib.configHandler import idleConf
+from idlelib.delegator import Delegator
+from idlelib.config import idleConf
DEBUG = False
@@ -49,11 +48,8 @@
insertbackground=cursor_color,
selectforeground=select_colors['foreground'],
selectbackground=select_colors['background'],
- )
- if TkVersion >= 8.5:
- text.config(
- inactiveselectbackground=select_colors['background'])
-
+ inactiveselectbackground=select_colors['background'], # new in 8.5
+ )
class ColorDelegator(Delegator):
@@ -259,7 +255,7 @@
def _color_delegator(parent): # htest #
from tkinter import Toplevel, Text
- from idlelib.Percolator import Percolator
+ from idlelib.percolator import Percolator
top = Toplevel(parent)
top.title("Test ColorDelegator")
@@ -277,5 +273,8 @@
p.insertfilter(d)
if __name__ == "__main__":
+ import unittest
+ unittest.main('idlelib.idle_test.test_colorizer',
+ verbosity=2, exit=False)
from idlelib.idle_test.htest import run
run(_color_delegator)
diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/config.py
similarity index 96%
rename from Lib/idlelib/configHandler.py
rename to Lib/idlelib/config.py
index 8ac1f60..4d87de0 100644
--- a/Lib/idlelib/configHandler.py
+++ b/Lib/idlelib/config.py
@@ -7,7 +7,7 @@
and if a file becomes empty, it will be deleted.
The contents of the user files may be altered using the Options/Configure IDLE
-menu to access the configuration GUI (configDialog.py), or manually.
+menu to access the configuration GUI (configdialog.py), or manually.
Throughout this module there is an emphasis on returning useable defaults
when a problem occurs in returning a requested configuration value back to
@@ -22,7 +22,6 @@
import sys
from configparser import ConfigParser
-from tkinter import TkVersion
from tkinter.font import Font, nametofont
class InvalidConfigType(Exception): pass
@@ -230,7 +229,7 @@
return self.userCfg[configType].Get(section, option,
type=type, raw=raw)
except ValueError:
- warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n'
+ warning = ('\n Warning: config.py - IdleConf.GetOption -\n'
' invalid %r value for configuration option %r\n'
' from section %r: %r' %
(type, option, section,
@@ -247,7 +246,7 @@
pass
#returning default, print warning
if warn_on_default:
- warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n'
+ warning = ('\n Warning: config.py - IdleConf.GetOption -\n'
' problem retrieving configuration option %r\n'
' from section %r.\n'
' returning default value: %r' %
@@ -358,7 +357,7 @@
for element in theme:
if not cfgParser.has_option(themeName, element):
# Print warning that will return a default color
- warning = ('\n Warning: configHandler.IdleConf.GetThemeDict'
+ warning = ('\n Warning: config.IdleConf.GetThemeDict'
' -\n problem retrieving theme element %r'
'\n from theme %r.\n'
' returning default color: %r' %
@@ -644,7 +643,7 @@
if binding:
keyBindings[event] = binding
else: #we are going to return a default, print warning
- warning=('\n Warning: configHandler.py - IdleConf.GetCoreKeys'
+ warning=('\n Warning: config.py - IdleConf.GetCoreKeys'
' -\n problem retrieving key binding for event %r'
'\n from key set %r.\n'
' returning default value: %r' %
@@ -713,16 +712,13 @@
bold = self.GetOption(configType, section, 'font-bold', default=0,
type='bool')
if (family == 'TkFixedFont'):
- if TkVersion < 8.5:
- family = 'Courier'
- else:
- f = Font(name='TkFixedFont', exists=True, root=root)
- actualFont = Font.actual(f)
- family = actualFont['family']
- size = actualFont['size']
- if size <= 0:
- size = 10 # if font in pixels, ignore actual size
- bold = actualFont['weight']=='bold'
+ f = Font(name='TkFixedFont', exists=True, root=root)
+ actualFont = Font.actual(f)
+ family = actualFont['family']
+ size = actualFont['size']
+ if size <= 0:
+ size = 10 # if font in pixels, ignore actual size
+ bold = actualFont['weight'] == 'bold'
return (family, size, 'bold' if bold else 'normal')
def LoadCfgFiles(self):
@@ -740,7 +736,7 @@
idleConf = IdleConf()
# TODO Revise test output, write expanded unittest
-### module test
+#
if __name__ == '__main__':
def dumpCfg(cfg):
print('\n', cfg, '\n')
diff --git a/Lib/idlelib/configSectionNameDialog.py b/Lib/idlelib/configSectionNameDialog.py
deleted file mode 100644
index 5137836..0000000
--- a/Lib/idlelib/configSectionNameDialog.py
+++ /dev/null
@@ -1,98 +0,0 @@
-"""
-Dialog that allows user to specify a new config file section name.
-Used to get new highlight theme and keybinding set names.
-The 'return value' for the dialog, used two placed in configDialog.py,
-is the .result attribute set in the Ok and Cancel methods.
-"""
-from tkinter import *
-import tkinter.messagebox as tkMessageBox
-
-class GetCfgSectionNameDialog(Toplevel):
- def __init__(self, parent, title, message, used_names, _htest=False):
- """
- message - string, informational message to display
- used_names - string collection, names already in use for validity check
- _htest - bool, change box location when running htest
- """
- Toplevel.__init__(self, parent)
- self.configure(borderwidth=5)
- self.resizable(height=FALSE, width=FALSE)
- self.title(title)
- self.transient(parent)
- self.grab_set()
- self.protocol("WM_DELETE_WINDOW", self.Cancel)
- self.parent = parent
- self.message = message
- self.used_names = used_names
- self.create_widgets()
- self.withdraw() #hide while setting geometry
- self.update_idletasks()
- #needs to be done here so that the winfo_reqwidth is valid
- self.messageInfo.config(width=self.frameMain.winfo_reqwidth())
- self.geometry(
- "+%d+%d" % (
- parent.winfo_rootx() +
- (parent.winfo_width()/2 - self.winfo_reqwidth()/2),
- parent.winfo_rooty() +
- ((parent.winfo_height()/2 - self.winfo_reqheight()/2)
- if not _htest else 100)
- ) ) #centre dialog over parent (or below htest box)
- self.deiconify() #geometry set, unhide
- self.wait_window()
-
- def create_widgets(self):
- self.name = StringVar(self.parent)
- self.fontSize = StringVar(self.parent)
- self.frameMain = Frame(self, borderwidth=2, relief=SUNKEN)
- self.frameMain.pack(side=TOP, expand=TRUE, fill=BOTH)
- self.messageInfo = Message(self.frameMain, anchor=W, justify=LEFT,
- padx=5, pady=5, text=self.message) #,aspect=200)
- entryName = Entry(self.frameMain, textvariable=self.name, width=30)
- entryName.focus_set()
- self.messageInfo.pack(padx=5, pady=5) #, expand=TRUE, fill=BOTH)
- entryName.pack(padx=5, pady=5)
-
- frameButtons = Frame(self, pady=2)
- frameButtons.pack(side=BOTTOM)
- self.buttonOk = Button(frameButtons, text='Ok',
- width=8, command=self.Ok)
- self.buttonOk.pack(side=LEFT, padx=5)
- self.buttonCancel = Button(frameButtons, text='Cancel',
- width=8, command=self.Cancel)
- self.buttonCancel.pack(side=RIGHT, padx=5)
-
- def name_ok(self):
- ''' After stripping entered name, check that it is a sensible
- ConfigParser file section name. Return it if it is, '' if not.
- '''
- name = self.name.get().strip()
- if not name: #no name specified
- tkMessageBox.showerror(title='Name Error',
- message='No name specified.', parent=self)
- elif len(name)>30: #name too long
- tkMessageBox.showerror(title='Name Error',
- message='Name too long. It should be no more than '+
- '30 characters.', parent=self)
- name = ''
- elif name in self.used_names:
- tkMessageBox.showerror(title='Name Error',
- message='This name is already in use.', parent=self)
- name = ''
- return name
-
- def Ok(self, event=None):
- name = self.name_ok()
- if name:
- self.result = name
- self.destroy()
-
- def Cancel(self, event=None):
- self.result = ''
- self.destroy()
-
-if __name__ == '__main__':
- import unittest
- unittest.main('idlelib.idle_test.test_config_name', verbosity=2, exit=False)
-
- from idlelib.idle_test.htest import run
- run(GetCfgSectionNameDialog)
diff --git a/Lib/idlelib/configHelpSourceEdit.py b/Lib/idlelib/config_help.py
similarity index 100%
rename from Lib/idlelib/configHelpSourceEdit.py
rename to Lib/idlelib/config_help.py
diff --git a/Lib/idlelib/keybindingDialog.py b/Lib/idlelib/config_key.py
similarity index 95%
rename from Lib/idlelib/keybindingDialog.py
rename to Lib/idlelib/config_key.py
index e6438bf..2602293 100644
--- a/Lib/idlelib/keybindingDialog.py
+++ b/Lib/idlelib/config_key.py
@@ -2,31 +2,35 @@
Dialog for building Tkinter accelerator key bindings
"""
from tkinter import *
+from tkinter.ttk import Scrollbar
import tkinter.messagebox as tkMessageBox
import string
import sys
class GetKeysDialog(Toplevel):
- def __init__(self,parent,title,action,currentKeySequences,_htest=False):
+ def __init__(self, parent, title, action, currentKeySequences,
+ _htest=False, _utest=False):
"""
action - string, the name of the virtual event these keys will be
mapped to
currentKeys - list, a list of all key sequence lists currently mapped
to virtual events, for overlap checking
+ _utest - bool, do not wait when running unittest
_htest - bool, change box location when running htest
"""
Toplevel.__init__(self, parent)
+ self.withdraw() #hide while setting geometry
self.configure(borderwidth=5)
- self.resizable(height=FALSE,width=FALSE)
+ self.resizable(height=FALSE, width=FALSE)
self.title(title)
self.transient(parent)
self.grab_set()
self.protocol("WM_DELETE_WINDOW", self.Cancel)
self.parent = parent
self.action=action
- self.currentKeySequences=currentKeySequences
- self.result=''
- self.keyString=StringVar(self)
+ self.currentKeySequences = currentKeySequences
+ self.result = ''
+ self.keyString = StringVar(self)
self.keyString.set('')
self.SetModifiersForPlatform() # set self.modifiers, self.modifier_label
self.modifier_vars = []
@@ -37,7 +41,6 @@
self.advanced = False
self.CreateWidgets()
self.LoadFinalKeyList()
- self.withdraw() #hide while setting geometry
self.update_idletasks()
self.geometry(
"+%d+%d" % (
@@ -47,8 +50,9 @@
((parent.winfo_height()/2 - self.winfo_reqheight()/2)
if not _htest else 150)
) ) #centre dialog over parent (or below htest box)
- self.deiconify() #geometry set, unhide
- self.wait_window()
+ if not _utest:
+ self.deiconify() #geometry set, unhide
+ self.wait_window()
def CreateWidgets(self):
frameMain = Frame(self,borderwidth=2,relief=SUNKEN)
@@ -261,6 +265,7 @@
keysOK = True
return keysOK
+
if __name__ == '__main__':
from idlelib.idle_test.htest import run
run(GetKeysDialog)
diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configdialog.py
similarity index 96%
rename from Lib/idlelib/configDialog.py
rename to Lib/idlelib/configdialog.py
index 5f5bd36..6629d70 100644
--- a/Lib/idlelib/configDialog.py
+++ b/Lib/idlelib/configdialog.py
@@ -10,18 +10,19 @@
"""
from tkinter import *
+from tkinter.ttk import Scrollbar
import tkinter.messagebox as tkMessageBox
import tkinter.colorchooser as tkColorChooser
import tkinter.font as tkFont
-from idlelib.configHandler import idleConf
-from idlelib.dynOptionMenuWidget import DynOptionMenu
-from idlelib.keybindingDialog import GetKeysDialog
-from idlelib.configSectionNameDialog import GetCfgSectionNameDialog
-from idlelib.configHelpSourceEdit import GetHelpSourceDialog
+from idlelib.config import idleConf
+from idlelib.dynoption import DynOptionMenu
+from idlelib.config_key import GetKeysDialog
+from idlelib.query import SectionName
+from idlelib.config_help import GetHelpSourceDialog
from idlelib.tabbedpages import TabbedPageSet
-from idlelib.textView import view_text
-from idlelib import macosxSupport
+from idlelib.textview import view_text
+from idlelib import macosx
class ConfigDialog(Toplevel):
@@ -91,7 +92,7 @@
self.create_action_buttons().pack(side=BOTTOM)
def create_action_buttons(self):
- if macosxSupport.isAquaTk():
+ if macosx.isAquaTk():
# Changing the default padding on OSX results in unreadable
# text in the buttons
paddingArgs = {}
@@ -464,24 +465,24 @@
return frame
def AttachVarCallbacks(self):
- self.fontSize.trace_variable('w', self.VarChanged_font)
- self.fontName.trace_variable('w', self.VarChanged_font)
- self.fontBold.trace_variable('w', self.VarChanged_font)
- self.spaceNum.trace_variable('w', self.VarChanged_spaceNum)
- self.colour.trace_variable('w', self.VarChanged_colour)
- self.builtinTheme.trace_variable('w', self.VarChanged_builtinTheme)
- self.customTheme.trace_variable('w', self.VarChanged_customTheme)
- self.themeIsBuiltin.trace_variable('w', self.VarChanged_themeIsBuiltin)
- self.highlightTarget.trace_variable('w', self.VarChanged_highlightTarget)
- self.keyBinding.trace_variable('w', self.VarChanged_keyBinding)
- self.builtinKeys.trace_variable('w', self.VarChanged_builtinKeys)
- self.customKeys.trace_variable('w', self.VarChanged_customKeys)
- self.keysAreBuiltin.trace_variable('w', self.VarChanged_keysAreBuiltin)
- self.winWidth.trace_variable('w', self.VarChanged_winWidth)
- self.winHeight.trace_variable('w', self.VarChanged_winHeight)
- self.startupEdit.trace_variable('w', self.VarChanged_startupEdit)
- self.autoSave.trace_variable('w', self.VarChanged_autoSave)
- self.encoding.trace_variable('w', self.VarChanged_encoding)
+ self.fontSize.trace_add('write', self.VarChanged_font)
+ self.fontName.trace_add('write', self.VarChanged_font)
+ self.fontBold.trace_add('write', self.VarChanged_font)
+ self.spaceNum.trace_add('write', self.VarChanged_spaceNum)
+ self.colour.trace_add('write', self.VarChanged_colour)
+ self.builtinTheme.trace_add('write', self.VarChanged_builtinTheme)
+ self.customTheme.trace_add('write', self.VarChanged_customTheme)
+ self.themeIsBuiltin.trace_add('write', self.VarChanged_themeIsBuiltin)
+ self.highlightTarget.trace_add('write', self.VarChanged_highlightTarget)
+ self.keyBinding.trace_add('write', self.VarChanged_keyBinding)
+ self.builtinKeys.trace_add('write', self.VarChanged_builtinKeys)
+ self.customKeys.trace_add('write', self.VarChanged_customKeys)
+ self.keysAreBuiltin.trace_add('write', self.VarChanged_keysAreBuiltin)
+ self.winWidth.trace_add('write', self.VarChanged_winWidth)
+ self.winHeight.trace_add('write', self.VarChanged_winHeight)
+ self.startupEdit.trace_add('write', self.VarChanged_startupEdit)
+ self.autoSave.trace_add('write', self.VarChanged_autoSave)
+ self.encoding.trace_add('write', self.VarChanged_encoding)
def remove_var_callbacks(self):
"Remove callbacks to prevent memory leaks."
@@ -492,7 +493,7 @@
self.keyBinding, self.builtinKeys, self.customKeys,
self.keysAreBuiltin, self.winWidth, self.winHeight,
self.startupEdit, self.autoSave, self.encoding,):
- var.trace_vdelete('w', var.trace_vinfo()[0][1])
+ var.trace_remove('write', var.trace_info()[0][1])
def VarChanged_font(self, *params):
'''When one font attribute changes, save them all, as they are
@@ -683,7 +684,7 @@
def GetNewKeysName(self, message):
usedNames = (idleConf.GetSectionList('user', 'keys') +
idleConf.GetSectionList('default', 'keys'))
- newKeySet = GetCfgSectionNameDialog(
+ newKeySet = SectionName(
self, 'New Custom Key Set', message, usedNames).result
return newKeySet
@@ -836,7 +837,7 @@
def GetNewThemeName(self, message):
usedNames = (idleConf.GetSectionList('user', 'highlight') +
idleConf.GetSectionList('default', 'highlight'))
- newTheme = GetCfgSectionNameDialog(
+ newTheme = SectionName(
self, 'New Custom Theme', message, usedNames).result
return newTheme
diff --git a/Lib/idlelib/Debugger.py b/Lib/idlelib/debugger.py
similarity index 97%
rename from Lib/idlelib/Debugger.py
rename to Lib/idlelib/debugger.py
index d5e217d..ea393b1 100644
--- a/Lib/idlelib/Debugger.py
+++ b/Lib/idlelib/debugger.py
@@ -1,9 +1,10 @@
import os
import bdb
from tkinter import *
-from idlelib.WindowList import ListedToplevel
-from idlelib.ScrolledList import ScrolledList
-from idlelib import macosxSupport
+from tkinter.ttk import Scrollbar
+from idlelib.windows import ListedToplevel
+from idlelib.scrolledlist import ScrolledList
+from idlelib import macosx
class Idb(bdb.Bdb):
@@ -34,8 +35,10 @@
return True
else:
prev_frame = frame.f_back
- if prev_frame.f_code.co_filename.count('Debugger.py'):
- # (that test will catch both Debugger.py and RemoteDebugger.py)
+ prev_name = prev_frame.f_code.co_filename
+ if 'idlelib' in prev_name and 'debugger' in prev_name:
+ # catch both idlelib/debugger.py and idlelib/debugger_r.py
+ # on both posix and windows
return False
return self.in_rpc_code(prev_frame)
@@ -370,7 +373,7 @@
class StackViewer(ScrolledList):
def __init__(self, master, flist, gui):
- if macosxSupport.isAquaTk():
+ if macosx.isAquaTk():
# At least on with the stock AquaTk version on OSX 10.4 you'll
# get a shaking GUI that eventually kills IDLE if the width
# argument is specified.
@@ -502,7 +505,7 @@
#
# There is also an obscure bug in sorted(dict) where the
# interpreter gets into a loop requesting non-existing dict[0],
- # dict[1], dict[2], etc from the RemoteDebugger.DictProxy.
+ # dict[1], dict[2], etc from the debugger_r.DictProxy.
###
keys_list = dict.keys()
names = sorted(keys_list)
diff --git a/Lib/idlelib/RemoteDebugger.py b/Lib/idlelib/debugger_r.py
similarity index 98%
rename from Lib/idlelib/RemoteDebugger.py
rename to Lib/idlelib/debugger_r.py
index be2262f..bc97127 100644
--- a/Lib/idlelib/RemoteDebugger.py
+++ b/Lib/idlelib/debugger_r.py
@@ -21,7 +21,7 @@
"""
import types
-from idlelib import Debugger
+from idlelib import debugger
debugging = 0
@@ -187,7 +187,7 @@
"""
gui_proxy = GUIProxy(rpchandler, gui_adap_oid)
- idb = Debugger.Idb(gui_proxy)
+ idb = debugger.Idb(gui_proxy)
idb_adap = IdbAdapter(idb)
rpchandler.register(idb_adap_oid, idb_adap)
return idb_adap_oid
@@ -362,7 +362,7 @@
idb_adap_oid = rpcclt.remotecall("exec", "start_the_debugger",\
(gui_adap_oid,), {})
idb_proxy = IdbProxy(rpcclt, pyshell, idb_adap_oid)
- gui = Debugger.Debugger(pyshell, idb_proxy)
+ gui = debugger.Debugger(pyshell, idb_proxy)
gui_adap = GUIAdapter(rpcclt, gui)
rpcclt.register(gui_adap_oid, gui_adap)
return gui
@@ -373,7 +373,7 @@
Request that the RPCServer shut down the subprocess debugger and link.
Unregister the GUIAdapter, which will cause a GC on the Idle process
debugger and RPC link objects. (The second reference to the debugger GUI
- is deleted in PyShell.close_remote_debugger().)
+ is deleted in pyshell.close_remote_debugger().)
"""
close_subprocess_debugger(rpcclt)
diff --git a/Lib/idlelib/ObjectBrowser.py b/Lib/idlelib/debugobj.py
similarity index 90%
rename from Lib/idlelib/ObjectBrowser.py
rename to Lib/idlelib/debugobj.py
index 7b57aa4..0d8b2b2 100644
--- a/Lib/idlelib/ObjectBrowser.py
+++ b/Lib/idlelib/debugobj.py
@@ -11,7 +11,7 @@
import re
-from idlelib.TreeWidget import TreeItem, TreeNode, ScrolledCanvas
+from idlelib.tree import TreeItem, TreeNode, ScrolledCanvas
from reprlib import Repr
@@ -122,21 +122,20 @@
return c(labeltext, object, setfunction)
-def _object_browser(parent):
+def _object_browser(parent): # htest #
import sys
- from tkinter import Tk
- root = Tk()
- root.title("Test ObjectBrowser")
+ from tkinter import Toplevel
+ top = Toplevel(parent)
+ top.title("Test debug object browser")
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 150))
- root.configure(bd=0, bg="yellow")
- root.focus_set()
- sc = ScrolledCanvas(root, bg="white", highlightthickness=0, takefocus=1)
+ top.geometry("+%d+%d"%(x + 100, y + 175))
+ top.configure(bd=0, bg="yellow")
+ top.focus_set()
+ sc = ScrolledCanvas(top, bg="white", highlightthickness=0, takefocus=1)
sc.frame.pack(expand=1, fill="both")
item = make_objecttreeitem("sys", sys)
node = TreeNode(sc.canvas, None, item)
node.update()
- root.mainloop()
if __name__ == '__main__':
from idlelib.idle_test.htest import run
diff --git a/Lib/idlelib/RemoteObjectBrowser.py b/Lib/idlelib/debugobj_r.py
similarity index 100%
rename from Lib/idlelib/RemoteObjectBrowser.py
rename to Lib/idlelib/debugobj_r.py
diff --git a/Lib/idlelib/Delegator.py b/Lib/idlelib/delegator.py
similarity index 100%
rename from Lib/idlelib/Delegator.py
rename to Lib/idlelib/delegator.py
diff --git a/Lib/idlelib/dynOptionMenuWidget.py b/Lib/idlelib/dynoption.py
similarity index 95%
rename from Lib/idlelib/dynOptionMenuWidget.py
rename to Lib/idlelib/dynoption.py
index 515b4ba..922ad5e 100644
--- a/Lib/idlelib/dynOptionMenuWidget.py
+++ b/Lib/idlelib/dynoption.py
@@ -34,9 +34,9 @@
self.variable.set(value)
def _dyn_option_menu(parent): # htest #
- from tkinter import Toplevel
+ from tkinter import Toplevel # + StringVar, Button
- top = Toplevel()
+ top = Toplevel(parent)
top.title("Tets dynamic option menu")
top.geometry("200x100+%d+%d" % (parent.winfo_rootx() + 200,
parent.winfo_rooty() + 150))
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/editor.py
similarity index 92%
rename from Lib/idlelib/EditorWindow.py
rename to Lib/idlelib/editor.py
index 9944da3..07a1181 100644
--- a/Lib/idlelib/EditorWindow.py
+++ b/Lib/idlelib/editor.py
@@ -7,27 +7,28 @@
import string
import sys
from tkinter import *
+from tkinter.ttk import Scrollbar
import tkinter.simpledialog as tkSimpleDialog
import tkinter.messagebox as tkMessageBox
import traceback
import webbrowser
-from idlelib.MultiCall import MultiCallCreator
-from idlelib import WindowList
-from idlelib import SearchDialog
-from idlelib import GrepDialog
-from idlelib import ReplaceDialog
-from idlelib import PyParse
-from idlelib.configHandler import idleConf
-from idlelib import aboutDialog, textView, configDialog
-from idlelib import macosxSupport
+from idlelib.multicall import MultiCallCreator
+from idlelib import windows
+from idlelib import search
+from idlelib import grep
+from idlelib import replace
+from idlelib import pyparse
+from idlelib.config import idleConf
+from idlelib import help_about, textview, configdialog
+from idlelib import macosx
from idlelib import help
# The default tab setting for a Text widget, in average-width characters.
TK_TABWIDTH_DEFAULT = 8
-
_py_version = ' (%s)' % platform.python_version()
+
def _sphinx_version():
"Format sys.version_info to produce the Sphinx version string used to install the chm docs"
major, minor, micro, level, serial = sys.version_info
@@ -40,63 +41,16 @@
return release
-class HelpDialog(object):
-
- def __init__(self):
- self.parent = None # parent of help window
- self.dlg = None # the help window iteself
-
- def display(self, parent, near=None):
- """ Display the help dialog.
-
- parent - parent widget for the help window
-
- near - a Toplevel widget (e.g. EditorWindow or PyShell)
- to use as a reference for placing the help window
- """
- import warnings as w
- w.warn("EditorWindow.HelpDialog is no longer used by Idle.\n"
- "It will be removed in 3.6 or later.\n"
- "It has been replaced by private help.HelpWindow\n",
- DeprecationWarning, stacklevel=2)
- if self.dlg is None:
- self.show_dialog(parent)
- if near:
- self.nearwindow(near)
-
- def show_dialog(self, parent):
- self.parent = parent
- fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),'help.txt')
- self.dlg = dlg = textView.view_file(parent,'Help',fn, modal=False)
- dlg.bind('<Destroy>', self.destroy, '+')
-
- def nearwindow(self, near):
- # Place the help dialog near the window specified by parent.
- # Note - this may not reposition the window in Metacity
- # if "/apps/metacity/general/disable_workarounds" is enabled
- dlg = self.dlg
- geom = (near.winfo_rootx() + 10, near.winfo_rooty() + 10)
- dlg.withdraw()
- dlg.geometry("=+%d+%d" % geom)
- dlg.deiconify()
- dlg.lift()
-
- def destroy(self, ev=None):
- self.dlg = None
- self.parent = None
-
-helpDialog = HelpDialog() # singleton instance, no longer used
-
-
class EditorWindow(object):
- from idlelib.Percolator import Percolator
- from idlelib.ColorDelegator import ColorDelegator, color_config
- from idlelib.UndoDelegator import UndoDelegator
- from idlelib.IOBinding import IOBinding, filesystemencoding, encoding
- from idlelib import Bindings
+ from idlelib.percolator import Percolator
+ from idlelib.colorizer import ColorDelegator, color_config
+ from idlelib.undo import UndoDelegator
+ from idlelib.iomenu import IOBinding, encoding
+ from idlelib import mainmenu
from tkinter import Toplevel
- from idlelib.MultiStatusBar import MultiStatusBar
+ from idlelib.statusbar import MultiStatusBar
+ filesystemencoding = sys.getfilesystemencoding() # for file names
help_url = None
def __init__(self, flist=None, filename=None, key=None, root=None):
@@ -136,11 +90,11 @@
except AttributeError:
sys.ps1 = '>>> '
self.menubar = Menu(root)
- self.top = top = WindowList.ListedToplevel(root, menu=self.menubar)
+ self.top = top = windows.ListedToplevel(root, menu=self.menubar)
if flist:
self.tkinter_vars = flist.vars
#self.top.instance_dict makes flist.inversedict available to
- #configDialog.py so it can access all EditorWindow instances
+ #configdialog.py so it can access all EditorWindow instances
self.top.instance_dict = flist.inversedict
else:
self.tkinter_vars = {} # keys: Tkinter event names
@@ -158,13 +112,10 @@
'wrap': 'none',
'highlightthickness': 0,
'width': self.width,
- 'height': idleConf.GetOption('main', 'EditorWindow',
- 'height', type='int')}
- if TkVersion >= 8.5:
- # Starting with tk 8.5 we have to set the new tabstyle option
- # to 'wordprocessor' to achieve the same display of tabs as in
- # older tk versions.
- text_options['tabstyle'] = 'wordprocessor'
+ 'tabstyle': 'wordprocessor', # new in 8.5
+ 'height': idleConf.GetOption(
+ 'main', 'EditorWindow', 'height', type='int'),
+ }
self.text = text = MultiCallCreator(Text)(text_frame, **text_options)
self.top.focused_widget = self.text
@@ -173,7 +124,7 @@
self.top.protocol("WM_DELETE_WINDOW", self.close)
self.top.bind("<<close-window>>", self.close_event)
- if macosxSupport.isAquaTk():
+ if macosx.isAquaTk():
# Command-W on editorwindows doesn't work without this.
text.bind('<<close-window>>', self.close_event)
# Some OS X systems have only one mouse button, so use
@@ -309,7 +260,7 @@
menu.add_separator()
end = end + 1
self.wmenu_end = end
- WindowList.register_callback(self.postwindowsmenu)
+ windows.register_callback(self.postwindowsmenu)
# Some abstractions so IDLE extensions are cross-IDE
self.askyesno = tkMessageBox.askyesno
@@ -418,7 +369,7 @@
underline, label = prepstr(label)
menudict[name] = menu = Menu(mbar, name=name, tearoff=0)
mbar.add_cascade(label=label, menu=menu, underline=underline)
- if macosxSupport.isCarbonTk():
+ if macosx.isCarbonTk():
# Insert the application menu
menudict['application'] = menu = Menu(mbar, name='apple',
tearoff=0)
@@ -439,7 +390,7 @@
end = -1
if end > self.wmenu_end:
menu.delete(self.wmenu_end+1, end)
- WindowList.add_windows_to_menu(menu)
+ windows.add_windows_to_menu(menu)
rmenu = None
@@ -507,17 +458,17 @@
def about_dialog(self, event=None):
"Handle Help 'About IDLE' event."
- # Synchronize with macosxSupport.overrideRootMenu.about_dialog.
- aboutDialog.AboutDialog(self.top,'About IDLE')
+ # Synchronize with macosx.overrideRootMenu.about_dialog.
+ help_about.AboutDialog(self.top,'About IDLE')
def config_dialog(self, event=None):
"Handle Options 'Configure IDLE' event."
- # Synchronize with macosxSupport.overrideRootMenu.config_dialog.
- configDialog.ConfigDialog(self.top,'Settings')
+ # Synchronize with macosx.overrideRootMenu.config_dialog.
+ configdialog.ConfigDialog(self.top,'Settings')
def help_dialog(self, event=None):
"Handle Help 'IDLE Help' event."
- # Synchronize with macosxSupport.overrideRootMenu.help_dialog.
+ # Synchronize with macosx.overrideRootMenu.help_dialog.
if self.root:
parent = self.root
else:
@@ -590,23 +541,23 @@
return "break"
def find_event(self, event):
- SearchDialog.find(self.text)
+ search.find(self.text)
return "break"
def find_again_event(self, event):
- SearchDialog.find_again(self.text)
+ search.find_again(self.text)
return "break"
def find_selection_event(self, event):
- SearchDialog.find_selection(self.text)
+ search.find_selection(self.text)
return "break"
def find_in_files_event(self, event):
- GrepDialog.grep(self.text, self.io, self.flist)
+ grep.grep(self.text, self.io, self.flist)
return "break"
def replace_event(self, event):
- ReplaceDialog.replace(self.text)
+ replace.replace(self.text)
return "break"
def goto_line_event(self, event):
@@ -673,12 +624,12 @@
return
head, tail = os.path.split(filename)
base, ext = os.path.splitext(tail)
- from idlelib import ClassBrowser
- ClassBrowser.ClassBrowser(self.flist, base, [head])
+ from idlelib import browser
+ browser.ClassBrowser(self.flist, base, [head])
def open_path_browser(self, event=None):
- from idlelib import PathBrowser
- PathBrowser.PathBrowser(self.flist)
+ from idlelib import pathbrowser
+ pathbrowser.PathBrowser(self.flist)
def open_turtle_demo(self, event = None):
import subprocess
@@ -739,7 +690,7 @@
def ResetColorizer(self):
"Update the color theme"
- # Called from self.filename_change_hook and from configDialog.py
+ # Called from self.filename_change_hook and from configdialog.py
self._rmcolorizer()
self._addcolorizer()
EditorWindow.color_config(self.text)
@@ -759,14 +710,14 @@
def ResetFont(self):
"Update the text widgets' font if it is changed"
- # Called from configDialog.py
+ # Called from configdialog.py
self.text['font'] = idleConf.GetFont(self.root, 'main','EditorWindow')
def RemoveKeybindings(self):
"Remove the keybindings before they are changed."
- # Called from configDialog.py
- self.Bindings.default_keydefs = keydefs = idleConf.GetCurrentKeySet()
+ # Called from configdialog.py
+ self.mainmenu.default_keydefs = keydefs = idleConf.GetCurrentKeySet()
for event, keylist in keydefs.items():
self.text.event_delete(event, *keylist)
for extensionName in self.get_standard_extension_names():
@@ -777,8 +728,8 @@
def ApplyKeybindings(self):
"Update the keybindings after they are changed"
- # Called from configDialog.py
- self.Bindings.default_keydefs = keydefs = idleConf.GetCurrentKeySet()
+ # Called from configdialog.py
+ self.mainmenu.default_keydefs = keydefs = idleConf.GetCurrentKeySet()
self.apply_bindings()
for extensionName in self.get_standard_extension_names():
xkeydefs = idleConf.GetExtensionBindings(extensionName)
@@ -786,7 +737,7 @@
self.apply_bindings(xkeydefs)
#update menu accelerators
menuEventDict = {}
- for menu in self.Bindings.menudefs:
+ for menu in self.mainmenu.menudefs:
menuEventDict[menu[0]] = {}
for item in menu[1]:
if item:
@@ -813,7 +764,7 @@
def set_notabs_indentwidth(self):
"Update the indentwidth if changed and not using tabs in this window"
- # Called from configDialog.py
+ # Called from configdialog.py
if not self.usetabs:
self.indentwidth = idleConf.GetOption('main', 'Indent','num-spaces',
type='int')
@@ -993,7 +944,7 @@
def _close(self):
if self.io.filename:
self.update_recent_files_list(new_file=self.io.filename)
- WindowList.unregister_callback(self.postwindowsmenu)
+ windows.unregister_callback(self.postwindowsmenu)
self.unload_extensions()
self.io.close()
self.io = None
@@ -1031,12 +982,25 @@
def get_standard_extension_names(self):
return idleConf.GetExtensions(editor_only=True)
+ extfiles = { # map config-extension section names to new file names
+ 'AutoComplete': 'autocomplete',
+ 'AutoExpand': 'autoexpand',
+ 'CallTips': 'calltips',
+ 'CodeContext': 'codecontext',
+ 'FormatParagraph': 'paragraph',
+ 'ParenMatch': 'parenmatch',
+ 'RstripExtension': 'rstrip',
+ 'ScriptBinding': 'runscript',
+ 'ZoomHeight': 'zoomheight',
+ }
+
def load_extension(self, name):
+ fname = self.extfiles.get(name, name)
try:
try:
- mod = importlib.import_module('.' + name, package=__package__)
+ mod = importlib.import_module('.' + fname, package=__package__)
except (ImportError, TypeError):
- mod = importlib.import_module(name)
+ mod = importlib.import_module(fname)
except ImportError:
print("\nFailed to import extension: ", name)
raise
@@ -1060,7 +1024,7 @@
def apply_bindings(self, keydefs=None):
if keydefs is None:
- keydefs = self.Bindings.default_keydefs
+ keydefs = self.mainmenu.default_keydefs
text = self.text
text.keydefs = keydefs
for event, keylist in keydefs.items():
@@ -1073,9 +1037,9 @@
Menus that are absent or None in self.menudict are ignored.
"""
if menudefs is None:
- menudefs = self.Bindings.menudefs
+ menudefs = self.mainmenu.menudefs
if keydefs is None:
- keydefs = self.Bindings.default_keydefs
+ keydefs = self.mainmenu.default_keydefs
menudict = self.menudict
text = self.text
for mname, entrylist in menudefs:
@@ -1302,7 +1266,7 @@
# adjust indentation for continuations and block
# open/close first need to find the last stmt
lno = index2line(text.index('insert'))
- y = PyParse.Parser(self.indentwidth, self.tabwidth)
+ y = pyparse.Parser(self.indentwidth, self.tabwidth)
if not self.context_use_ps1:
for context in self.num_context_lines:
startat = max(lno - context, 1)
@@ -1326,22 +1290,22 @@
y.set_lo(0)
c = y.get_continuation_type()
- if c != PyParse.C_NONE:
+ if c != pyparse.C_NONE:
# The current stmt hasn't ended yet.
- if c == PyParse.C_STRING_FIRST_LINE:
+ if c == pyparse.C_STRING_FIRST_LINE:
# after the first line of a string; do not indent at all
pass
- elif c == PyParse.C_STRING_NEXT_LINES:
+ elif c == pyparse.C_STRING_NEXT_LINES:
# inside a string which started before this line;
# just mimic the current indent
text.insert("insert", indent)
- elif c == PyParse.C_BRACKET:
+ elif c == pyparse.C_BRACKET:
# line up with the first (if any) element of the
# last open bracket structure; else indent one
# level beyond the indent of the line with the
# last open bracket
self.reindent_to(y.compute_bracket_indent())
- elif c == PyParse.C_BACKSLASH:
+ elif c == pyparse.C_BACKSLASH:
# if more than one line in this stmt already, just
# mimic the current indent; else if initial line
# has a start on an assignment stmt, indent to
@@ -1644,7 +1608,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 (macosx.isCocoaTk() and eventname in {
"<<open-module>>",
"<<goto-line>>",
"<<change-indentwidth>>"}):
@@ -1679,12 +1643,15 @@
filename = sys.argv[1]
else:
filename = None
- macosxSupport.setupApp(root, None)
+ macosx.setupApp(root, None)
edit = EditorWindow(root=root, filename=filename)
edit.text.bind("<<close-all-windows>>", edit.close_event)
# Does not stop error, neither does following
# edit.text.bind("<<close-window>>", edit.close_event)
if __name__ == '__main__':
+ import unittest
+ unittest.main('idlelib.idle_test.test_editor', verbosity=2, exit=False)
+
from idlelib.idle_test.htest import run
run(_editor_window)
diff --git a/Lib/idlelib/FileList.py b/Lib/idlelib/filelist.py
similarity index 97%
rename from Lib/idlelib/FileList.py
rename to Lib/idlelib/filelist.py
index a9989a8..b5af90cc 100644
--- a/Lib/idlelib/FileList.py
+++ b/Lib/idlelib/filelist.py
@@ -6,7 +6,7 @@
class FileList:
# N.B. this import overridden in PyShellFileList.
- from idlelib.EditorWindow import EditorWindow
+ from idlelib.editor import EditorWindow
def __init__(self, root):
self.root = root
@@ -111,7 +111,7 @@
def _test():
- from idlelib.EditorWindow import fixwordbreaks
+ from idlelib.editor import fixwordbreaks
import sys
root = Tk()
fixwordbreaks(root)
diff --git a/Lib/idlelib/GrepDialog.py b/Lib/idlelib/grep.py
similarity index 88%
rename from Lib/idlelib/GrepDialog.py
rename to Lib/idlelib/grep.py
index 721b231..6324b4f 100644
--- a/Lib/idlelib/GrepDialog.py
+++ b/Lib/idlelib/grep.py
@@ -3,15 +3,14 @@
import re # for htest
import sys
from tkinter import StringVar, BooleanVar, Checkbutton # for GrepDialog
-from tkinter import Tk, Text, Button, SEL, END # for htest
-from idlelib import SearchEngine
-from idlelib.SearchDialogBase import SearchDialogBase
+from idlelib import searchengine
+from idlelib.searchbase import SearchDialogBase
# Importing OutputWindow fails due to import loop
# EditorWindow -> GrepDialop -> OutputWindow -> EditorWindow
def grep(text, io=None, flist=None):
root = text._root()
- engine = SearchEngine.get(root)
+ engine = searchengine.get(root)
if not hasattr(engine, "_grepdialog"):
engine._grepdialog = GrepDialog(root, engine, flist)
dialog = engine._grepdialog
@@ -67,7 +66,7 @@
if not path:
self.top.bell()
return
- from idlelib.OutputWindow import OutputWindow # leave here!
+ from idlelib.outwin import OutputWindow # leave here!
save = sys.stdout
try:
sys.stdout = OutputWindow(self.flist)
@@ -131,14 +130,15 @@
def _grep_dialog(parent): # htest #
- from idlelib.PyShell import PyShellFileList
- root = Tk()
- root.title("Test GrepDialog")
+ from idlelib.pyshell import PyShellFileList
+ from tkinter import Toplevel, Text, Button, SEL, END
+ top = Toplevel(parent)
+ top.title("Test GrepDialog")
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 150))
+ top.geometry("+%d+%d"%(x, y + 150))
- flist = PyShellFileList(root)
- text = Text(root, height=5)
+ flist = PyShellFileList(top)
+ text = Text(top, height=5)
text.pack()
def show_grep_dialog():
@@ -146,9 +146,8 @@
grep(text, flist=flist)
text.tag_remove(SEL, "1.0", END)
- button = Button(root, text="Show GrepDialog", command=show_grep_dialog)
+ button = Button(top, text="Show GrepDialog", command=show_grep_dialog)
button.pack()
- root.mainloop()
if __name__ == "__main__":
import unittest
diff --git a/Lib/idlelib/help.py b/Lib/idlelib/help.py
index d0c59c5..d18d1ca 100644
--- a/Lib/idlelib/help.py
+++ b/Lib/idlelib/help.py
@@ -4,7 +4,7 @@
Help => About IDLE: diplay About Idle dialog
-<to be moved here from aboutDialog.py>
+<to be moved here from help_about.py>
Help => IDLE Help: Display help.html with proper formatting.
@@ -25,14 +25,11 @@
show_idlehelp - Create HelpWindow. Called in EditorWindow.help_dialog.
"""
from html.parser import HTMLParser
-from os.path import abspath, dirname, isdir, isfile, join
-from tkinter import Tk, Toplevel, Frame, Text, Scrollbar, Menu, Menubutton
+from os.path import abspath, dirname, isfile, join
+from tkinter import Toplevel, Frame, Text, Menu
+from tkinter.ttk import Menubutton, Scrollbar
from tkinter import font as tkfont
-from idlelib.configHandler import idleConf
-
-use_ttk = False # until available to import
-if use_ttk:
- from tkinter.ttk import Menubutton
+from idlelib.config import idleConf
## About IDLE ##
@@ -196,15 +193,18 @@
"Display html text, scrollbar, and toc."
def __init__(self, parent, filename):
Frame.__init__(self, parent)
- text = HelpText(self, filename)
+ # keep references to widgets for test access.
+ self.text = text = HelpText(self, filename)
self['background'] = text['background']
- scroll = Scrollbar(self, command=text.yview)
+ self.toc = toc = self.toc_menu(text)
+ self.scroll = scroll = Scrollbar(self, command=text.yview)
text['yscrollcommand'] = scroll.set
+
self.rowconfigure(0, weight=1)
self.columnconfigure(1, weight=1) # text
- self.toc_menu(text).grid(column=0, row=0, sticky='nw')
- text.grid(column=1, row=0, sticky='nsew')
- scroll.grid(column=2, row=0, sticky='ns')
+ toc.grid(row=0, column=0, sticky='nw')
+ text.grid(row=0, column=1, sticky='nsew')
+ scroll.grid(row=0, column=2, sticky='ns')
def toc_menu(self, text):
"Create table of contents as drop-down menu."
@@ -265,7 +265,7 @@
if not isfile(filename):
# try copy_strip, present message
return
- HelpWindow(parent, filename, 'IDLE Help')
+ return HelpWindow(parent, filename, 'IDLE Help')
if __name__ == '__main__':
from idlelib.idle_test.htest import run
diff --git a/Lib/idlelib/help.txt b/Lib/idlelib/help.txt
deleted file mode 100644
index 89fbe0b..0000000
--- a/Lib/idlelib/help.txt
+++ /dev/null
@@ -1,372 +0,0 @@
-This file, idlelib/help.txt is out-of-date and no longer used by Idle.
-It is deprecated and will be removed in the future, possibly in 3.6
-----------------------------------------------------------------------
-
-[See the end of this file for ** TIPS ** on using IDLE !!]
-
-IDLE is the Python IDE built with the tkinter GUI toolkit.
-
-IDLE has the following features:
--coded in 100% pure Python, using the tkinter GUI toolkit
--cross-platform: works on Windows, Unix, and OS X
--multi-window text editor with multiple undo, Python colorizing, smart indent,
-call tips, and many other features
--Python shell window (a.k.a interactive interpreter)
--debugger (not complete, but you can set breakpoints, view and step)
-
-Menus:
-
-IDLE has two window types the Shell window and the Editor window. It is
-possible to have multiple editor windows simultaneously. IDLE's
-menus dynamically change based on which window is currently selected. Each menu
-documented below indicates which window type it is associated with.
-
-File Menu (Shell and Editor):
-
- New File -- Create a new file editing window
- Open... -- Open an existing file
- Open Module... -- Open an existing module (searches sys.path)
- Recent Files... -- Open a list of recent files
- Class Browser -- Show classes and methods in current file
- Path Browser -- Show sys.path directories, modules, classes,
- and methods
- ---
- Save -- Save current window to the associated file (unsaved
- windows have a * before and after the window title)
-
- Save As... -- Save current window to new file, which becomes
- the associated file
- Save Copy As... -- Save current window to different file
- without changing the associated file
- ---
- Print Window -- Print the current window
- ---
- Close -- Close current window (asks to save if unsaved)
- Exit -- Close all windows, quit (asks to save if unsaved)
-
-Edit Menu (Shell and Editor):
-
- Undo -- Undo last change to current window
- (a maximum of 1000 changes may be undone)
- Redo -- Redo last undone change to current window
- ---
- Cut -- Copy a selection into system-wide clipboard,
- then delete the selection
- Copy -- Copy selection into system-wide clipboard
- Paste -- Insert system-wide clipboard into window
- Select All -- Select the entire contents of the edit buffer
- ---
- Find... -- Open a search dialog box with many options
- Find Again -- Repeat last search
- Find Selection -- Search for the string in the selection
- Find in Files... -- Open a search dialog box for searching files
- Replace... -- Open a search-and-replace dialog box
- Go to Line -- Ask for a line number and show that line
- Expand Word -- Expand the word you have typed to match another
- word in the same buffer; repeat to get a
- different expansion
- Show Calltip -- After an unclosed parenthesis for a function, open
- a small window with function parameter hints
- Show Parens -- Highlight the surrounding parenthesis
- Show Completions -- Open a scroll window allowing selection keywords
- and attributes. (see '*TIPS*', below)
-
-Format Menu (Editor window only):
-
- Indent Region -- Shift selected lines right by the indent width
- (default 4 spaces)
- Dedent Region -- Shift selected lines left by the indent width
- (default 4 spaces)
- Comment Out Region -- Insert ## in front of selected lines
- Uncomment Region -- Remove leading # or ## from selected lines
- Tabify Region -- Turns *leading* stretches of spaces into tabs.
- (Note: We recommend using 4 space blocks to indent Python code.)
- Untabify Region -- Turn *all* tabs into the corrent number of spaces
- Toggle tabs -- Open a dialog to switch between indenting with
- spaces and tabs.
- New Indent Width... -- Open a dialog to change indent width. The
- accepted default by the Python community is 4
- spaces.
- Format Paragraph -- Reformat the current blank-line-separated
- paragraph. All lines in the paragraph will be
- formatted to less than 80 columns.
- ---
- Strip trailing whitespace -- Removed any space characters after the end
- of the last non-space character
-
-Run Menu (Editor window only):
-
- Python Shell -- Open or wake up the Python shell window
- ---
- Check Module -- Check the syntax of the module currently open in the
- Editor window. If the module has not been saved IDLE
- will prompt the user to save the code.
- Run Module -- Restart the shell to clean the environment, then
- execute the currently open module. If the module has
- not been saved IDLE will prompt the user to save the
- code.
-
-Shell Menu (Shell window only):
-
- View Last Restart -- Scroll the shell window to the last Shell restart
- Restart Shell -- Restart the shell to clean the environment
-
-Debug Menu (Shell window only):
-
- Go to File/Line -- Look around the insert point for a filename
- and line number, open the file, and show the line.
- Useful to view the source lines referenced in an
- exception traceback. Available in the context
- menu of the Shell window.
- Debugger (toggle) -- This feature is not complete and considered
- experimental. Run commands in the shell under the
- debugger.
- Stack Viewer -- Show the stack traceback of the last exception
- Auto-open Stack Viewer (toggle) -- Toggle automatically opening the
- stack viewer on unhandled
- exception
-
-Options Menu (Shell and Editor):
-
- Configure IDLE -- Open a configuration dialog. Fonts, indentation,
- keybindings, and color themes may be altered.
- Startup Preferences may be set, and additional Help
- sources can be specified. On OS X, open the
- configuration dialog by selecting Preferences
- in the application menu.
-
- ---
- Code Context (toggle) -- Open a pane at the top of the edit window
- which shows the block context of the section
- of code which is scrolling off the top or the
- window. This is not present in the Shell
- window only the Editor window.
-
-Window Menu (Shell and Editor):
-
- Zoom Height -- Toggles the window between normal size (40x80 initial
- setting) and maximum height. The initial size is in the Configure
- IDLE dialog under the general tab.
- ---
- The rest of this menu lists the names of all open windows;
- select one to bring it to the foreground (deiconifying it if
- necessary).
-
-Help Menu:
-
- About IDLE -- Version, copyright, license, credits
- ---
- IDLE Help -- Display this file which is a help file for IDLE
- detailing the menu options, basic editing and navigation,
- and other tips.
- Python Docs -- Access local Python documentation, if
- installed. Or will start a web browser and open
- docs.python.org showing the latest Python documentation.
- ---
- Additional help sources may be added here with the Configure IDLE
- dialog under the General tab.
-
-Editor context menu (Right-click / Control-click on OS X in Edit window):
-
- Cut -- Copy a selection into system-wide clipboard,
- then delete the selection
- Copy -- Copy selection into system-wide clipboard
- Paste -- Insert system-wide clipboard into window
- Set Breakpoint -- Sets a breakpoint. Breakpoints are only enabled
- when the debugger is open.
- Clear Breakpoint -- Clears the breakpoint on that line
-
-Shell context menu (Right-click / Control-click on OS X in Shell window):
-
- Cut -- Copy a selection into system-wide clipboard,
- then delete the selection
- Copy -- Copy selection into system-wide clipboard
- Paste -- Insert system-wide clipboard into window
- ---
- Go to file/line -- Same as in Debug menu
-
-
-** TIPS **
-==========
-
-Additional Help Sources:
-
- Windows users can Google on zopeshelf.chm to access Zope help files in
- the Windows help format. The Additional Help Sources feature of the
- configuration GUI supports .chm, along with any other filetypes
- supported by your browser. Supply a Menu Item title, and enter the
- location in the Help File Path slot of the New Help Source dialog. Use
- http:// and/or www. to identify external URLs, or download the file and
- browse for its path on your machine using the Browse button.
-
- All users can access the extensive sources of help, including
- tutorials, available at docs.python.org. Selected URLs can be added
- or removed from the Help menu at any time using Configure IDLE.
-
-Basic editing and navigation:
-
- Backspace deletes char to the left; DEL deletes char to the right.
- Control-backspace deletes word left, Control-DEL deletes word right.
- Arrow keys and Page Up/Down move around.
- Control-left/right Arrow moves by words in a strange but useful way.
- Home/End go to begin/end of line.
- Control-Home/End go to begin/end of file.
- Some useful Emacs bindings are inherited from Tcl/Tk:
- Control-a beginning of line
- Control-e end of line
- Control-k kill line (but doesn't put it in clipboard)
- Control-l center window around the insertion point
- Standard keybindings (like Control-c to copy and Control-v to
- paste) may work. Keybindings are selected in the Configure IDLE
- dialog.
-
-Automatic indentation:
-
- After a block-opening statement, the next line is indented by 4 spaces
- (in the Python Shell window by one tab). After certain keywords
- (break, return etc.) the next line is dedented. In leading
- indentation, Backspace deletes up to 4 spaces if they are there. Tab
- inserts spaces (in the Python Shell window one tab), number depends on
- Indent Width. Currently tabs are restricted to four spaces due
- to Tcl/Tk limitations.
-
- See also the indent/dedent region commands in the edit menu.
-
-Completions:
-
- Completions are supplied for functions, classes, and attributes of
- classes, both built-in and user-defined. Completions are also provided
- for filenames.
-
- The AutoCompleteWindow (ACW) will open after a predefined delay
- (default is two seconds) after a '.' or (in a string) an os.sep is
- typed. If after one of those characters (plus zero or more other
- characters) a tab is typed the ACW will open immediately if a possible
- continuation is found.
-
- If there is only one possible completion for the characters entered, a
- tab will supply that completion without opening the ACW.
-
- 'Show Completions' will force open a completions window, by default the
- Control-space keys will open a completions window. In an empty
- string, this will contain the files in the current directory. On a
- blank line, it will contain the built-in and user-defined functions and
- classes in the current name spaces, plus any modules imported. If some
- characters have been entered, the ACW will attempt to be more specific.
-
- If string of characters is typed, the ACW selection will jump to the
- entry most closely matching those characters. Entering a tab will cause
- the longest non-ambiguous match to be entered in the Edit window or
- Shell. Two tabs in a row will supply the current ACW selection, as
- will return or a double click. Cursor keys, Page Up/Down, mouse
- selection, and the scroll wheel all operate on the ACW.
-
- "Hidden" attributes can be accessed by typing the beginning of hidden
- name after a '.', e.g. '_'. This allows access to modules with
- '__all__' set, or to class-private attributes.
-
- Completions and the 'Expand Word' facility can save a lot of typing!
-
- Completions are currently limited to those in the namespaces. Names in
- an Editor window which are not via __main__ or sys.modules will not be
- found. Run the module once with your imports to correct this
- situation. Note that IDLE itself places quite a few modules in
- sys.modules, so much can be found by default, e.g. the re module.
-
- If you don't like the ACW popping up unbidden, simply make the delay
- longer or disable the extension. Or another option is the delay could
- be set to zero. Another alternative to preventing ACW popups is to
- disable the call tips extension.
-
-Python Shell window:
-
- Control-c interrupts executing command.
- Control-d sends end-of-file; closes window if typed at >>> prompt.
- Alt-/ expand word is also useful to reduce typing.
-
- Command history:
-
- Alt-p retrieves previous command matching what you have typed. On OS X
- use Control-p.
- Alt-n retrieves next. On OS X use Control-n.
- Return while cursor is on a previous command retrieves that command.
-
- Syntax colors:
-
- The coloring is applied in a background "thread", so you may
- occasionally see uncolorized text. To change the color
- scheme, use the Configure IDLE / Highlighting dialog.
-
- Python default syntax colors:
-
- Keywords orange
- Builtins royal purple
- Strings green
- Comments red
- Definitions blue
-
- Shell default colors:
-
- Console output brown
- stdout blue
- stderr red
- stdin black
-
-Other preferences:
-
- The font preferences, highlighting, keys, and general preferences can
- be changed via the Configure IDLE menu option. Be sure to note that
- keys can be user defined, IDLE ships with four built in key sets. In
- addition a user can create a custom key set in the Configure IDLE
- dialog under the keys tab.
-
-Command line usage:
-
- Enter idle -h at the command prompt to get a usage message.
-
- idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ...
-
- -c command run this command
- -d enable debugger
- -e edit mode; arguments are files to be edited
- -s run $IDLESTARTUP or $PYTHONSTARTUP first
- -t title set title of shell window
-
- If there are arguments:
- 1. If -e is used, arguments are files opened for editing and sys.argv
- reflects the arguments passed to IDLE itself.
- 2. Otherwise, if -c is used, all arguments are placed in
- sys.argv[1:...], with sys.argv[0] set to -c.
- 3. Otherwise, if neither -e nor -c is used, the first argument is a
- script which is executed with the remaining arguments in
- sys.argv[1:...] and sys.argv[0] set to the script name. If the
- script name is -, no script is executed but an interactive Python
- session is started; the arguments are still available in sys.argv.
-
-Running without a subprocess: (DEPRECATED in Python 3.4 see Issue 16123)
-
- If IDLE is started with the -n command line switch it will run in a
- single process and will not create the subprocess which runs the RPC
- Python execution server. This can be useful if Python cannot create
- the subprocess or the RPC socket interface on your platform. However,
- in this mode user code is not isolated from IDLE itself. Also, the
- environment is not restarted when Run/Run Module (F5) is selected. If
- your code has been modified, you must reload() the affected modules and
- re-import any specific items (e.g. from foo import baz) if the changes
- are to take effect. For these reasons, it is preferable to run IDLE
- with the default subprocess if at all possible.
-
-Extensions:
-
- IDLE contains an extension facility. See the beginning of
- config-extensions.def in the idlelib directory for further information.
- The default extensions are currently:
-
- FormatParagraph
- AutoExpand
- ZoomHeight
- ScriptBinding
- CallTips
- ParenMatch
- AutoComplete
- CodeContext
diff --git a/Lib/idlelib/aboutDialog.py b/Lib/idlelib/help_about.py
similarity index 96%
rename from Lib/idlelib/aboutDialog.py
rename to Lib/idlelib/help_about.py
index a8f75d2..54f3599 100644
--- a/Lib/idlelib/aboutDialog.py
+++ b/Lib/idlelib/help_about.py
@@ -5,7 +5,7 @@
import os
from sys import version
from tkinter import *
-from idlelib import textView
+from idlelib import textview
class AboutDialog(Toplevel):
"""Modal about dialog for idle
@@ -135,17 +135,17 @@
def display_printer_text(self, title, printer):
printer._Printer__setup()
text = '\n'.join(printer._Printer__lines)
- textView.view_text(self, title, text)
+ textview.view_text(self, title, text)
def display_file_text(self, title, filename, encoding=None):
fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), filename)
- textView.view_file(self, title, fn, encoding)
+ textview.view_file(self, title, fn, encoding)
def Ok(self, event=None):
self.destroy()
if __name__ == '__main__':
import unittest
- unittest.main('idlelib.idle_test.test_helpabout', verbosity=2, exit=False)
+ unittest.main('idlelib.idle_test.test_help_about', verbosity=2, exit=False)
from idlelib.idle_test.htest import run
run(AboutDialog)
diff --git a/Lib/idlelib/IdleHistory.py b/Lib/idlelib/history.py
similarity index 97%
rename from Lib/idlelib/IdleHistory.py
rename to Lib/idlelib/history.py
index 078af29..6068d4f 100644
--- a/Lib/idlelib/IdleHistory.py
+++ b/Lib/idlelib/history.py
@@ -1,11 +1,11 @@
"Implement Idle Shell history mechanism with History class"
-from idlelib.configHandler import idleConf
+from idlelib.config import idleConf
class History:
''' Implement Idle Shell history mechanism.
- store - Store source statement (called from PyShell.resetoutput).
+ store - Store source statement (called from pyshell.resetoutput).
fetch - Fetch stored statement matching prefix already entered.
history_next - Bound to <<history-next>> event (default Alt-N).
history_prev - Bound to <<history-prev>> event (default Alt-P).
diff --git a/Lib/idlelib/HyperParser.py b/Lib/idlelib/hyperparser.py
similarity index 99%
rename from Lib/idlelib/HyperParser.py
rename to Lib/idlelib/hyperparser.py
index 77cb057..f904a39 100644
--- a/Lib/idlelib/HyperParser.py
+++ b/Lib/idlelib/hyperparser.py
@@ -7,7 +7,7 @@
import string
from keyword import iskeyword
-from idlelib import PyParse
+from idlelib import pyparse
# all ASCII chars that may be in an identifier
@@ -30,7 +30,7 @@
self.editwin = editwin
self.text = text = editwin.text
- parser = PyParse.Parser(editwin.indentwidth, editwin.tabwidth)
+ parser = pyparse.Parser(editwin.indentwidth, editwin.tabwidth)
def index2line(index):
return int(float(index))
diff --git a/Lib/idlelib/idle.py b/Lib/idlelib/idle.py
index a249557..c01cf99 100644
--- a/Lib/idlelib/idle.py
+++ b/Lib/idlelib/idle.py
@@ -7,5 +7,5 @@
idlelib_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, idlelib_dir)
-import idlelib.PyShell
-idlelib.PyShell.main()
+import idlelib.pyshell
+idlelib.pyshell.main()
diff --git a/Lib/idlelib/idle.pyw b/Lib/idlelib/idle.pyw
index 142cb32..e73c049 100644
--- a/Lib/idlelib/idle.pyw
+++ b/Lib/idlelib/idle.pyw
@@ -1,10 +1,10 @@
try:
- import idlelib.PyShell
+ import idlelib.pyshell
except ImportError:
- # IDLE is not installed, but maybe PyShell is on sys.path:
- from . import PyShell
+ # IDLE is not installed, but maybe pyshell is on sys.path:
+ from . import pyshell
import os
- idledir = os.path.dirname(os.path.abspath(PyShell.__file__))
+ idledir = os.path.dirname(os.path.abspath(pyshell.__file__))
if idledir != os.getcwd():
# We're not in the IDLE directory, help the subprocess find run.py
pypath = os.environ.get('PYTHONPATH', '')
@@ -12,6 +12,6 @@
os.environ['PYTHONPATH'] = pypath + ':' + idledir
else:
os.environ['PYTHONPATH'] = idledir
- PyShell.main()
+ pyshell.main()
else:
- idlelib.PyShell.main()
+ idlelib.pyshell.main()
diff --git a/Lib/idlelib/idle_test/__init__.py b/Lib/idlelib/idle_test/__init__.py
index 845c92d..ad067b4 100644
--- a/Lib/idlelib/idle_test/__init__.py
+++ b/Lib/idlelib/idle_test/__init__.py
@@ -1,6 +1,8 @@
'''idlelib.idle_test is a private implementation of test.test_idle,
which tests the IDLE application as part of the stdlib test suite.
Run IDLE tests alone with "python -m test.test_idle".
+Starting with Python 3.6, IDLE requires tcl/tk 8.5 or later.
+
This package and its contained modules are subject to change and
any direct use is at your own risk.
'''
diff --git a/Lib/idlelib/idle_test/htest.py b/Lib/idlelib/idle_test/htest.py
index 58e62cb..d809d30 100644
--- a/Lib/idlelib/idle_test/htest.py
+++ b/Lib/idlelib/idle_test/htest.py
@@ -59,19 +59,20 @@
Modules and classes not being tested at the moment:
-PyShell.PyShellEditorWindow
-Debugger.Debugger
-AutoCompleteWindow.AutoCompleteWindow
-OutputWindow.OutputWindow (indirectly being tested with grep test)
+pyshell.PyShellEditorWindow
+debugger.Debugger
+autocomplete_w.AutoCompleteWindow
+outwin.OutputWindow (indirectly being tested with grep test)
'''
from importlib import import_module
-from idlelib.macosxSupport import _initializeTkVariantTests
import tkinter as tk
+from tkinter.ttk import Scrollbar
+tk.NoDefaultRoot()
AboutDialog_spec = {
- 'file': 'aboutDialog',
- 'kwds': {'title': 'aboutDialog test',
+ 'file': 'help_about',
+ 'kwds': {'title': 'help_about test',
'_htest': True,
},
'msg': "Test every button. Ensure Python, TK and IDLE versions "
@@ -79,14 +80,14 @@
}
_calltip_window_spec = {
- 'file': 'CallTipWindow',
+ 'file': 'calltip_w',
'kwds': {},
'msg': "Typing '(' should display a calltip.\n"
"Typing ') should hide the calltip.\n"
}
_class_browser_spec = {
- 'file': 'ClassBrowser',
+ 'file': 'browser',
'kwds': {},
'msg': "Inspect names of module, class(with superclass if "
"applicable), methods and functions.\nToggle nested items.\n"
@@ -95,7 +96,7 @@
}
_color_delegator_spec = {
- 'file': 'ColorDelegator',
+ 'file': 'colorizer',
'kwds': {},
'msg': "The text is sample Python code.\n"
"Ensure components like comments, keywords, builtins,\n"
@@ -104,7 +105,7 @@
}
ConfigDialog_spec = {
- 'file': 'configDialog',
+ 'file': 'configdialog',
'kwds': {'title': 'ConfigDialogTest',
'_htest': True,},
'msg': "IDLE preferences dialog.\n"
@@ -121,7 +122,7 @@
# TODO Improve message
_dyn_option_menu_spec = {
- 'file': 'dynOptionMenuWidget',
+ 'file': 'dynoption',
'kwds': {},
'msg': "Select one of the many options in the 'old option set'.\n"
"Click the button to change the option set.\n"
@@ -130,26 +131,14 @@
# TODO edit wrapper
_editor_window_spec = {
- 'file': 'EditorWindow',
+ 'file': 'editor',
'kwds': {},
'msg': "Test editor functions of interest.\n"
"Best to close editor first."
}
-GetCfgSectionNameDialog_spec = {
- 'file': 'configSectionNameDialog',
- 'kwds': {'title':'Get Name',
- 'message':'Enter something',
- 'used_names': {'abc'},
- '_htest': True},
- 'msg': "After the text entered with [Ok] is stripped, <nothing>, "
- "'abc', or more that 30 chars are errors.\n"
- "Close 'Get Name' with a valid entry (printed to Shell), "
- "[Cancel], or [X]",
- }
-
GetHelpSourceDialog_spec = {
- 'file': 'configHelpSourceEdit',
+ 'file': 'config_help',
'kwds': {'title': 'Get helpsource',
'_htest': True},
'msg': "Enter menu item name and help file path\n "
@@ -162,7 +151,7 @@
# Update once issue21519 is resolved.
GetKeysDialog_spec = {
- 'file': 'keybindingDialog',
+ 'file': 'config_key',
'kwds': {'title': 'Test keybindings',
'action': 'find-again',
'currentKeySequences': [''] ,
@@ -177,7 +166,7 @@
}
_grep_dialog_spec = {
- 'file': 'GrepDialog',
+ 'file': 'grep',
'kwds': {},
'msg': "Click the 'Show GrepDialog' button.\n"
"Test the various 'Find-in-files' functions.\n"
@@ -187,7 +176,7 @@
}
_io_binding_spec = {
- 'file': 'IOBinding',
+ 'file': 'iomenu',
'kwds': {},
'msg': "Test the following bindings.\n"
"<Control-o> to open file from dialog.\n"
@@ -200,7 +189,7 @@
}
_multi_call_spec = {
- 'file': 'MultiCall',
+ 'file': 'multicall',
'kwds': {},
'msg': "The following actions should trigger a print to console or IDLE"
" Shell.\nEntering and leaving the text area, key entry, "
@@ -210,14 +199,14 @@
}
_multistatus_bar_spec = {
- 'file': 'MultiStatusBar',
+ 'file': 'statusbar',
'kwds': {},
'msg': "Ensure presence of multi-status bar below text area.\n"
"Click 'Update Status' to change the multi-status text"
}
_object_browser_spec = {
- 'file': 'ObjectBrowser',
+ 'file': 'debugobj',
'kwds': {},
'msg': "Double click on items upto the lowest level.\n"
"Attributes of the objects and related information "
@@ -225,7 +214,7 @@
}
_path_browser_spec = {
- 'file': 'PathBrowser',
+ 'file': 'pathbrowser',
'kwds': {},
'msg': "Test for correct display of all paths in sys.path.\n"
"Toggle nested items upto the lowest level.\n"
@@ -234,7 +223,7 @@
}
_percolator_spec = {
- 'file': 'Percolator',
+ 'file': 'percolator',
'kwds': {},
'msg': "There are two tracers which can be toggled using a checkbox.\n"
"Toggling a tracer 'on' by checking it should print tracer"
@@ -244,8 +233,19 @@
"Test for actions like text entry, and removal."
}
+Query_spec = {
+ 'file': 'query',
+ 'kwds': {'title':'Query',
+ 'message':'Enter something',
+ '_htest': True},
+ 'msg': "Enter with <Return> or [Ok]. Print valid entry to Shell\n"
+ "Blank line, after stripping, is ignored\n"
+ "Close dialog with valid entry, [Cancel] or [X]",
+ }
+
+
_replace_dialog_spec = {
- 'file': 'ReplaceDialog',
+ 'file': 'replace',
'kwds': {},
'msg': "Click the 'Replace' button.\n"
"Test various replace options in the 'Replace dialog'.\n"
@@ -253,7 +253,7 @@
}
_search_dialog_spec = {
- 'file': 'SearchDialog',
+ 'file': 'search',
'kwds': {},
'msg': "Click the 'Search' button.\n"
"Test various search options in the 'Search dialog'.\n"
@@ -261,7 +261,7 @@
}
_scrolled_list_spec = {
- 'file': 'ScrolledList',
+ 'file': 'scrolledlist',
'kwds': {},
'msg': "You should see a scrollable list of items\n"
"Selecting (clicking) or double clicking an item "
@@ -277,7 +277,7 @@
}
_stack_viewer_spec = {
- 'file': 'StackViewer',
+ 'file': 'stackviewer',
'kwds': {},
'msg': "A stacktrace for a NameError exception.\n"
"Expand 'idlelib ...' and '<locals>'.\n"
@@ -295,8 +295,8 @@
}
TextViewer_spec = {
- 'file': 'textView',
- 'kwds': {'title': 'Test textView',
+ 'file': 'textview',
+ 'kwds': {'title': 'Test textview',
'text':'The quick brown fox jumps over the lazy dog.\n'*35,
'_htest': True},
'msg': "Test for read-only property of text.\n"
@@ -304,21 +304,21 @@
}
_tooltip_spec = {
- 'file': 'ToolTip',
+ 'file': 'tooltip',
'kwds': {},
'msg': "Place mouse cursor over both the buttons\n"
"A tooltip should appear with some text."
}
_tree_widget_spec = {
- 'file': 'TreeWidget',
+ 'file': 'tree',
'kwds': {},
'msg': "The canvas is scrollable.\n"
"Click on folders upto to the lowest level."
}
_undo_delegator_spec = {
- 'file': 'UndoDelegator',
+ 'file': 'undo',
'kwds': {},
'msg': "Click [Undo] to undo any action.\n"
"Click [Redo] to redo any action.\n"
@@ -327,7 +327,7 @@
}
_widget_redirector_spec = {
- 'file': 'WidgetRedirector',
+ 'file': 'redirector',
'kwds': {},
'msg': "Every text insert should be printed to the console."
"or the IDLE shell."
@@ -337,14 +337,13 @@
root = tk.Tk()
root.title('IDLE htest')
root.resizable(0, 0)
- _initializeTkVariantTests(root)
# a scrollable Label like constant width text widget.
frameLabel = tk.Frame(root, padx=10)
frameLabel.pack()
text = tk.Text(frameLabel, wrap='word')
text.configure(bg=root.cget('bg'), relief='flat', height=4, width=70)
- scrollbar = tk.Scrollbar(frameLabel, command=text.yview)
+ scrollbar = Scrollbar(frameLabel, command=text.yview)
text.config(yscrollcommand=scrollbar.set)
scrollbar.pack(side='right', fill='y', expand=False)
text.pack(side='left', fill='both', expand=True)
@@ -365,7 +364,7 @@
test = getattr(mod, test_name)
test_list.append((test_spec, test))
- test_name = tk.StringVar('')
+ test_name = tk.StringVar(root)
callable_object = None
test_kwds = None
diff --git a/Lib/idlelib/idle_test/mock_idle.py b/Lib/idlelib/idle_test/mock_idle.py
index 1672a34..c7b49ef 100644
--- a/Lib/idlelib/idle_test/mock_idle.py
+++ b/Lib/idlelib/idle_test/mock_idle.py
@@ -33,7 +33,7 @@
class Editor:
- '''Minimally imitate EditorWindow.EditorWindow class.
+ '''Minimally imitate editor.EditorWindow class.
'''
def __init__(self, flist=None, filename=None, key=None, root=None):
self.text = Text()
@@ -46,7 +46,7 @@
class UndoDelegator:
- '''Minimally imitate UndoDelegator,UndoDelegator class.
+ '''Minimally imitate undo.UndoDelegator class.
'''
# A real undo block is only needed for user interaction.
def undo_block_start(*args):
diff --git a/Lib/idlelib/idle_test/test_autocomplete.py b/Lib/idlelib/idle_test/test_autocomplete.py
index e4493d1..a14c6db 100644
--- a/Lib/idlelib/idle_test/test_autocomplete.py
+++ b/Lib/idlelib/idle_test/test_autocomplete.py
@@ -1,10 +1,14 @@
+''' Test autocomplete and autocomple_w
+
+Coverage of autocomple: 56%
+'''
import unittest
from test.support import requires
from tkinter import Tk, Text
-import idlelib.AutoComplete as ac
-import idlelib.AutoCompleteWindow as acw
-import idlelib.macosxSupport as mac
+import idlelib.autocomplete as ac
+import idlelib.autocomplete_w as acw
+from idlelib import macosx
from idlelib.idle_test.mock_idle import Func
from idlelib.idle_test.mock_tk import Event
@@ -27,7 +31,7 @@
def setUpClass(cls):
requires('gui')
cls.root = Tk()
- mac.setupApp(cls.root, None)
+ macosx.setupApp(cls.root, None)
cls.text = Text(cls.root)
cls.editor = DummyEditwin(cls.root, cls.text)
diff --git a/Lib/idlelib/idle_test/test_autoexpand.py b/Lib/idlelib/idle_test/test_autoexpand.py
index d2a3156..5d234dd 100644
--- a/Lib/idlelib/idle_test/test_autoexpand.py
+++ b/Lib/idlelib/idle_test/test_autoexpand.py
@@ -1,9 +1,9 @@
-"""Unit tests for idlelib.AutoExpand"""
+"""Unit tests for idlelib.autoexpand"""
import unittest
from test.support import requires
from tkinter import Text, Tk
#from idlelib.idle_test.mock_tk import Text
-from idlelib.AutoExpand import AutoExpand
+from idlelib.autoexpand import AutoExpand
class Dummy_Editwin:
diff --git a/Lib/idlelib/idle_test/test_calltips.py b/Lib/idlelib/idle_test/test_calltips.py
index b2a733c..0b11602 100644
--- a/Lib/idlelib/idle_test/test_calltips.py
+++ b/Lib/idlelib/idle_test/test_calltips.py
@@ -1,5 +1,5 @@
import unittest
-import idlelib.CallTips as ct
+import idlelib.calltips as ct
import textwrap
import types
diff --git a/Lib/idlelib/idle_test/test_colorizer.py b/Lib/idlelib/idle_test/test_colorizer.py
new file mode 100644
index 0000000..238bc3e
--- /dev/null
+++ b/Lib/idlelib/idle_test/test_colorizer.py
@@ -0,0 +1,56 @@
+'''Test idlelib/colorizer.py
+
+Perform minimal sanity checks that module imports and some things run.
+
+Coverage 22%.
+'''
+from idlelib import colorizer # always test import
+from test.support import requires
+from tkinter import Tk, Text
+import unittest
+
+
+class FunctionTest(unittest.TestCase):
+
+ def test_any(self):
+ self.assertTrue(colorizer.any('test', ('a', 'b')))
+
+ def test_make_pat(self):
+ self.assertTrue(colorizer.make_pat())
+
+
+class ColorConfigTest(unittest.TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ requires('gui')
+ cls.root = Tk()
+ cls.text = Text(cls.root)
+
+ @classmethod
+ def tearDownClass(cls):
+ del cls.text
+ cls.root.destroy()
+ del cls.root
+
+ def test_colorizer(self):
+ colorizer.color_config(self.text)
+
+class ColorDelegatorTest(unittest.TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ requires('gui')
+ cls.root = Tk()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.root.destroy()
+ del cls.root
+
+ def test_colorizer(self):
+ colorizer.ColorDelegator()
+
+
+if __name__ == '__main__':
+ unittest.main(verbosity=2)
diff --git a/Lib/idlelib/idle_test/test_config_help.py b/Lib/idlelib/idle_test/test_config_help.py
index 664f8ed..b89b4e3 100644
--- a/Lib/idlelib/idle_test/test_config_help.py
+++ b/Lib/idlelib/idle_test/test_config_help.py
@@ -1,7 +1,7 @@
-"""Unittests for idlelib.configHelpSourceEdit"""
+"""Unittests for idlelib.config_help.py"""
import unittest
from idlelib.idle_test.mock_tk import Var, Mbox, Entry
-from idlelib import configHelpSourceEdit as help_dialog_module
+from idlelib import config_help as help_dialog_module
help_dialog = help_dialog_module.GetHelpSourceDialog
diff --git a/Lib/idlelib/idle_test/test_config_key.py b/Lib/idlelib/idle_test/test_config_key.py
new file mode 100644
index 0000000..8109829
--- /dev/null
+++ b/Lib/idlelib/idle_test/test_config_key.py
@@ -0,0 +1,31 @@
+''' Test idlelib.config_key.
+
+Coverage: 56%
+'''
+from idlelib import config_key
+from test.support import requires
+requires('gui')
+import unittest
+from tkinter import Tk, Text
+
+
+class GetKeysTest(unittest.TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ cls.root = Tk()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.root.destroy()
+ del cls.root
+
+
+ def test_init(self):
+ dia = config_key.GetKeysDialog(
+ self.root, 'test', '<<Test>>', ['<Key-F12>'], _utest=True)
+ dia.Cancel()
+
+
+if __name__ == '__main__':
+ unittest.main(verbosity=2)
diff --git a/Lib/idlelib/idle_test/test_config_name.py b/Lib/idlelib/idle_test/test_config_name.py
deleted file mode 100644
index 40e72b9..0000000
--- a/Lib/idlelib/idle_test/test_config_name.py
+++ /dev/null
@@ -1,75 +0,0 @@
-"""Unit tests for idlelib.configSectionNameDialog"""
-import unittest
-from idlelib.idle_test.mock_tk import Var, Mbox
-from idlelib import configSectionNameDialog as name_dialog_module
-
-name_dialog = name_dialog_module.GetCfgSectionNameDialog
-
-class Dummy_name_dialog:
- # Mock for testing the following methods of name_dialog
- name_ok = name_dialog.name_ok
- Ok = name_dialog.Ok
- Cancel = name_dialog.Cancel
- # Attributes, constant or variable, needed for tests
- used_names = ['used']
- name = Var()
- result = None
- destroyed = False
- def destroy(self):
- self.destroyed = True
-
-# name_ok calls Mbox.showerror if name is not ok
-orig_mbox = name_dialog_module.tkMessageBox
-showerror = Mbox.showerror
-
-class ConfigNameTest(unittest.TestCase):
- dialog = Dummy_name_dialog()
-
- @classmethod
- def setUpClass(cls):
- name_dialog_module.tkMessageBox = Mbox
-
- @classmethod
- def tearDownClass(cls):
- name_dialog_module.tkMessageBox = orig_mbox
-
- def test_blank_name(self):
- self.dialog.name.set(' ')
- self.assertEqual(self.dialog.name_ok(), '')
- self.assertEqual(showerror.title, 'Name Error')
- self.assertIn('No', showerror.message)
-
- def test_used_name(self):
- self.dialog.name.set('used')
- self.assertEqual(self.dialog.name_ok(), '')
- self.assertEqual(showerror.title, 'Name Error')
- self.assertIn('use', showerror.message)
-
- def test_long_name(self):
- self.dialog.name.set('good'*8)
- self.assertEqual(self.dialog.name_ok(), '')
- self.assertEqual(showerror.title, 'Name Error')
- self.assertIn('too long', showerror.message)
-
- def test_good_name(self):
- self.dialog.name.set(' good ')
- showerror.title = 'No Error' # should not be called
- self.assertEqual(self.dialog.name_ok(), 'good')
- self.assertEqual(showerror.title, 'No Error')
-
- def test_ok(self):
- self.dialog.destroyed = False
- self.dialog.name.set('good')
- self.dialog.Ok()
- self.assertEqual(self.dialog.result, 'good')
- self.assertTrue(self.dialog.destroyed)
-
- def test_cancel(self):
- self.dialog.destroyed = False
- self.dialog.Cancel()
- self.assertEqual(self.dialog.result, '')
- self.assertTrue(self.dialog.destroyed)
-
-
-if __name__ == '__main__':
- unittest.main(verbosity=2, exit=False)
diff --git a/Lib/idlelib/idle_test/test_configdialog.py b/Lib/idlelib/idle_test/test_configdialog.py
index b063601..1801a7d 100644
--- a/Lib/idlelib/idle_test/test_configdialog.py
+++ b/Lib/idlelib/idle_test/test_configdialog.py
@@ -1,21 +1,19 @@
-'''Test idlelib.configDialog.
+'''Test idlelib.configdialog.
Coverage: 46% just by creating dialog.
The other half is code for working with user customizations.
'''
-from idlelib.configDialog import ConfigDialog # always test import
+from idlelib.configdialog import ConfigDialog # always test import
from test.support import requires
requires('gui')
from tkinter import Tk
import unittest
-from idlelib import macosxSupport as macosx
class ConfigDialogTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.root = Tk()
- macosx._initializeTkVariantTests(cls.root)
@classmethod
def tearDownClass(cls):
diff --git a/Lib/idlelib/idle_test/test_debugger.py b/Lib/idlelib/idle_test/test_debugger.py
new file mode 100644
index 0000000..bcba9a4
--- /dev/null
+++ b/Lib/idlelib/idle_test/test_debugger.py
@@ -0,0 +1,29 @@
+''' Test idlelib.debugger.
+
+Coverage: 19%
+'''
+from idlelib import debugger
+from test.support import requires
+requires('gui')
+import unittest
+from tkinter import Tk
+
+
+class NameSpaceTest(unittest.TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ cls.root = Tk()
+ cls.root.withdraw()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.root.destroy()
+ del cls.root
+
+ def test_init(self):
+ debugger.NamespaceViewer(self.root, 'Test')
+
+
+if __name__ == '__main__':
+ unittest.main(verbosity=2)
diff --git a/Lib/idlelib/idle_test/test_delegator.py b/Lib/idlelib/idle_test/test_delegator.py
index 1f0baa9..85624fb 100644
--- a/Lib/idlelib/idle_test/test_delegator.py
+++ b/Lib/idlelib/idle_test/test_delegator.py
@@ -1,5 +1,5 @@
import unittest
-from idlelib.Delegator import Delegator
+from idlelib.delegator import Delegator
class DelegatorTest(unittest.TestCase):
diff --git a/Lib/idlelib/idle_test/test_editmenu.py b/Lib/idlelib/idle_test/test_editmenu.py
index 50317a9..654f060 100644
--- a/Lib/idlelib/idle_test/test_editmenu.py
+++ b/Lib/idlelib/idle_test/test_editmenu.py
@@ -5,8 +5,9 @@
from test.support import requires
requires('gui')
import tkinter as tk
+from tkinter import ttk
import unittest
-from idlelib import PyShell
+from idlelib import pyshell
class PasteTest(unittest.TestCase):
'''Test pasting into widgets that allow pasting.
@@ -16,16 +17,17 @@
@classmethod
def setUpClass(cls):
cls.root = root = tk.Tk()
- PyShell.fix_x11_paste(root)
+ pyshell.fix_x11_paste(root)
cls.text = tk.Text(root)
cls.entry = tk.Entry(root)
+ cls.tentry = ttk.Entry(root)
cls.spin = tk.Spinbox(root)
root.clipboard_clear()
root.clipboard_append('two')
@classmethod
def tearDownClass(cls):
- del cls.text, cls.entry, cls.spin
+ del cls.text, cls.entry, cls.tentry
cls.root.clipboard_clear()
cls.root.update_idletasks()
cls.root.destroy()
@@ -43,16 +45,16 @@
def test_paste_entry(self):
"Test pasting into an entry with and without a selection."
- # On 3.6, generated <<Paste>> fails without empty select range
- # for 'no selection'. Live widget works fine.
- entry = self.entry
- for end, ans in (0, 'onetwo'), ('end', 'two'):
- with self.subTest(entry=entry, end=end, ans=ans):
- entry.delete(0, 'end')
- entry.insert(0, 'one')
- entry.select_range(0, end) # see note
- entry.event_generate('<<Paste>>')
- self.assertEqual(entry.get(), ans)
+ # Generated <<Paste>> fails for tk entry without empty select
+ # range for 'no selection'. Live widget works fine.
+ for entry in self.entry, self.tentry:
+ for end, ans in (0, 'onetwo'), ('end', 'two'):
+ with self.subTest(entry=entry, end=end, ans=ans):
+ entry.delete(0, 'end')
+ entry.insert(0, 'one')
+ entry.select_range(0, end)
+ entry.event_generate('<<Paste>>')
+ self.assertEqual(entry.get(), ans)
def test_paste_spin(self):
"Test pasting into a spinbox with and without a selection."
diff --git a/Lib/idlelib/idle_test/test_editor.py b/Lib/idlelib/idle_test/test_editor.py
index a31d26d..e9d29d4 100644
--- a/Lib/idlelib/idle_test/test_editor.py
+++ b/Lib/idlelib/idle_test/test_editor.py
@@ -1,6 +1,6 @@
import unittest
from tkinter import Tk, Text
-from idlelib.EditorWindow import EditorWindow
+from idlelib.editor import EditorWindow
from test.support import requires
class Editor_func_test(unittest.TestCase):
diff --git a/Lib/idlelib/idle_test/test_grep.py b/Lib/idlelib/idle_test/test_grep.py
index 0d8ff0d..6b54c13 100644
--- a/Lib/idlelib/idle_test/test_grep.py
+++ b/Lib/idlelib/idle_test/test_grep.py
@@ -1,5 +1,5 @@
""" !Changing this line will break Test_findfile.test_found!
-Non-gui unit tests for idlelib.GrepDialog methods.
+Non-gui unit tests for grep.GrepDialog methods.
dummy_command calls grep_it calls findfiles.
An exception raised in one method will fail callers.
Otherwise, tests are mostly independent.
@@ -8,7 +8,7 @@
import unittest
from test.support import captured_stdout
from idlelib.idle_test.mock_tk import Var
-from idlelib.GrepDialog import GrepDialog
+from idlelib.grep import GrepDialog
import re
class Dummy_searchengine:
@@ -72,7 +72,7 @@
self.assertTrue(lines[4].startswith('(Hint:'))
class Default_commandTest(unittest.TestCase):
- # To write this, mode OutputWindow import to top of GrepDialog
+ # To write this, move outwin import to top of GrepDialog
# so it can be replaced by captured_stdout in class setup/teardown.
pass
diff --git a/Lib/idlelib/idle_test/test_help.py b/Lib/idlelib/idle_test/test_help.py
new file mode 100644
index 0000000..cdded2a
--- /dev/null
+++ b/Lib/idlelib/idle_test/test_help.py
@@ -0,0 +1,34 @@
+'''Test idlelib.help.
+
+Coverage: 87%
+'''
+from idlelib import help
+from test.support import requires
+requires('gui')
+from os.path import abspath, dirname, join
+from tkinter import Tk
+import unittest
+
+class HelpFrameTest(unittest.TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ "By itself, this tests that file parsed without exception."
+ cls.root = root = Tk()
+ root.withdraw()
+ helpfile = join(abspath(dirname(dirname(__file__))), 'help.html')
+ cls.frame = help.HelpFrame(root, helpfile)
+
+ @classmethod
+ def tearDownClass(cls):
+ del cls.frame
+ cls.root.update_idletasks()
+ cls.root.destroy()
+ del cls.root
+
+ def test_line1(self):
+ text = self.frame.text
+ self.assertEqual(text.get('1.0', '1.end'), ' IDLE ')
+
+if __name__ == '__main__':
+ unittest.main(verbosity=2)
diff --git a/Lib/idlelib/idle_test/test_help_about.py b/Lib/idlelib/idle_test/test_help_about.py
index d0a0127..843efb9 100644
--- a/Lib/idlelib/idle_test/test_help_about.py
+++ b/Lib/idlelib/idle_test/test_help_about.py
@@ -2,10 +2,10 @@
Coverage:
'''
-from idlelib import aboutDialog as help_about
-from idlelib import textView as textview
+from idlelib import help_about
+from idlelib import textview
from idlelib.idle_test.mock_idle import Func
-from idlelib.idle_test.mock_tk import Mbox
+from idlelib.idle_test.mock_tk import Mbox_func
import unittest
About = help_about.AboutDialog
@@ -19,33 +19,33 @@
class DisplayFileTest(unittest.TestCase):
- "Test that .txt files are found and properly decoded."
dialog = Dummy_about_dialog()
@classmethod
def setUpClass(cls):
- cls.orig_mbox = textview.tkMessageBox
+ cls.orig_error = textview.showerror
cls.orig_view = textview.view_text
- cls.mbox = Mbox()
+ cls.error = Mbox_func()
cls.view = Func()
- textview.tkMessageBox = cls.mbox
+ textview.showerror = cls.error
textview.view_text = cls.view
cls.About = Dummy_about_dialog()
@classmethod
def tearDownClass(cls):
- textview.tkMessageBox = cls.orig_mbox
+ textview.showerror = cls.orig_error
textview.view_text = cls.orig_view
def test_file_isplay(self):
for handler in (self.dialog.idle_credits,
self.dialog.idle_readme,
self.dialog.idle_news):
- self.mbox.showerror.message = ''
+ self.error.message = ''
self.view.called = False
- handler()
- self.assertEqual(self.mbox.showerror.message, '')
- self.assertEqual(self.view.called, True)
+ with self.subTest(handler=handler):
+ handler()
+ self.assertEqual(self.error.message, '')
+ self.assertEqual(self.view.called, True)
if __name__ == '__main__':
diff --git a/Lib/idlelib/idle_test/test_idlehistory.py b/Lib/idlelib/idle_test/test_history.py
similarity index 98%
rename from Lib/idlelib/idle_test/test_idlehistory.py
rename to Lib/idlelib/idle_test/test_history.py
index d7c3d70..6e8269c 100644
--- a/Lib/idlelib/idle_test/test_idlehistory.py
+++ b/Lib/idlelib/idle_test/test_history.py
@@ -4,8 +4,8 @@
import tkinter as tk
from tkinter import Text as tkText
from idlelib.idle_test.mock_tk import Text as mkText
-from idlelib.IdleHistory import History
-from idlelib.configHandler import idleConf
+from idlelib.history import History
+from idlelib.config import idleConf
line1 = 'a = 7'
line2 = 'b = a'
diff --git a/Lib/idlelib/idle_test/test_hyperparser.py b/Lib/idlelib/idle_test/test_hyperparser.py
index edfc783..067e5b1 100644
--- a/Lib/idlelib/idle_test/test_hyperparser.py
+++ b/Lib/idlelib/idle_test/test_hyperparser.py
@@ -1,9 +1,9 @@
-"""Unittest for idlelib.HyperParser"""
+"""Unittest for idlelib.hyperparser.py."""
import unittest
from test.support import requires
from tkinter import Tk, Text
-from idlelib.EditorWindow import EditorWindow
-from idlelib.HyperParser import HyperParser
+from idlelib.editor import EditorWindow
+from idlelib.hyperparser import HyperParser
class DummyEditwin:
def __init__(self, text):
diff --git a/Lib/idlelib/idle_test/test_io.py b/Lib/idlelib/idle_test/test_iomenu.py
similarity index 98%
rename from Lib/idlelib/idle_test/test_io.py
rename to Lib/idlelib/idle_test/test_iomenu.py
index e0e3b98..f8ff112 100644
--- a/Lib/idlelib/idle_test/test_io.py
+++ b/Lib/idlelib/idle_test/test_iomenu.py
@@ -1,6 +1,6 @@
import unittest
import io
-from idlelib.PyShell import PseudoInputFile, PseudoOutputFile
+from idlelib.pyshell import PseudoInputFile, PseudoOutputFile
class S(str):
diff --git a/Lib/idlelib/idle_test/test_macosx.py b/Lib/idlelib/idle_test/test_macosx.py
new file mode 100644
index 0000000..3c6161c
--- /dev/null
+++ b/Lib/idlelib/idle_test/test_macosx.py
@@ -0,0 +1,101 @@
+'''Test idlelib.macosx.py.
+
+Coverage: 71% on Windows.
+'''
+from idlelib import macosx
+from test.support import requires
+import sys
+import tkinter as tk
+import unittest
+import unittest.mock as mock
+from idlelib.filelist import FileList
+
+mactypes = {'carbon', 'cocoa', 'xquartz'}
+nontypes = {'other'}
+alltypes = mactypes | nontypes
+
+
+class InitTktypeTest(unittest.TestCase):
+ "Test _init_tk_type."
+
+ @classmethod
+ def setUpClass(cls):
+ requires('gui')
+ cls.root = tk.Tk()
+ cls.orig_platform = macosx.platform
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.root.update_idletasks()
+ cls.root.destroy()
+ del cls.root
+ macosx.platform = cls.orig_platform
+
+ def test_init_sets_tktype(self):
+ "Test that _init_tk_type sets _tk_type according to platform."
+ for platform, types in ('darwin', alltypes), ('other', nontypes):
+ with self.subTest(platform=platform):
+ macosx.platform = platform
+ macosx._tk_type == None
+ macosx._init_tk_type()
+ self.assertIn(macosx._tk_type, types)
+
+
+class IsTypeTkTest(unittest.TestCase):
+ "Test each of the four isTypeTk predecates."
+ isfuncs = ((macosx.isAquaTk, ('carbon', 'cocoa')),
+ (macosx.isCarbonTk, ('carbon')),
+ (macosx.isCocoaTk, ('cocoa')),
+ (macosx.isXQuartz, ('xquartz')),
+ )
+
+ @mock.patch('idlelib.macosx._init_tk_type')
+ def test_is_calls_init(self, mockinit):
+ "Test that each isTypeTk calls _init_tk_type when _tk_type is None."
+ macosx._tk_type = None
+ for func, whentrue in self.isfuncs:
+ with self.subTest(func=func):
+ func()
+ self.assertTrue(mockinit.called)
+ mockinit.reset_mock()
+
+ def test_isfuncs(self):
+ "Test that each isTypeTk return correct bool."
+ for func, whentrue in self.isfuncs:
+ for tktype in alltypes:
+ with self.subTest(func=func, whentrue=whentrue, tktype=tktype):
+ macosx._tk_type = tktype
+ (self.assertTrue if tktype in whentrue else self.assertFalse)\
+ (func())
+
+
+class SetupTest(unittest.TestCase):
+ "Test setupApp."
+
+ @classmethod
+ def setUpClass(cls):
+ requires('gui')
+ cls.root = tk.Tk()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.root.update_idletasks()
+ cls.root.destroy()
+ del cls.root
+
+ @mock.patch('idlelib.macosx.overrideRootMenu') #27312
+ def test_setupapp(self, overrideRootMenu):
+ "Call setupApp with each possible graphics type."
+ root = self.root
+ flist = FileList(root)
+ for tktype in alltypes:
+ with self.subTest(tktype=tktype):
+ macosx._tk_type = tktype
+ macosx.setupApp(root, flist)
+ if tktype in ('carbon', 'cocoa'):
+ self.assertTrue(overrideRootMenu.called)
+ overrideRootMenu.reset_mock()
+
+
+if __name__ == '__main__':
+ unittest.main(verbosity=2)
diff --git a/Lib/idlelib/idle_test/test_formatparagraph.py b/Lib/idlelib/idle_test/test_paragraph.py
similarity index 98%
rename from Lib/idlelib/idle_test/test_formatparagraph.py
rename to Lib/idlelib/idle_test/test_paragraph.py
index e5561d8..4741eb8 100644
--- a/Lib/idlelib/idle_test/test_formatparagraph.py
+++ b/Lib/idlelib/idle_test/test_paragraph.py
@@ -1,7 +1,7 @@
-# Test the functions and main class method of FormatParagraph.py
+# Test the functions and main class method of paragraph.py
import unittest
-from idlelib import FormatParagraph as fp
-from idlelib.EditorWindow import EditorWindow
+from idlelib import paragraph as fp
+from idlelib.editor import EditorWindow
from tkinter import Tk, Text
from test.support import requires
@@ -38,7 +38,7 @@
class FindTest(unittest.TestCase):
- """Test the find_paragraph function in FormatParagraph.
+ """Test the find_paragraph function in paragraph module.
Using the runcase() function, find_paragraph() is called with 'mark' set at
multiple indexes before and inside the test paragraph.
diff --git a/Lib/idlelib/idle_test/test_parenmatch.py b/Lib/idlelib/idle_test/test_parenmatch.py
index 95cc22c..d467a9a 100644
--- a/Lib/idlelib/idle_test/test_parenmatch.py
+++ b/Lib/idlelib/idle_test/test_parenmatch.py
@@ -1,4 +1,4 @@
-'''Test idlelib.ParenMatch.
+'''Test idlelib.parenmatch.
This must currently be a gui test because ParenMatch methods use
several text methods not defined on idlelib.idle_test.mock_tk.Text.
@@ -9,7 +9,7 @@
import unittest
from unittest.mock import Mock
from tkinter import Tk, Text
-from idlelib.ParenMatch import ParenMatch
+from idlelib.parenmatch import ParenMatch
class DummyEditwin:
def __init__(self, text):
diff --git a/Lib/idlelib/idle_test/test_pathbrowser.py b/Lib/idlelib/idle_test/test_pathbrowser.py
index afb886f..813cbcc 100644
--- a/Lib/idlelib/idle_test/test_pathbrowser.py
+++ b/Lib/idlelib/idle_test/test_pathbrowser.py
@@ -2,13 +2,13 @@
import os
import sys
import idlelib
-from idlelib import PathBrowser
+from idlelib import pathbrowser
class PathBrowserTest(unittest.TestCase):
def test_DirBrowserTreeItem(self):
# Issue16226 - make sure that getting a sublist works
- d = PathBrowser.DirBrowserTreeItem('')
+ d = pathbrowser.DirBrowserTreeItem('')
d.GetSubList()
self.assertEqual('', d.GetText())
@@ -17,11 +17,11 @@
self.assertEqual(d.ispackagedir(dir + '/Icons'), False)
def test_PathBrowserTreeItem(self):
- p = PathBrowser.PathBrowserTreeItem()
+ p = pathbrowser.PathBrowserTreeItem()
self.assertEqual(p.GetText(), 'sys.path')
sub = p.GetSubList()
self.assertEqual(len(sub), len(sys.path))
- self.assertEqual(type(sub[0]), PathBrowser.DirBrowserTreeItem)
+ self.assertEqual(type(sub[0]), pathbrowser.DirBrowserTreeItem)
if __name__ == '__main__':
unittest.main(verbosity=2, exit=False)
diff --git a/Lib/idlelib/idle_test/test_percolator.py b/Lib/idlelib/idle_test/test_percolator.py
index 4c0a7ad..573b9a1 100644
--- a/Lib/idlelib/idle_test/test_percolator.py
+++ b/Lib/idlelib/idle_test/test_percolator.py
@@ -1,10 +1,10 @@
-'''Test Percolator'''
+'''Test percolator.py.'''
from test.support import requires
requires('gui')
import unittest
from tkinter import Text, Tk, END
-from idlelib.Percolator import Percolator, Delegator
+from idlelib.percolator import Percolator, Delegator
class MyFilter(Delegator):
diff --git a/Lib/idlelib/idle_test/test_query.py b/Lib/idlelib/idle_test/test_query.py
new file mode 100644
index 0000000..e9c4bd4
--- /dev/null
+++ b/Lib/idlelib/idle_test/test_query.py
@@ -0,0 +1,164 @@
+"""Test idlelib.query.
+
+Coverage: 100%.
+"""
+from test.support import requires
+from tkinter import Tk
+import unittest
+from unittest import mock
+from idlelib.idle_test.mock_tk import Var, Mbox_func
+from idlelib import query
+Query, SectionName = query.Query, query.SectionName
+
+class Dummy_Query:
+ # Mock for testing the following methods Query
+ entry_ok = Query.entry_ok
+ ok = Query.ok
+ cancel = Query.cancel
+ # Attributes, constant or variable, needed for tests
+ entry = Var()
+ result = None
+ destroyed = False
+ def destroy(self):
+ self.destroyed = True
+
+# entry_ok calls modal messagebox.showerror if entry is not ok.
+# Mock showerrer returns, so don't need to click to continue.
+orig_showerror = query.showerror
+showerror = Mbox_func() # Instance has __call__ method.
+
+def setUpModule():
+ query.showerror = showerror
+
+def tearDownModule():
+ query.showerror = orig_showerror
+
+
+class QueryTest(unittest.TestCase):
+ dialog = Dummy_Query()
+
+ def setUp(self):
+ showerror.title = None
+ self.dialog.result = None
+ self.dialog.destroyed = False
+
+ def test_blank_entry(self):
+ dialog = self.dialog
+ Equal = self.assertEqual
+ dialog.entry.set(' ')
+ Equal(dialog.entry_ok(), '')
+ Equal((dialog.result, dialog.destroyed), (None, False))
+ Equal(showerror.title, 'Entry Error')
+ self.assertIn('Blank', showerror.message)
+
+ def test_good_entry(self):
+ dialog = self.dialog
+ Equal = self.assertEqual
+ dialog.entry.set(' good ')
+ Equal(dialog.entry_ok(), 'good')
+ Equal((dialog.result, dialog.destroyed), (None, False))
+ Equal(showerror.title, None)
+
+ def test_ok(self):
+ dialog = self.dialog
+ Equal = self.assertEqual
+ dialog.entry.set('good')
+ Equal(dialog.ok(), None)
+ Equal((dialog.result, dialog.destroyed), ('good', True))
+
+ def test_cancel(self):
+ dialog = self.dialog
+ Equal = self.assertEqual
+ Equal(self.dialog.cancel(), None)
+ Equal((dialog.result, dialog.destroyed), (None, True))
+
+
+class Dummy_SectionName:
+ # Mock for testing the following method of Section_Name
+ entry_ok = SectionName.entry_ok
+ # Attributes, constant or variable, needed for tests
+ used_names = ['used']
+ entry = Var()
+
+class SectionNameTest(unittest.TestCase):
+ dialog = Dummy_SectionName()
+
+
+ def setUp(self):
+ showerror.title = None
+
+ def test_blank_name(self):
+ dialog = self.dialog
+ Equal = self.assertEqual
+ dialog.entry.set(' ')
+ Equal(dialog.entry_ok(), '')
+ Equal(showerror.title, 'Name Error')
+ self.assertIn('No', showerror.message)
+
+ def test_used_name(self):
+ dialog = self.dialog
+ Equal = self.assertEqual
+ dialog.entry.set('used')
+ Equal(self.dialog.entry_ok(), '')
+ Equal(showerror.title, 'Name Error')
+ self.assertIn('use', showerror.message)
+
+ def test_long_name(self):
+ dialog = self.dialog
+ Equal = self.assertEqual
+ dialog.entry.set('good'*8)
+ Equal(self.dialog.entry_ok(), '')
+ Equal(showerror.title, 'Name Error')
+ self.assertIn('too long', showerror.message)
+
+ def test_good_entry(self):
+ dialog = self.dialog
+ Equal = self.assertEqual
+ dialog.entry.set(' good ')
+ Equal(dialog.entry_ok(), 'good')
+ Equal(showerror.title, None)
+
+
+class QueryGuiTest(unittest.TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ requires('gui')
+ cls.root = Tk()
+ cls.dialog = Query(cls.root, 'TEST', 'test', _utest=True)
+ cls.dialog.destroy = mock.Mock()
+
+ @classmethod
+ def tearDownClass(cls):
+ del cls.dialog
+ cls.root.destroy()
+ del cls.root
+
+ def setUp(self):
+ self.dialog.entry.delete(0, 'end')
+ self.dialog.result = None
+ self.dialog.destroy.reset_mock()
+
+ def test_click_ok(self):
+ dialog = self.dialog
+ dialog.entry.insert(0, 'abc')
+ dialog.button_ok.invoke()
+ self.assertEqual(dialog.result, 'abc')
+ self.assertTrue(dialog.destroy.called)
+
+ def test_click_blank(self):
+ dialog = self.dialog
+ dialog.button_ok.invoke()
+ self.assertEqual(dialog.result, None)
+ self.assertFalse(dialog.destroy.called)
+
+ def test_click_cancel(self):
+ dialog = self.dialog
+ dialog.entry.insert(0, 'abc')
+ dialog.button_cancel.invoke()
+ self.assertEqual(dialog.result, None)
+ self.assertTrue(dialog.destroy.called)
+
+
+if __name__ == '__main__':
+ unittest.main(verbosity=2, exit=False)
diff --git a/Lib/idlelib/idle_test/test_widgetredir.py b/Lib/idlelib/idle_test/test_redirector.py
similarity index 97%
rename from Lib/idlelib/idle_test/test_widgetredir.py
rename to Lib/idlelib/idle_test/test_redirector.py
index c68dfcc..c8dd118 100644
--- a/Lib/idlelib/idle_test/test_widgetredir.py
+++ b/Lib/idlelib/idle_test/test_redirector.py
@@ -1,4 +1,4 @@
-'''Test idlelib.WidgetRedirector.
+'''Test idlelib.redirector.
100% coverage
'''
@@ -6,7 +6,7 @@
import unittest
from idlelib.idle_test.mock_idle import Func
from tkinter import Tk, Text, TclError
-from idlelib.WidgetRedirector import WidgetRedirector
+from idlelib.redirector import WidgetRedirector
class InitCloseTest(unittest.TestCase):
@@ -118,6 +118,5 @@
self.assertEqual(self.root.call(self.text._w, 'insert', 'boo'), '')
-
if __name__ == '__main__':
unittest.main(verbosity=2)
diff --git a/Lib/idlelib/idle_test/test_replacedialog.py b/Lib/idlelib/idle_test/test_replace.py
similarity index 98%
rename from Lib/idlelib/idle_test/test_replacedialog.py
rename to Lib/idlelib/idle_test/test_replace.py
index ff44820..a9f3e15 100644
--- a/Lib/idlelib/idle_test/test_replacedialog.py
+++ b/Lib/idlelib/idle_test/test_replace.py
@@ -1,4 +1,4 @@
-"""Unittest for idlelib.ReplaceDialog"""
+"""Unittest for idlelib.replace.py"""
from test.support import requires
requires('gui')
@@ -6,8 +6,8 @@
from unittest.mock import Mock
from tkinter import Tk, Text
from idlelib.idle_test.mock_tk import Mbox
-import idlelib.SearchEngine as se
-import idlelib.ReplaceDialog as rd
+import idlelib.searchengine as se
+import idlelib.replace as rd
orig_mbox = se.tkMessageBox
showerror = Mbox.showerror
diff --git a/Lib/idlelib/idle_test/test_rstrip.py b/Lib/idlelib/idle_test/test_rstrip.py
index 1c90b93..130e6be 100644
--- a/Lib/idlelib/idle_test/test_rstrip.py
+++ b/Lib/idlelib/idle_test/test_rstrip.py
@@ -1,5 +1,5 @@
import unittest
-import idlelib.RstripExtension as rs
+import idlelib.rstrip as rs
from idlelib.idle_test.mock_idle import Editor
class rstripTest(unittest.TestCase):
@@ -21,7 +21,7 @@
def test_rstrip_multiple(self):
editor = Editor()
# Uncomment following to verify that test passes with real widgets.
-## from idlelib.EditorWindow import EditorWindow as Editor
+## from idlelib.editor import EditorWindow as Editor
## from tkinter import Tk
## editor = Editor(root=Tk())
text = editor.text
diff --git a/Lib/idlelib/idle_test/test_scrolledlist.py b/Lib/idlelib/idle_test/test_scrolledlist.py
new file mode 100644
index 0000000..56aabfe
--- /dev/null
+++ b/Lib/idlelib/idle_test/test_scrolledlist.py
@@ -0,0 +1,29 @@
+''' Test idlelib.scrolledlist.
+
+Coverage: 39%
+'''
+from idlelib import scrolledlist
+from test.support import requires
+requires('gui')
+import unittest
+from tkinter import Tk
+
+
+class ScrolledListTest(unittest.TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ cls.root = Tk()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.root.destroy()
+ del cls.root
+
+
+ def test_init(self):
+ scrolledlist.ScrolledList(self.root)
+
+
+if __name__ == '__main__':
+ unittest.main(verbosity=2)
diff --git a/Lib/idlelib/idle_test/test_searchdialog.py b/Lib/idlelib/idle_test/test_search.py
similarity index 94%
rename from Lib/idlelib/idle_test/test_searchdialog.py
rename to Lib/idlelib/idle_test/test_search.py
index 190c866..0735d84 100644
--- a/Lib/idlelib/idle_test/test_searchdialog.py
+++ b/Lib/idlelib/idle_test/test_search.py
@@ -1,4 +1,4 @@
-"""Test SearchDialog class in SearchDialogue.py"""
+"""Test SearchDialog class in idlelib.search.py"""
# Does not currently test the event handler wrappers.
# A usage test should simulate clicks and check hilighting.
@@ -11,8 +11,8 @@
import unittest
import tkinter as tk
from tkinter import BooleanVar
-import idlelib.SearchEngine as se
-import idlelib.SearchDialog as sd
+import idlelib.searchengine as se
+import idlelib.search as sd
class SearchDialogTest(unittest.TestCase):
diff --git a/Lib/idlelib/idle_test/test_searchdialogbase.py b/Lib/idlelib/idle_test/test_searchbase.py
similarity index 94%
rename from Lib/idlelib/idle_test/test_searchdialogbase.py
rename to Lib/idlelib/idle_test/test_searchbase.py
index 8036b91..a0b1231 100644
--- a/Lib/idlelib/idle_test/test_searchdialogbase.py
+++ b/Lib/idlelib/idle_test/test_searchbase.py
@@ -1,4 +1,4 @@
-'''Unittests for idlelib/SearchDialogBase.py
+'''Unittests for idlelib/searchbase.py
Coverage: 99%. The only thing not covered is inconsequential --
testing skipping of suite when self.needwrapbutton is false.
@@ -7,8 +7,8 @@
import unittest
from test.support import requires
from tkinter import Tk, Toplevel, Frame ##, BooleanVar, StringVar
-from idlelib import SearchEngine as se
-from idlelib import SearchDialogBase as sdb
+from idlelib import searchengine as se
+from idlelib import searchbase as sdb
from idlelib.idle_test.mock_idle import Func
## from idlelib.idle_test.mock_tk import Var
@@ -74,7 +74,7 @@
def test_make_entry(self):
equal = self.assertEqual
self.dialog.row = 0
- self.dialog.top = Toplevel(self.root)
+ self.dialog.top = self.root
entry, label = self.dialog.make_entry("Test:", 'hello')
equal(label['text'], 'Test:')
@@ -87,6 +87,7 @@
equal(self.dialog.row, 1)
def test_create_entries(self):
+ self.dialog.top = self.root
self.dialog.row = 0
self.engine.setpat('hello')
self.dialog.create_entries()
@@ -94,7 +95,7 @@
def test_make_frame(self):
self.dialog.row = 0
- self.dialog.top = Toplevel(self.root)
+ self.dialog.top = self.root
frame, label = self.dialog.make_frame()
self.assertEqual(label, '')
self.assertIsInstance(frame, Frame)
@@ -104,7 +105,7 @@
self.assertIsInstance(frame, Frame)
def btn_test_setup(self, meth):
- self.dialog.top = Toplevel(self.root)
+ self.dialog.top = self.root
self.dialog.row = 0
return meth()
@@ -145,12 +146,13 @@
self.assertEqual(var.get(), state)
def test_make_button(self):
- self.dialog.top = Toplevel(self.root)
+ self.dialog.top = self.root
self.dialog.buttonframe = Frame(self.dialog.top)
btn = self.dialog.make_button('Test', self.dialog.close)
self.assertEqual(btn['text'], 'Test')
def test_create_command_buttons(self):
+ self.dialog.top = self.root
self.dialog.create_command_buttons()
# Look for close button command in buttonframe
closebuttoncommand = ''
diff --git a/Lib/idlelib/idle_test/test_searchengine.py b/Lib/idlelib/idle_test/test_searchengine.py
index edbd558..7e6f8b7 100644
--- a/Lib/idlelib/idle_test/test_searchengine.py
+++ b/Lib/idlelib/idle_test/test_searchengine.py
@@ -1,4 +1,4 @@
-'''Test functions and SearchEngine class in SearchEngine.py.'''
+'''Test functions and SearchEngine class in idlelib.searchengine.py.'''
# With mock replacements, the module does not use any gui widgets.
# The use of tk.Text is avoided (for now, until mock Text is improved)
@@ -10,7 +10,7 @@
# from test.support import requires
from tkinter import BooleanVar, StringVar, TclError # ,Tk, Text
import tkinter.messagebox as tkMessageBox
-from idlelib import SearchEngine as se
+from idlelib import searchengine as se
from idlelib.idle_test.mock_tk import Var, Mbox
from idlelib.idle_test.mock_tk import Text as mockText
diff --git a/Lib/idlelib/idle_test/test_text.py b/Lib/idlelib/idle_test/test_text.py
index 7e823df..a5ba7bb 100644
--- a/Lib/idlelib/idle_test/test_text.py
+++ b/Lib/idlelib/idle_test/test_text.py
@@ -1,17 +1,19 @@
-# Test mock_tk.Text class against tkinter.Text class by running same tests with both.
+''' Test mock_tk.Text class against tkinter.Text class
+
+Run same tests with both by creating a mixin class.
+'''
import unittest
from test.support import requires
-
from _tkinter import TclError
class TextTest(object):
+ "Define items common to both sets of tests."
- hw = 'hello\nworld' # usual initial insert after initialization
+ hw = 'hello\nworld' # Several tests insert this after after initialization.
hwn = hw+'\n' # \n present at initialization, before insert
- Text = None
- def setUp(self):
- self.text = self.Text()
+ # setUpClass defines cls.Text and maybe cls.root.
+ # setUp defines self.text from Text and maybe root.
def test_init(self):
self.assertEqual(self.text.get('1.0'), '\n')
@@ -196,6 +198,10 @@
from idlelib.idle_test.mock_tk import Text
cls.Text = Text
+ def setUp(self):
+ self.text = self.Text()
+
+
def test_decode(self):
# test endflags (-1, 0) not tested by test_index (which uses +1)
decode = self.text._decode
@@ -222,6 +228,9 @@
cls.root.destroy()
del cls.root
+ def setUp(self):
+ self.text = self.Text(self.root)
+
if __name__ == '__main__':
unittest.main(verbosity=2, exit=False)
diff --git a/Lib/idlelib/idle_test/test_textview.py b/Lib/idlelib/idle_test/test_textview.py
index 02d1472..0c625ee 100644
--- a/Lib/idlelib/idle_test/test_textview.py
+++ b/Lib/idlelib/idle_test/test_textview.py
@@ -1,21 +1,21 @@
-'''Test idlelib.textView.
+'''Test idlelib.textview.
Since all methods and functions create (or destroy) a TextViewer, which
is a widget containing multiple widgets, all tests must be gui tests.
Using mock Text would not change this. Other mocks are used to retrieve
information about calls.
-The coverage is essentially 100%.
+Coverage: 94%.
'''
+from idlelib import textview as tv
from test.support import requires
requires('gui')
import unittest
import os
from tkinter import Tk
-from idlelib import textView as tv
from idlelib.idle_test.mock_idle import Func
-from idlelib.idle_test.mock_tk import Mbox
+from idlelib.idle_test.mock_tk import Mbox_func
def setUpModule():
global root
@@ -64,17 +64,17 @@
view.destroy
-class textviewTest(unittest.TestCase):
+class ViewFunctionTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
- cls.orig_mbox = tv.tkMessageBox
- tv.tkMessageBox = Mbox
+ cls.orig_error = tv.showerror
+ tv.showerror = Mbox_func()
@classmethod
def tearDownClass(cls):
- tv.tkMessageBox = cls.orig_mbox
- del cls.orig_mbox
+ tv.showerror = cls.orig_error
+ del cls.orig_error
def test_view_text(self):
# If modal True, tkinter will error with 'can't invoke "event" command'
@@ -89,7 +89,7 @@
self.assertIn('Test', view.textView.get('1.0', '1.end'))
view.Ok()
- # Mock messagebox will be used and view_file will not return anything
+ # Mock showerror will be used and view_file will return None
testfile = os.path.join(test_dir, '../notthere.py')
view = tv.view_file(root, 'Title', testfile, modal=False)
self.assertIsNone(view)
diff --git a/Lib/idlelib/idle_test/test_tree.py b/Lib/idlelib/idle_test/test_tree.py
new file mode 100644
index 0000000..09ba964
--- /dev/null
+++ b/Lib/idlelib/idle_test/test_tree.py
@@ -0,0 +1,36 @@
+''' Test idlelib.tree.
+
+Coverage: 56%
+'''
+from idlelib import tree
+from test.support import requires
+requires('gui')
+import os
+import unittest
+from tkinter import Tk
+
+
+class TreeTest(unittest.TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ cls.root = Tk()
+ cls.root.withdraw()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.root.destroy()
+ del cls.root
+
+ def test_init(self):
+ # Start with code slightly adapted from htest.
+ sc = tree.ScrolledCanvas(
+ self.root, bg="white", highlightthickness=0, takefocus=1)
+ sc.frame.pack(expand=1, fill="both", side='left')
+ item = tree.FileTreeItem(tree.ICONDIR)
+ node = tree.TreeNode(sc.canvas, None, item)
+ node.expand()
+
+
+if __name__ == '__main__':
+ unittest.main(verbosity=2)
diff --git a/Lib/idlelib/idle_test/test_undodelegator.py b/Lib/idlelib/idle_test/test_undo.py
similarity index 96%
rename from Lib/idlelib/idle_test/test_undodelegator.py
rename to Lib/idlelib/idle_test/test_undo.py
index 2b83c99..80f1b80 100644
--- a/Lib/idlelib/idle_test/test_undodelegator.py
+++ b/Lib/idlelib/idle_test/test_undo.py
@@ -1,4 +1,4 @@
-"""Unittest for UndoDelegator in idlelib.UndoDelegator.
+"""Unittest for UndoDelegator in idlelib.undo.py.
Coverage about 80% (retest).
"""
@@ -8,8 +8,8 @@
import unittest
from unittest.mock import Mock
from tkinter import Text, Tk
-from idlelib.UndoDelegator import UndoDelegator
-from idlelib.Percolator import Percolator
+from idlelib.undo import UndoDelegator
+from idlelib.percolator import Percolator
class UndoDelegatorTest(unittest.TestCase):
diff --git a/Lib/idlelib/idle_test/test_warning.py b/Lib/idlelib/idle_test/test_warning.py
index 18627dd..f3269f1 100644
--- a/Lib/idlelib/idle_test/test_warning.py
+++ b/Lib/idlelib/idle_test/test_warning.py
@@ -1,4 +1,4 @@
-'''Test warnings replacement in PyShell.py and run.py.
+'''Test warnings replacement in pyshell.py and run.py.
This file could be expanded to include traceback overrides
(in same two modules). If so, change name.
@@ -17,9 +17,9 @@
running_in_idle = 'idle' in showwarning.__name__
from idlelib import run
-from idlelib import PyShell as shell
+from idlelib import pyshell as shell
-# The following was generated from PyShell.idle_formatwarning
+# The following was generated from pyshell.idle_formatwarning
# and checked as matching expectation.
idlemsg = '''
Warning (from warnings module):
diff --git a/Lib/idlelib/idlever.py b/Lib/idlelib/idlever.py
deleted file mode 100644
index 3e9f69a..0000000
--- a/Lib/idlelib/idlever.py
+++ /dev/null
@@ -1,12 +0,0 @@
-"""
-The separate Idle version was eliminated years ago;
-idlelib.idlever is no longer used by Idle
-and will be removed in 3.6 or later. Use
- from sys import version
- IDLE_VERSION = version[:version.index(' ')]
-"""
-# Kept for now only for possible existing extension use
-import warnings as w
-w.warn(__doc__, DeprecationWarning, stacklevel=2)
-from sys import version
-IDLE_VERSION = version[:version.index(' ')]
diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/iomenu.py
similarity index 89%
rename from Lib/idlelib/IOBinding.py
rename to Lib/idlelib/iomenu.py
index 84f39a2..18c68bd 100644
--- a/Lib/idlelib/IOBinding.py
+++ b/Lib/idlelib/iomenu.py
@@ -10,57 +10,60 @@
import tkinter.messagebox as tkMessageBox
from tkinter.simpledialog import askstring
-from idlelib.configHandler import idleConf
+import idlelib
+from idlelib.config import idleConf
-
-# Try setting the locale, so that we can find out
-# what encoding to use
-try:
- import locale
- locale.setlocale(locale.LC_CTYPE, "")
-except (ImportError, locale.Error):
- pass
-
-# Encoding for file names
-filesystemencoding = sys.getfilesystemencoding() ### currently unused
-
-locale_encoding = 'ascii'
-if sys.platform == 'win32':
- # On Windows, we could use "mbcs". However, to give the user
- # a portable encoding name, we need to find the code page
- try:
- locale_encoding = locale.getdefaultlocale()[1]
- codecs.lookup(locale_encoding)
- except LookupError:
- pass
+if idlelib.testing: # Set True by test.test_idle to avoid setlocale.
+ encoding = 'utf-8'
else:
+ # Try setting the locale, so that we can find out
+ # what encoding to use
try:
- # Different things can fail here: the locale module may not be
- # loaded, it may not offer nl_langinfo, or CODESET, or the
- # resulting codeset may be unknown to Python. We ignore all
- # these problems, falling back to ASCII
- locale_encoding = locale.nl_langinfo(locale.CODESET)
- if locale_encoding is None or locale_encoding is '':
- # situation occurs on Mac OS X
- locale_encoding = 'ascii'
- codecs.lookup(locale_encoding)
- except (NameError, AttributeError, LookupError):
- # Try getdefaultlocale: it parses environment variables,
- # which may give a clue. Unfortunately, getdefaultlocale has
- # bugs that can cause ValueError.
+ import locale
+ locale.setlocale(locale.LC_CTYPE, "")
+ except (ImportError, locale.Error):
+ pass
+
+ locale_decode = 'ascii'
+ if sys.platform == 'win32':
+ # On Windows, we could use "mbcs". However, to give the user
+ # a portable encoding name, we need to find the code page
try:
locale_encoding = locale.getdefaultlocale()[1]
+ codecs.lookup(locale_encoding)
+ except LookupError:
+ pass
+ else:
+ try:
+ # Different things can fail here: the locale module may not be
+ # loaded, it may not offer nl_langinfo, or CODESET, or the
+ # resulting codeset may be unknown to Python. We ignore all
+ # these problems, falling back to ASCII
+ locale_encoding = locale.nl_langinfo(locale.CODESET)
if locale_encoding is None or locale_encoding is '':
# situation occurs on Mac OS X
locale_encoding = 'ascii'
codecs.lookup(locale_encoding)
- except (ValueError, LookupError):
- pass
+ except (NameError, AttributeError, LookupError):
+ # Try getdefaultlocale: it parses environment variables,
+ # which may give a clue. Unfortunately, getdefaultlocale has
+ # bugs that can cause ValueError.
+ try:
+ locale_encoding = locale.getdefaultlocale()[1]
+ if locale_encoding is None or locale_encoding is '':
+ # situation occurs on Mac OS X
+ locale_encoding = 'ascii'
+ codecs.lookup(locale_encoding)
+ except (ValueError, LookupError):
+ pass
-locale_encoding = locale_encoding.lower()
+ locale_encoding = locale_encoding.lower()
-encoding = locale_encoding ### KBK 07Sep07 This is used all over IDLE, check!
- ### 'encoding' is used below in encode(), check!
+ encoding = locale_encoding
+ # Encoding is used in multiple files; locale_encoding nowhere.
+ # The only use of 'encoding' below is in _decode as initial value
+ # of deprecated block asking user for encoding.
+ # Perhaps use elsewhere should be reviewed.
coding_re = re.compile(r'^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)', re.ASCII)
blank_re = re.compile(r'^[ \t\f]*(?:[#\r\n]|$)', re.ASCII)
@@ -107,6 +110,9 @@
class IOBinding:
+# One instance per editor Window so methods know which to save, close.
+# Open returns focus to self.editwin if aborted.
+# EditorWindow.open_module, others, belong here.
def __init__(self, editwin):
self.editwin = editwin
@@ -301,7 +307,7 @@
"The file's encoding is invalid for Python 3.x.\n"
"IDLE will convert it to UTF-8.\n"
"What is the current encoding of the file?",
- initialvalue = locale_encoding,
+ initialvalue = encoding,
parent = self.editwin.text)
if enc:
@@ -561,5 +567,8 @@
IOBinding(editwin)
if __name__ == "__main__":
+ import unittest
+ unittest.main('idlelib.idle_test.test_iomenu', verbosity=2, exit=False)
+
from idlelib.idle_test.htest import run
run(_io_binding)
diff --git a/Lib/idlelib/macosxSupport.py b/Lib/idlelib/macosx.py
similarity index 78%
rename from Lib/idlelib/macosxSupport.py
rename to Lib/idlelib/macosx.py
index b96bae1..f9f558d 100644
--- a/Lib/idlelib/macosxSupport.py
+++ b/Lib/idlelib/macosx.py
@@ -1,30 +1,24 @@
"""
A number of functions that enhance IDLE on Mac OSX.
"""
-import sys
+from sys import platform # Used in _init_tk_type, changed by test.
import tkinter
-from os import path
import warnings
-def runningAsOSXApp():
- warnings.warn("runningAsOSXApp() is deprecated, use isAquaTk()",
- DeprecationWarning, stacklevel=2)
- return isAquaTk()
-def isCarbonAquaTk(root):
- warnings.warn("isCarbonAquaTk(root) is deprecated, use isCarbonTk()",
- DeprecationWarning, stacklevel=2)
- return isCarbonTk()
+## Define functions that query the Mac graphics type.
+## _tk_type and its initializer are private to this section.
_tk_type = None
-def _initializeTkVariantTests(root):
+def _init_tk_type():
"""
Initializes OS X Tk variant values for
isAquaTk(), isCarbonTk(), isCocoaTk(), and isXQuartz().
"""
global _tk_type
- if sys.platform == 'darwin':
+ if platform == 'darwin':
+ root = tkinter.Tk()
ws = root.tk.call('tk', 'windowingsystem')
if 'x11' in ws:
_tk_type = "xquartz"
@@ -34,6 +28,7 @@
_tk_type = "cocoa"
else:
_tk_type = "carbon"
+ root.destroy()
else:
_tk_type = "other"
@@ -41,7 +36,8 @@
"""
Returns True if IDLE is using a native OS X Tk (Cocoa or Carbon).
"""
- assert _tk_type is not None
+ if not _tk_type:
+ _init_tk_type()
return _tk_type == "cocoa" or _tk_type == "carbon"
def isCarbonTk():
@@ -49,23 +45,27 @@
Returns True if IDLE is using a Carbon Aqua Tk (instead of the
newer Cocoa Aqua Tk).
"""
- assert _tk_type is not None
+ if not _tk_type:
+ _init_tk_type()
return _tk_type == "carbon"
def isCocoaTk():
"""
Returns True if IDLE is using a Cocoa Aqua Tk.
"""
- assert _tk_type is not None
+ if not _tk_type:
+ _init_tk_type()
return _tk_type == "cocoa"
def isXQuartz():
"""
Returns True if IDLE is using an OS X X11 Tk.
"""
- assert _tk_type is not None
+ if not _tk_type:
+ _init_tk_type()
return _tk_type == "xquartz"
+
def tkVersionWarning(root):
"""
Returns a string warning message if the Tk version in use appears to
@@ -86,6 +86,9 @@
else:
return False
+
+## Fix the menu and related functions.
+
def addOpenEventSupport(root, flist):
"""
This ensures that the application will respond to open AppleEvents, which
@@ -124,23 +127,23 @@
# Due to a (mis-)feature of TkAqua the user will also see an empty Help
# menu.
from tkinter import Menu
- from idlelib import Bindings
- from idlelib import WindowList
+ from idlelib import mainmenu
+ from idlelib import windows
- closeItem = Bindings.menudefs[0][1][-2]
+ closeItem = mainmenu.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 Bindings.menudefs[0][1][-3:]
- Bindings.menudefs[0][1].insert(6, closeItem)
+ del mainmenu.menudefs[0][1][-3:]
+ mainmenu.menudefs[0][1].insert(6, closeItem)
# Remove the 'About' entry from the help menu, it is in the application
# menu
- del Bindings.menudefs[-1][1][0:2]
+ del mainmenu.menudefs[-1][1][0:2]
# Remove the 'Configure Idle' entry from the options menu, it is in the
# application menu as 'Preferences'
- del Bindings.menudefs[-2][1][0]
+ del mainmenu.menudefs[-2][1][0]
menubar = Menu(root)
root.configure(menu=menubar)
menudict = {}
@@ -155,30 +158,30 @@
if end > 0:
menu.delete(0, end)
- WindowList.add_windows_to_menu(menu)
- WindowList.register_callback(postwindowsmenu)
+ windows.add_windows_to_menu(menu)
+ windows.register_callback(postwindowsmenu)
def about_dialog(event=None):
"Handle Help 'About IDLE' event."
- # Synchronize with EditorWindow.EditorWindow.about_dialog.
- from idlelib import aboutDialog
- aboutDialog.AboutDialog(root, 'About IDLE')
+ # Synchronize with editor.EditorWindow.about_dialog.
+ from idlelib import help_about
+ help_about.AboutDialog(root, 'About IDLE')
def config_dialog(event=None):
"Handle Options 'Configure IDLE' event."
- # Synchronize with EditorWindow.EditorWindow.config_dialog.
- from idlelib import configDialog
+ # Synchronize with editor.EditorWindow.config_dialog.
+ from idlelib import configdialog
# Ensure that the root object has an instance_dict attribute,
# mirrors code in EditorWindow (although that sets the attribute
# on an EditorWindow instance that is then passed as the first
# argument to ConfigDialog)
root.instance_dict = flist.inversedict
- configDialog.ConfigDialog(root, 'Settings')
+ configdialog.ConfigDialog(root, 'Settings')
def help_dialog(event=None):
"Handle Help 'IDLE Help' event."
- # Synchronize with EditorWindow.EditorWindow.help_dialog.
+ # Synchronize with editor.EditorWindow.help_dialog.
from idlelib import help
help.show_idlehelp(root)
@@ -198,29 +201,33 @@
menudict['application'] = menu = Menu(menubar, name='apple',
tearoff=0)
menubar.add_cascade(label='IDLE', menu=menu)
- Bindings.menudefs.insert(0,
+ mainmenu.menudefs.insert(0,
('application', [
('About IDLE', '<<about-idle>>'),
None,
]))
- tkversion = root.tk.eval('info patchlevel')
- if tuple(map(int, tkversion.split('.'))) < (8, 4, 14):
- # for earlier AquaTk versions, supply a Preferences menu item
- Bindings.menudefs[0][1].append(
- ('_Preferences....', '<<open-config-dialog>>'),
- )
if isCocoaTk():
# replace default About dialog with About IDLE one
root.createcommand('tkAboutDialog', about_dialog)
# replace default "Help" item in Help menu
root.createcommand('::tk::mac::ShowHelp', help_dialog)
# remove redundant "IDLE Help" from menu
- del Bindings.menudefs[-1][1][0]
+ del mainmenu.menudefs[-1][1][0]
+
+def fixb2context(root):
+ '''Removed bad AquaTk Button-2 (right) and Paste bindings.
+
+ They prevent context menu access and seem to be gone in AquaTk8.6.
+ See issue #24801.
+ '''
+ root.unbind_class('Text', '<B2>')
+ root.unbind_class('Text', '<B2-Motion>')
+ root.unbind_class('Text', '<<PasteSelection>>')
def setupApp(root, flist):
"""
Perform initial OS X customizations if needed.
- Called from PyShell.main() after initial calls to Tk()
+ Called from pyshell.main() after initial calls to Tk()
There are currently three major versions of Tk in use on OS X:
1. Aqua Cocoa Tk (native default since OS X 10.6)
@@ -233,8 +240,13 @@
isAquaTk(), isCarbonTk(), isCocoaTk(), isXQuartz() functions which
are initialized here as well.
"""
- _initializeTkVariantTests(root)
if isAquaTk():
hideTkConsole(root)
overrideRootMenu(root, flist)
addOpenEventSupport(root, flist)
+ fixb2context(root)
+
+
+if __name__ == '__main__':
+ from unittest import main
+ main('idlelib.idle_test.test_macosx', verbosity=2)
diff --git a/Lib/idlelib/Bindings.py b/Lib/idlelib/mainmenu.py
similarity index 95%
rename from Lib/idlelib/Bindings.py
rename to Lib/idlelib/mainmenu.py
index ab25ff1..965ada3 100644
--- a/Lib/idlelib/Bindings.py
+++ b/Lib/idlelib/mainmenu.py
@@ -10,9 +10,9 @@
"""
from importlib.util import find_spec
-from idlelib.configHandler import idleConf
+from idlelib.config import idleConf
-# Warning: menudefs is altered in macosxSupport.overrideRootMenu()
+# Warning: menudefs is altered in macosx.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
diff --git a/Lib/idlelib/MultiCall.py b/Lib/idlelib/multicall.py
similarity index 98%
rename from Lib/idlelib/MultiCall.py
rename to Lib/idlelib/multicall.py
index 8462854..bf02f59 100644
--- a/Lib/idlelib/MultiCall.py
+++ b/Lib/idlelib/multicall.py
@@ -414,12 +414,12 @@
return MultiCall
-def _multi_call(parent):
- root = tkinter.Tk()
- root.title("Test MultiCall")
+def _multi_call(parent): # htest #
+ top = tkinter.Toplevel(parent)
+ top.title("Test MultiCall")
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 150))
- text = MultiCallCreator(tkinter.Text)(root)
+ top.geometry("+%d+%d"%(x, y + 150))
+ text = MultiCallCreator(tkinter.Text)(top)
text.pack()
def bindseq(seq, n=[0]):
def handler(event):
@@ -439,7 +439,6 @@
bindseq("<FocusOut>")
bindseq("<Enter>")
bindseq("<Leave>")
- root.mainloop()
if __name__ == "__main__":
from idlelib.idle_test.htest import run
diff --git a/Lib/idlelib/OutputWindow.py b/Lib/idlelib/outwin.py
similarity index 96%
rename from Lib/idlelib/OutputWindow.py
rename to Lib/idlelib/outwin.py
index e614f9b..b3bc786 100644
--- a/Lib/idlelib/OutputWindow.py
+++ b/Lib/idlelib/outwin.py
@@ -1,8 +1,8 @@
from tkinter import *
-from idlelib.EditorWindow import EditorWindow
+from idlelib.editor import EditorWindow
import re
import tkinter.messagebox as tkMessageBox
-from idlelib import IOBinding
+from idlelib import iomenu
class OutputWindow(EditorWindow):
@@ -36,7 +36,7 @@
def write(self, s, tags=(), mark="insert"):
if isinstance(s, (bytes, bytes)):
- s = s.decode(IOBinding.encoding, "replace")
+ s = s.decode(iomenu.encoding, "replace")
self.text.insert(mark, s, tags)
self.text.see(mark)
self.text.update()
diff --git a/Lib/idlelib/FormatParagraph.py b/Lib/idlelib/paragraph.py
similarity index 98%
rename from Lib/idlelib/FormatParagraph.py
rename to Lib/idlelib/paragraph.py
index 7a9d185..0323b53 100644
--- a/Lib/idlelib/FormatParagraph.py
+++ b/Lib/idlelib/paragraph.py
@@ -16,7 +16,7 @@
"""
import re
-from idlelib.configHandler import idleConf
+from idlelib.config import idleConf
class FormatParagraph:
@@ -191,5 +191,5 @@
if __name__ == "__main__":
import unittest
- unittest.main('idlelib.idle_test.test_formatparagraph',
+ unittest.main('idlelib.idle_test.test_paragraph',
verbosity=2, exit=False)
diff --git a/Lib/idlelib/ParenMatch.py b/Lib/idlelib/parenmatch.py
similarity index 98%
rename from Lib/idlelib/ParenMatch.py
rename to Lib/idlelib/parenmatch.py
index 19bad8c..e98fac1 100644
--- a/Lib/idlelib/ParenMatch.py
+++ b/Lib/idlelib/parenmatch.py
@@ -5,8 +5,8 @@
parentheses, square brackets, and curly braces.
"""
-from idlelib.HyperParser import HyperParser
-from idlelib.configHandler import idleConf
+from idlelib.hyperparser import HyperParser
+from idlelib.config import idleConf
_openers = {')':'(',']':'[','}':'{'}
CHECK_DELAY = 100 # miliseconds
diff --git a/Lib/idlelib/PathBrowser.py b/Lib/idlelib/pathbrowser.py
similarity index 95%
rename from Lib/idlelib/PathBrowser.py
rename to Lib/idlelib/pathbrowser.py
index 9ab7632..966af4b 100644
--- a/Lib/idlelib/PathBrowser.py
+++ b/Lib/idlelib/pathbrowser.py
@@ -2,9 +2,9 @@
import sys
import importlib.machinery
-from idlelib.TreeWidget import TreeItem
-from idlelib.ClassBrowser import ClassBrowser, ModuleBrowserTreeItem
-from idlelib.PyShell import PyShellFileList
+from idlelib.tree import TreeItem
+from idlelib.browser import ClassBrowser, ModuleBrowserTreeItem
+from idlelib.pyshell import PyShellFileList
class PathBrowser(ClassBrowser):
diff --git a/Lib/idlelib/Percolator.py b/Lib/idlelib/percolator.py
similarity index 95%
rename from Lib/idlelib/Percolator.py
rename to Lib/idlelib/percolator.py
index b8be2aa..2111e03 100644
--- a/Lib/idlelib/Percolator.py
+++ b/Lib/idlelib/percolator.py
@@ -1,5 +1,5 @@
-from idlelib.WidgetRedirector import WidgetRedirector
-from idlelib.Delegator import Delegator
+from idlelib.redirector import WidgetRedirector
+from idlelib.delegator import Delegator
class Percolator:
@@ -89,10 +89,10 @@
(pin if var2.get() else pout)(t2)
text.pack()
- var1 = tk.IntVar()
+ var1 = tk.IntVar(parent)
cb1 = tk.Checkbutton(box, text="Tracer1", command=toggle1, variable=var1)
cb1.pack()
- var2 = tk.IntVar()
+ var2 = tk.IntVar(parent)
cb2 = tk.Checkbutton(box, text="Tracer2", command=toggle2, variable=var2)
cb2.pack()
diff --git a/Lib/idlelib/PyParse.py b/Lib/idlelib/pyparse.py
similarity index 100%
rename from Lib/idlelib/PyParse.py
rename to Lib/idlelib/pyparse.py
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/pyshell.py
similarity index 96%
rename from Lib/idlelib/PyShell.py
rename to Lib/idlelib/pyshell.py
index 5dec68e..82e77f9 100755
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/pyshell.py
@@ -1,5 +1,20 @@
#! /usr/bin/env python3
+try:
+ from tkinter import *
+except ImportError:
+ print("** IDLE can't import Tkinter.\n"
+ "Your Python may not be configured for Tk. **", file=sys.__stderr__)
+ sys.exit(1)
+import tkinter.messagebox as tkMessageBox
+if TkVersion < 8.5:
+ root = Tk() # otherwise create root in main
+ root.withdraw()
+ tkMessageBox.showerror("Idle Cannot Start",
+ "Idle requires tcl/tk 8.5+, not $s." % TkVersion,
+ parent=root)
+ sys.exit(1)
+
import getopt
import os
import os.path
@@ -16,24 +31,16 @@
from code import InteractiveInterpreter
from platform import python_version, system
-try:
- from tkinter import *
-except ImportError:
- print("** IDLE can't import Tkinter.\n"
- "Your Python may not be configured for Tk. **", file=sys.__stderr__)
- sys.exit(1)
-import tkinter.messagebox as tkMessageBox
-
-from idlelib.EditorWindow import EditorWindow, fixwordbreaks
-from idlelib.FileList import FileList
-from idlelib.ColorDelegator import ColorDelegator
-from idlelib.UndoDelegator import UndoDelegator
-from idlelib.OutputWindow import OutputWindow
-from idlelib.configHandler import idleConf
+from idlelib.editor import EditorWindow, fixwordbreaks
+from idlelib.filelist import FileList
+from idlelib.colorizer import ColorDelegator
+from idlelib.undo import UndoDelegator
+from idlelib.outwin import OutputWindow
+from idlelib.config import idleConf
from idlelib import rpc
-from idlelib import Debugger
-from idlelib import RemoteDebugger
-from idlelib import macosxSupport
+from idlelib import debugger
+from idlelib import debugger_r
+from idlelib import macosx
HOST = '127.0.0.1' # python execution server on localhost loopback
PORT = 0 # someday pass in host, port for remote debug capability
@@ -410,7 +417,7 @@
# run from the IDLE source directory.
del_exitf = idleConf.GetOption('main', 'General', 'delete-exitfunc',
default=False, type='bool')
- if __name__ == 'idlelib.PyShell':
+ if __name__ == 'idlelib.pyshell':
command = "__import__('idlelib.run').run.main(%r)" % (del_exitf,)
else:
command = "__import__('run').main(%r)" % (del_exitf,)
@@ -468,7 +475,7 @@
if debug:
try:
# Only close subprocess debugger, don't unregister gui_adap!
- RemoteDebugger.close_subprocess_debugger(self.rpcclt)
+ debugger_r.close_subprocess_debugger(self.rpcclt)
except:
pass
# Kill subprocess, spawn a new one, accept connection.
@@ -497,7 +504,7 @@
# restart subprocess debugger
if debug:
# Restarted debugger connects to current instance of debug GUI
- RemoteDebugger.restart_subprocess_debugger(self.rpcclt)
+ debugger_r.restart_subprocess_debugger(self.rpcclt)
# reload remote debugger breakpoints for all PyShellEditWindows
debug.load_breakpoints()
self.compile.compiler.flags = self.original_compiler_flags
@@ -578,7 +585,7 @@
if self.tkconsole.getvar("<<toggle-jit-stack-viewer>>"):
self.remote_stack_viewer()
elif how == "ERROR":
- errmsg = "PyShell.ModifiedInterpreter: Subprocess ERROR:\n"
+ errmsg = "pyshell.ModifiedInterpreter: Subprocess ERROR:\n"
print(errmsg, what, file=sys.__stderr__)
print(errmsg, what, file=console)
# we received a response to the currently active seq number:
@@ -613,13 +620,13 @@
return
def remote_stack_viewer(self):
- from idlelib import RemoteObjectBrowser
+ from idlelib import debugobj_r
oid = self.rpcclt.remotequeue("exec", "stackviewer", ("flist",), {})
if oid is None:
self.tkconsole.root.bell()
return
- item = RemoteObjectBrowser.StubObjectTreeItem(self.rpcclt, oid)
- from idlelib.TreeWidget import ScrolledCanvas, TreeNode
+ item = debugobj_r.StubObjectTreeItem(self.rpcclt, oid)
+ from idlelib.tree import ScrolledCanvas, TreeNode
top = Toplevel(self.tkconsole.root)
theme = idleConf.CurrentTheme()
background = idleConf.GetHighlight(theme, 'normal')['background']
@@ -662,9 +669,9 @@
# at the moment, InteractiveInterpreter expects str
assert isinstance(source, str)
#if isinstance(source, str):
- # from idlelib import IOBinding
+ # from idlelib import iomenu
# try:
- # source = source.encode(IOBinding.encoding)
+ # source = source.encode(iomenu.encoding)
# except UnicodeError:
# self.tkconsole.resetoutput()
# self.write("Unsupported characters in input\n")
@@ -850,7 +857,7 @@
# New classes
- from idlelib.IdleHistory import History
+ from idlelib.history import History
def __init__(self, flist=None):
if use_subprocess:
@@ -888,11 +895,11 @@
self.save_stdout = sys.stdout
self.save_stderr = sys.stderr
self.save_stdin = sys.stdin
- from idlelib import IOBinding
- self.stdin = PseudoInputFile(self, "stdin", IOBinding.encoding)
- self.stdout = PseudoOutputFile(self, "stdout", IOBinding.encoding)
- self.stderr = PseudoOutputFile(self, "stderr", IOBinding.encoding)
- self.console = PseudoOutputFile(self, "console", IOBinding.encoding)
+ from idlelib import iomenu
+ self.stdin = PseudoInputFile(self, "stdin", iomenu.encoding)
+ self.stdout = PseudoOutputFile(self, "stdout", iomenu.encoding)
+ self.stderr = PseudoOutputFile(self, "stderr", iomenu.encoding)
+ self.console = PseudoOutputFile(self, "console", iomenu.encoding)
if not use_subprocess:
sys.stdout = self.stdout
sys.stderr = self.stderr
@@ -900,7 +907,7 @@
try:
# page help() text to shell.
import pydoc # import must be done here to capture i/o rebinding.
- # XXX KBK 27Dec07 use a textView someday, but must work w/o subproc
+ # XXX KBK 27Dec07 use TextViewer someday, but must work w/o subproc
pydoc.pager = pydoc.plainpager
except:
sys.stderr = sys.__stderr__
@@ -954,7 +961,7 @@
self.interp.setdebugger(None)
db.close()
if self.interp.rpcclt:
- RemoteDebugger.close_remote_debugger(self.interp.rpcclt)
+ debugger_r.close_remote_debugger(self.interp.rpcclt)
self.resetoutput()
self.console.write("[DEBUG OFF]\n")
sys.ps1 = ">>> "
@@ -963,10 +970,10 @@
def open_debugger(self):
if self.interp.rpcclt:
- dbg_gui = RemoteDebugger.start_remote_debugger(self.interp.rpcclt,
+ dbg_gui = debugger_r.start_remote_debugger(self.interp.rpcclt,
self)
else:
- dbg_gui = Debugger.Debugger(self)
+ dbg_gui = debugger.Debugger(self)
self.interp.setdebugger(dbg_gui)
dbg_gui.load_breakpoints()
sys.ps1 = "[DEBUG ON]\n>>> "
@@ -1241,7 +1248,7 @@
"(sys.last_traceback is not defined)",
parent=self.text)
return
- from idlelib.StackViewer import StackBrowser
+ from idlelib.stackviewer import StackBrowser
StackBrowser(self.root, self.flist)
def view_restart_mark(self, event=None):
@@ -1540,7 +1547,9 @@
enable_edit = enable_edit or edit_start
enable_shell = enable_shell or not enable_edit
- # start editor and/or shell windows:
+ # Setup root.
+ if use_subprocess: # Don't break user code run in IDLE process
+ NoDefaultRoot()
root = Tk(className="Idle")
root.withdraw()
@@ -1549,25 +1558,19 @@
if system() == 'Windows':
iconfile = os.path.join(icondir, 'idle.ico')
root.wm_iconbitmap(default=iconfile)
- elif TkVersion >= 8.5:
+ else:
ext = '.png' if TkVersion >= 8.6 else '.gif'
iconfiles = [os.path.join(icondir, 'idle_%d%s' % (size, ext))
for size in (16, 32, 48)]
- icons = [PhotoImage(file=iconfile) for iconfile in iconfiles]
+ icons = [PhotoImage(master=root, file=iconfile)
+ for iconfile in iconfiles]
root.wm_iconphoto(True, *icons)
+ # start editor and/or shell windows:
fixwordbreaks(root)
fix_x11_paste(root)
flist = PyShellFileList(root)
- macosxSupport.setupApp(root, flist)
-
- if macosxSupport.isAquaTk():
- # There are some screwed up <2> class bindings for text
- # widgets defined in Tk which we need to do away with.
- # See issue #24801.
- root.unbind_class('Text', '<B2>')
- root.unbind_class('Text', '<B2-Motion>')
- root.unbind_class('Text', '<<PasteSelection>>')
+ macosx.setupApp(root, flist)
if enable_edit:
if not (cmd or script):
@@ -1582,7 +1585,7 @@
shell = flist.open_shell()
if not shell:
return # couldn't open shell
- if macosxSupport.isAquaTk() and flist.dict:
+ if macosx.isAquaTk() 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
@@ -1616,7 +1619,7 @@
# check for problematic OS X Tk versions and print a warning
# message in the IDLE shell window; this is less intrusive
# than always opening a separate window.
- tkversionwarning = macosxSupport.tkVersionWarning(root)
+ tkversionwarning = macosx.tkVersionWarning(root)
if tkversionwarning:
shell.interp.runcommand("print('%s')" % tkversionwarning)
@@ -1626,7 +1629,7 @@
capture_warnings(False)
if __name__ == "__main__":
- sys.modules['PyShell'] = sys.modules['__main__']
+ sys.modules['pyshell'] = sys.modules['__main__']
main()
capture_warnings(False) # Make sure turned off; see issue 18081
diff --git a/Lib/idlelib/query.py b/Lib/idlelib/query.py
new file mode 100644
index 0000000..e3937a1
--- /dev/null
+++ b/Lib/idlelib/query.py
@@ -0,0 +1,148 @@
+"""
+Dialogs that query users and verify the answer before accepting.
+Use ttk widgets, limiting use to tcl/tk 8.5+, as in IDLE 3.6+.
+
+Query is the generic base class for a popup dialog.
+The user must either enter a valid answer or close the dialog.
+Entries are validated when <Return> is entered or [Ok] is clicked.
+Entries are ignored when [Cancel] or [X] are clicked.
+The 'return value' is .result set to either a valid answer or None.
+
+Subclass SectionName gets a name for a new config file section.
+Configdialog uses it for new highlight theme and keybinding set names.
+"""
+# Query and Section name result from splitting GetCfgSectionNameDialog
+# of configSectionNameDialog.py (temporarily config_sec.py) into
+# generic and specific parts.
+
+from tkinter import FALSE, TRUE, Toplevel
+from tkinter.messagebox import showerror
+from tkinter.ttk import Frame, Button, Entry, Label
+
+class Query(Toplevel):
+ """Base class for getting verified answer from a user.
+
+ For this base class, accept any non-blank string.
+ """
+ def __init__(self, parent, title, message,
+ *, _htest=False, _utest=False): # Call from override.
+ """Create popup, do not return until tk widget destroyed.
+
+ Additional subclass init must be done before calling this.
+
+ title - string, title of popup dialog
+ message - string, informational message to display
+ _htest - bool, change box location when running htest
+ _utest - bool, leave window hidden and not modal
+ """
+ Toplevel.__init__(self, parent)
+ self.configure(borderwidth=5)
+ self.resizable(height=FALSE, width=FALSE)
+ self.title(title)
+ self.transient(parent)
+ self.grab_set()
+ self.bind('<Key-Return>', self.ok)
+ self.protocol("WM_DELETE_WINDOW", self.cancel)
+ self.parent = parent
+ self.message = message
+ self.create_widgets()
+ self.update_idletasks()
+ #needs to be done here so that the winfo_reqwidth is valid
+ self.withdraw() # Hide while configuring, especially geometry.
+ self.geometry(
+ "+%d+%d" % (
+ parent.winfo_rootx() +
+ (parent.winfo_width()/2 - self.winfo_reqwidth()/2),
+ parent.winfo_rooty() +
+ ((parent.winfo_height()/2 - self.winfo_reqheight()/2)
+ if not _htest else 150)
+ ) ) #centre dialog over parent (or below htest box)
+ if not _utest:
+ self.deiconify() #geometry set, unhide
+ self.wait_window()
+
+ def create_widgets(self): # Call from override, if any.
+ frame = Frame(self, borderwidth=2, relief='sunken', )
+ label = Label(frame, anchor='w', justify='left',
+ text=self.message)
+ self.entry = Entry(frame, width=30) # Bind name for entry_ok.
+ self.entry.focus_set()
+
+ buttons = Frame(self) # Bind buttons for invoke in unittest.
+ self.button_ok = Button(buttons, text='Ok',
+ width=8, command=self.ok)
+ self.button_cancel = Button(buttons, text='Cancel',
+ width=8, command=self.cancel)
+
+ frame.pack(side='top', expand=TRUE, fill='both')
+ label.pack(padx=5, pady=5)
+ self.entry.pack(padx=5, pady=5)
+ buttons.pack(side='bottom')
+ self.button_ok.pack(side='left', padx=5)
+ self.button_cancel.pack(side='right', padx=5)
+
+ def entry_ok(self): # Usually replace.
+ "Check that entry not blank."
+ entry = self.entry.get().strip()
+ if not entry:
+ showerror(title='Entry Error',
+ message='Blank line.', parent=self)
+ return entry
+
+ def ok(self, event=None): # Do not replace.
+ '''If entry is valid, bind it to 'result' and destroy tk widget.
+
+ Otherwise leave dialog open for user to correct entry or cancel.
+ '''
+ entry = self.entry_ok()
+ if entry:
+ self.result = entry
+ self.destroy()
+ else:
+ # [Ok] (but not <Return>) moves focus. Move it back.
+ self.entry.focus_set()
+
+ def cancel(self, event=None): # Do not replace.
+ "Set dialog result to None and destroy tk widget."
+ self.result = None
+ self.destroy()
+
+
+class SectionName(Query):
+ "Get a name for a config file section name."
+
+ def __init__(self, parent, title, message, used_names,
+ *, _htest=False, _utest=False):
+ "used_names - collection of strings already in use"
+
+ self.used_names = used_names
+ Query.__init__(self, parent, title, message,
+ _htest=_htest, _utest=_utest)
+ # This call does ot return until tk widget is destroyed.
+
+ def entry_ok(self):
+ '''Stripping entered name, check that it is a sensible
+ ConfigParser file section name. Return it if it is, '' if not.
+ '''
+ name = self.entry.get().strip()
+ if not name:
+ showerror(title='Name Error',
+ message='No name specified.', parent=self)
+ elif len(name)>30:
+ showerror(title='Name Error',
+ message='Name too long. It should be no more than '+
+ '30 characters.', parent=self)
+ name = ''
+ elif name in self.used_names:
+ showerror(title='Name Error',
+ message='This name is already in use.', parent=self)
+ name = ''
+ return name
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main('idlelib.idle_test.test_query', verbosity=2, exit=False)
+
+ from idlelib.idle_test.htest import run
+ run(Query)
diff --git a/Lib/idlelib/WidgetRedirector.py b/Lib/idlelib/redirector.py
similarity index 95%
rename from Lib/idlelib/WidgetRedirector.py
rename to Lib/idlelib/redirector.py
index b66be9e..3a11055 100644
--- a/Lib/idlelib/WidgetRedirector.py
+++ b/Lib/idlelib/redirector.py
@@ -104,7 +104,7 @@
Note that if a registered function is called, the operation is not
passed through to Tk. Apply the function returned by self.register()
- to *args to accomplish that. For an example, see ColorDelegator.py.
+ to *args to accomplish that. For an example, see colorizer.py.
'''
m = self._operations.get(operation)
@@ -151,14 +151,14 @@
def _widget_redirector(parent): # htest #
- from tkinter import Tk, Text
+ from tkinter import Toplevel, Text
import re
- root = Tk()
- root.title("Test WidgetRedirector")
+ top = Toplevel(parent)
+ top.title("Test WidgetRedirector")
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 150))
- text = Text(root)
+ top.geometry("+%d+%d"%(x, y + 150))
+ text = Text(top)
text.pack()
text.focus_set()
redir = WidgetRedirector(text)
@@ -166,11 +166,10 @@
print("insert", args)
original_insert(*args)
original_insert = redir.register("insert", my_insert)
- root.mainloop()
if __name__ == "__main__":
import unittest
- unittest.main('idlelib.idle_test.test_widgetredir',
+ unittest.main('idlelib.idle_test.test_redirector',
verbosity=2, exit=False)
from idlelib.idle_test.htest import run
run(_widget_redirector)
diff --git a/Lib/idlelib/ReplaceDialog.py b/Lib/idlelib/replace.py
similarity index 97%
rename from Lib/idlelib/ReplaceDialog.py
rename to Lib/idlelib/replace.py
index f2ea22e..589b814 100644
--- a/Lib/idlelib/ReplaceDialog.py
+++ b/Lib/idlelib/replace.py
@@ -5,8 +5,8 @@
"""
from tkinter import *
-from idlelib import SearchEngine
-from idlelib.SearchDialogBase import SearchDialogBase
+from idlelib import searchengine
+from idlelib.searchbase import SearchDialogBase
import re
@@ -14,7 +14,7 @@
"""Returns a singleton ReplaceDialog instance.The single dialog
saves user entries and preferences across instances."""
root = text._root()
- engine = SearchEngine.get(root)
+ engine = searchengine.get(root)
if not hasattr(engine, "_replacedialog"):
engine._replacedialog = ReplaceDialog(root, engine)
dialog = engine._replacedialog
@@ -164,7 +164,7 @@
pos = None
if not pos:
first = last = pos = text.index("insert")
- line, col = SearchEngine.get_line_col(pos)
+ line, col = searchengine.get_line_col(pos)
chars = text.get("%d.0" % line, "%d.0" % (line+1))
m = prog.match(chars, col)
if not prog:
diff --git a/Lib/idlelib/RstripExtension.py b/Lib/idlelib/rstrip.py
similarity index 100%
rename from Lib/idlelib/RstripExtension.py
rename to Lib/idlelib/rstrip.py
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
index 595e7bc..eb34944 100644
--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -7,15 +7,15 @@
import queue
import tkinter
-from idlelib import CallTips
-from idlelib import AutoComplete
+from idlelib import calltips
+from idlelib import autocomplete
-from idlelib import RemoteDebugger
-from idlelib import RemoteObjectBrowser
-from idlelib import StackViewer
+from idlelib import debugger_r
+from idlelib import debugobj_r
+from idlelib import stackviewer
from idlelib import rpc
-from idlelib import PyShell
-from idlelib import IOBinding
+from idlelib import pyshell
+from idlelib import iomenu
import __main__
@@ -32,7 +32,7 @@
if file is None:
file = sys.stderr
try:
- file.write(PyShell.idle_formatwarning(
+ file.write(pyshell.idle_formatwarning(
message, category, filename, lineno, line))
except IOError:
pass # the file (probably stderr) is invalid - this warning gets lost.
@@ -82,7 +82,7 @@
MyHandler object. That reference is saved as attribute rpchandler of the
Executive instance. The Executive methods have access to the reference and
can pass it on to entities that they command
- (e.g. RemoteDebugger.Debugger.start_debugger()). The latter, in turn, can
+ (e.g. debugger_r.Debugger.start_debugger()). The latter, in turn, can
call MyHandler(SocketIO) register/unregister methods via the reference to
register and unregister themselves.
@@ -204,7 +204,7 @@
tbe = traceback.extract_tb(tb)
print('Traceback (most recent call last):', file=efile)
exclude = ("run.py", "rpc.py", "threading.py", "queue.py",
- "RemoteDebugger.py", "bdb.py")
+ "debugger_r.py", "bdb.py")
cleanup_traceback(tbe, exclude)
traceback.print_list(tbe, file=efile)
lines = traceback.format_exception_only(typ, exc)
@@ -298,12 +298,12 @@
executive = Executive(self)
self.register("exec", executive)
self.console = self.get_remote_proxy("console")
- sys.stdin = PyShell.PseudoInputFile(self.console, "stdin",
- IOBinding.encoding)
- sys.stdout = PyShell.PseudoOutputFile(self.console, "stdout",
- IOBinding.encoding)
- sys.stderr = PyShell.PseudoOutputFile(self.console, "stderr",
- IOBinding.encoding)
+ sys.stdin = pyshell.PseudoInputFile(self.console, "stdin",
+ iomenu.encoding)
+ sys.stdout = pyshell.PseudoOutputFile(self.console, "stdout",
+ iomenu.encoding)
+ sys.stderr = pyshell.PseudoOutputFile(self.console, "stderr",
+ iomenu.encoding)
sys.displayhook = rpc.displayhook
# page help() text to shell.
@@ -339,8 +339,8 @@
def __init__(self, rpchandler):
self.rpchandler = rpchandler
self.locals = __main__.__dict__
- self.calltip = CallTips.CallTips()
- self.autocomplete = AutoComplete.AutoComplete()
+ self.calltip = calltips.CallTips()
+ self.autocomplete = autocomplete.AutoComplete()
def runcode(self, code):
global interruptable
@@ -372,7 +372,7 @@
thread.interrupt_main()
def start_the_debugger(self, gui_adap_oid):
- return RemoteDebugger.start_debugger(self.rpchandler, gui_adap_oid)
+ return debugger_r.start_debugger(self.rpchandler, gui_adap_oid)
def stop_the_debugger(self, idb_adap_oid):
"Unregister the Idb Adapter. Link objects and Idb then subject to GC"
@@ -396,7 +396,7 @@
tb = tb.tb_next
sys.last_type = typ
sys.last_value = val
- item = StackViewer.StackTreeItem(flist, tb)
- return RemoteObjectBrowser.remote_object_tree_item(item)
+ item = stackviewer.StackTreeItem(flist, tb)
+ return debugobj_r.remote_object_tree_item(item)
capture_warnings(False) # Make sure turned off; see issue 18081
diff --git a/Lib/idlelib/ScriptBinding.py b/Lib/idlelib/runscript.py
similarity index 95%
rename from Lib/idlelib/ScriptBinding.py
rename to Lib/idlelib/runscript.py
index 5cb818d..7e7524a 100644
--- a/Lib/idlelib/ScriptBinding.py
+++ b/Lib/idlelib/runscript.py
@@ -21,10 +21,10 @@
import tabnanny
import tokenize
import tkinter.messagebox as tkMessageBox
-from idlelib import PyShell
+from idlelib import pyshell
-from idlelib.configHandler import idleConf
-from idlelib import macosxSupport
+from idlelib.config import idleConf
+from idlelib import macosx
indent_message = """Error: Inconsistent indentation detected!
@@ -46,12 +46,12 @@
def __init__(self, editwin):
self.editwin = editwin
- # Provide instance variables referenced by Debugger
+ # Provide instance variables referenced by debugger
# XXX This should be done differently
self.flist = self.editwin.flist
self.root = self.editwin.root
- if macosxSupport.isCocoaTk():
+ if macosx.isCocoaTk():
self.editwin.text_frame.bind('<<run-module-event-2>>', self._run_module_event)
def check_module_event(self, event):
@@ -112,7 +112,7 @@
shell.set_warning_stream(saved_stream)
def run_module_event(self, event):
- if macosxSupport.isCocoaTk():
+ if macosx.isCocoaTk():
# 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
@@ -142,7 +142,7 @@
if not self.tabnanny(filename):
return 'break'
interp = self.shell.interp
- if PyShell.use_subprocess:
+ if pyshell.use_subprocess:
interp.restart_subprocess(with_cwd=False, filename=
self.editwin._filename_to_unicode(filename))
dirname = os.path.dirname(filename)
@@ -161,7 +161,7 @@
interp.prepend_syspath(filename)
# XXX KBK 03Jul04 When run w/o subprocess, runtime warnings still
# go to __stderr__. With subprocess, they go to the shell.
- # Need to change streams in PyShell.ModifiedInterpreter.
+ # Need to change streams in pyshell.ModifiedInterpreter.
interp.runcode(code)
return 'break'
diff --git a/Lib/idlelib/ScrolledList.py b/Lib/idlelib/scrolledlist.py
similarity index 92%
rename from Lib/idlelib/ScrolledList.py
rename to Lib/idlelib/scrolledlist.py
index 53576b5..d0b6610 100644
--- a/Lib/idlelib/ScrolledList.py
+++ b/Lib/idlelib/scrolledlist.py
@@ -1,5 +1,6 @@
from tkinter import *
-from idlelib import macosxSupport
+from idlelib import macosx
+from tkinter.ttk import Scrollbar
class ScrolledList:
@@ -23,7 +24,7 @@
# Bind events to the list box
listbox.bind("<ButtonRelease-1>", self.click_event)
listbox.bind("<Double-ButtonRelease-1>", self.double_click_event)
- if macosxSupport.isAquaTk():
+ if macosx.isAquaTk():
listbox.bind("<ButtonPress-2>", self.popup_event)
listbox.bind("<Control-Button-1>", self.popup_event)
else:
@@ -124,22 +125,20 @@
pass
-def _scrolled_list(parent):
- root = Tk()
- root.title("Test ScrolledList")
+def _scrolled_list(parent): # htest #
+ top = Toplevel(parent)
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 150))
+ top.geometry("+%d+%d"%(x+200, y + 175))
class MyScrolledList(ScrolledList):
def fill_menu(self): self.menu.add_command(label="right click")
def on_select(self, index): print("select", self.get(index))
def on_double(self, index): print("double", self.get(index))
- scrolled_list = MyScrolledList(root)
+ scrolled_list = MyScrolledList(top)
for i in range(30):
scrolled_list.append("Item %02d" % i)
- root.mainloop()
-
if __name__ == '__main__':
+ # At the moment, test_scrolledlist merely creates instance, like htest.
from idlelib.idle_test.htest import run
run(_scrolled_list)
diff --git a/Lib/idlelib/SearchDialog.py b/Lib/idlelib/search.py
similarity index 95%
rename from Lib/idlelib/SearchDialog.py
rename to Lib/idlelib/search.py
index 765d53f..a609fd9 100644
--- a/Lib/idlelib/SearchDialog.py
+++ b/Lib/idlelib/search.py
@@ -1,12 +1,12 @@
from tkinter import *
-from idlelib import SearchEngine
-from idlelib.SearchDialogBase import SearchDialogBase
+from idlelib import searchengine
+from idlelib.searchbase import SearchDialogBase
def _setup(text):
"Create or find the singleton SearchDialog instance."
root = text._root()
- engine = SearchEngine.get(root)
+ engine = searchengine.get(root)
if not hasattr(engine, "_searchdialog"):
engine._searchdialog = SearchDialog(root, engine)
return engine._searchdialog
diff --git a/Lib/idlelib/SearchDialogBase.py b/Lib/idlelib/searchbase.py
similarity index 98%
rename from Lib/idlelib/SearchDialogBase.py
rename to Lib/idlelib/searchbase.py
index 5fa84e2..9206bf5 100644
--- a/Lib/idlelib/SearchDialogBase.py
+++ b/Lib/idlelib/searchbase.py
@@ -125,7 +125,7 @@
def create_option_buttons(self):
'''Return (filled frame, options) for testing.
- Options is a list of SearchEngine booleanvar, label pairs.
+ Options is a list of searchengine booleanvar, label pairs.
A gridded frame from make_frame is filled with a Checkbutton
for each pair, bound to the var, with the corresponding label.
'''
diff --git a/Lib/idlelib/SearchEngine.py b/Lib/idlelib/searchengine.py
similarity index 99%
rename from Lib/idlelib/SearchEngine.py
rename to Lib/idlelib/searchengine.py
index 37883bf..2e3700e 100644
--- a/Lib/idlelib/SearchEngine.py
+++ b/Lib/idlelib/searchengine.py
@@ -57,7 +57,7 @@
def setcookedpat(self, pat):
"Set pattern after escaping if re."
- # called only in SearchDialog.py: 66
+ # called only in search.py: 66
if self.isre():
pat = re.escape(pat)
self.setpat(pat)
diff --git a/Lib/idlelib/StackViewer.py b/Lib/idlelib/stackviewer.py
similarity index 89%
rename from Lib/idlelib/StackViewer.py
rename to Lib/idlelib/stackviewer.py
index ccc755c..b3b99bc 100644
--- a/Lib/idlelib/StackViewer.py
+++ b/Lib/idlelib/stackviewer.py
@@ -4,9 +4,9 @@
import re
import tkinter as tk
-from idlelib.TreeWidget import TreeNode, TreeItem, ScrolledCanvas
-from idlelib.ObjectBrowser import ObjectTreeItem, make_objecttreeitem
-from idlelib.PyShell import PyShellFileList
+from idlelib.tree import TreeNode, TreeItem, ScrolledCanvas
+from idlelib.debugobj import ObjectTreeItem, make_objecttreeitem
+from idlelib.pyshell import PyShellFileList
def StackBrowser(root, flist=None, tb=None, top=None):
if top is None:
@@ -120,15 +120,12 @@
sublist.append(item)
return sublist
- def keys(self): # unused, left for possible 3rd party use
- return list(self.object.keys())
-
def _stack_viewer(parent):
- root = tk.Tk()
- root.title("Test StackViewer")
+ top = tk.Toplevel(parent)
+ top.title("Test StackViewer")
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 150))
- flist = PyShellFileList(root)
+ top.geometry("+%d+%d"%(x, y + 150))
+ flist = PyShellFileList(top)
try: # to obtain a traceback object
intentional_name_error
except NameError:
@@ -139,7 +136,7 @@
sys.last_value = exc_value
sys.last_traceback = exc_tb
- StackBrowser(root, flist=flist, top=root, tb=exc_tb)
+ StackBrowser(top, flist=flist, top=top, tb=exc_tb)
# restore sys to original state
del sys.last_type
diff --git a/Lib/idlelib/MultiStatusBar.py b/Lib/idlelib/statusbar.py
similarity index 61%
rename from Lib/idlelib/MultiStatusBar.py
rename to Lib/idlelib/statusbar.py
index e82ba9a..c093920 100644
--- a/Lib/idlelib/MultiStatusBar.py
+++ b/Lib/idlelib/statusbar.py
@@ -1,16 +1,14 @@
-from tkinter import *
+from tkinter import Frame, Label
class MultiStatusBar(Frame):
- def __init__(self, master=None, **kw):
- if master is None:
- master = Tk()
+ def __init__(self, master, **kw):
Frame.__init__(self, master, **kw)
self.labels = {}
- def set_label(self, name, text='', side=LEFT, width=0):
+ def set_label(self, name, text='', side='left', width=0):
if name not in self.labels:
- label = Label(self, borderwidth=0, anchor=W)
+ label = Label(self, borderwidth=0, anchor='w')
label.pack(side=side, pady=0, padx=4)
self.labels[name] = label
else:
@@ -20,27 +18,27 @@
label.config(text=text)
def _multistatus_bar(parent):
- root = Tk()
+ import re
+ from tkinter import Toplevel, Frame, Text, Button
+ top = Toplevel(parent)
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d" %(x, y + 150))
- root.title("Test multistatus bar")
- frame = Frame(root)
+ top.geometry("+%d+%d" %(x, y + 150))
+ top.title("Test multistatus bar")
+ frame = Frame(top)
text = Text(frame)
text.pack()
msb = MultiStatusBar(frame)
msb.set_label("one", "hello")
msb.set_label("two", "world")
- msb.pack(side=BOTTOM, fill=X)
+ msb.pack(side='bottom', fill='x')
def change():
msb.set_label("one", "foo")
msb.set_label("two", "bar")
- button = Button(root, text="Update status", command=change)
- button.pack(side=BOTTOM)
+ button = Button(top, text="Update status", command=change)
+ button.pack(side='bottom')
frame.pack()
- frame.mainloop()
- root.mainloop()
if __name__ == '__main__':
from idlelib.idle_test.htest import run
diff --git a/Lib/idlelib/tabbedpages.py b/Lib/idlelib/tabbedpages.py
index 965f9f8..5f67097 100644
--- a/Lib/idlelib/tabbedpages.py
+++ b/Lib/idlelib/tabbedpages.py
@@ -467,31 +467,29 @@
self._tab_set.set_selected_tab(page_name)
-def _tabbed_pages(parent):
- # test dialog
- root=Tk()
+def _tabbed_pages(parent): # htest #
+ import re
+ top=Toplevel(parent)
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 175))
- root.title("Test tabbed pages")
- tabPage=TabbedPageSet(root, page_names=['Foobar','Baz'], n_rows=0,
+ top.geometry("+%d+%d"%(x, y + 175))
+ top.title("Test tabbed pages")
+ tabPage=TabbedPageSet(top, page_names=['Foobar','Baz'], n_rows=0,
expand_tabs=False,
)
tabPage.pack(side=TOP, expand=TRUE, fill=BOTH)
Label(tabPage.pages['Foobar'].frame, text='Foo', pady=20).pack()
Label(tabPage.pages['Foobar'].frame, text='Bar', pady=20).pack()
Label(tabPage.pages['Baz'].frame, text='Baz').pack()
- entryPgName=Entry(root)
- buttonAdd=Button(root, text='Add Page',
+ entryPgName=Entry(top)
+ buttonAdd=Button(top, text='Add Page',
command=lambda:tabPage.add_page(entryPgName.get()))
- buttonRemove=Button(root, text='Remove Page',
+ buttonRemove=Button(top, text='Remove Page',
command=lambda:tabPage.remove_page(entryPgName.get()))
- labelPgName=Label(root, text='name of page to add/remove:')
+ labelPgName=Label(top, text='name of page to add/remove:')
buttonAdd.pack(padx=5, pady=5)
buttonRemove.pack(padx=5, pady=5)
labelPgName.pack(padx=5)
entryPgName.pack(padx=5)
- root.mainloop()
-
if __name__ == '__main__':
from idlelib.idle_test.htest import run
diff --git a/Lib/idlelib/textView.py b/Lib/idlelib/textview.py
similarity index 85%
rename from Lib/idlelib/textView.py
rename to Lib/idlelib/textview.py
index 12ac319..7664524 100644
--- a/Lib/idlelib/textView.py
+++ b/Lib/idlelib/textview.py
@@ -3,7 +3,8 @@
"""
from tkinter import *
-import tkinter.messagebox as tkMessageBox
+from tkinter.ttk import Scrollbar
+from tkinter.messagebox import showerror
class TextViewer(Toplevel):
"""A simple text viewer dialog for IDLE
@@ -50,7 +51,7 @@
self.buttonOk = Button(frameButtons, text='Close',
command=self.Ok, takefocus=FALSE)
self.scrollbarView = Scrollbar(frameText, orient=VERTICAL,
- takefocus=FALSE, highlightthickness=0)
+ takefocus=FALSE)
self.textView = Text(frameText, wrap=WORD, highlightthickness=0,
fg=self.fg, bg=self.bg)
self.scrollbarView.config(command=self.textView.yview)
@@ -72,14 +73,14 @@
try:
with open(filename, 'r', encoding=encoding) as file:
contents = file.read()
- except IOError:
- tkMessageBox.showerror(title='File Load Error',
- message='Unable to load file %r .' % filename,
- parent=parent)
+ except OSError:
+ showerror(title='File Load Error',
+ message='Unable to load file %r .' % filename,
+ parent=parent)
except UnicodeDecodeError as err:
- tkMessageBox.showerror(title='Unicode Decode Error',
- message=str(err),
- parent=parent)
+ showerror(title='Unicode Decode Error',
+ message=str(err),
+ parent=parent)
else:
return view_text(parent, title, contents, modal)
diff --git a/Lib/idlelib/ToolTip.py b/Lib/idlelib/tooltip.py
similarity index 96%
rename from Lib/idlelib/ToolTip.py
rename to Lib/idlelib/tooltip.py
index 964107e..c3eafed 100644
--- a/Lib/idlelib/ToolTip.py
+++ b/Lib/idlelib/tooltip.py
@@ -1,4 +1,4 @@
-# general purpose 'tooltip' routines - currently unused in idlefork
+# general purpose 'tooltip' routines - currently unused in idlelib
# (although the 'calltips' extension is partly based on this code)
# may be useful for some purposes in (or almost in ;) the current project scope
# Ideas gleaned from PySol
@@ -76,7 +76,7 @@
for item in self.items:
listbox.insert(END, item)
-def _tooltip(parent):
+def _tooltip(parent): # htest #
root = Tk()
root.title("Test tooltip")
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
diff --git a/Lib/idlelib/TreeWidget.py b/Lib/idlelib/tree.py
similarity index 96%
rename from Lib/idlelib/TreeWidget.py
rename to Lib/idlelib/tree.py
index a19578f..cb7f9ae 100644
--- a/Lib/idlelib/TreeWidget.py
+++ b/Lib/idlelib/tree.py
@@ -16,9 +16,9 @@
import os
from tkinter import *
-
-from idlelib import ZoomHeight
-from idlelib.configHandler import idleConf
+from tkinter.ttk import Scrollbar
+from idlelib import zoomheight
+from idlelib.config import idleConf
ICONDIR = "Icons"
@@ -445,22 +445,21 @@
self.canvas.yview_scroll(1, "unit")
return "break"
def zoom_height(self, event):
- ZoomHeight.zoom_height(self.master)
+ zoomheight.zoom_height(self.master)
return "break"
-def _tree_widget(parent):
- root = Tk()
- root.title("Test TreeWidget")
+def _tree_widget(parent): # htest #
+ top = Toplevel(parent)
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- root.geometry("+%d+%d"%(x, y + 150))
- sc = ScrolledCanvas(root, bg="white", highlightthickness=0, takefocus=1)
+ top.geometry("+%d+%d"%(x+50, y+175))
+ sc = ScrolledCanvas(top, bg="white", highlightthickness=0, takefocus=1)
sc.frame.pack(expand=1, fill="both", side=LEFT)
- item = FileTreeItem(os.getcwd())
+ item = FileTreeItem(ICONDIR)
node = TreeNode(sc.canvas, None, item)
node.expand()
- root.mainloop()
if __name__ == '__main__':
+ # test_tree is currently a copy of this
from idlelib.idle_test.htest import run
run(_tree_widget)
diff --git a/Lib/idlelib/UndoDelegator.py b/Lib/idlelib/undo.py
similarity index 96%
rename from Lib/idlelib/UndoDelegator.py
rename to Lib/idlelib/undo.py
index 1c2502d..ccc962a 100644
--- a/Lib/idlelib/UndoDelegator.py
+++ b/Lib/idlelib/undo.py
@@ -1,7 +1,7 @@
import string
-from tkinter import *
-
-from idlelib.Delegator import Delegator
+from idlelib.delegator import Delegator
+# tkintter import not needed because module does not create widgets,
+# although many methods operate on text widget arguments.
#$ event <<redo>>
#$ win <Control-y>
@@ -339,12 +339,12 @@
def _undo_delegator(parent): # htest #
import re
- import tkinter as tk
- from idlelib.Percolator import Percolator
- undowin = tk.Toplevel()
+ from tkinter import Toplevel, Text, Button
+ from idlelib.percolator import Percolator
+ undowin = Toplevel(parent)
undowin.title("Test UndoDelegator")
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
- undowin.geometry("+%d+%d"%(x, y + 150))
+ undowin.geometry("+%d+%d"%(x, y + 175))
text = Text(undowin, height=10)
text.pack()
@@ -362,7 +362,7 @@
if __name__ == "__main__":
import unittest
- unittest.main('idlelib.idle_test.test_undodelegator', verbosity=2,
+ unittest.main('idlelib.idle_test.test_undo', verbosity=2,
exit=False)
from idlelib.idle_test.htest import run
run(_undo_delegator)
diff --git a/Lib/idlelib/WindowList.py b/Lib/idlelib/windows.py
similarity index 100%
rename from Lib/idlelib/WindowList.py
rename to Lib/idlelib/windows.py
diff --git a/Lib/idlelib/ZoomHeight.py b/Lib/idlelib/zoomheight.py
similarity index 94%
rename from Lib/idlelib/ZoomHeight.py
rename to Lib/idlelib/zoomheight.py
index a5d679e..0016e9d 100644
--- a/Lib/idlelib/ZoomHeight.py
+++ b/Lib/idlelib/zoomheight.py
@@ -3,7 +3,7 @@
import re
import sys
-from idlelib import macosxSupport
+from idlelib import macosx
class ZoomHeight:
@@ -32,7 +32,7 @@
newy = 0
newheight = newheight - 72
- elif macosxSupport.isAquaTk():
+ elif macosx.isAquaTk():
# 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 --git a/Lib/imaplib.py b/Lib/imaplib.py
index 4e8a4bb..a63ba8d 100644
--- a/Lib/imaplib.py
+++ b/Lib/imaplib.py
@@ -111,7 +111,15 @@
# Literal is no longer used; kept for backward compatibility.
Literal = re.compile(br'.*{(?P<size>\d+)}$', re.ASCII)
MapCRLF = re.compile(br'\r\n|\r|\n')
-Response_code = re.compile(br'\[(?P<type>[A-Z-]+)( (?P<data>[^\]]*))?\]')
+# We no longer exclude the ']' character from the data portion of the response
+# code, even though it violates the RFC. Popular IMAP servers such as Gmail
+# allow flags with ']', and there are programs (including imaplib!) that can
+# produce them. The problem with this is if the 'text' portion of the response
+# includes a ']' we'll parse the response wrong (which is the point of the RFC
+# restriction). However, that seems less likely to be a problem in practice
+# than being unable to correctly parse flags that include ']' chars, which
+# was reported as a real-world problem in issue #21815.
+Response_code = re.compile(br'\[(?P<type>[A-Z-]+)( (?P<data>.*))?\]')
Untagged_response = re.compile(br'\* (?P<type>[A-Z-]+)( (?P<data>.*))?')
# Untagged_status is no longer used; kept for backward compatibility
Untagged_status = re.compile(
diff --git a/Lib/imp.py b/Lib/imp.py
index f6fff44..b339952 100644
--- a/Lib/imp.py
+++ b/Lib/imp.py
@@ -30,7 +30,7 @@
warnings.warn("the imp module is deprecated in favour of importlib; "
"see the module's documentation for alternative uses",
- PendingDeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=2)
# DEPRECATED
SEARCH_ERROR = 0
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index 9eecbfe..afc31ee 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -878,13 +878,20 @@
def _find_spec(name, path, target=None):
"""Find a module's loader."""
- if sys.meta_path is not None and not sys.meta_path:
+ meta_path = sys.meta_path
+ if meta_path is None:
+ # PyImport_Cleanup() is running or has been called.
+ raise ImportError("sys.meta_path is None, Python is likely "
+ "shutting down")
+
+ if not meta_path:
_warnings.warn('sys.meta_path is empty', ImportWarning)
+
# We check sys.modules here for the reload case. While a passed-in
# target will usually indicate a reload there is no guarantee, whereas
# sys.modules provides one.
is_reload = name in sys.modules
- for finder in sys.meta_path:
+ for finder in meta_path:
with _ImportLockContext():
try:
find_spec = finder.find_spec
@@ -925,6 +932,9 @@
if level > 0:
if not isinstance(package, str):
raise TypeError('__package__ not set to a string')
+ elif not package:
+ raise ImportError('attempted relative import with no known parent '
+ 'package')
elif package not in sys.modules:
msg = ('Parent module {!r} not loaded, cannot perform relative '
'import')
@@ -1033,7 +1043,19 @@
"""
package = globals.get('__package__')
- if package is None:
+ spec = globals.get('__spec__')
+ if package is not None:
+ if spec is not None and package != spec.parent:
+ _warnings.warn("__package__ != __spec__.parent "
+ f"({package!r} != {spec.parent!r})",
+ ImportWarning, stacklevel=3)
+ return package
+ elif spec is not None:
+ return spec.parent
+ else:
+ _warnings.warn("can't resolve package from __spec__ or __package__, "
+ "falling back on __name__ and __path__",
+ ImportWarning, stacklevel=3)
package = globals['__name__']
if '__path__' not in globals:
package = package.rpartition('.')[0]
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
index 08ddb2b..30e8330 100644
--- a/Lib/importlib/_bootstrap_external.py
+++ b/Lib/importlib/_bootstrap_external.py
@@ -130,10 +130,6 @@
# a .pyc file in text mode the magic number will be wrong; also, the
# Apple MPW compiler swaps their values, botching string constants.
#
-# The magic numbers must be spaced apart at least 2 values, as the
-# -U interpeter flag will cause MAGIC+1 being used. They have been
-# odd numbers for some time now.
-#
# There were a variety of old schemes for setting the magic number.
# The current working scheme is to increment the previous value by
# 10.
@@ -224,6 +220,12 @@
# Python 3.5b2 3340 (fix dictionary display evaluation order #11205)
# Python 3.5b2 3350 (add GET_YIELD_FROM_ITER opcode #24400)
# Python 3.5.2 3351 (fix BUILD_MAP_UNPACK_WITH_CALL opcode #27286)
+# Python 3.6a0 3360 (add FORMAT_VALUE opcode #25483
+# Python 3.6a0 3361 (lineno delta of code.co_lnotab becomes signed)
+# Python 3.6a1 3370 (16 bit wordcode)
+# Python 3.6a1 3371 (add BUILD_CONST_KEY_MAP opcode #27140)
+# Python 3.6a1 3372 (MAKE_FUNCTION simplification, remove MAKE_CLOSURE
+ #27095)
#
# MAGIC must change whenever the bytecode emitted by the compiler may no
# longer be understood by older implementations of the eval loop (usually
@@ -232,7 +234,7 @@
# Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array
# in PC/launcher.c must also be updated.
-MAGIC_NUMBER = (3351).to_bytes(2, 'little') + b'\r\n'
+MAGIC_NUMBER = (3372).to_bytes(2, 'little') + b'\r\n'
_RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c
_PYCACHE = '__pycache__'
@@ -364,14 +366,6 @@
return mode
-def _verbose_message(message, *args, verbosity=1):
- """Print the message to stderr if -v/PYTHONVERBOSE is turned on."""
- if sys.flags.verbose >= verbosity:
- if not message.startswith(('#', 'import ')):
- message = '# ' + message
- print(message.format(*args), file=sys.stderr)
-
-
def _check_name(method):
"""Decorator to verify that the module being requested matches the one the
loader can handle.
@@ -441,15 +435,15 @@
raw_size = data[8:12]
if magic != MAGIC_NUMBER:
message = 'bad magic number in {!r}: {!r}'.format(name, magic)
- _verbose_message('{}', message)
+ _bootstrap._verbose_message('{}', message)
raise ImportError(message, **exc_details)
elif len(raw_timestamp) != 4:
message = 'reached EOF while reading timestamp in {!r}'.format(name)
- _verbose_message('{}', message)
+ _bootstrap._verbose_message('{}', message)
raise EOFError(message)
elif len(raw_size) != 4:
message = 'reached EOF while reading size of source in {!r}'.format(name)
- _verbose_message('{}', message)
+ _bootstrap._verbose_message('{}', message)
raise EOFError(message)
if source_stats is not None:
try:
@@ -459,7 +453,7 @@
else:
if _r_long(raw_timestamp) != source_mtime:
message = 'bytecode is stale for {!r}'.format(name)
- _verbose_message('{}', message)
+ _bootstrap._verbose_message('{}', message)
raise ImportError(message, **exc_details)
try:
source_size = source_stats['size'] & 0xFFFFFFFF
@@ -476,7 +470,7 @@
"""Compile bytecode as returned by _validate_bytecode_header()."""
code = marshal.loads(data)
if isinstance(code, _code_type):
- _verbose_message('code object from {!r}', bytecode_path)
+ _bootstrap._verbose_message('code object from {!r}', bytecode_path)
if source_path is not None:
_imp._fix_co_filename(code, source_path)
return code
@@ -603,7 +597,7 @@
else:
registry_key = cls.REGISTRY_KEY
key = registry_key.format(fullname=fullname,
- sys_version=sys.version[:3])
+ sys_version='%d.%d' % sys.version_info[:2])
try:
with cls._open_registry(key) as hkey:
filepath = _winreg.QueryValue(hkey, '')
@@ -666,6 +660,7 @@
_bootstrap._call_with_frames_removed(exec, code, module.__dict__)
def load_module(self, fullname):
+ """This module is deprecated."""
return _bootstrap._load_module_shim(self, fullname)
@@ -759,21 +754,21 @@
except (ImportError, EOFError):
pass
else:
- _verbose_message('{} matches {}', bytecode_path,
- source_path)
+ _bootstrap._verbose_message('{} matches {}', bytecode_path,
+ source_path)
return _compile_bytecode(bytes_data, name=fullname,
bytecode_path=bytecode_path,
source_path=source_path)
source_bytes = self.get_data(source_path)
code_object = self.source_to_code(source_bytes, source_path)
- _verbose_message('code object from {}', source_path)
+ _bootstrap._verbose_message('code object from {}', source_path)
if (not sys.dont_write_bytecode and bytecode_path is not None and
source_mtime is not None):
data = _code_to_bytecode(code_object, source_mtime,
len(source_bytes))
try:
self._cache_bytecode(source_path, bytecode_path, data)
- _verbose_message('wrote {!r}', bytecode_path)
+ _bootstrap._verbose_message('wrote {!r}', bytecode_path)
except NotImplementedError:
pass
return code_object
@@ -853,14 +848,16 @@
except OSError as exc:
# Could be a permission error, read-only filesystem: just forget
# about writing the data.
- _verbose_message('could not create {!r}: {!r}', parent, exc)
+ _bootstrap._verbose_message('could not create {!r}: {!r}',
+ parent, exc)
return
try:
_write_atomic(path, data, _mode)
- _verbose_message('created {!r}', path)
+ _bootstrap._verbose_message('created {!r}', path)
except OSError as exc:
# Same as above: just don't write the bytecode.
- _verbose_message('could not create {!r}: {!r}', path, exc)
+ _bootstrap._verbose_message('could not create {!r}: {!r}', path,
+ exc)
class SourcelessFileLoader(FileLoader, _LoaderBasics):
@@ -905,14 +902,14 @@
"""Create an unitialized extension module"""
module = _bootstrap._call_with_frames_removed(
_imp.create_dynamic, spec)
- _verbose_message('extension module {!r} loaded from {!r}',
+ _bootstrap._verbose_message('extension module {!r} loaded from {!r}',
spec.name, self.path)
return module
def exec_module(self, module):
"""Initialize an extension module"""
_bootstrap._call_with_frames_removed(_imp.exec_dynamic, module)
- _verbose_message('extension module {!r} executed from {!r}',
+ _bootstrap._verbose_message('extension module {!r} executed from {!r}',
self.name, self.path)
def is_package(self, fullname):
@@ -978,6 +975,9 @@
def __iter__(self):
return iter(self._recalculate())
+ def __setitem__(self, index, path):
+ self._path[index] = path
+
def __len__(self):
return len(self._recalculate())
@@ -1027,7 +1027,8 @@
"""
# The import system never calls this method.
- _verbose_message('namespace module loaded with path {!r}', self._path)
+ _bootstrap._verbose_message('namespace module loaded with path {!r}',
+ self._path)
return _bootstrap._load_module_shim(self, fullname)
@@ -1247,12 +1248,13 @@
# Check for a file w/ a proper suffix exists.
for suffix, loader_class in self._loaders:
full_path = _path_join(self.path, tail_module + suffix)
- _verbose_message('trying {}'.format(full_path), verbosity=2)
+ _bootstrap._verbose_message('trying {}', full_path, verbosity=2)
if cache_module + suffix in cache:
if _path_isfile(full_path):
- return self._get_spec(loader_class, fullname, full_path, None, target)
+ return self._get_spec(loader_class, fullname, full_path,
+ None, target)
if is_namespace:
- _verbose_message('possible namespace for {}'.format(base_path))
+ _bootstrap._verbose_message('possible namespace for {}', base_path)
spec = _bootstrap.ModuleSpec(fullname, None)
spec.submodule_search_locations = [base_path]
return spec
diff --git a/Lib/importlib/util.py b/Lib/importlib/util.py
index e1fa07a..6bdf0d4 100644
--- a/Lib/importlib/util.py
+++ b/Lib/importlib/util.py
@@ -22,8 +22,8 @@
if not name.startswith('.'):
return name
elif not package:
- raise ValueError('{!r} is not a relative name '
- '(no leading dot)'.format(name))
+ raise ValueError(f'no package specified for {repr(name)} '
+ '(required for relative module names)')
level = 0
for character in name:
if character != '.':
@@ -204,11 +204,6 @@
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."""
@@ -218,13 +213,14 @@
# All module metadata must be garnered from __spec__ in order to avoid
# using mutated values.
# Stop triggering this method.
- self.__class__ = _Module
+ self.__class__ = types.ModuleType
# 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_then = self.__spec__.loader_state['__dict__']
+ original_type = self.__spec__.loader_state['__class__']
attrs_now = self.__dict__
attrs_updated = {}
for key, value in attrs_now.items():
@@ -239,9 +235,9 @@
# 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))
+ raise ValueError(f"module object for {original_name!r} "
+ "substituted in sys.modules during a lazy "
+ "load")
# Update after loading since that's what would happen in an eager
# loading situation.
self.__dict__.update(attrs_updated)
@@ -275,8 +271,7 @@
self.loader = loader
def create_module(self, spec):
- """Create a module which can have its __class__ manipulated."""
- return _Module(spec.name)
+ return self.loader.create_module(spec)
def exec_module(self, module):
"""Make the module load lazily."""
@@ -286,5 +281,8 @@
# 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()
+ loader_state = {}
+ loader_state['__dict__'] = module.__dict__.copy()
+ loader_state['__class__'] = module.__class__
+ module.__spec__.loader_state = loader_state
module.__class__ = _LazyModule
diff --git a/Lib/inspect.py b/Lib/inspect.py
index e830eb6..45d2110 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -16,7 +16,7 @@
getmodule() - determine the module that an object came from
getclasstree() - arrange classes so as to represent their hierarchy
- getargspec(), getargvalues(), getcallargs() - get info about function arguments
+ getargvalues(), getcallargs() - get info about function arguments
getfullargspec() - same, with support for Python 3 features
formatargspec(), formatargvalues() - format an argument spec
getouterframes(), getinnerframes() - get info about frames
@@ -624,23 +624,6 @@
raise TypeError('{!r} is not a module, class, method, '
'function, traceback, frame, or code object'.format(object))
-ModuleInfo = namedtuple('ModuleInfo', 'name suffix mode module_type')
-
-def getmoduleinfo(path):
- """Get the module name, suffix, mode, and module type for a given file."""
- warnings.warn('inspect.getmoduleinfo() is deprecated', DeprecationWarning,
- 2)
- with warnings.catch_warnings():
- warnings.simplefilter('ignore', PendingDeprecationWarning)
- import imp
- filename = os.path.basename(path)
- suffixes = [(-len(suffix), suffix, mode, mtype)
- for suffix, mode, mtype in imp.get_suffixes()]
- suffixes.sort() # try longest suffixes first, in case they overlap
- for neglen, suffix, mode, mtype in suffixes:
- if filename[neglen:] == suffix:
- return ModuleInfo(filename[:neglen], suffix, mode, mtype)
-
def getmodulename(path):
"""Return the module name for a given file, or None."""
fname = os.path.basename(path)
@@ -1061,8 +1044,6 @@
'kwonlydefaults' is a dictionary mapping names from kwonlyargs to defaults.
'annotations' is a dictionary mapping argument names to annotations.
- The first four items in the tuple correspond to getargspec().
-
This function is deprecated, use inspect.signature() instead.
"""
@@ -1173,8 +1154,7 @@
formatvalue=lambda value: '=' + repr(value),
formatreturns=lambda text: ' -> ' + text,
formatannotation=formatannotation):
- """Format an argument spec from the values returned by getargspec
- or getfullargspec.
+ """Format an argument spec from the values returned by getfullargspec.
The first seven arguments are (args, varargs, varkw, defaults,
kwonlyargs, kwonlydefaults, annotations). The other five arguments
@@ -2416,6 +2396,20 @@
if not isinstance(name, str):
raise TypeError("name must be a str, not a {!r}".format(name))
+ if name[0] == '.' and name[1:].isdigit():
+ # These are implicit arguments generated by comprehensions. In
+ # order to provide a friendlier interface to users, we recast
+ # their name as "implicitN" and treat them as positional-only.
+ # See issue 19611.
+ if kind != _POSITIONAL_OR_KEYWORD:
+ raise ValueError(
+ 'implicit arguments must be passed in as {}'.format(
+ _POSITIONAL_OR_KEYWORD
+ )
+ )
+ self._kind = _POSITIONAL_ONLY
+ name = 'implicit{}'.format(name[1:])
+
if not name.isidentifier():
raise ValueError('{!r} is not a valid parameter name'.format(name))
diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py
index 1f90058..20f33cb 100644
--- a/Lib/ipaddress.py
+++ b/Lib/ipaddress.py
@@ -636,12 +636,12 @@
broadcast = int(self.broadcast_address)
if n >= 0:
if network + n > broadcast:
- raise IndexError
+ raise IndexError('address out of range')
return self._address_class(network + n)
else:
n += 1
if broadcast + n < network:
- raise IndexError
+ raise IndexError('address out of range')
return self._address_class(broadcast + n)
def __lt__(self, other):
diff --git a/Lib/json/__init__.py b/Lib/json/__init__.py
index f72b058..f2c0d23 100644
--- a/Lib/json/__init__.py
+++ b/Lib/json/__init__.py
@@ -116,7 +116,7 @@
default=None,
)
-def dump(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True,
+def dump(obj, fp, *, skipkeys=False, ensure_ascii=True, check_circular=True,
allow_nan=True, cls=None, indent=None, separators=None,
default=None, sort_keys=False, **kw):
"""Serialize ``obj`` as a JSON formatted stream to ``fp`` (a
@@ -179,7 +179,7 @@
fp.write(chunk)
-def dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True,
+def dumps(obj, *, skipkeys=False, ensure_ascii=True, check_circular=True,
allow_nan=True, cls=None, indent=None, separators=None,
default=None, sort_keys=False, **kw):
"""Serialize ``obj`` to a JSON formatted ``str``.
@@ -240,7 +240,7 @@
_default_decoder = JSONDecoder(object_hook=None, object_pairs_hook=None)
-def load(fp, cls=None, object_hook=None, parse_float=None,
+def load(fp, *, cls=None, object_hook=None, parse_float=None,
parse_int=None, parse_constant=None, object_pairs_hook=None, **kw):
"""Deserialize ``fp`` (a ``.read()``-supporting file-like object containing
a JSON document) to a Python object.
@@ -268,7 +268,7 @@
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
-def loads(s, encoding=None, cls=None, object_hook=None, parse_float=None,
+def loads(s, *, encoding=None, cls=None, object_hook=None, parse_float=None,
parse_int=None, parse_constant=None, object_pairs_hook=None, **kw):
"""Deserialize ``s`` (a ``str`` instance containing a JSON
document) to a Python object.
diff --git a/Lib/json/decoder.py b/Lib/json/decoder.py
index 0f03f20..2422c6a 100644
--- a/Lib/json/decoder.py
+++ b/Lib/json/decoder.py
@@ -280,7 +280,7 @@
"""
- def __init__(self, object_hook=None, parse_float=None,
+ def __init__(self, *, object_hook=None, parse_float=None,
parse_int=None, parse_constant=None, strict=True,
object_pairs_hook=None):
"""``object_hook``, if specified, will be called with the result
diff --git a/Lib/json/encoder.py b/Lib/json/encoder.py
index d596489..41a497c 100644
--- a/Lib/json/encoder.py
+++ b/Lib/json/encoder.py
@@ -101,7 +101,7 @@
"""
item_separator = ', '
key_separator = ': '
- def __init__(self, skipkeys=False, ensure_ascii=True,
+ def __init__(self, *, skipkeys=False, ensure_ascii=True,
check_circular=True, allow_nan=True, sort_keys=False,
indent=None, separators=None, default=None):
"""Constructor for JSONEncoder, with sensible defaults.
@@ -176,7 +176,8 @@
return JSONEncoder.default(self, o)
"""
- raise TypeError(repr(o) + " is not JSON serializable")
+ raise TypeError("Object of type '%s' is not JSON serializable" %
+ o.__class__.__name__)
def encode(self, o):
"""Return a JSON string representation of a Python data structure.
diff --git a/Lib/lib2to3/fixer_util.py b/Lib/lib2to3/fixer_util.py
index 44502bf..babe6cb 100644
--- a/Lib/lib2to3/fixer_util.py
+++ b/Lib/lib2to3/fixer_util.py
@@ -1,8 +1,6 @@
"""Utility functions, node construction macros, etc."""
# Author: Collin Winter
-from itertools import islice
-
# Local imports
from .pgen2 import token
from .pytree import Leaf, Node
diff --git a/Lib/lib2to3/fixes/fix_dict.py b/Lib/lib2to3/fixes/fix_dict.py
index 963f952..d3655c9 100644
--- a/Lib/lib2to3/fixes/fix_dict.py
+++ b/Lib/lib2to3/fixes/fix_dict.py
@@ -30,9 +30,8 @@
# Local imports
from .. import pytree
from .. import patcomp
-from ..pgen2 import token
from .. import fixer_base
-from ..fixer_util import Name, Call, LParen, RParen, ArgList, Dot
+from ..fixer_util import Name, Call, Dot
from .. import fixer_util
diff --git a/Lib/lib2to3/fixes/fix_exec.py b/Lib/lib2to3/fixes/fix_exec.py
index 2c9b72d..ab921ee 100644
--- a/Lib/lib2to3/fixes/fix_exec.py
+++ b/Lib/lib2to3/fixes/fix_exec.py
@@ -10,7 +10,6 @@
"""
# Local imports
-from .. import pytree
from .. import fixer_base
from ..fixer_util import Comma, Name, Call
diff --git a/Lib/lib2to3/fixes/fix_filter.py b/Lib/lib2to3/fixes/fix_filter.py
index 391889f..bb6718c 100644
--- a/Lib/lib2to3/fixes/fix_filter.py
+++ b/Lib/lib2to3/fixes/fix_filter.py
@@ -14,7 +14,6 @@
"""
# Local imports
-from ..pgen2 import token
from .. import fixer_base
from ..fixer_util import Name, Call, ListComp, in_special_context
diff --git a/Lib/lib2to3/fixes/fix_has_key.py b/Lib/lib2to3/fixes/fix_has_key.py
index 18c560f..439708c 100644
--- a/Lib/lib2to3/fixes/fix_has_key.py
+++ b/Lib/lib2to3/fixes/fix_has_key.py
@@ -31,7 +31,6 @@
# Local imports
from .. import pytree
-from ..pgen2 import token
from .. import fixer_base
from ..fixer_util import Name, parenthesize
diff --git a/Lib/lib2to3/fixes/fix_metaclass.py b/Lib/lib2to3/fixes/fix_metaclass.py
index 46c7aaf..8e34463 100644
--- a/Lib/lib2to3/fixes/fix_metaclass.py
+++ b/Lib/lib2to3/fixes/fix_metaclass.py
@@ -20,7 +20,7 @@
# Local imports
from .. import fixer_base
from ..pygram import token
-from ..fixer_util import Name, syms, Node, Leaf
+from ..fixer_util import syms, Node, Leaf
def has_metaclass(parent):
diff --git a/Lib/lib2to3/fixes/fix_nonzero.py b/Lib/lib2to3/fixes/fix_nonzero.py
index ad91a29..c229596 100644
--- a/Lib/lib2to3/fixes/fix_nonzero.py
+++ b/Lib/lib2to3/fixes/fix_nonzero.py
@@ -3,7 +3,7 @@
# Local imports
from .. import fixer_base
-from ..fixer_util import Name, syms
+from ..fixer_util import Name
class FixNonzero(fixer_base.BaseFix):
BM_compatible = True
diff --git a/Lib/lib2to3/fixes/fix_print.py b/Lib/lib2to3/fixes/fix_print.py
index a1fe2f5..8780322 100644
--- a/Lib/lib2to3/fixes/fix_print.py
+++ b/Lib/lib2to3/fixes/fix_print.py
@@ -18,7 +18,7 @@
from .. import pytree
from ..pgen2 import token
from .. import fixer_base
-from ..fixer_util import Name, Call, Comma, String, is_tuple
+from ..fixer_util import Name, Call, Comma, String
parend_expr = patcomp.compile_pattern(
diff --git a/Lib/lib2to3/fixes/fix_types.py b/Lib/lib2to3/fixes/fix_types.py
index db34104..67bf51f 100644
--- a/Lib/lib2to3/fixes/fix_types.py
+++ b/Lib/lib2to3/fixes/fix_types.py
@@ -20,7 +20,6 @@
"""
# Local imports
-from ..pgen2 import token
from .. import fixer_base
from ..fixer_util import Name
@@ -42,7 +41,7 @@
'NotImplementedType' : 'type(NotImplemented)',
'SliceType' : 'slice',
'StringType': 'bytes', # XXX ?
- 'StringTypes' : 'str', # XXX ?
+ 'StringTypes' : '(str,)', # XXX ?
'TupleType': 'tuple',
'TypeType' : 'type',
'UnicodeType': 'str',
diff --git a/Lib/lib2to3/fixes/fix_urllib.py b/Lib/lib2to3/fixes/fix_urllib.py
index 1481cd9..5a36049 100644
--- a/Lib/lib2to3/fixes/fix_urllib.py
+++ b/Lib/lib2to3/fixes/fix_urllib.py
@@ -6,7 +6,6 @@
# Local imports
from lib2to3.fixes.fix_imports import alternates, FixImports
-from lib2to3 import fixer_base
from lib2to3.fixer_util import (Name, Comma, FromImport, Newline,
find_indentation, Node, syms)
diff --git a/Lib/lib2to3/refactor.py b/Lib/lib2to3/refactor.py
index 0728083..b60b9de 100644
--- a/Lib/lib2to3/refactor.py
+++ b/Lib/lib2to3/refactor.py
@@ -26,7 +26,6 @@
from .pgen2 import driver, tokenize, token
from .fixer_util import find_root
from . import pytree, pygram
-from . import btm_utils as bu
from . import btm_matcher as bm
diff --git a/Lib/lib2to3/tests/data/py3_test_grammar.py b/Lib/lib2to3/tests/data/py3_test_grammar.py
index c0bf7f2..cf31a54 100644
--- a/Lib/lib2to3/tests/data/py3_test_grammar.py
+++ b/Lib/lib2to3/tests/data/py3_test_grammar.py
@@ -319,7 +319,7 @@
def f(x) -> list: pass
self.assertEquals(f.__annotations__, {'return': list})
- # test MAKE_CLOSURE with a variety of oparg's
+ # test closures with a variety of oparg's
closure = 1
def f(): return closure
def f(x=1): return closure
diff --git a/Lib/lib2to3/tests/support.py b/Lib/lib2to3/tests/support.py
index 6f2d214..7153bb6 100644
--- a/Lib/lib2to3/tests/support.py
+++ b/Lib/lib2to3/tests/support.py
@@ -3,10 +3,8 @@
# Python imports
import unittest
-import sys
import os
import os.path
-import re
from textwrap import dedent
# Local imports
diff --git a/Lib/lib2to3/tests/test_all_fixers.py b/Lib/lib2to3/tests/test_all_fixers.py
index 15079fe..c0507cf 100644
--- a/Lib/lib2to3/tests/test_all_fixers.py
+++ b/Lib/lib2to3/tests/test_all_fixers.py
@@ -10,7 +10,6 @@
import test.support
# Local imports
-from lib2to3 import refactor
from . import support
diff --git a/Lib/lib2to3/tests/test_fixers.py b/Lib/lib2to3/tests/test_fixers.py
index 06b0033..b97b73a 100644
--- a/Lib/lib2to3/tests/test_fixers.py
+++ b/Lib/lib2to3/tests/test_fixers.py
@@ -2,12 +2,11 @@
# Python imports
import os
-import unittest
from itertools import chain
from operator import itemgetter
# Local imports
-from lib2to3 import pygram, pytree, refactor, fixer_util
+from lib2to3 import pygram, fixer_util
from lib2to3.tests import support
@@ -3322,6 +3321,10 @@
a = """type(None)"""
self.check(b, a)
+ b = "types.StringTypes"
+ a = "(str,)"
+ self.check(b, a)
+
class Test_idioms(FixerTestCase):
fixer = "idioms"
diff --git a/Lib/lib2to3/tests/test_parser.py b/Lib/lib2to3/tests/test_parser.py
index b533c01..36eb176 100644
--- a/Lib/lib2to3/tests/test_parser.py
+++ b/Lib/lib2to3/tests/test_parser.py
@@ -10,12 +10,11 @@
# Testing imports
from . import support
-from .support import driver, test_dir
+from .support import driver
from test.support import verbose
# Python imports
import os
-import sys
import unittest
import warnings
import subprocess
diff --git a/Lib/lib2to3/tests/test_pytree.py b/Lib/lib2to3/tests/test_pytree.py
index 4d585a8..a611d17 100644
--- a/Lib/lib2to3/tests/test_pytree.py
+++ b/Lib/lib2to3/tests/test_pytree.py
@@ -11,9 +11,6 @@
from __future__ import with_statement
-import sys
-import warnings
-
# Testing imports
from . import support
diff --git a/Lib/lib2to3/tests/test_refactor.py b/Lib/lib2to3/tests/test_refactor.py
index 8563001..94dc135 100644
--- a/Lib/lib2to3/tests/test_refactor.py
+++ b/Lib/lib2to3/tests/test_refactor.py
@@ -7,19 +7,15 @@
import sys
import os
import codecs
-import operator
import io
import re
import tempfile
import shutil
import unittest
-import warnings
from lib2to3 import refactor, pygram, fixer_base
from lib2to3.pgen2 import token
-from . import support
-
TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data")
FIXER_DIR = os.path.join(TEST_DATA_DIR, "fixers")
diff --git a/Lib/lib2to3/tests/test_util.py b/Lib/lib2to3/tests/test_util.py
index d2be82c..c6c6139 100644
--- a/Lib/lib2to3/tests/test_util.py
+++ b/Lib/lib2to3/tests/test_util.py
@@ -3,9 +3,6 @@
# Testing imports
from . import support
-# Python imports
-import os.path
-
# Local imports
from lib2to3.pytree import Node, Leaf
from lib2to3 import fixer_util
diff --git a/Lib/locale.py b/Lib/locale.py
index 6d59cd8..4de0090 100644
--- a/Lib/locale.py
+++ b/Lib/locale.py
@@ -302,12 +302,16 @@
def delocalize(string):
"Parses a string as a normalized number according to the locale settings."
+
+ conv = localeconv()
+
#First, get rid of the grouping
- ts = localeconv()['thousands_sep']
+ ts = conv['thousands_sep']
if ts:
string = string.replace(ts, '')
+
#next, replace the decimal point with a dot
- dd = localeconv()['decimal_point']
+ dd = conv['decimal_point']
if dd:
string = string.replace(dd, '.')
return string
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index a7bd890..f941f48 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -33,8 +33,9 @@
'StreamHandler', 'WARN', 'WARNING', 'addLevelName', 'basicConfig',
'captureWarnings', 'critical', 'debug', 'disable', 'error',
'exception', 'fatal', 'getLevelName', 'getLogger', 'getLoggerClass',
- 'info', 'log', 'makeLogRecord', 'setLoggerClass', 'warn', 'warning',
- 'getLogRecordFactory', 'setLogRecordFactory', 'lastResort']
+ 'info', 'log', 'makeLogRecord', 'setLoggerClass', 'shutdown',
+ 'warn', 'warning', 'getLogRecordFactory', 'setLogRecordFactory',
+ 'lastResort', 'raiseExceptions']
try:
import threading
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index c9f8217..c0748a8 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -440,11 +440,11 @@
sres = os.fstat(self.stream.fileno())
self.dev, self.ino = sres[ST_DEV], sres[ST_INO]
- def emit(self, record):
+ def reopenIfNeeded(self):
"""
- Emit a record.
+ Reopen log file if needed.
- First check if the underlying file has changed, and if it
+ Checks if the underlying file has changed, and if it
has, close the old stream and reopen the file to get the
current stream.
"""
@@ -467,6 +467,15 @@
# open a new file handle and get new stat info from that fd
self.stream = self._open()
self._statstream()
+
+ def emit(self, record):
+ """
+ Emit a record.
+
+ If underlying file has changed, reopen the file before emitting the
+ record to it.
+ """
+ self.reopenIfNeeded()
logging.FileHandler.emit(self, record)
diff --git a/Lib/mailbox.py b/Lib/mailbox.py
index 0270e25..0e23987 100644
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -23,9 +23,10 @@
except ImportError:
fcntl = None
-__all__ = [ 'Mailbox', 'Maildir', 'mbox', 'MH', 'Babyl', 'MMDF',
- 'Message', 'MaildirMessage', 'mboxMessage', 'MHMessage',
- 'BabylMessage', 'MMDFMessage']
+__all__ = ['Mailbox', 'Maildir', 'mbox', 'MH', 'Babyl', 'MMDF',
+ 'Message', 'MaildirMessage', 'mboxMessage', 'MHMessage',
+ 'BabylMessage', 'MMDFMessage', 'Error', 'NoSuchMailboxError',
+ 'NotEmptyError', 'ExternalClashError', 'FormatError']
linesep = os.linesep.encode('ascii')
diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py
index 0be76ad..9a88680 100644
--- a/Lib/mimetypes.py
+++ b/Lib/mimetypes.py
@@ -33,8 +33,10 @@
_winreg = None
__all__ = [
- "guess_type","guess_extension","guess_all_extensions",
- "add_type","read_mime_types","init"
+ "knownfiles", "inited", "MimeTypes",
+ "guess_type", "guess_all_extensions", "guess_extension",
+ "add_type", "init", "read_mime_types",
+ "suffix_map", "encodings_map", "types_map", "common_types"
]
knownfiles = [
diff --git a/Lib/modulefinder.py b/Lib/modulefinder.py
index 8103502..e220315 100644
--- a/Lib/modulefinder.py
+++ b/Lib/modulefinder.py
@@ -10,7 +10,7 @@
import struct
import warnings
with warnings.catch_warnings():
- warnings.simplefilter('ignore', PendingDeprecationWarning)
+ warnings.simplefilter('ignore', DeprecationWarning)
import imp
LOAD_CONST = dis.opmap['LOAD_CONST']
@@ -336,8 +336,7 @@
fullname = name + "." + sub
self._add_badmodule(fullname, caller)
- def scan_opcodes_25(self, co,
- unpack = struct.unpack):
+ def scan_opcodes(self, co):
# Scan the code, and yield 'interesting' opcode combinations
code = co.co_code
names = co.co_names
@@ -360,7 +359,7 @@
def scan_code(self, co, m):
code = co.co_code
- scanner = self.scan_opcodes_25
+ scanner = self.scan_opcodes
for what, args in scanner(co):
if what == "store":
name, = args
diff --git a/Lib/msilib/__init__.py b/Lib/msilib/__init__.py
index 6d0a28f..823644a 100644
--- a/Lib/msilib/__init__.py
+++ b/Lib/msilib/__init__.py
@@ -1,7 +1,7 @@
# Copyright (C) 2005 Martin v. Löwis
# Licensed to PSF under a Contributor Agreement.
from _msi import *
-import glob
+import fnmatch
import os
import re
import string
@@ -379,7 +379,13 @@
def glob(self, pattern, exclude = None):
"""Add a list of files to the current component as specified in the
glob pattern. Individual files can be excluded in the exclude list."""
- files = glob.glob1(self.absolute, pattern)
+ try:
+ files = os.listdir(self.absolute)
+ except OSError:
+ return []
+ if pattern[:1] != '.':
+ files = (f for f in files if f[0] != '.')
+ files = fnmatch.filter(files, pattern)
for f in files:
if exclude and f in exclude: continue
self.add_file(f)
diff --git a/Lib/multiprocessing/pool.py b/Lib/multiprocessing/pool.py
index 6d25469..ffdf426 100644
--- a/Lib/multiprocessing/pool.py
+++ b/Lib/multiprocessing/pool.py
@@ -638,22 +638,26 @@
self._number_left = length//chunksize + bool(length % chunksize)
def _set(self, i, success_result):
+ self._number_left -= 1
success, result = success_result
- if success:
+ if success and self._success:
self._value[i*self._chunksize:(i+1)*self._chunksize] = result
- self._number_left -= 1
if self._number_left == 0:
if self._callback:
self._callback(self._value)
del self._cache[self._job]
self._event.set()
else:
- self._success = False
- self._value = result
- if self._error_callback:
- self._error_callback(self._value)
- del self._cache[self._job]
- self._event.set()
+ if not success and self._success:
+ # only store first exception
+ self._success = False
+ self._value = result
+ if self._number_left == 0:
+ # only consider the result ready once all jobs are done
+ if self._error_callback:
+ self._error_callback(self._value)
+ del self._cache[self._job]
+ self._event.set()
#
# Class whose instances are returned by `Pool.imap()`
diff --git a/Lib/opcode.py b/Lib/opcode.py
index 4c826a7..0640819 100644
--- a/Lib/opcode.py
+++ b/Lib/opcode.py
@@ -34,9 +34,7 @@
hasnargs = []
opmap = {}
-opname = [''] * 256
-for op in range(256): opname[op] = '<%r>' % (op,)
-del op
+opname = ['<%r>' % (op,) for op in range(256)]
def def_op(name, op):
opname[op] = name
@@ -175,9 +173,8 @@
def_op('RAISE_VARARGS', 130) # Number of raise arguments (1, 2, or 3)
def_op('CALL_FUNCTION', 131) # #args + (#kwargs << 8)
hasnargs.append(131)
-def_op('MAKE_FUNCTION', 132) # Number of args with default values
+def_op('MAKE_FUNCTION', 132) # Flags
def_op('BUILD_SLICE', 133) # Number of items
-def_op('MAKE_CLOSURE', 134)
def_op('LOAD_CLOSURE', 135)
hasfree.append(135)
def_op('LOAD_DEREF', 136)
@@ -214,4 +211,7 @@
def_op('BUILD_TUPLE_UNPACK', 152)
def_op('BUILD_SET_UNPACK', 153)
+def_op('FORMAT_VALUE', 155)
+def_op('BUILD_CONST_KEY_MAP', 156)
+
del def_op, name_op, jrel_op, jabs_op
diff --git a/Lib/optparse.py b/Lib/optparse.py
index 74b3b36..e8ac1e1 100644
--- a/Lib/optparse.py
+++ b/Lib/optparse.py
@@ -38,7 +38,8 @@
'OptionError',
'OptionConflictError',
'OptionValueError',
- 'BadOptionError']
+ 'BadOptionError',
+ 'check_choice']
__copyright__ = """
Copyright (c) 2001-2006 Gregory P. Ward. All rights reserved.
diff --git a/Lib/os.py b/Lib/os.py
index b4c651d..c31ecb2 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -22,7 +22,7 @@
"""
#'
-
+import abc
import sys, errno
import stat as st
@@ -356,6 +356,7 @@
dirs = []
nondirs = []
+ walk_dirs = []
# We may not have read permission for top, in which case we can't
# get a list of the files the directory contains. os.walk
@@ -369,42 +370,52 @@
# Note that scandir is global in this module due
# to earlier import-*.
scandir_it = scandir(top)
- entries = list(scandir_it)
except OSError as error:
if onerror is not None:
onerror(error)
return
- for entry in entries:
- try:
- is_dir = entry.is_dir()
- except OSError:
- # If is_dir() raises an OSError, consider that the entry is not
- # a directory, same behaviour than os.path.isdir().
- is_dir = False
-
- if is_dir:
- dirs.append(entry.name)
- else:
- nondirs.append(entry.name)
-
- if not topdown and is_dir:
- # Bottom-up: recurse into sub-directory, but exclude symlinks to
- # directories if followlinks is False
- if followlinks:
- walk_into = True
- else:
+ with scandir_it:
+ while True:
+ try:
try:
- is_symlink = entry.is_symlink()
- except OSError:
- # If is_symlink() raises an OSError, consider that the
- # entry is not a symbolic link, same behaviour than
- # os.path.islink().
- is_symlink = False
- walk_into = not is_symlink
+ entry = next(scandir_it)
+ except StopIteration:
+ break
+ except OSError as error:
+ if onerror is not None:
+ onerror(error)
+ return
- if walk_into:
- yield from walk(entry.path, topdown, onerror, followlinks)
+ try:
+ is_dir = entry.is_dir()
+ except OSError:
+ # If is_dir() raises an OSError, consider that the entry is not
+ # a directory, same behaviour than os.path.isdir().
+ is_dir = False
+
+ if is_dir:
+ dirs.append(entry.name)
+ else:
+ nondirs.append(entry.name)
+
+ if not topdown and is_dir:
+ # Bottom-up: recurse into sub-directory, but exclude symlinks to
+ # directories if followlinks is False
+ if followlinks:
+ walk_into = True
+ else:
+ try:
+ is_symlink = entry.is_symlink()
+ except OSError:
+ # If is_symlink() raises an OSError, consider that the
+ # entry is not a symbolic link, same behaviour than
+ # os.path.islink().
+ is_symlink = False
+ walk_into = not is_symlink
+
+ if walk_into:
+ walk_dirs.append(entry.path)
# Yield before recursion if going top down
if topdown:
@@ -421,6 +432,9 @@
if followlinks or not islink(new_path):
yield from walk(new_path, topdown, onerror, followlinks)
else:
+ # Recurse into sub-directories
+ for new_path in walk_dirs:
+ yield from walk(new_path, topdown, onerror, followlinks)
# Yield after recursion if going bottom up
yield top, dirs, nondirs
@@ -467,10 +481,23 @@
stat = self.stat(follow_symlinks=False)
return st.S_ISLNK(stat.st_mode)
-def _dummy_scandir(dir):
+class _dummy_scandir:
# listdir-based implementation for bytes patches on Windows
- for name in listdir(dir):
- yield _DummyDirEntry(dir, name)
+ def __init__(self, dir):
+ self.dir = dir
+ self.it = iter(listdir(dir))
+
+ def __iter__(self):
+ return self
+
+ def __next__(self):
+ return _DummyDirEntry(self.dir, next(self.it))
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self, *args):
+ self.it = iter(())
__all__.append("walk")
@@ -849,30 +876,28 @@
errors = 'surrogateescape'
def fsencode(filename):
+ """Encode filename (an os.PathLike, bytes, or str) to the filesystem
+ encoding with 'surrogateescape' error handler, return bytes unchanged.
+ On Windows, use 'strict' error handler if the file system encoding is
+ 'mbcs' (which is the default encoding).
"""
- Encode filename to the filesystem encoding with 'surrogateescape' error
- handler, return bytes unchanged. On Windows, use 'strict' error handler if
- the file system encoding is 'mbcs' (which is the default encoding).
- """
- if isinstance(filename, bytes):
- return filename
- elif isinstance(filename, str):
+ filename = fspath(filename) # Does type-checking of `filename`.
+ if isinstance(filename, str):
return filename.encode(encoding, errors)
else:
- raise TypeError("expect bytes or str, not %s" % type(filename).__name__)
+ return filename
def fsdecode(filename):
+ """Decode filename (an os.PathLike, bytes, or str) from the filesystem
+ encoding with 'surrogateescape' error handler, return str unchanged. On
+ Windows, use 'strict' error handler if the file system encoding is
+ 'mbcs' (which is the default encoding).
"""
- Decode filename from the filesystem encoding with 'surrogateescape' error
- handler, return str unchanged. On Windows, use 'strict' error handler if
- the file system encoding is 'mbcs' (which is the default encoding).
- """
- if isinstance(filename, str):
- return filename
- elif isinstance(filename, bytes):
+ filename = fspath(filename) # Does type-checking of `filename`.
+ if isinstance(filename, bytes):
return filename.decode(encoding, errors)
else:
- raise TypeError("expect bytes or str, not %s" % type(filename).__name__)
+ return filename
return fsencode, fsdecode
@@ -1070,3 +1095,55 @@
raise TypeError("invalid fd type (%s, expected integer)" % type(fd))
import io
return io.open(fd, *args, **kwargs)
+
+
+# For testing purposes, make sure the function is available when the C
+# implementation exists.
+def _fspath(path):
+ """Return the path representation of a path-like object.
+
+ If str or bytes is passed in, it is returned unchanged. Otherwise the
+ os.PathLike interface is used to get the path representation. If the
+ path representation is not str or bytes, TypeError is raised. If the
+ provided path is not str, bytes, or os.PathLike, TypeError is raised.
+ """
+ if isinstance(path, (str, bytes)):
+ return path
+
+ # Work from the object's type to match method resolution of other magic
+ # methods.
+ path_type = type(path)
+ try:
+ path_repr = path_type.__fspath__(path)
+ except AttributeError:
+ if hasattr(path_type, '__fspath__'):
+ raise
+ else:
+ raise TypeError("expected str, bytes or os.PathLike object, "
+ "not " + path_type.__name__)
+ if isinstance(path_repr, (str, bytes)):
+ return path_repr
+ else:
+ raise TypeError("expected {}.__fspath__() to return str or bytes, "
+ "not {}".format(path_type.__name__,
+ type(path_repr).__name__))
+
+# If there is no C implementation, make the pure Python version the
+# implementation as transparently as possible.
+if not _exists('fspath'):
+ fspath = _fspath
+ fspath.__name__ = "fspath"
+
+
+class PathLike(abc.ABC):
+
+ """Abstract base class for implementing the file system path protocol."""
+
+ @abc.abstractmethod
+ def __fspath__(self):
+ """Return the file system path representation of the object."""
+ raise NotImplementedError
+
+ @classmethod
+ def __subclasshook__(cls, subclass):
+ return hasattr(subclass, '__fspath__')
diff --git a/Lib/pathlib.py b/Lib/pathlib.py
index 1480e2f..a06676f 100644
--- a/Lib/pathlib.py
+++ b/Lib/pathlib.py
@@ -634,13 +634,16 @@
for a in args:
if isinstance(a, PurePath):
parts += a._parts
- elif isinstance(a, str):
- # Force-cast str subclasses to str (issue #21127)
- parts.append(str(a))
else:
- raise TypeError(
- "argument should be a path or str object, not %r"
- % type(a))
+ a = os.fspath(a)
+ if isinstance(a, str):
+ # Force-cast str subclasses to str (issue #21127)
+ parts.append(str(a))
+ else:
+ raise TypeError(
+ "argument should be a str object or an os.PathLike "
+ "object returning str, not %r"
+ % type(a))
return cls._flavour.parse_parts(parts)
@classmethod
@@ -693,6 +696,9 @@
self._parts) or '.'
return self._str
+ def __fspath__(self):
+ return str(self)
+
def as_posix(self):
"""Return the string representation of the path with forward (/)
slashes."""
@@ -943,6 +949,10 @@
return False
return True
+# Can't subclass os.PathLike from PurePath and keep the constructor
+# optimizations in PurePath._parse_args().
+os.PathLike.register(PurePath)
+
class PurePosixPath(PurePath):
_flavour = _posix_flavour
diff --git a/Lib/pickle.py b/Lib/pickle.py
index 7760425..963b595 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -27,6 +27,7 @@
from copyreg import dispatch_table
from copyreg import _extension_registry, _inverted_registry, _extension_cache
from itertools import islice
+from functools import partial
import sys
from sys import maxsize
from struct import pack, unpack
@@ -544,7 +545,7 @@
write = self.write
func_name = getattr(func, "__name__", "")
- if self.proto >= 4 and func_name == "__newobj_ex__":
+ if self.proto >= 2 and func_name == "__newobj_ex__":
cls, args, kwargs = args
if not hasattr(cls, "__new__"):
raise PicklingError("args[0] from {} args has no __new__"
@@ -552,10 +553,16 @@
if obj is not None and cls is not obj.__class__:
raise PicklingError("args[0] from {} args has the wrong class"
.format(func_name))
- save(cls)
- save(args)
- save(kwargs)
- write(NEWOBJ_EX)
+ if self.proto >= 4:
+ save(cls)
+ save(args)
+ save(kwargs)
+ write(NEWOBJ_EX)
+ else:
+ func = partial(cls.__new__, cls, *args, **kwargs)
+ save(func)
+ save(())
+ write(REDUCE)
elif self.proto >= 2 and func_name == "__newobj__":
# A __reduce__ implementation can direct protocol 2 or newer to
# use the more efficient NEWOBJ opcode, while still
@@ -1024,7 +1031,7 @@
self._unframer = _Unframer(self._file_read, self._file_readline)
self.read = self._unframer.read
self.readline = self._unframer.readline
- self.mark = object() # any new unique object
+ self.metastack = []
self.stack = []
self.append = self.stack.append
self.proto = 0
@@ -1040,20 +1047,12 @@
except _Stop as stopinst:
return stopinst.value
- # Return largest index k such that self.stack[k] is self.mark.
- # If the stack doesn't contain a mark, eventually raises IndexError.
- # This could be sped by maintaining another stack, of indices at which
- # the mark appears. For that matter, the latter stack would suffice,
- # and we wouldn't need to push mark objects on self.stack at all.
- # Doing so is probably a good thing, though, since if the pickle is
- # corrupt (or hostile) we may get a clue from finding self.mark embedded
- # in unpickled objects.
- def marker(self):
- stack = self.stack
- mark = self.mark
- k = len(stack)-1
- while stack[k] is not mark: k = k-1
- return k
+ # Return a list of items pushed in the stack after last MARK instruction.
+ def pop_mark(self):
+ items = self.stack
+ self.stack = self.metastack.pop()
+ self.append = self.stack.append
+ return items
def persistent_load(self, pid):
raise UnpicklingError("unsupported persistent id encountered")
@@ -1230,8 +1229,8 @@
dispatch[SHORT_BINUNICODE[0]] = load_short_binunicode
def load_tuple(self):
- k = self.marker()
- self.stack[k:] = [tuple(self.stack[k+1:])]
+ items = self.pop_mark()
+ self.append(tuple(items))
dispatch[TUPLE[0]] = load_tuple
def load_empty_tuple(self):
@@ -1263,21 +1262,20 @@
dispatch[EMPTY_SET[0]] = load_empty_set
def load_frozenset(self):
- k = self.marker()
- self.stack[k:] = [frozenset(self.stack[k+1:])]
+ items = self.pop_mark()
+ self.append(frozenset(items))
dispatch[FROZENSET[0]] = load_frozenset
def load_list(self):
- k = self.marker()
- self.stack[k:] = [self.stack[k+1:]]
+ items = self.pop_mark()
+ self.append(items)
dispatch[LIST[0]] = load_list
def load_dict(self):
- k = self.marker()
- items = self.stack[k+1:]
+ items = self.pop_mark()
d = {items[i]: items[i+1]
for i in range(0, len(items), 2)}
- self.stack[k:] = [d]
+ self.append(d)
dispatch[DICT[0]] = load_dict
# INST and OBJ differ only in how they get a class object. It's not
@@ -1285,9 +1283,7 @@
# previously diverged and grew different bugs.
# klass is the class to instantiate, and k points to the topmost mark
# object, following which are the arguments for klass.__init__.
- def _instantiate(self, klass, k):
- args = tuple(self.stack[k+1:])
- del self.stack[k:]
+ def _instantiate(self, klass, args):
if (args or not isinstance(klass, type) or
hasattr(klass, "__getinitargs__")):
try:
@@ -1303,14 +1299,14 @@
module = self.readline()[:-1].decode("ascii")
name = self.readline()[:-1].decode("ascii")
klass = self.find_class(module, name)
- self._instantiate(klass, self.marker())
+ self._instantiate(klass, self.pop_mark())
dispatch[INST[0]] = load_inst
def load_obj(self):
# Stack is ... markobject classobject arg1 arg2 ...
- k = self.marker()
- klass = self.stack.pop(k+1)
- self._instantiate(klass, k)
+ args = self.pop_mark()
+ cls = args.pop(0)
+ self._instantiate(cls, args)
dispatch[OBJ[0]] = load_obj
def load_newobj(self):
@@ -1395,12 +1391,14 @@
dispatch[REDUCE[0]] = load_reduce
def load_pop(self):
- del self.stack[-1]
+ if self.stack:
+ del self.stack[-1]
+ else:
+ self.pop_mark()
dispatch[POP[0]] = load_pop
def load_pop_mark(self):
- k = self.marker()
- del self.stack[k:]
+ self.pop_mark()
dispatch[POP_MARK[0]] = load_pop_mark
def load_dup(self):
@@ -1456,17 +1454,14 @@
dispatch[APPEND[0]] = load_append
def load_appends(self):
- stack = self.stack
- mark = self.marker()
- list_obj = stack[mark - 1]
- items = stack[mark + 1:]
+ items = self.pop_mark()
+ list_obj = self.stack[-1]
if isinstance(list_obj, list):
list_obj.extend(items)
else:
append = list_obj.append
for item in items:
append(item)
- del stack[mark:]
dispatch[APPENDS[0]] = load_appends
def load_setitem(self):
@@ -1478,27 +1473,21 @@
dispatch[SETITEM[0]] = load_setitem
def load_setitems(self):
- stack = self.stack
- mark = self.marker()
- dict = stack[mark - 1]
- for i in range(mark + 1, len(stack), 2):
- dict[stack[i]] = stack[i + 1]
-
- del stack[mark:]
+ items = self.pop_mark()
+ dict = self.stack[-1]
+ for i in range(0, len(items), 2):
+ dict[items[i]] = items[i + 1]
dispatch[SETITEMS[0]] = load_setitems
def load_additems(self):
- stack = self.stack
- mark = self.marker()
- set_obj = stack[mark - 1]
- items = stack[mark + 1:]
+ items = self.pop_mark()
+ set_obj = self.stack[-1]
if isinstance(set_obj, set):
set_obj.update(items)
else:
add = set_obj.add
for item in items:
add(item)
- del stack[mark:]
dispatch[ADDITEMS[0]] = load_additems
def load_build(self):
@@ -1526,7 +1515,9 @@
dispatch[BUILD[0]] = load_build
def load_mark(self):
- self.append(self.mark)
+ self.metastack.append(self.stack)
+ self.stack = []
+ self.append = self.stack.append
dispatch[MARK[0]] = load_mark
def load_stop(self):
diff --git a/Lib/pickletools.py b/Lib/pickletools.py
index 16ae7d5..4eefc19 100644
--- a/Lib/pickletools.py
+++ b/Lib/pickletools.py
@@ -2440,6 +2440,7 @@
if opcode.name in ("PUT", "BINPUT", "LONG_BINPUT", "MEMOIZE"):
if opcode.name == "MEMOIZE":
memo_idx = len(memo)
+ markmsg = "(as %d)" % memo_idx
else:
assert arg is not None
memo_idx = arg
diff --git a/Lib/pkgutil.py b/Lib/pkgutil.py
index 97726a9..a04b7d1 100644
--- a/Lib/pkgutil.py
+++ b/Lib/pkgutil.py
@@ -180,7 +180,7 @@
def _import_imp():
global imp
with warnings.catch_warnings():
- warnings.simplefilter('ignore', PendingDeprecationWarning)
+ warnings.simplefilter('ignore', DeprecationWarning)
imp = importlib.import_module('imp')
class ImpImporter:
diff --git a/Lib/plat-linux/regen b/Lib/plat-linux/regen
index c76950e..10633cb 100755
--- a/Lib/plat-linux/regen
+++ b/Lib/plat-linux/regen
@@ -1,8 +1,33 @@
#! /bin/sh
case `uname` in
-Linux*) ;;
+Linux*|GNU*) ;;
*) echo Probably not on a Linux system 1>&2
exit 1;;
esac
-set -v
-h2py -i '(u_long)' /usr/include/sys/types.h /usr/include/netinet/in.h /usr/include/dlfcn.h
+if [ -z "$CC" ]; then
+ echo >&2 "$(basename $0): CC is not set"
+ exit 1
+fi
+headers="sys/types.h netinet/in.h dlfcn.h"
+incdirs="$(echo $($CC -v -E - < /dev/null 2>&1|awk '/^#include/, /^End of search/' | grep '^ '))"
+if [ -z "$incdirs" ]; then
+ incdirs="/usr/include"
+fi
+for h in $headers; do
+ absh=
+ for d in $incdirs; do
+ if [ -f "$d/$h" ]; then
+ absh="$d/$h"
+ break
+ fi
+ done
+ if [ -n "$absh" ]; then
+ absheaders="$absheaders $absh"
+ else
+ echo >&2 "$(basename $0): header $h not found"
+ exit 1
+ fi
+done
+
+set -x
+${H2PY:-h2py} -i '(u_long)' $absheaders
diff --git a/Lib/plistlib.py b/Lib/plistlib.py
index b66639c..4f360f3 100644
--- a/Lib/plistlib.py
+++ b/Lib/plistlib.py
@@ -47,7 +47,7 @@
"""
__all__ = [
"readPlist", "writePlist", "readPlistFromBytes", "writePlistToBytes",
- "Plist", "Data", "Dict", "FMT_XML", "FMT_BINARY",
+ "Plist", "Data", "Dict", "InvalidFileException", "FMT_XML", "FMT_BINARY",
"load", "dump", "loads", "dumps"
]
diff --git a/Lib/pyclbr.py b/Lib/pyclbr.py
index 4d40b87..d7dba97 100644
--- a/Lib/pyclbr.py
+++ b/Lib/pyclbr.py
@@ -40,12 +40,10 @@
"""
import io
-import os
import sys
import importlib.util
import tokenize
from token import NAME, DEDENT, OP
-from operator import itemgetter
__all__ = ["readmodule", "readmodule_ex", "Class", "Function"]
@@ -328,6 +326,7 @@
def _main():
# Main program for testing.
import os
+ from operator import itemgetter
mod = sys.argv[1]
if os.path.exists(mod):
path = [os.path.dirname(mod)]
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
old mode 100755
new mode 100644
index 0d0d0ab..d7a177f
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -209,6 +209,18 @@
results.append((name, kind, cls, value))
return results
+def sort_attributes(attrs, object):
+ 'Sort the attrs list in-place by _fields and then alphabetically by name'
+ # This allows data descriptors to be ordered according
+ # to a _fields attribute if present.
+ fields = getattr(object, '_fields', [])
+ try:
+ field_order = {name : i-len(fields) for (i, name) in enumerate(fields)}
+ except TypeError:
+ field_order = {}
+ keyfunc = lambda attr: (field_order.get(attr[0], 0), attr[0])
+ attrs.sort(key=keyfunc)
+
# ----------------------------------------------------- module manipulation
def ispackage(path):
@@ -868,8 +880,7 @@
object.__module__)
tag += ':<br>\n'
- # Sort attrs by name.
- attrs.sort(key=lambda t: t[0])
+ sort_attributes(attrs, object)
# Pump out the attrs, segregated by kind.
attrs = spill('Methods %s' % tag, attrs,
@@ -1287,8 +1298,8 @@
else:
tag = "inherited from %s" % classname(thisclass,
object.__module__)
- # Sort attrs by name.
- attrs.sort()
+
+ sort_attributes(attrs, object)
# Pump out the attrs, segregated by kind.
attrs = spill("Methods %s:\n" % tag, attrs,
@@ -1418,13 +1429,14 @@
return plainpager
if not sys.stdin.isatty() or not sys.stdout.isatty():
return plainpager
- if 'PAGER' in os.environ:
+ use_pager = os.environ.get('MANPAGER') or os.environ.get('PAGER')
+ if use_pager:
if sys.platform == 'win32': # pipes completely broken in Windows
- return lambda text: tempfilepager(plain(text), os.environ['PAGER'])
+ return lambda text: tempfilepager(plain(text), use_pager)
elif os.environ.get('TERM') in ('dumb', 'emacs'):
- return lambda text: pipepager(plain(text), os.environ['PAGER'])
+ return lambda text: pipepager(plain(text), use_pager)
else:
- return lambda text: pipepager(text, os.environ['PAGER'])
+ return lambda text: pipepager(text, use_pager)
if os.environ.get('TERM') in ('dumb', 'emacs'):
return plainpager
if sys.platform == 'win32':
@@ -1901,10 +1913,10 @@
def intro(self):
self.output.write('''
-Welcome to Python %s's help utility!
+Welcome to Python {0}'s 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/.
+the tutorial on the Internet at http://docs.python.org/{0}/tutorial/.
Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To quit this help utility and
@@ -1914,7 +1926,7 @@
"modules", "keywords", "symbols", or "topics". Each module also comes
with a one-line summary of what it does; to list the modules whose name
or summary contain a given string such as "spam", type "modules spam".
-''' % tuple([sys.version[:3]]*2))
+'''.format('%d.%d' % sys.version_info[:2]))
def list(self, items, columns=4, width=80):
items = list(sorted(items))
diff --git a/Lib/pydoc_data/topics.py b/Lib/pydoc_data/topics.py
index d6f1366..be61bdd 100644
--- a/Lib/pydoc_data/topics.py
+++ b/Lib/pydoc_data/topics.py
@@ -1,79 +1,12728 @@
# -*- coding: utf-8 -*-
-# Autogenerated by Sphinx on Sat Jun 25 14:08:44 2016
-topics = {'assert': u'\nThe "assert" statement\n**********************\n\nAssert statements are a convenient way to insert debugging assertions\ninto a program:\n\n assert_stmt ::= "assert" expression ["," expression]\n\nThe simple form, "assert expression", is equivalent to\n\n if __debug__:\n if not expression: raise AssertionError\n\nThe extended form, "assert expression1, expression2", is equivalent to\n\n if __debug__:\n if not expression1: raise AssertionError(expression2)\n\nThese equivalences assume that "__debug__" and "AssertionError" refer\nto the built-in variables with those names. In the current\nimplementation, the built-in variable "__debug__" is "True" under\nnormal circumstances, "False" when optimization is requested (command\nline option -O). The current code generator emits no code for an\nassert statement when optimization is requested at compile time. Note\nthat it is unnecessary to include the source code for the expression\nthat failed in the error message; it will be displayed as part of the\nstack trace.\n\nAssignments to "__debug__" are illegal. The value for the built-in\nvariable is determined when the interpreter starts.\n',
- 'assignment': u'\nAssignment statements\n*********************\n\nAssignment statements are used to (re)bind names to values and to\nmodify attributes or items of mutable objects:\n\n assignment_stmt ::= (target_list "=")+ (starred_expression | yield_expression)\n target_list ::= target ("," target)* [","]\n target ::= identifier\n | "(" target_list ")"\n | "[" [target_list] "]"\n | attributeref\n | subscription\n | slicing\n | "*" target\n\n(See section *Primaries* for the syntax definitions for\n*attributeref*, *subscription*, and *slicing*.)\n\nAn assignment statement evaluates the expression list (remember that\nthis can be a single expression or a comma-separated list, the latter\nyielding a tuple) and assigns the single resulting object to each of\nthe target lists, from left to right.\n\nAssignment is defined recursively depending on the form of the target\n(list). When a target is part of a mutable object (an attribute\nreference, subscription or slicing), the mutable object must\nultimately perform the assignment and decide about its validity, and\nmay raise an exception if the assignment is unacceptable. The rules\nobserved by various types and the exceptions raised are given with the\ndefinition of the object types (see section *The standard type\nhierarchy*).\n\nAssignment of an object to a target list, optionally enclosed in\nparentheses or square brackets, is recursively defined as follows.\n\n* If the target list is empty: The object must also be an empty\n iterable.\n\n* If the target list is a single target in parentheses: The object\n is assigned to that target.\n\n* If the target list is a comma-separated list of targets, or a\n single target in square brackets: The object must be an iterable\n with the same number of items as there are targets in the target\n list, and the items are assigned, from left to right, to the\n corresponding targets.\n\n * If the target list contains one target prefixed with an\n asterisk, called a "starred" target: The object must be an\n iterable with at least as many items as there are targets in the\n target list, minus one. The first items of the iterable are\n assigned, from left to right, to the targets before the starred\n target. The final items of the iterable are assigned to the\n targets after the starred target. A list of the remaining items\n in the iterable is then assigned to the starred target (the list\n can be empty).\n\n * Else: The object must be an iterable with the same number of\n items as there are targets in the target list, and the items are\n assigned, from left to right, to the corresponding targets.\n\nAssignment of an object to a single target is recursively defined as\nfollows.\n\n* If the target is an identifier (name):\n\n * If the name does not occur in a "global" or "nonlocal" statement\n in the current code block: the name is bound to the object in the\n current local namespace.\n\n * Otherwise: the name is bound to the object in the global\n namespace or the outer namespace determined by "nonlocal",\n respectively.\n\n The name is rebound if it was already bound. This may cause the\n reference count for the object previously bound to the name to reach\n zero, causing the object to be deallocated and its destructor (if it\n has one) to be called.\n\n* If the target is an attribute reference: The primary expression in\n the reference is evaluated. It should yield an object with\n assignable attributes; if this is not the case, "TypeError" is\n raised. That object is then asked to assign the assigned object to\n the given attribute; if it cannot perform the assignment, it raises\n an exception (usually but not necessarily "AttributeError").\n\n Note: If the object is a class instance and the attribute reference\n occurs on both sides of the assignment operator, the RHS expression,\n "a.x" can access either an instance attribute or (if no instance\n attribute exists) a class attribute. The LHS target "a.x" is always\n set as an instance attribute, creating it if necessary. Thus, the\n two occurrences of "a.x" do not necessarily refer to the same\n attribute: if the RHS expression refers to a class attribute, the\n LHS creates a new instance attribute as the target of the\n assignment:\n\n class Cls:\n x = 3 # class variable\n inst = Cls()\n inst.x = inst.x + 1 # writes inst.x as 4 leaving Cls.x as 3\n\n This description does not necessarily apply to descriptor\n attributes, such as properties created with "property()".\n\n* If the target is a subscription: The primary expression in the\n reference is evaluated. It should yield either a mutable sequence\n object (such as a list) or a mapping object (such as a dictionary).\n Next, the subscript expression is evaluated.\n\n If the primary is a mutable sequence object (such as a list), the\n subscript must yield an integer. If it is negative, the sequence\'s\n length is added to it. The resulting value must be a nonnegative\n integer less than the sequence\'s length, and the sequence is asked\n to assign the assigned object to its item with that index. If the\n index is out of range, "IndexError" is raised (assignment to a\n subscripted sequence cannot add new items to a list).\n\n If the primary is a mapping object (such as a dictionary), the\n subscript must have a type compatible with the mapping\'s key type,\n and the mapping is then asked to create a key/datum pair which maps\n the subscript to the assigned object. This can either replace an\n existing key/value pair with the same key value, or insert a new\n key/value pair (if no key with the same value existed).\n\n For user-defined objects, the "__setitem__()" method is called with\n appropriate arguments.\n\n* If the target is a slicing: The primary expression in the\n reference is evaluated. It should yield a mutable sequence object\n (such as a list). The assigned object should be a sequence object\n of the same type. Next, the lower and upper bound expressions are\n evaluated, insofar they are present; defaults are zero and the\n sequence\'s length. The bounds should evaluate to integers. If\n either bound is negative, the sequence\'s length is added to it. The\n resulting bounds are clipped to lie between zero and the sequence\'s\n length, inclusive. Finally, the sequence object is asked to replace\n the slice with the items of the assigned sequence. The length of\n the slice may be different from the length of the assigned sequence,\n thus changing the length of the target sequence, if the target\n sequence allows it.\n\n**CPython implementation detail:** In the current implementation, the\nsyntax for targets is taken to be the same as for expressions, and\ninvalid syntax is rejected during the code generation phase, causing\nless detailed error messages.\n\nAlthough the definition of assignment implies that overlaps between\nthe left-hand side and the right-hand side are \'simultaneous\' (for\nexample "a, b = b, a" swaps two variables), overlaps *within* the\ncollection of assigned-to variables occur left-to-right, sometimes\nresulting in confusion. For instance, the following program prints\n"[0, 2]":\n\n x = [0, 1]\n i = 0\n i, x[i] = 1, 2 # i is updated, then x[i] is updated\n print(x)\n\nSee also: **PEP 3132** - Extended Iterable Unpacking\n\n The specification for the "*target" feature.\n\n\nAugmented assignment statements\n===============================\n\nAugmented assignment is the combination, in a single statement, of a\nbinary operation and an assignment statement:\n\n augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)\n augtarget ::= identifier | attributeref | subscription | slicing\n augop ::= "+=" | "-=" | "*=" | "@=" | "/=" | "//=" | "%=" | "**="\n | ">>=" | "<<=" | "&=" | "^=" | "|="\n\n(See section *Primaries* for the syntax definitions of the last three\nsymbols.)\n\nAn augmented assignment evaluates the target (which, unlike normal\nassignment statements, cannot be an unpacking) and the expression\nlist, performs the binary operation specific to the type of assignment\non the two operands, and assigns the result to the original target.\nThe target is only evaluated once.\n\nAn augmented assignment expression like "x += 1" can be rewritten as\n"x = x + 1" to achieve a similar, but not exactly equal effect. In the\naugmented version, "x" is only evaluated once. Also, when possible,\nthe actual operation is performed *in-place*, meaning that rather than\ncreating a new object and assigning that to the target, the old object\nis modified instead.\n\nUnlike normal assignments, augmented assignments evaluate the left-\nhand side *before* evaluating the right-hand side. For example, "a[i]\n+= f(x)" first looks-up "a[i]", then it evaluates "f(x)" and performs\nthe addition, and lastly, it writes the result back to "a[i]".\n\nWith the exception of assigning to tuples and multiple targets in a\nsingle statement, the assignment done by augmented assignment\nstatements is handled the same way as normal assignments. Similarly,\nwith the exception of the possible *in-place* behavior, the binary\noperation performed by augmented assignment is the same as the normal\nbinary operations.\n\nFor targets which are attribute references, the same *caveat about\nclass and instance attributes* applies as for regular assignments.\n',
- 'atom-identifiers': u'\nIdentifiers (Names)\n*******************\n\nAn identifier occurring as an atom is a name. See section\n*Identifiers and keywords* for lexical definition and section *Naming\nand binding* for documentation of naming and binding.\n\nWhen the name is bound to an object, evaluation of the atom yields\nthat object. When a name is not bound, an attempt to evaluate it\nraises a "NameError" exception.\n\n**Private name mangling:** When an identifier that textually occurs in\na class definition begins with two or more underscore characters and\ndoes not end in two or more underscores, it is considered a *private\nname* of that class. Private names are transformed to a longer form\nbefore code is generated for them. The transformation inserts the\nclass name, with leading underscores removed and a single underscore\ninserted, in front of the name. For example, the identifier "__spam"\noccurring in a class named "Ham" will be transformed to "_Ham__spam".\nThis transformation is independent of the syntactical context in which\nthe identifier is used. If the transformed name is extremely long\n(longer than 255 characters), implementation defined truncation may\nhappen. If the class name consists only of underscores, no\ntransformation is done.\n',
- 'atom-literals': u"\nLiterals\n********\n\nPython supports string and bytes literals and various numeric\nliterals:\n\n literal ::= stringliteral | bytesliteral\n | integer | floatnumber | imagnumber\n\nEvaluation of a literal yields an object of the given type (string,\nbytes, integer, floating point number, complex number) with the given\nvalue. The value may be approximated in the case of floating point\nand imaginary (complex) literals. See section *Literals* for details.\n\nAll literals correspond to immutable data types, and hence the\nobject's identity is less important than its value. Multiple\nevaluations of literals with the same value (either the same\noccurrence in the program text or a different occurrence) may obtain\nthe same object or a different object with the same value.\n",
- 'attribute-access': u'\nCustomizing attribute access\n****************************\n\nThe following methods can be defined to customize the meaning of\nattribute access (use of, assignment to, or deletion of "x.name") for\nclass instances.\n\nobject.__getattr__(self, name)\n\n Called when an attribute lookup has not found the attribute in the\n usual places (i.e. it is not an instance attribute nor is it found\n in the class tree for "self"). "name" is the attribute name. This\n method should return the (computed) attribute value or raise an\n "AttributeError" exception.\n\n Note that if the attribute is found through the normal mechanism,\n "__getattr__()" is not called. (This is an intentional asymmetry\n between "__getattr__()" and "__setattr__()".) This is done both for\n efficiency reasons and because otherwise "__getattr__()" would have\n no way to access other attributes of the instance. Note that at\n least for instance variables, you can fake total control by not\n inserting any values in the instance attribute dictionary (but\n instead inserting them in another object). See the\n "__getattribute__()" method below for a way to actually get total\n control over attribute access.\n\nobject.__getattribute__(self, name)\n\n Called unconditionally to implement attribute accesses for\n instances of the class. If the class also defines "__getattr__()",\n the latter will not be called unless "__getattribute__()" either\n calls it explicitly or raises an "AttributeError". This method\n should return the (computed) attribute value or raise an\n "AttributeError" exception. In order to avoid infinite recursion in\n this method, its implementation should always call the base class\n method with the same name to access any attributes it needs, for\n example, "object.__getattribute__(self, name)".\n\n Note: This method may still be bypassed when looking up special\n methods as the result of implicit invocation via language syntax\n or built-in functions. See *Special method lookup*.\n\nobject.__setattr__(self, name, value)\n\n Called when an attribute assignment is attempted. This is called\n instead of the normal mechanism (i.e. store the value in the\n instance dictionary). *name* is the attribute name, *value* is the\n value to be assigned to it.\n\n If "__setattr__()" wants to assign to an instance attribute, it\n should call the base class method with the same name, for example,\n "object.__setattr__(self, name, value)".\n\nobject.__delattr__(self, name)\n\n Like "__setattr__()" but for attribute deletion instead of\n assignment. This should only be implemented if "del obj.name" is\n meaningful for the object.\n\nobject.__dir__(self)\n\n Called when "dir()" is called on the object. A sequence must be\n returned. "dir()" converts the returned sequence to a list and\n sorts it.\n\n\nImplementing Descriptors\n========================\n\nThe following methods only apply when an instance of the class\ncontaining the method (a so-called *descriptor* class) appears in an\n*owner* class (the descriptor must be in either the owner\'s class\ndictionary or in the class dictionary for one of its parents). In the\nexamples below, "the attribute" refers to the attribute whose name is\nthe key of the property in the owner class\' "__dict__".\n\nobject.__get__(self, instance, owner)\n\n Called to get the attribute of the owner class (class attribute\n access) or of an instance of that class (instance attribute\n access). *owner* is always the owner class, while *instance* is the\n instance that the attribute was accessed through, or "None" when\n the attribute is accessed through the *owner*. This method should\n return the (computed) attribute value or raise an "AttributeError"\n exception.\n\nobject.__set__(self, instance, value)\n\n Called to set the attribute on an instance *instance* of the owner\n class to a new value, *value*.\n\nobject.__delete__(self, instance)\n\n Called to delete the attribute on an instance *instance* of the\n owner class.\n\nThe attribute "__objclass__" is interpreted by the "inspect" module as\nspecifying the class where this object was defined (setting this\nappropriately can assist in runtime introspection of dynamic class\nattributes). For callables, it may indicate that an instance of the\ngiven type (or a subclass) is expected or required as the first\npositional argument (for example, CPython sets this attribute for\nunbound methods that are implemented in C).\n\n\nInvoking Descriptors\n====================\n\nIn general, a descriptor is an object attribute with "binding\nbehavior", one whose attribute access has been overridden by methods\nin the descriptor protocol: "__get__()", "__set__()", and\n"__delete__()". If any of those methods are defined for an object, it\nis said to be a descriptor.\n\nThe default behavior for attribute access is to get, set, or delete\nthe attribute from an object\'s dictionary. For instance, "a.x" has a\nlookup chain starting with "a.__dict__[\'x\']", then\n"type(a).__dict__[\'x\']", and continuing through the base classes of\n"type(a)" excluding metaclasses.\n\nHowever, if the looked-up value is an object defining one of the\ndescriptor methods, then Python may override the default behavior and\ninvoke the descriptor method instead. Where this occurs in the\nprecedence chain depends on which descriptor methods were defined and\nhow they were called.\n\nThe starting point for descriptor invocation is a binding, "a.x". How\nthe arguments are assembled depends on "a":\n\nDirect Call\n The simplest and least common call is when user code directly\n invokes a descriptor method: "x.__get__(a)".\n\nInstance Binding\n If binding to an object instance, "a.x" is transformed into the\n call: "type(a).__dict__[\'x\'].__get__(a, type(a))".\n\nClass Binding\n If binding to a class, "A.x" is transformed into the call:\n "A.__dict__[\'x\'].__get__(None, A)".\n\nSuper Binding\n If "a" is an instance of "super", then the binding "super(B,\n obj).m()" searches "obj.__class__.__mro__" for the base class "A"\n immediately preceding "B" and then invokes the descriptor with the\n call: "A.__dict__[\'m\'].__get__(obj, obj.__class__)".\n\nFor instance bindings, the precedence of descriptor invocation depends\non the which descriptor methods are defined. A descriptor can define\nany combination of "__get__()", "__set__()" and "__delete__()". If it\ndoes not define "__get__()", then accessing the attribute will return\nthe descriptor object itself unless there is a value in the object\'s\ninstance dictionary. If the descriptor defines "__set__()" and/or\n"__delete__()", it is a data descriptor; if it defines neither, it is\na non-data descriptor. Normally, data descriptors define both\n"__get__()" and "__set__()", while non-data descriptors have just the\n"__get__()" method. Data descriptors with "__set__()" and "__get__()"\ndefined always override a redefinition in an instance dictionary. In\ncontrast, non-data descriptors can be overridden by instances.\n\nPython methods (including "staticmethod()" and "classmethod()") are\nimplemented as non-data descriptors. Accordingly, instances can\nredefine and override methods. This allows individual instances to\nacquire behaviors that differ from other instances of the same class.\n\nThe "property()" function is implemented as a data descriptor.\nAccordingly, instances cannot override the behavior of a property.\n\n\n__slots__\n=========\n\nBy default, instances of classes have a dictionary for attribute\nstorage. This wastes space for objects having very few instance\nvariables. The space consumption can become acute when creating large\nnumbers of instances.\n\nThe default can be overridden by defining *__slots__* in a class\ndefinition. The *__slots__* declaration takes a sequence of instance\nvariables and reserves just enough space in each instance to hold a\nvalue for each variable. Space is saved because *__dict__* is not\ncreated for each instance.\n\nobject.__slots__\n\n This class variable can be assigned a string, iterable, or sequence\n of strings with variable names used by instances. *__slots__*\n reserves space for the declared variables and prevents the\n automatic creation of *__dict__* and *__weakref__* for each\n instance.\n\n\nNotes on using *__slots__*\n--------------------------\n\n* When inheriting from a class without *__slots__*, the *__dict__*\n attribute of that class will always be accessible, so a *__slots__*\n definition in the subclass is meaningless.\n\n* Without a *__dict__* variable, instances cannot be assigned new\n variables not listed in the *__slots__* definition. Attempts to\n assign to an unlisted variable name raises "AttributeError". If\n dynamic assignment of new variables is desired, then add\n "\'__dict__\'" to the sequence of strings in the *__slots__*\n declaration.\n\n* Without a *__weakref__* variable for each instance, classes\n defining *__slots__* do not support weak references to its\n instances. If weak reference support is needed, then add\n "\'__weakref__\'" to the sequence of strings in the *__slots__*\n declaration.\n\n* *__slots__* are implemented at the class level by creating\n descriptors (*Implementing Descriptors*) for each variable name. As\n a result, class attributes cannot be used to set default values for\n instance variables defined by *__slots__*; otherwise, the class\n attribute would overwrite the descriptor assignment.\n\n* The action of a *__slots__* declaration is limited to the class\n where it is defined. As a result, subclasses will have a *__dict__*\n unless they also define *__slots__* (which must only contain names\n of any *additional* slots).\n\n* If a class defines a slot also defined in a base class, the\n instance variable defined by the base class slot is inaccessible\n (except by retrieving its descriptor directly from the base class).\n This renders the meaning of the program undefined. In the future, a\n check may be added to prevent this.\n\n* Nonempty *__slots__* does not work for classes derived from\n "variable-length" built-in types such as "int", "bytes" and "tuple".\n\n* Any non-string iterable may be assigned to *__slots__*. Mappings\n may also be used; however, in the future, special meaning may be\n assigned to the values corresponding to each key.\n\n* *__class__* assignment works only if both classes have the same\n *__slots__*.\n',
- 'attribute-references': u'\nAttribute references\n********************\n\nAn attribute reference is a primary followed by a period and a name:\n\n attributeref ::= primary "." identifier\n\nThe primary must evaluate to an object of a type that supports\nattribute references, which most objects do. This object is then\nasked to produce the attribute whose name is the identifier. This\nproduction can be customized by overriding the "__getattr__()" method.\nIf this attribute is not available, the exception "AttributeError" is\nraised. Otherwise, the type and value of the object produced is\ndetermined by the object. Multiple evaluations of the same attribute\nreference may yield different objects.\n',
- 'augassign': u'\nAugmented assignment statements\n*******************************\n\nAugmented assignment is the combination, in a single statement, of a\nbinary operation and an assignment statement:\n\n augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)\n augtarget ::= identifier | attributeref | subscription | slicing\n augop ::= "+=" | "-=" | "*=" | "@=" | "/=" | "//=" | "%=" | "**="\n | ">>=" | "<<=" | "&=" | "^=" | "|="\n\n(See section *Primaries* for the syntax definitions of the last three\nsymbols.)\n\nAn augmented assignment evaluates the target (which, unlike normal\nassignment statements, cannot be an unpacking) and the expression\nlist, performs the binary operation specific to the type of assignment\non the two operands, and assigns the result to the original target.\nThe target is only evaluated once.\n\nAn augmented assignment expression like "x += 1" can be rewritten as\n"x = x + 1" to achieve a similar, but not exactly equal effect. In the\naugmented version, "x" is only evaluated once. Also, when possible,\nthe actual operation is performed *in-place*, meaning that rather than\ncreating a new object and assigning that to the target, the old object\nis modified instead.\n\nUnlike normal assignments, augmented assignments evaluate the left-\nhand side *before* evaluating the right-hand side. For example, "a[i]\n+= f(x)" first looks-up "a[i]", then it evaluates "f(x)" and performs\nthe addition, and lastly, it writes the result back to "a[i]".\n\nWith the exception of assigning to tuples and multiple targets in a\nsingle statement, the assignment done by augmented assignment\nstatements is handled the same way as normal assignments. Similarly,\nwith the exception of the possible *in-place* behavior, the binary\noperation performed by augmented assignment is the same as the normal\nbinary operations.\n\nFor targets which are attribute references, the same *caveat about\nclass and instance attributes* applies as for regular assignments.\n',
- 'binary': u'\nBinary arithmetic operations\n****************************\n\nThe binary arithmetic operations have the conventional priority\nlevels. Note that some of these operations also apply to certain non-\nnumeric types. Apart from the power operator, there are only two\nlevels, one for multiplicative operators and one for additive\noperators:\n\n m_expr ::= u_expr | m_expr "*" u_expr | m_expr "@" m_expr |\n m_expr "//" u_expr| m_expr "/" u_expr |\n m_expr "%" u_expr\n a_expr ::= m_expr | a_expr "+" m_expr | a_expr "-" m_expr\n\nThe "*" (multiplication) operator yields the product of its arguments.\nThe arguments must either both be numbers, or one argument must be an\ninteger and the other must be a sequence. In the former case, the\nnumbers are converted to a common type and then multiplied together.\nIn the latter case, sequence repetition is performed; a negative\nrepetition factor yields an empty sequence.\n\nThe "@" (at) operator is intended to be used for matrix\nmultiplication. No builtin Python types implement this operator.\n\nNew in version 3.5.\n\nThe "/" (division) and "//" (floor division) operators yield the\nquotient of their arguments. The numeric arguments are first\nconverted to a common type. Division of integers yields a float, while\nfloor division of integers results in an integer; the result is that\nof mathematical division with the \'floor\' function applied to the\nresult. Division by zero raises the "ZeroDivisionError" exception.\n\nThe "%" (modulo) operator yields the remainder from the division of\nthe first argument by the second. The numeric arguments are first\nconverted to a common type. A zero right argument raises the\n"ZeroDivisionError" exception. The arguments may be floating point\nnumbers, e.g., "3.14%0.7" equals "0.34" (since "3.14" equals "4*0.7 +\n0.34".) The modulo operator always yields a result with the same sign\nas its second operand (or zero); the absolute value of the result is\nstrictly smaller than the absolute value of the second operand [1].\n\nThe floor division and modulo operators are connected by the following\nidentity: "x == (x//y)*y + (x%y)". Floor division and modulo are also\nconnected with the built-in function "divmod()": "divmod(x, y) ==\n(x//y, x%y)". [2].\n\nIn addition to performing the modulo operation on numbers, the "%"\noperator is also overloaded by string objects to perform old-style\nstring formatting (also known as interpolation). The syntax for\nstring formatting is described in the Python Library Reference,\nsection *printf-style String Formatting*.\n\nThe floor division operator, the modulo operator, and the "divmod()"\nfunction are not defined for complex numbers. Instead, convert to a\nfloating point number using the "abs()" function if appropriate.\n\nThe "+" (addition) operator yields the sum of its arguments. The\narguments must either both be numbers or both be sequences of the same\ntype. In the former case, the numbers are converted to a common type\nand then added together. In the latter case, the sequences are\nconcatenated.\n\nThe "-" (subtraction) operator yields the difference of its arguments.\nThe numeric arguments are first converted to a common type.\n',
- 'bitwise': u'\nBinary bitwise operations\n*************************\n\nEach of the three bitwise operations has a different priority level:\n\n and_expr ::= shift_expr | and_expr "&" shift_expr\n xor_expr ::= and_expr | xor_expr "^" and_expr\n or_expr ::= xor_expr | or_expr "|" xor_expr\n\nThe "&" operator yields the bitwise AND of its arguments, which must\nbe integers.\n\nThe "^" operator yields the bitwise XOR (exclusive OR) of its\narguments, which must be integers.\n\nThe "|" operator yields the bitwise (inclusive) OR of its arguments,\nwhich must be integers.\n',
- 'bltin-code-objects': u'\nCode Objects\n************\n\nCode objects are used by the implementation to represent "pseudo-\ncompiled" executable Python code such as a function body. They differ\nfrom function objects because they don\'t contain a reference to their\nglobal execution environment. Code objects are returned by the built-\nin "compile()" function and can be extracted from function objects\nthrough their "__code__" attribute. See also the "code" module.\n\nA code object can be executed or evaluated by passing it (instead of a\nsource string) to the "exec()" or "eval()" built-in functions.\n\nSee *The standard type hierarchy* for more information.\n',
- 'bltin-ellipsis-object': u'\nThe Ellipsis Object\n*******************\n\nThis object is commonly used by slicing (see *Slicings*). It supports\nno special operations. There is exactly one ellipsis object, named\n"Ellipsis" (a built-in name). "type(Ellipsis)()" produces the\n"Ellipsis" singleton.\n\nIt is written as "Ellipsis" or "...".\n',
- 'bltin-null-object': u'\nThe Null Object\n***************\n\nThis object is returned by functions that don\'t explicitly return a\nvalue. It supports no special operations. There is exactly one null\nobject, named "None" (a built-in name). "type(None)()" produces the\nsame singleton.\n\nIt is written as "None".\n',
- 'bltin-type-objects': u'\nType Objects\n************\n\nType objects represent the various object types. An object\'s type is\naccessed by the built-in function "type()". There are no special\noperations on types. The standard module "types" defines names for\nall standard built-in types.\n\nTypes are written like this: "<class \'int\'>".\n',
- 'booleans': u'\nBoolean operations\n******************\n\n or_test ::= and_test | or_test "or" and_test\n and_test ::= not_test | and_test "and" not_test\n not_test ::= comparison | "not" not_test\n\nIn the context of Boolean operations, and also when expressions are\nused by control flow statements, the following values are interpreted\nas false: "False", "None", numeric zero of all types, and empty\nstrings and containers (including strings, tuples, lists,\ndictionaries, sets and frozensets). All other values are interpreted\nas true. User-defined objects can customize their truth value by\nproviding a "__bool__()" method.\n\nThe operator "not" yields "True" if its argument is false, "False"\notherwise.\n\nThe expression "x and y" first evaluates *x*; if *x* is false, its\nvalue is returned; otherwise, *y* is evaluated and the resulting value\nis returned.\n\nThe expression "x or y" first evaluates *x*; if *x* is true, its value\nis returned; otherwise, *y* is evaluated and the resulting value is\nreturned.\n\n(Note that neither "and" nor "or" restrict the value and type they\nreturn to "False" and "True", but rather return the last evaluated\nargument. This is sometimes useful, e.g., if "s" is a string that\nshould be replaced by a default value if it is empty, the expression\n"s or \'foo\'" yields the desired value. Because "not" has to create a\nnew value, it returns a boolean value regardless of the type of its\nargument (for example, "not \'foo\'" produces "False" rather than "\'\'".)\n',
- 'break': u'\nThe "break" statement\n*********************\n\n break_stmt ::= "break"\n\n"break" may only occur syntactically nested in a "for" or "while"\nloop, but not nested in a function or class definition within that\nloop.\n\nIt terminates the nearest enclosing loop, skipping the optional "else"\nclause if the loop has one.\n\nIf a "for" loop is terminated by "break", the loop control target\nkeeps its current value.\n\nWhen "break" passes control out of a "try" statement with a "finally"\nclause, that "finally" clause is executed before really leaving the\nloop.\n',
- 'callable-types': u'\nEmulating callable objects\n**************************\n\nobject.__call__(self[, args...])\n\n Called when the instance is "called" as a function; if this method\n is defined, "x(arg1, arg2, ...)" is a shorthand for\n "x.__call__(arg1, arg2, ...)".\n',
- 'calls': u'\nCalls\n*****\n\nA call calls a callable object (e.g., a *function*) with a possibly\nempty series of *arguments*:\n\n call ::= primary "(" [argument_list [","] | comprehension] ")"\n argument_list ::= positional_arguments ["," starred_and_keywords]\n ["," keywords_arguments]\n | starred_and_keywords ["," keywords_arguments]\n | keywords_arguments\n positional_arguments ::= ["*"] expression ("," ["*"] expression)*\n starred_and_keywords ::= ("*" expression | keyword_item)\n ("," "*" expression | "," keyword_item)*\n keywords_arguments ::= (keyword_item | "**" expression)\n ("," keyword_item | "**" expression)*\n keyword_item ::= identifier "=" expression\n\nAn optional trailing comma may be present after the positional and\nkeyword arguments but does not affect the semantics.\n\nThe primary must evaluate to a callable object (user-defined\nfunctions, built-in functions, methods of built-in objects, class\nobjects, methods of class instances, and all objects having a\n"__call__()" method are callable). All argument expressions are\nevaluated before the call is attempted. Please refer to section\n*Function definitions* for the syntax of formal *parameter* lists.\n\nIf keyword arguments are present, they are first converted to\npositional arguments, as follows. First, a list of unfilled slots is\ncreated for the formal parameters. If there are N positional\narguments, they are placed in the first N slots. Next, for each\nkeyword argument, the identifier is used to determine the\ncorresponding slot (if the identifier is the same as the first formal\nparameter name, the first slot is used, and so on). If the slot is\nalready filled, a "TypeError" exception is raised. Otherwise, the\nvalue of the argument is placed in the slot, filling it (even if the\nexpression is "None", it fills the slot). When all arguments have\nbeen processed, the slots that are still unfilled are filled with the\ncorresponding default value from the function definition. (Default\nvalues are calculated, once, when the function is defined; thus, a\nmutable object such as a list or dictionary used as default value will\nbe shared by all calls that don\'t specify an argument value for the\ncorresponding slot; this should usually be avoided.) If there are any\nunfilled slots for which no default value is specified, a "TypeError"\nexception is raised. Otherwise, the list of filled slots is used as\nthe argument list for the call.\n\n**CPython implementation detail:** An implementation may provide\nbuilt-in functions whose positional parameters do not have names, even\nif they are \'named\' for the purpose of documentation, and which\ntherefore cannot be supplied by keyword. In CPython, this is the case\nfor functions implemented in C that use "PyArg_ParseTuple()" to parse\ntheir arguments.\n\nIf there are more positional arguments than there are formal parameter\nslots, a "TypeError" exception is raised, unless a formal parameter\nusing the syntax "*identifier" is present; in this case, that formal\nparameter receives a tuple containing the excess positional arguments\n(or an empty tuple if there were no excess positional arguments).\n\nIf any keyword argument does not correspond to a formal parameter\nname, a "TypeError" exception is raised, unless a formal parameter\nusing the syntax "**identifier" is present; in this case, that formal\nparameter receives a dictionary containing the excess keyword\narguments (using the keywords as keys and the argument values as\ncorresponding values), or a (new) empty dictionary if there were no\nexcess keyword arguments.\n\nIf the syntax "*expression" appears in the function call, "expression"\nmust evaluate to an *iterable*. Elements from these iterables are\ntreated as if they were additional positional arguments. For the call\n"f(x1, x2, *y, x3, x4)", if *y* evaluates to a sequence *y1*, ...,\n*yM*, this is equivalent to a call with M+4 positional arguments *x1*,\n*x2*, *y1*, ..., *yM*, *x3*, *x4*.\n\nA consequence of this is that although the "*expression" syntax may\nappear *after* explicit keyword arguments, it is processed *before*\nthe keyword arguments (and any "**expression" arguments -- see below).\nSo:\n\n >>> def f(a, b):\n ... print(a, b)\n ...\n >>> f(b=1, *(2,))\n 2 1\n >>> f(a=1, *(2,))\n Traceback (most recent call last):\n File "<stdin>", line 1, in ?\n TypeError: f() got multiple values for keyword argument \'a\'\n >>> f(1, *(2,))\n 1 2\n\nIt is unusual for both keyword arguments and the "*expression" syntax\nto be used in the same call, so in practice this confusion does not\narise.\n\nIf the syntax "**expression" appears in the function call,\n"expression" must evaluate to a *mapping*, the contents of which are\ntreated as additional keyword arguments. If a keyword is already\npresent (as an explicit keyword argument, or from another unpacking),\na "TypeError" exception is raised.\n\nFormal parameters using the syntax "*identifier" or "**identifier"\ncannot be used as positional argument slots or as keyword argument\nnames.\n\nChanged in version 3.5: Function calls accept any number of "*" and\n"**" unpackings, positional arguments may follow iterable unpackings\n("*"), and keyword arguments may follow dictionary unpackings ("**").\nOriginally proposed by **PEP 448**.\n\nA call always returns some value, possibly "None", unless it raises an\nexception. How this value is computed depends on the type of the\ncallable object.\n\nIf it is---\n\na user-defined function:\n The code block for the function is executed, passing it the\n argument list. The first thing the code block will do is bind the\n formal parameters to the arguments; this is described in section\n *Function definitions*. When the code block executes a "return"\n statement, this specifies the return value of the function call.\n\na built-in function or method:\n The result is up to the interpreter; see *Built-in Functions* for\n the descriptions of built-in functions and methods.\n\na class object:\n A new instance of that class is returned.\n\na class instance method:\n The corresponding user-defined function is called, with an argument\n list that is one longer than the argument list of the call: the\n instance becomes the first argument.\n\na class instance:\n The class must define a "__call__()" method; the effect is then the\n same as if that method was called.\n',
- 'class': u'\nClass definitions\n*****************\n\nA class definition defines a class object (see section *The standard\ntype hierarchy*):\n\n classdef ::= [decorators] "class" classname [inheritance] ":" suite\n inheritance ::= "(" [argument_list] ")"\n classname ::= identifier\n\nA class definition is an executable statement. The inheritance list\nusually gives a list of base classes (see *Customizing class creation*\nfor more advanced uses), so each item in the list should evaluate to a\nclass object which allows subclassing. Classes without an inheritance\nlist inherit, by default, from the base class "object"; hence,\n\n class Foo:\n pass\n\nis equivalent to\n\n class Foo(object):\n pass\n\nThe class\'s suite is then executed in a new execution frame (see\n*Naming and binding*), using a newly created local namespace and the\noriginal global namespace. (Usually, the suite contains mostly\nfunction definitions.) When the class\'s suite finishes execution, its\nexecution frame is discarded but its local namespace is saved. [4] A\nclass object is then created using the inheritance list for the base\nclasses and the saved local namespace for the attribute dictionary.\nThe class name is bound to this class object in the original local\nnamespace.\n\nClass creation can be customized heavily using *metaclasses*.\n\nClasses can also be decorated: just like when decorating functions,\n\n @f1(arg)\n @f2\n class Foo: pass\n\nis equivalent to\n\n class Foo: pass\n Foo = f1(arg)(f2(Foo))\n\nThe evaluation rules for the decorator expressions are the same as for\nfunction decorators. The result must be a class object, which is then\nbound to the class name.\n\n**Programmer\'s note:** Variables defined in the class definition are\nclass attributes; they are shared by instances. Instance attributes\ncan be set in a method with "self.name = value". Both class and\ninstance attributes are accessible through the notation ""self.name"",\nand an instance attribute hides a class attribute with the same name\nwhen accessed in this way. Class attributes can be used as defaults\nfor instance attributes, but using mutable values there can lead to\nunexpected results. *Descriptors* can be used to create instance\nvariables with different implementation details.\n\nSee also: **PEP 3115** - Metaclasses in Python 3 **PEP 3129** -\n Class Decorators\n',
- 'comparisons': u'\nComparisons\n***********\n\nUnlike C, all comparison operations in Python have the same priority,\nwhich is lower than that of any arithmetic, shifting or bitwise\noperation. Also unlike C, expressions like "a < b < c" have the\ninterpretation that is conventional in mathematics:\n\n comparison ::= or_expr ( comp_operator or_expr )*\n comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="\n | "is" ["not"] | ["not"] "in"\n\nComparisons yield boolean values: "True" or "False".\n\nComparisons can be chained arbitrarily, e.g., "x < y <= z" is\nequivalent to "x < y and y <= z", except that "y" is evaluated only\nonce (but in both cases "z" is not evaluated at all when "x < y" is\nfound to be false).\n\nFormally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and *op1*,\n*op2*, ..., *opN* are comparison operators, then "a op1 b op2 c ... y\nopN z" is equivalent to "a op1 b and b op2 c and ... y opN z", except\nthat each expression is evaluated at most once.\n\nNote that "a op1 b op2 c" doesn\'t imply any kind of comparison between\n*a* and *c*, so that, e.g., "x < y > z" is perfectly legal (though\nperhaps not pretty).\n\n\nValue comparisons\n=================\n\nThe operators "<", ">", "==", ">=", "<=", and "!=" compare the values\nof two objects. The objects do not need to have the same type.\n\nChapter *Objects, values and types* states that objects have a value\n(in addition to type and identity). The value of an object is a\nrather abstract notion in Python: For example, there is no canonical\naccess method for an object\'s value. Also, there is no requirement\nthat the value of an object should be constructed in a particular way,\ne.g. comprised of all its data attributes. Comparison operators\nimplement a particular notion of what the value of an object is. One\ncan think of them as defining the value of an object indirectly, by\nmeans of their comparison implementation.\n\nBecause all types are (direct or indirect) subtypes of "object", they\ninherit the default comparison behavior from "object". Types can\ncustomize their comparison behavior by implementing *rich comparison\nmethods* like "__lt__()", described in *Basic customization*.\n\nThe default behavior for equality comparison ("==" and "!=") is based\non the identity of the objects. Hence, equality comparison of\ninstances with the same identity results in equality, and equality\ncomparison of instances with different identities results in\ninequality. A motivation for this default behavior is the desire that\nall objects should be reflexive (i.e. "x is y" implies "x == y").\n\nA default order comparison ("<", ">", "<=", and ">=") is not provided;\nan attempt raises "TypeError". A motivation for this default behavior\nis the lack of a similar invariant as for equality.\n\nThe behavior of the default equality comparison, that instances with\ndifferent identities are always unequal, may be in contrast to what\ntypes will need that have a sensible definition of object value and\nvalue-based equality. Such types will need to customize their\ncomparison behavior, and in fact, a number of built-in types have done\nthat.\n\nThe following list describes the comparison behavior of the most\nimportant built-in types.\n\n* Numbers of built-in numeric types (*Numeric Types --- int, float,\n complex*) and of the standard library types "fractions.Fraction" and\n "decimal.Decimal" can be compared within and across their types,\n with the restriction that complex numbers do not support order\n comparison. Within the limits of the types involved, they compare\n mathematically (algorithmically) correct without loss of precision.\n\n The not-a-number values "float(\'NaN\')" and "Decimal(\'NaN\')" are\n special. They are identical to themselves ("x is x" is true) but\n are not equal to themselves ("x == x" is false). Additionally,\n comparing any number to a not-a-number value will return "False".\n For example, both "3 < float(\'NaN\')" and "float(\'NaN\') < 3" will\n return "False".\n\n* Binary sequences (instances of "bytes" or "bytearray") can be\n compared within and across their types. They compare\n lexicographically using the numeric values of their elements.\n\n* Strings (instances of "str") compare lexicographically using the\n numerical Unicode code points (the result of the built-in function\n "ord()") of their characters. [3]\n\n Strings and binary sequences cannot be directly compared.\n\n* Sequences (instances of "tuple", "list", or "range") can be\n compared only within each of their types, with the restriction that\n ranges do not support order comparison. Equality comparison across\n these types results in unequality, and ordering comparison across\n these types raises "TypeError".\n\n Sequences compare lexicographically using comparison of\n corresponding elements, whereby reflexivity of the elements is\n enforced.\n\n In enforcing reflexivity of elements, the comparison of collections\n assumes that for a collection element "x", "x == x" is always true.\n Based on that assumption, element identity is compared first, and\n element comparison is performed only for distinct elements. This\n approach yields the same result as a strict element comparison\n would, if the compared elements are reflexive. For non-reflexive\n elements, the result is different than for strict element\n comparison, and may be surprising: The non-reflexive not-a-number\n values for example result in the following comparison behavior when\n used in a list:\n\n >>> nan = float(\'NaN\')\n >>> nan is nan\n True\n >>> nan == nan\n False <-- the defined non-reflexive behavior of NaN\n >>> [nan] == [nan]\n True <-- list enforces reflexivity and tests identity first\n\n Lexicographical comparison between built-in collections works as\n follows:\n\n * For two collections to compare equal, they must be of the same\n type, have the same length, and each pair of corresponding\n elements must compare equal (for example, "[1,2] == (1,2)" is\n false because the type is not the same).\n\n * Collections that support order comparison are ordered the same\n as their first unequal elements (for example, "[1,2,x] <= [1,2,y]"\n has the same value as "x <= y"). If a corresponding element does\n not exist, the shorter collection is ordered first (for example,\n "[1,2] < [1,2,3]" is true).\n\n* Mappings (instances of "dict") compare equal if and only if they\n have equal *(key, value)* pairs. Equality comparison of the keys and\n elements enforces reflexivity.\n\n Order comparisons ("<", ">", "<=", and ">=") raise "TypeError".\n\n* Sets (instances of "set" or "frozenset") can be compared within\n and across their types.\n\n They define order comparison operators to mean subset and superset\n tests. Those relations do not define total orderings (for example,\n the two sets "{1,2}" and "{2,3}" are not equal, nor subsets of one\n another, nor supersets of one another). Accordingly, sets are not\n appropriate arguments for functions which depend on total ordering\n (for example, "min()", "max()", and "sorted()" produce undefined\n results given a list of sets as inputs).\n\n Comparison of sets enforces reflexivity of its elements.\n\n* Most other built-in types have no comparison methods implemented,\n so they inherit the default comparison behavior.\n\nUser-defined classes that customize their comparison behavior should\nfollow some consistency rules, if possible:\n\n* Equality comparison should be reflexive. In other words, identical\n objects should compare equal:\n\n "x is y" implies "x == y"\n\n* Comparison should be symmetric. In other words, the following\n expressions should have the same result:\n\n "x == y" and "y == x"\n\n "x != y" and "y != x"\n\n "x < y" and "y > x"\n\n "x <= y" and "y >= x"\n\n* Comparison should be transitive. The following (non-exhaustive)\n examples illustrate that:\n\n "x > y and y > z" implies "x > z"\n\n "x < y and y <= z" implies "x < z"\n\n* Inverse comparison should result in the boolean negation. In other\n words, the following expressions should have the same result:\n\n "x == y" and "not x != y"\n\n "x < y" and "not x >= y" (for total ordering)\n\n "x > y" and "not x <= y" (for total ordering)\n\n The last two expressions apply to totally ordered collections (e.g.\n to sequences, but not to sets or mappings). See also the\n "total_ordering()" decorator.\n\nPython does not enforce these consistency rules. In fact, the\nnot-a-number values are an example for not following these rules.\n\n\nMembership test operations\n==========================\n\nThe operators "in" and "not in" test for membership. "x in s"\nevaluates to true if *x* is a member of *s*, and false otherwise. "x\nnot in s" returns the negation of "x in s". All built-in sequences\nand set types support this as well as dictionary, for which "in" tests\nwhether the dictionary has a given key. For container types such as\nlist, tuple, set, frozenset, dict, or collections.deque, the\nexpression "x in y" is equivalent to "any(x is e or x == e for e in\ny)".\n\nFor the string and bytes types, "x in y" is true if and only if *x* is\na substring of *y*. An equivalent test is "y.find(x) != -1". Empty\nstrings are always considered to be a substring of any other string,\nso """ in "abc"" will return "True".\n\nFor user-defined classes which define the "__contains__()" method, "x\nin y" is true if and only if "y.__contains__(x)" is true.\n\nFor user-defined classes which do not define "__contains__()" but do\ndefine "__iter__()", "x in y" is true if some value "z" with "x == z"\nis produced while iterating over "y". If an exception is raised\nduring the iteration, it is as if "in" raised that exception.\n\nLastly, the old-style iteration protocol is tried: if a class defines\n"__getitem__()", "x in y" is true if and only if there is a non-\nnegative integer index *i* such that "x == y[i]", and all lower\ninteger indices do not raise "IndexError" exception. (If any other\nexception is raised, it is as if "in" raised that exception).\n\nThe operator "not in" is defined to have the inverse true value of\n"in".\n\n\nIdentity comparisons\n====================\n\nThe operators "is" and "is not" test for object identity: "x is y" is\ntrue if and only if *x* and *y* are the same object. "x is not y"\nyields the inverse truth value. [4]\n',
- 'compound': u'\nCompound statements\n*******************\n\nCompound statements contain (groups of) other statements; they affect\nor control the execution of those other statements in some way. In\ngeneral, compound statements span multiple lines, although in simple\nincarnations a whole compound statement may be contained in one line.\n\nThe "if", "while" and "for" statements implement traditional control\nflow constructs. "try" specifies exception handlers and/or cleanup\ncode for a group of statements, while the "with" statement allows the\nexecution of initialization and finalization code around a block of\ncode. Function and class definitions are also syntactically compound\nstatements.\n\nA compound statement consists of one or more \'clauses.\' A clause\nconsists of a header and a \'suite.\' The clause headers of a\nparticular compound statement are all at the same indentation level.\nEach clause header begins with a uniquely identifying keyword and ends\nwith a colon. A suite is a group of statements controlled by a\nclause. A suite can be one or more semicolon-separated simple\nstatements on the same line as the header, following the header\'s\ncolon, or it can be one or more indented statements on subsequent\nlines. Only the latter form of a suite can contain nested compound\nstatements; the following is illegal, mostly because it wouldn\'t be\nclear to which "if" clause a following "else" clause would belong:\n\n if test1: if test2: print(x)\n\nAlso note that the semicolon binds tighter than the colon in this\ncontext, so that in the following example, either all or none of the\n"print()" calls are executed:\n\n if x < y < z: print(x); print(y); print(z)\n\nSummarizing:\n\n compound_stmt ::= if_stmt\n | while_stmt\n | for_stmt\n | try_stmt\n | with_stmt\n | funcdef\n | classdef\n | async_with_stmt\n | async_for_stmt\n | async_funcdef\n suite ::= stmt_list NEWLINE | NEWLINE INDENT statement+ DEDENT\n statement ::= stmt_list NEWLINE | compound_stmt\n stmt_list ::= simple_stmt (";" simple_stmt)* [";"]\n\nNote that statements always end in a "NEWLINE" possibly followed by a\n"DEDENT". Also note that optional continuation clauses always begin\nwith a keyword that cannot start a statement, thus there are no\nambiguities (the \'dangling "else"\' problem is solved in Python by\nrequiring nested "if" statements to be indented).\n\nThe formatting of the grammar rules in the following sections places\neach clause on a separate line for clarity.\n\n\nThe "if" statement\n==================\n\nThe "if" statement is used for conditional execution:\n\n if_stmt ::= "if" expression ":" suite\n ( "elif" expression ":" suite )*\n ["else" ":" suite]\n\nIt selects exactly one of the suites by evaluating the expressions one\nby one until one is found to be true (see section *Boolean operations*\nfor the definition of true and false); then that suite is executed\n(and no other part of the "if" statement is executed or evaluated).\nIf all expressions are false, the suite of the "else" clause, if\npresent, is executed.\n\n\nThe "while" statement\n=====================\n\nThe "while" statement is used for repeated execution as long as an\nexpression is true:\n\n while_stmt ::= "while" expression ":" suite\n ["else" ":" suite]\n\nThis repeatedly tests the expression and, if it is true, executes the\nfirst suite; if the expression is false (which may be the first time\nit is tested) the suite of the "else" clause, if present, is executed\nand the loop terminates.\n\nA "break" statement executed in the first suite terminates the loop\nwithout executing the "else" clause\'s suite. A "continue" statement\nexecuted in the first suite skips the rest of the suite and goes back\nto testing the expression.\n\n\nThe "for" statement\n===================\n\nThe "for" statement is used to iterate over the elements of a sequence\n(such as a string, tuple or list) or other iterable object:\n\n for_stmt ::= "for" target_list "in" expression_list ":" suite\n ["else" ":" suite]\n\nThe expression list is evaluated once; it should yield an iterable\nobject. An iterator is created for the result of the\n"expression_list". The suite is then executed once for each item\nprovided by the iterator, in the order returned by the iterator. Each\nitem in turn is assigned to the target list using the standard rules\nfor assignments (see *Assignment statements*), and then the suite is\nexecuted. When the items are exhausted (which is immediately when the\nsequence is empty or an iterator raises a "StopIteration" exception),\nthe suite in the "else" clause, if present, is executed, and the loop\nterminates.\n\nA "break" statement executed in the first suite terminates the loop\nwithout executing the "else" clause\'s suite. A "continue" statement\nexecuted in the first suite skips the rest of the suite and continues\nwith the next item, or with the "else" clause if there is no next\nitem.\n\nThe for-loop makes assignments to the variables(s) in the target list.\nThis overwrites all previous assignments to those variables including\nthose made in the suite of the for-loop:\n\n for i in range(10):\n print(i)\n i = 5 # this will not affect the for-loop\n # because i will be overwritten with the next\n # index in the range\n\nNames in the target list are not deleted when the loop is finished,\nbut if the sequence is empty, they will not have been assigned to at\nall by the loop. Hint: the built-in function "range()" returns an\niterator of integers suitable to emulate the effect of Pascal\'s "for i\n:= a to b do"; e.g., "list(range(3))" returns the list "[0, 1, 2]".\n\nNote: There is a subtlety when the sequence is being modified by the\n loop (this can only occur for mutable sequences, i.e. lists). An\n internal counter is used to keep track of which item is used next,\n and this is incremented on each iteration. When this counter has\n reached the length of the sequence the loop terminates. This means\n that if the suite deletes the current (or a previous) item from the\n sequence, the next item will be skipped (since it gets the index of\n the current item which has already been treated). Likewise, if the\n suite inserts an item in the sequence before the current item, the\n current item will be treated again the next time through the loop.\n This can lead to nasty bugs that can be avoided by making a\n temporary copy using a slice of the whole sequence, e.g.,\n\n for x in a[:]:\n if x < 0: a.remove(x)\n\n\nThe "try" statement\n===================\n\nThe "try" statement specifies exception handlers and/or cleanup code\nfor a group of statements:\n\n try_stmt ::= try1_stmt | try2_stmt\n try1_stmt ::= "try" ":" suite\n ("except" [expression ["as" identifier]] ":" suite)+\n ["else" ":" suite]\n ["finally" ":" suite]\n try2_stmt ::= "try" ":" suite\n "finally" ":" suite\n\nThe "except" clause(s) specify one or more exception handlers. When no\nexception occurs in the "try" clause, no exception handler is\nexecuted. When an exception occurs in the "try" suite, a search for an\nexception handler is started. This search inspects the except clauses\nin turn until one is found that matches the exception. An expression-\nless except clause, if present, must be last; it matches any\nexception. For an except clause with an expression, that expression\nis evaluated, and the clause matches the exception if the resulting\nobject is "compatible" with the exception. An object is compatible\nwith an exception if it is the class or a base class of the exception\nobject or a tuple containing an item compatible with the exception.\n\nIf no except clause matches the exception, the search for an exception\nhandler continues in the surrounding code and on the invocation stack.\n[1]\n\nIf the evaluation of an expression in the header of an except clause\nraises an exception, the original search for a handler is canceled and\na search starts for the new exception in the surrounding code and on\nthe call stack (it is treated as if the entire "try" statement raised\nthe exception).\n\nWhen a matching except clause is found, the exception is assigned to\nthe target specified after the "as" keyword in that except clause, if\npresent, and the except clause\'s suite is executed. All except\nclauses must have an executable block. When the end of this block is\nreached, execution continues normally after the entire try statement.\n(This means that if two nested handlers exist for the same exception,\nand the exception occurs in the try clause of the inner handler, the\nouter handler will not handle the exception.)\n\nWhen an exception has been assigned using "as target", it is cleared\nat the end of the except clause. This is as if\n\n except E as N:\n foo\n\nwas translated to\n\n except E as N:\n try:\n foo\n finally:\n del N\n\nThis means the exception must be assigned to a different name to be\nable to refer to it after the except clause. Exceptions are cleared\nbecause with the traceback attached to them, they form a reference\ncycle with the stack frame, keeping all locals in that frame alive\nuntil the next garbage collection occurs.\n\nBefore an except clause\'s suite is executed, details about the\nexception are stored in the "sys" module and can be accessed via\n"sys.exc_info()". "sys.exc_info()" returns a 3-tuple consisting of the\nexception class, the exception instance and a traceback object (see\nsection *The standard type hierarchy*) identifying the point in the\nprogram where the exception occurred. "sys.exc_info()" values are\nrestored to their previous values (before the call) when returning\nfrom a function that handled an exception.\n\nThe optional "else" clause is executed if and when control flows off\nthe end of the "try" clause. [2] Exceptions in the "else" clause are\nnot handled by the preceding "except" clauses.\n\nIf "finally" is present, it specifies a \'cleanup\' handler. The "try"\nclause is executed, including any "except" and "else" clauses. If an\nexception occurs in any of the clauses and is not handled, the\nexception is temporarily saved. The "finally" clause is executed. If\nthere is a saved exception it is re-raised at the end of the "finally"\nclause. If the "finally" clause raises another exception, the saved\nexception is set as the context of the new exception. If the "finally"\nclause executes a "return" or "break" statement, the saved exception\nis discarded:\n\n >>> def f():\n ... try:\n ... 1/0\n ... finally:\n ... return 42\n ...\n >>> f()\n 42\n\nThe exception information is not available to the program during\nexecution of the "finally" clause.\n\nWhen a "return", "break" or "continue" statement is executed in the\n"try" suite of a "try"..."finally" statement, the "finally" clause is\nalso executed \'on the way out.\' A "continue" statement is illegal in\nthe "finally" clause. (The reason is a problem with the current\nimplementation --- this restriction may be lifted in the future).\n\nThe return value of a function is determined by the last "return"\nstatement executed. Since the "finally" clause always executes, a\n"return" statement executed in the "finally" clause will always be the\nlast one executed:\n\n >>> def foo():\n ... try:\n ... return \'try\'\n ... finally:\n ... return \'finally\'\n ...\n >>> foo()\n \'finally\'\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information on using the "raise" statement to\ngenerate exceptions may be found in section *The raise statement*.\n\n\nThe "with" statement\n====================\n\nThe "with" statement is used to wrap the execution of a block with\nmethods defined by a context manager (see section *With Statement\nContext Managers*). This allows common "try"..."except"..."finally"\nusage patterns to be encapsulated for convenient reuse.\n\n with_stmt ::= "with" with_item ("," with_item)* ":" suite\n with_item ::= expression ["as" target]\n\nThe execution of the "with" statement with one "item" proceeds as\nfollows:\n\n1. The context expression (the expression given in the "with_item")\n is evaluated to obtain a context manager.\n\n2. The context manager\'s "__exit__()" is loaded for later use.\n\n3. The context manager\'s "__enter__()" method is invoked.\n\n4. If a target was included in the "with" statement, the return\n value from "__enter__()" is assigned to it.\n\n Note: The "with" statement guarantees that if the "__enter__()"\n method returns without an error, then "__exit__()" will always be\n called. Thus, if an error occurs during the assignment to the\n target list, it will be treated the same as an error occurring\n within the suite would be. See step 6 below.\n\n5. The suite is executed.\n\n6. The context manager\'s "__exit__()" method is invoked. If an\n exception caused the suite to be exited, its type, value, and\n traceback are passed as arguments to "__exit__()". Otherwise, three\n "None" arguments are supplied.\n\n If the suite was exited due to an exception, and the return value\n from the "__exit__()" method was false, the exception is reraised.\n If the return value was true, the exception is suppressed, and\n execution continues with the statement following the "with"\n statement.\n\n If the suite was exited for any reason other than an exception, the\n return value from "__exit__()" is ignored, and execution proceeds\n at the normal location for the kind of exit that was taken.\n\nWith more than one item, the context managers are processed as if\nmultiple "with" statements were nested:\n\n with A() as a, B() as b:\n suite\n\nis equivalent to\n\n with A() as a:\n with B() as b:\n suite\n\nChanged in version 3.1: Support for multiple context expressions.\n\nSee also: **PEP 343** - The "with" statement\n\n The specification, background, and examples for the Python "with"\n statement.\n\n\nFunction definitions\n====================\n\nA function definition defines a user-defined function object (see\nsection *The standard type hierarchy*):\n\n funcdef ::= [decorators] "def" funcname "(" [parameter_list] ")" ["->" expression] ":" suite\n decorators ::= decorator+\n decorator ::= "@" dotted_name ["(" [argument_list [","]] ")"] NEWLINE\n dotted_name ::= identifier ("." identifier)*\n parameter_list ::= (defparameter ",")*\n | "*" [parameter] ("," defparameter)* ["," "**" parameter]\n | "**" parameter\n | defparameter [","] )\n parameter ::= identifier [":" expression]\n defparameter ::= parameter ["=" expression]\n funcname ::= identifier\n\nA function definition is an executable statement. Its execution binds\nthe function name in the current local namespace to a function object\n(a wrapper around the executable code for the function). This\nfunction object contains a reference to the current global namespace\nas the global namespace to be used when the function is called.\n\nThe function definition does not execute the function body; this gets\nexecuted only when the function is called. [3]\n\nA function definition may be wrapped by one or more *decorator*\nexpressions. Decorator expressions are evaluated when the function is\ndefined, in the scope that contains the function definition. The\nresult must be a callable, which is invoked with the function object\nas the only argument. The returned value is bound to the function name\ninstead of the function object. Multiple decorators are applied in\nnested fashion. For example, the following code\n\n @f1(arg)\n @f2\n def func(): pass\n\nis equivalent to\n\n def func(): pass\n func = f1(arg)(f2(func))\n\nWhen one or more *parameters* have the form *parameter* "="\n*expression*, the function is said to have "default parameter values."\nFor a parameter with a default value, the corresponding *argument* may\nbe omitted from a call, in which case the parameter\'s default value is\nsubstituted. If a parameter has a default value, all following\nparameters up until the ""*"" must also have a default value --- this\nis a syntactic restriction that is not expressed by the grammar.\n\n**Default parameter values are evaluated from left to right when the\nfunction definition is executed.** This means that the expression is\nevaluated once, when the function is defined, and that the same "pre-\ncomputed" value is used for each call. This is especially important\nto understand when a default parameter is a mutable object, such as a\nlist or a dictionary: if the function modifies the object (e.g. by\nappending an item to a list), the default value is in effect modified.\nThis is generally not what was intended. A way around this is to use\n"None" as the default, and explicitly test for it in the body of the\nfunction, e.g.:\n\n def whats_on_the_telly(penguin=None):\n if penguin is None:\n penguin = []\n penguin.append("property of the zoo")\n return penguin\n\nFunction call semantics are described in more detail in section\n*Calls*. A function call always assigns values to all parameters\nmentioned in the parameter list, either from position arguments, from\nkeyword arguments, or from default values. If the form\n""*identifier"" is present, it is initialized to a tuple receiving any\nexcess positional parameters, defaulting to the empty tuple. If the\nform ""**identifier"" is present, it is initialized to a new\ndictionary receiving any excess keyword arguments, defaulting to a new\nempty dictionary. Parameters after ""*"" or ""*identifier"" are\nkeyword-only parameters and may only be passed used keyword arguments.\n\nParameters may have annotations of the form "": expression"" following\nthe parameter name. Any parameter may have an annotation even those\nof the form "*identifier" or "**identifier". Functions may have\n"return" annotation of the form ""-> expression"" after the parameter\nlist. These annotations can be any valid Python expression and are\nevaluated when the function definition is executed. Annotations may\nbe evaluated in a different order than they appear in the source code.\nThe presence of annotations does not change the semantics of a\nfunction. The annotation values are available as values of a\ndictionary keyed by the parameters\' names in the "__annotations__"\nattribute of the function object.\n\nIt is also possible to create anonymous functions (functions not bound\nto a name), for immediate use in expressions. This uses lambda\nexpressions, described in section *Lambdas*. Note that the lambda\nexpression is merely a shorthand for a simplified function definition;\na function defined in a ""def"" statement can be passed around or\nassigned to another name just like a function defined by a lambda\nexpression. The ""def"" form is actually more powerful since it\nallows the execution of multiple statements and annotations.\n\n**Programmer\'s note:** Functions are first-class objects. A ""def""\nstatement executed inside a function definition defines a local\nfunction that can be returned or passed around. Free variables used\nin the nested function can access the local variables of the function\ncontaining the def. See section *Naming and binding* for details.\n\nSee also: **PEP 3107** - Function Annotations\n\n The original specification for function annotations.\n\n\nClass definitions\n=================\n\nA class definition defines a class object (see section *The standard\ntype hierarchy*):\n\n classdef ::= [decorators] "class" classname [inheritance] ":" suite\n inheritance ::= "(" [argument_list] ")"\n classname ::= identifier\n\nA class definition is an executable statement. The inheritance list\nusually gives a list of base classes (see *Customizing class creation*\nfor more advanced uses), so each item in the list should evaluate to a\nclass object which allows subclassing. Classes without an inheritance\nlist inherit, by default, from the base class "object"; hence,\n\n class Foo:\n pass\n\nis equivalent to\n\n class Foo(object):\n pass\n\nThe class\'s suite is then executed in a new execution frame (see\n*Naming and binding*), using a newly created local namespace and the\noriginal global namespace. (Usually, the suite contains mostly\nfunction definitions.) When the class\'s suite finishes execution, its\nexecution frame is discarded but its local namespace is saved. [4] A\nclass object is then created using the inheritance list for the base\nclasses and the saved local namespace for the attribute dictionary.\nThe class name is bound to this class object in the original local\nnamespace.\n\nClass creation can be customized heavily using *metaclasses*.\n\nClasses can also be decorated: just like when decorating functions,\n\n @f1(arg)\n @f2\n class Foo: pass\n\nis equivalent to\n\n class Foo: pass\n Foo = f1(arg)(f2(Foo))\n\nThe evaluation rules for the decorator expressions are the same as for\nfunction decorators. The result must be a class object, which is then\nbound to the class name.\n\n**Programmer\'s note:** Variables defined in the class definition are\nclass attributes; they are shared by instances. Instance attributes\ncan be set in a method with "self.name = value". Both class and\ninstance attributes are accessible through the notation ""self.name"",\nand an instance attribute hides a class attribute with the same name\nwhen accessed in this way. Class attributes can be used as defaults\nfor instance attributes, but using mutable values there can lead to\nunexpected results. *Descriptors* can be used to create instance\nvariables with different implementation details.\n\nSee also: **PEP 3115** - Metaclasses in Python 3 **PEP 3129** -\n Class Decorators\n\n\nCoroutines\n==========\n\nNew in version 3.5.\n\n\nCoroutine function definition\n-----------------------------\n\n async_funcdef ::= [decorators] "async" "def" funcname "(" [parameter_list] ")" ["->" expression] ":" suite\n\nExecution of Python coroutines can be suspended and resumed at many\npoints (see *coroutine*). In the body of a coroutine, any "await" and\n"async" identifiers become reserved keywords; "await" expressions,\n"async for" and "async with" can only be used in coroutine bodies.\n\nFunctions defined with "async def" syntax are always coroutine\nfunctions, even if they do not contain "await" or "async" keywords.\n\nIt is a "SyntaxError" to use "yield" expressions in "async def"\ncoroutines.\n\nAn example of a coroutine function:\n\n async def func(param1, param2):\n do_stuff()\n await some_coroutine()\n\n\nThe "async for" statement\n-------------------------\n\n async_for_stmt ::= "async" for_stmt\n\nAn *asynchronous iterable* is able to call asynchronous code in its\n*iter* implementation, and *asynchronous iterator* can call\nasynchronous code in its *next* method.\n\nThe "async for" statement allows convenient iteration over\nasynchronous iterators.\n\nThe following code:\n\n async for TARGET in ITER:\n BLOCK\n else:\n BLOCK2\n\nIs semantically equivalent to:\n\n iter = (ITER)\n iter = type(iter).__aiter__(iter)\n running = True\n while running:\n try:\n TARGET = await type(iter).__anext__(iter)\n except StopAsyncIteration:\n running = False\n else:\n BLOCK\n else:\n BLOCK2\n\nSee also "__aiter__()" and "__anext__()" for details.\n\nIt is a "SyntaxError" to use "async for" statement outside of an\n"async def" function.\n\n\nThe "async with" statement\n--------------------------\n\n async_with_stmt ::= "async" with_stmt\n\nAn *asynchronous context manager* is a *context manager* that is able\nto suspend execution in its *enter* and *exit* methods.\n\nThe following code:\n\n async with EXPR as VAR:\n BLOCK\n\nIs semantically equivalent to:\n\n mgr = (EXPR)\n aexit = type(mgr).__aexit__\n aenter = type(mgr).__aenter__(mgr)\n exc = True\n\n VAR = await aenter\n try:\n BLOCK\n except:\n if not await aexit(mgr, *sys.exc_info()):\n raise\n else:\n await aexit(mgr, None, None, None)\n\nSee also "__aenter__()" and "__aexit__()" for details.\n\nIt is a "SyntaxError" to use "async with" statement outside of an\n"async def" function.\n\nSee also: **PEP 492** - Coroutines with async and await syntax\n\n-[ Footnotes ]-\n\n[1] The exception is propagated to the invocation stack unless\n there is a "finally" clause which happens to raise another\n exception. That new exception causes the old one to be lost.\n\n[2] Currently, control "flows off the end" except in the case of\n an exception or the execution of a "return", "continue", or\n "break" statement.\n\n[3] A string literal appearing as the first statement in the\n function body is transformed into the function\'s "__doc__"\n attribute and therefore the function\'s *docstring*.\n\n[4] A string literal appearing as the first statement in the class\n body is transformed into the namespace\'s "__doc__" item and\n therefore the class\'s *docstring*.\n',
- 'context-managers': u'\nWith Statement Context Managers\n*******************************\n\nA *context manager* is an object that defines the runtime context to\nbe established when executing a "with" statement. The context manager\nhandles the entry into, and the exit from, the desired runtime context\nfor the execution of the block of code. Context managers are normally\ninvoked using the "with" statement (described in section *The with\nstatement*), but can also be used by directly invoking their methods.\n\nTypical uses of context managers include saving and restoring various\nkinds of global state, locking and unlocking resources, closing opened\nfiles, etc.\n\nFor more information on context managers, see *Context Manager Types*.\n\nobject.__enter__(self)\n\n Enter the runtime context related to this object. The "with"\n statement will bind this method\'s return value to the target(s)\n specified in the "as" clause of the statement, if any.\n\nobject.__exit__(self, exc_type, exc_value, traceback)\n\n Exit the runtime context related to this object. The parameters\n describe the exception that caused the context to be exited. If the\n context was exited without an exception, all three arguments will\n be "None".\n\n If an exception is supplied, and the method wishes to suppress the\n exception (i.e., prevent it from being propagated), it should\n return a true value. Otherwise, the exception will be processed\n normally upon exit from this method.\n\n Note that "__exit__()" methods should not reraise the passed-in\n exception; this is the caller\'s responsibility.\n\nSee also: **PEP 343** - The "with" statement\n\n The specification, background, and examples for the Python "with"\n statement.\n',
- 'continue': u'\nThe "continue" statement\n************************\n\n continue_stmt ::= "continue"\n\n"continue" may only occur syntactically nested in a "for" or "while"\nloop, but not nested in a function or class definition or "finally"\nclause within that loop. It continues with the next cycle of the\nnearest enclosing loop.\n\nWhen "continue" passes control out of a "try" statement with a\n"finally" clause, that "finally" clause is executed before really\nstarting the next loop cycle.\n',
- 'conversions': u'\nArithmetic conversions\n**********************\n\nWhen a description of an arithmetic operator below uses the phrase\n"the numeric arguments are converted to a common type," this means\nthat the operator implementation for built-in types works as follows:\n\n* If either argument is a complex number, the other is converted to\n complex;\n\n* otherwise, if either argument is a floating point number, the\n other is converted to floating point;\n\n* otherwise, both must be integers and no conversion is necessary.\n\nSome additional rules apply for certain operators (e.g., a string as a\nleft argument to the \'%\' operator). Extensions must define their own\nconversion behavior.\n',
- 'customization': u'\nBasic customization\n*******************\n\nobject.__new__(cls[, ...])\n\n Called to create a new instance of class *cls*. "__new__()" is a\n static method (special-cased so you need not declare it as such)\n that takes the class of which an instance was requested as its\n first argument. The remaining arguments are those passed to the\n object constructor expression (the call to the class). The return\n value of "__new__()" should be the new object instance (usually an\n instance of *cls*).\n\n Typical implementations create a new instance of the class by\n invoking the superclass\'s "__new__()" method using\n "super(currentclass, cls).__new__(cls[, ...])" with appropriate\n arguments and then modifying the newly-created instance as\n necessary before returning it.\n\n If "__new__()" returns an instance of *cls*, then the new\n instance\'s "__init__()" method will be invoked like\n "__init__(self[, ...])", where *self* is the new instance and the\n remaining arguments are the same as were passed to "__new__()".\n\n If "__new__()" does not return an instance of *cls*, then the new\n instance\'s "__init__()" method will not be invoked.\n\n "__new__()" is intended mainly to allow subclasses of immutable\n types (like int, str, or tuple) to customize instance creation. It\n is also commonly overridden in custom metaclasses in order to\n customize class creation.\n\nobject.__init__(self[, ...])\n\n Called after the instance has been created (by "__new__()"), but\n before it is returned to the caller. The arguments are those\n passed to the class constructor expression. If a base class has an\n "__init__()" method, the derived class\'s "__init__()" method, if\n any, must explicitly call it to ensure proper initialization of the\n base class part of the instance; for example:\n "BaseClass.__init__(self, [args...])".\n\n Because "__new__()" and "__init__()" work together in constructing\n objects ("__new__()" to create it, and "__init__()" to customise\n it), no non-"None" value may be returned by "__init__()"; doing so\n will cause a "TypeError" to be raised at runtime.\n\nobject.__del__(self)\n\n Called when the instance is about to be destroyed. This is also\n called a destructor. If a base class has a "__del__()" method, the\n derived class\'s "__del__()" method, if any, must explicitly call it\n to ensure proper deletion of the base class part of the instance.\n Note that it is possible (though not recommended!) for the\n "__del__()" method to postpone destruction of the instance by\n creating a new reference to it. It may then be called at a later\n time when this new reference is deleted. It is not guaranteed that\n "__del__()" methods are called for objects that still exist when\n the interpreter exits.\n\n Note: "del x" doesn\'t directly call "x.__del__()" --- the former\n decrements the reference count for "x" by one, and the latter is\n only called when "x"\'s reference count reaches zero. Some common\n situations that may prevent the reference count of an object from\n going to zero include: circular references between objects (e.g.,\n a doubly-linked list or a tree data structure with parent and\n child pointers); a reference to the object on the stack frame of\n a function that caught an exception (the traceback stored in\n "sys.exc_info()[2]" keeps the stack frame alive); or a reference\n to the object on the stack frame that raised an unhandled\n exception in interactive mode (the traceback stored in\n "sys.last_traceback" keeps the stack frame alive). The first\n situation can only be remedied by explicitly breaking the cycles;\n the second can be resolved by freeing the reference to the\n traceback object when it is no longer useful, and the third can\n be resolved by storing "None" in "sys.last_traceback". Circular\n references which are garbage are detected and cleaned up when the\n cyclic garbage collector is enabled (it\'s on by default). Refer\n to the documentation for the "gc" module for more information\n about this topic.\n\n Warning: Due to the precarious circumstances under which\n "__del__()" methods are invoked, exceptions that occur during\n their execution are ignored, and a warning is printed to\n "sys.stderr" instead. Also, when "__del__()" is invoked in\n response to a module being deleted (e.g., when execution of the\n program is done), other globals referenced by the "__del__()"\n method may already have been deleted or in the process of being\n torn down (e.g. the import machinery shutting down). For this\n reason, "__del__()" methods should do the absolute minimum needed\n to maintain external invariants. Starting with version 1.5,\n Python guarantees that globals whose name begins with a single\n underscore are deleted from their module before other globals are\n deleted; if no other references to such globals exist, this may\n help in assuring that imported modules are still available at the\n time when the "__del__()" method is called.\n\nobject.__repr__(self)\n\n Called by the "repr()" built-in function to compute the "official"\n string representation of an object. If at all possible, this\n should look like a valid Python expression that could be used to\n recreate an object with the same value (given an appropriate\n environment). If this is not possible, a string of the form\n "<...some useful description...>" should be returned. The return\n value must be a string object. If a class defines "__repr__()" but\n not "__str__()", then "__repr__()" is also used when an "informal"\n string representation of instances of that class is required.\n\n This is typically used for debugging, so it is important that the\n representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n Called by "str(object)" and the built-in functions "format()" and\n "print()" to compute the "informal" or nicely printable string\n representation of an object. The return value must be a *string*\n object.\n\n This method differs from "object.__repr__()" in that there is no\n expectation that "__str__()" return a valid Python expression: a\n more convenient or concise representation can be used.\n\n The default implementation defined by the built-in type "object"\n calls "object.__repr__()".\n\nobject.__bytes__(self)\n\n Called by "bytes()" to compute a byte-string representation of an\n object. This should return a "bytes" object.\n\nobject.__format__(self, format_spec)\n\n Called by the "format()" built-in function (and by extension, the\n "str.format()" method of class "str") to produce a "formatted"\n string representation of an object. The "format_spec" argument is a\n string that contains a description of the formatting options\n desired. The interpretation of the "format_spec" argument is up to\n the type implementing "__format__()", however most classes will\n either delegate formatting to one of the built-in types, or use a\n similar formatting option syntax.\n\n See *Format Specification Mini-Language* for a description of the\n standard formatting syntax.\n\n The return value must be a string object.\n\n Changed in version 3.4: The __format__ method of "object" itself\n raises a "TypeError" if passed any non-empty string.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n These are the so-called "rich comparison" methods. The\n correspondence between operator symbols and method names is as\n follows: "x<y" calls "x.__lt__(y)", "x<=y" calls "x.__le__(y)",\n "x==y" calls "x.__eq__(y)", "x!=y" calls "x.__ne__(y)", "x>y" calls\n "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".\n\n A rich comparison method may return the singleton "NotImplemented"\n if it does not implement the operation for a given pair of\n arguments. By convention, "False" and "True" are returned for a\n successful comparison. However, these methods can return any value,\n so if the comparison operator is used in a Boolean context (e.g.,\n in the condition of an "if" statement), Python will call "bool()"\n on the value to determine if the result is true or false.\n\n By default, "__ne__()" delegates to "__eq__()" and inverts the\n result unless it is "NotImplemented". There are no other implied\n relationships among the comparison operators, for example, the\n truth of "(x<y or x==y)" does not imply "x<=y". To automatically\n generate ordering operations from a single root operation, see\n "functools.total_ordering()".\n\n See the paragraph on "__hash__()" for some important notes on\n creating *hashable* objects which support custom comparison\n operations and are usable as dictionary keys.\n\n There are no swapped-argument versions of these methods (to be used\n when the left argument does not support the operation but the right\n argument does); rather, "__lt__()" and "__gt__()" are each other\'s\n reflection, "__le__()" and "__ge__()" are each other\'s reflection,\n and "__eq__()" and "__ne__()" are their own reflection. If the\n operands are of different types, and right operand\'s type is a\n direct or indirect subclass of the left operand\'s type, the\n reflected method of the right operand has priority, otherwise the\n left operand\'s method has priority. Virtual subclassing is not\n considered.\n\nobject.__hash__(self)\n\n Called by built-in function "hash()" and for operations on members\n of hashed collections including "set", "frozenset", and "dict".\n "__hash__()" should return an integer. The only required property\n is that objects which compare equal have the same hash value; it is\n advised to somehow mix together (e.g. using exclusive or) the hash\n values for the components of the object that also play a part in\n comparison of objects.\n\n Note: "hash()" truncates the value returned from an object\'s\n custom "__hash__()" method to the size of a "Py_ssize_t". This\n is typically 8 bytes on 64-bit builds and 4 bytes on 32-bit\n builds. If an object\'s "__hash__()" must interoperate on builds\n of different bit sizes, be sure to check the width on all\n supported builds. An easy way to do this is with "python -c\n "import sys; print(sys.hash_info.width)"".\n\n If a class does not define an "__eq__()" method it should not\n define a "__hash__()" operation either; if it defines "__eq__()"\n but not "__hash__()", its instances will not be usable as items in\n hashable collections. If a class defines mutable objects and\n implements an "__eq__()" method, it should not implement\n "__hash__()", since the implementation of hashable collections\n requires that a key\'s hash value is immutable (if the object\'s hash\n value changes, it will be in the wrong hash bucket).\n\n User-defined classes have "__eq__()" and "__hash__()" methods by\n default; with them, all objects compare unequal (except with\n themselves) and "x.__hash__()" returns an appropriate value such\n that "x == y" implies both that "x is y" and "hash(x) == hash(y)".\n\n A class that overrides "__eq__()" and does not define "__hash__()"\n will have its "__hash__()" implicitly set to "None". When the\n "__hash__()" method of a class is "None", instances of the class\n will raise an appropriate "TypeError" when a program attempts to\n retrieve their hash value, and will also be correctly identified as\n unhashable when checking "isinstance(obj, collections.Hashable)".\n\n If a class that overrides "__eq__()" needs to retain the\n implementation of "__hash__()" from a parent class, the interpreter\n must be told this explicitly by setting "__hash__ =\n <ParentClass>.__hash__".\n\n If a class that does not override "__eq__()" wishes to suppress\n hash support, it should include "__hash__ = None" in the class\n definition. A class which defines its own "__hash__()" that\n explicitly raises a "TypeError" would be incorrectly identified as\n hashable by an "isinstance(obj, collections.Hashable)" call.\n\n Note: By default, the "__hash__()" values of str, bytes and\n datetime objects are "salted" with an unpredictable random value.\n Although they remain constant within an individual Python\n process, they are not predictable between repeated invocations of\n Python.This is intended to provide protection against a denial-\n of-service caused by carefully-chosen inputs that exploit the\n worst case performance of a dict insertion, O(n^2) complexity.\n See http://www.ocert.org/advisories/ocert-2011-003.html for\n details.Changing hash values affects the iteration order of\n dicts, sets and other mappings. Python has never made guarantees\n about this ordering (and it typically varies between 32-bit and\n 64-bit builds).See also "PYTHONHASHSEED".\n\n Changed in version 3.3: Hash randomization is enabled by default.\n\nobject.__bool__(self)\n\n Called to implement truth value testing and the built-in operation\n "bool()"; should return "False" or "True". When this method is not\n defined, "__len__()" is called, if it is defined, and the object is\n considered true if its result is nonzero. If a class defines\n neither "__len__()" nor "__bool__()", all its instances are\n considered true.\n',
- 'debugger': u'\n"pdb" --- The Python Debugger\n*****************************\n\n**Source code:** Lib/pdb.py\n\n======================================================================\n\nThe module "pdb" defines an interactive source code debugger for\nPython programs. It supports setting (conditional) breakpoints and\nsingle stepping at the source line level, inspection of stack frames,\nsource code listing, and evaluation of arbitrary Python code in the\ncontext of any stack frame. It also supports post-mortem debugging\nand can be called under program control.\n\nThe debugger is extensible -- it is actually defined as the class\n"Pdb". This is currently undocumented but easily understood by reading\nthe source. The extension interface uses the modules "bdb" and "cmd".\n\nThe debugger\'s prompt is "(Pdb)". Typical usage to run a program under\ncontrol of the debugger is:\n\n >>> import pdb\n >>> import mymodule\n >>> pdb.run(\'mymodule.test()\')\n > <string>(0)?()\n (Pdb) continue\n > <string>(1)?()\n (Pdb) continue\n NameError: \'spam\'\n > <string>(1)?()\n (Pdb)\n\nChanged in version 3.3: Tab-completion via the "readline" module is\navailable for commands and command arguments, e.g. the current global\nand local names are offered as arguments of the "p" command.\n\n"pdb.py" can also be invoked as a script to debug other scripts. For\nexample:\n\n python3 -m pdb myscript.py\n\nWhen invoked as a script, pdb will automatically enter post-mortem\ndebugging if the program being debugged exits abnormally. After post-\nmortem debugging (or after normal exit of the program), pdb will\nrestart the program. Automatic restarting preserves pdb\'s state (such\nas breakpoints) and in most cases is more useful than quitting the\ndebugger upon program\'s exit.\n\nNew in version 3.2: "pdb.py" now accepts a "-c" option that executes\ncommands as if given in a ".pdbrc" file, see *Debugger Commands*.\n\nThe typical usage to break into the debugger from a running program is\nto insert\n\n import pdb; pdb.set_trace()\n\nat the location you want to break into the debugger. You can then\nstep through the code following this statement, and continue running\nwithout the debugger using the "continue" command.\n\nThe typical usage to inspect a crashed program is:\n\n >>> import pdb\n >>> import mymodule\n >>> mymodule.test()\n Traceback (most recent call last):\n File "<stdin>", line 1, in ?\n File "./mymodule.py", line 4, in test\n test2()\n File "./mymodule.py", line 3, in test2\n print(spam)\n NameError: spam\n >>> pdb.pm()\n > ./mymodule.py(3)test2()\n -> print(spam)\n (Pdb)\n\nThe module defines the following functions; each enters the debugger\nin a slightly different way:\n\npdb.run(statement, globals=None, locals=None)\n\n Execute the *statement* (given as a string or a code object) under\n debugger control. The debugger prompt appears before any code is\n executed; you can set breakpoints and type "continue", or you can\n step through the statement using "step" or "next" (all these\n commands are explained below). The optional *globals* and *locals*\n arguments specify the environment in which the code is executed; by\n default the dictionary of the module "__main__" is used. (See the\n explanation of the built-in "exec()" or "eval()" functions.)\n\npdb.runeval(expression, globals=None, locals=None)\n\n Evaluate the *expression* (given as a string or a code object)\n under debugger control. When "runeval()" returns, it returns the\n value of the expression. Otherwise this function is similar to\n "run()".\n\npdb.runcall(function, *args, **kwds)\n\n Call the *function* (a function or method object, not a string)\n with the given arguments. When "runcall()" returns, it returns\n whatever the function call returned. The debugger prompt appears\n as soon as the function is entered.\n\npdb.set_trace()\n\n Enter the debugger at the calling stack frame. This is useful to\n hard-code a breakpoint at a given point in a program, even if the\n code is not otherwise being debugged (e.g. when an assertion\n fails).\n\npdb.post_mortem(traceback=None)\n\n Enter post-mortem debugging of the given *traceback* object. If no\n *traceback* is given, it uses the one of the exception that is\n currently being handled (an exception must be being handled if the\n default is to be used).\n\npdb.pm()\n\n Enter post-mortem debugging of the traceback found in\n "sys.last_traceback".\n\nThe "run*" functions and "set_trace()" are aliases for instantiating\nthe "Pdb" class and calling the method of the same name. If you want\nto access further features, you have to do this yourself:\n\nclass class pdb.Pdb(completekey=\'tab\', stdin=None, stdout=None, skip=None, nosigint=False)\n\n "Pdb" is the debugger class.\n\n The *completekey*, *stdin* and *stdout* arguments are passed to the\n underlying "cmd.Cmd" class; see the description there.\n\n The *skip* argument, if given, must be an iterable of glob-style\n module name patterns. The debugger will not step into frames that\n originate in a module that matches one of these patterns. [1]\n\n By default, Pdb sets a handler for the SIGINT signal (which is sent\n when the user presses "Ctrl-C" on the console) when you give a\n "continue" command. This allows you to break into the debugger\n again by pressing "Ctrl-C". If you want Pdb not to touch the\n SIGINT handler, set *nosigint* tot true.\n\n Example call to enable tracing with *skip*:\n\n import pdb; pdb.Pdb(skip=[\'django.*\']).set_trace()\n\n New in version 3.1: The *skip* argument.\n\n New in version 3.2: The *nosigint* argument. Previously, a SIGINT\n handler was never set by Pdb.\n\n run(statement, globals=None, locals=None)\n runeval(expression, globals=None, locals=None)\n runcall(function, *args, **kwds)\n set_trace()\n\n See the documentation for the functions explained above.\n\n\nDebugger Commands\n=================\n\nThe commands recognized by the debugger are listed below. Most\ncommands can be abbreviated to one or two letters as indicated; e.g.\n"h(elp)" means that either "h" or "help" can be used to enter the help\ncommand (but not "he" or "hel", nor "H" or "Help" or "HELP").\nArguments to commands must be separated by whitespace (spaces or\ntabs). Optional arguments are enclosed in square brackets ("[]") in\nthe command syntax; the square brackets must not be typed.\nAlternatives in the command syntax are separated by a vertical bar\n("|").\n\nEntering a blank line repeats the last command entered. Exception: if\nthe last command was a "list" command, the next 11 lines are listed.\n\nCommands that the debugger doesn\'t recognize are assumed to be Python\nstatements and are executed in the context of the program being\ndebugged. Python statements can also be prefixed with an exclamation\npoint ("!"). This is a powerful way to inspect the program being\ndebugged; it is even possible to change a variable or call a function.\nWhen an exception occurs in such a statement, the exception name is\nprinted but the debugger\'s state is not changed.\n\nThe debugger supports *aliases*. Aliases can have parameters which\nallows one a certain level of adaptability to the context under\nexamination.\n\nMultiple commands may be entered on a single line, separated by ";;".\n(A single ";" is not used as it is the separator for multiple commands\nin a line that is passed to the Python parser.) No intelligence is\napplied to separating the commands; the input is split at the first\n";;" pair, even if it is in the middle of a quoted string.\n\nIf a file ".pdbrc" exists in the user\'s home directory or in the\ncurrent directory, it is read in and executed as if it had been typed\nat the debugger prompt. This is particularly useful for aliases. If\nboth files exist, the one in the home directory is read first and\naliases defined there can be overridden by the local file.\n\nChanged in version 3.2: ".pdbrc" can now contain commands that\ncontinue debugging, such as "continue" or "next". Previously, these\ncommands had no effect.\n\nh(elp) [command]\n\n Without argument, print the list of available commands. With a\n *command* as argument, print help about that command. "help pdb"\n displays the full documentation (the docstring of the "pdb"\n module). Since the *command* argument must be an identifier, "help\n exec" must be entered to get help on the "!" command.\n\nw(here)\n\n Print a stack trace, with the most recent frame at the bottom. An\n arrow indicates the current frame, which determines the context of\n most commands.\n\nd(own) [count]\n\n Move the current frame *count* (default one) levels down in the\n stack trace (to a newer frame).\n\nu(p) [count]\n\n Move the current frame *count* (default one) levels up in the stack\n trace (to an older frame).\n\nb(reak) [([filename:]lineno | function) [, condition]]\n\n With a *lineno* argument, set a break there in the current file.\n With a *function* argument, set a break at the first executable\n statement within that function. The line number may be prefixed\n with a filename and a colon, to specify a breakpoint in another\n file (probably one that hasn\'t been loaded yet). The file is\n searched on "sys.path". Note that each breakpoint is assigned a\n number to which all the other breakpoint commands refer.\n\n If a second argument is present, it is an expression which must\n evaluate to true before the breakpoint is honored.\n\n Without argument, list all breaks, including for each breakpoint,\n the number of times that breakpoint has been hit, the current\n ignore count, and the associated condition if any.\n\ntbreak [([filename:]lineno | function) [, condition]]\n\n Temporary breakpoint, which is removed automatically when it is\n first hit. The arguments are the same as for "break".\n\ncl(ear) [filename:lineno | bpnumber [bpnumber ...]]\n\n With a *filename:lineno* argument, clear all the breakpoints at\n this line. With a space separated list of breakpoint numbers, clear\n those breakpoints. Without argument, clear all breaks (but first\n ask confirmation).\n\ndisable [bpnumber [bpnumber ...]]\n\n Disable the breakpoints given as a space separated list of\n breakpoint numbers. Disabling a breakpoint means it cannot cause\n the program to stop execution, but unlike clearing a breakpoint, it\n remains in the list of breakpoints and can be (re-)enabled.\n\nenable [bpnumber [bpnumber ...]]\n\n Enable the breakpoints specified.\n\nignore bpnumber [count]\n\n Set the ignore count for the given breakpoint number. If count is\n omitted, the ignore count is set to 0. A breakpoint becomes active\n when the ignore count is zero. When non-zero, the count is\n decremented each time the breakpoint is reached and the breakpoint\n is not disabled and any associated condition evaluates to true.\n\ncondition bpnumber [condition]\n\n Set a new *condition* for the breakpoint, an expression which must\n evaluate to true before the breakpoint is honored. If *condition*\n is absent, any existing condition is removed; i.e., the breakpoint\n is made unconditional.\n\ncommands [bpnumber]\n\n Specify a list of commands for breakpoint number *bpnumber*. The\n commands themselves appear on the following lines. Type a line\n containing just "end" to terminate the commands. An example:\n\n (Pdb) commands 1\n (com) p some_variable\n (com) end\n (Pdb)\n\n To remove all commands from a breakpoint, type commands and follow\n it immediately with "end"; that is, give no commands.\n\n With no *bpnumber* argument, commands refers to the last breakpoint\n set.\n\n You can use breakpoint commands to start your program up again.\n Simply use the continue command, or step, or any other command that\n resumes execution.\n\n Specifying any command resuming execution (currently continue,\n step, next, return, jump, quit and their abbreviations) terminates\n the command list (as if that command was immediately followed by\n end). This is because any time you resume execution (even with a\n simple next or step), you may encounter another breakpoint--which\n could have its own command list, leading to ambiguities about which\n list to execute.\n\n If you use the \'silent\' command in the command list, the usual\n message about stopping at a breakpoint is not printed. This may be\n desirable for breakpoints that are to print a specific message and\n then continue. If none of the other commands print anything, you\n see no sign that the breakpoint was reached.\n\ns(tep)\n\n Execute the current line, stop at the first possible occasion\n (either in a function that is called or on the next line in the\n current function).\n\nn(ext)\n\n Continue execution until the next line in the current function is\n reached or it returns. (The difference between "next" and "step"\n is that "step" stops inside a called function, while "next"\n executes called functions at (nearly) full speed, only stopping at\n the next line in the current function.)\n\nunt(il) [lineno]\n\n Without argument, continue execution until the line with a number\n greater than the current one is reached.\n\n With a line number, continue execution until a line with a number\n greater or equal to that is reached. In both cases, also stop when\n the current frame returns.\n\n Changed in version 3.2: Allow giving an explicit line number.\n\nr(eturn)\n\n Continue execution until the current function returns.\n\nc(ont(inue))\n\n Continue execution, only stop when a breakpoint is encountered.\n\nj(ump) lineno\n\n Set the next line that will be executed. Only available in the\n bottom-most frame. This lets you jump back and execute code again,\n or jump forward to skip code that you don\'t want to run.\n\n It should be noted that not all jumps are allowed -- for instance\n it is not possible to jump into the middle of a "for" loop or out\n of a "finally" clause.\n\nl(ist) [first[, last]]\n\n List source code for the current file. Without arguments, list 11\n lines around the current line or continue the previous listing.\n With "." as argument, list 11 lines around the current line. With\n one argument, list 11 lines around at that line. With two\n arguments, list the given range; if the second argument is less\n than the first, it is interpreted as a count.\n\n The current line in the current frame is indicated by "->". If an\n exception is being debugged, the line where the exception was\n originally raised or propagated is indicated by ">>", if it differs\n from the current line.\n\n New in version 3.2: The ">>" marker.\n\nll | longlist\n\n List all source code for the current function or frame.\n Interesting lines are marked as for "list".\n\n New in version 3.2.\n\na(rgs)\n\n Print the argument list of the current function.\n\np expression\n\n Evaluate the *expression* in the current context and print its\n value.\n\n Note: "print()" can also be used, but is not a debugger command\n --- this executes the Python "print()" function.\n\npp expression\n\n Like the "p" command, except the value of the expression is pretty-\n printed using the "pprint" module.\n\nwhatis expression\n\n Print the type of the *expression*.\n\nsource expression\n\n Try to get source code for the given object and display it.\n\n New in version 3.2.\n\ndisplay [expression]\n\n Display the value of the expression if it changed, each time\n execution stops in the current frame.\n\n Without expression, list all display expressions for the current\n frame.\n\n New in version 3.2.\n\nundisplay [expression]\n\n Do not display the expression any more in the current frame.\n Without expression, clear all display expressions for the current\n frame.\n\n New in version 3.2.\n\ninteract\n\n Start an interative interpreter (using the "code" module) whose\n global namespace contains all the (global and local) names found in\n the current scope.\n\n New in version 3.2.\n\nalias [name [command]]\n\n Create an alias called *name* that executes *command*. The command\n must *not* be enclosed in quotes. Replaceable parameters can be\n indicated by "%1", "%2", and so on, while "%*" is replaced by all\n the parameters. If no command is given, the current alias for\n *name* is shown. If no arguments are given, all aliases are listed.\n\n Aliases may be nested and can contain anything that can be legally\n typed at the pdb prompt. Note that internal pdb commands *can* be\n overridden by aliases. Such a command is then hidden until the\n alias is removed. Aliasing is recursively applied to the first\n word of the command line; all other words in the line are left\n alone.\n\n As an example, here are two useful aliases (especially when placed\n in the ".pdbrc" file):\n\n # Print instance variables (usage "pi classInst")\n alias pi for k in %1.__dict__.keys(): print("%1.",k,"=",%1.__dict__[k])\n # Print instance variables in self\n alias ps pi self\n\nunalias name\n\n Delete the specified alias.\n\n! statement\n\n Execute the (one-line) *statement* in the context of the current\n stack frame. The exclamation point can be omitted unless the first\n word of the statement resembles a debugger command. To set a\n global variable, you can prefix the assignment command with a\n "global" statement on the same line, e.g.:\n\n (Pdb) global list_options; list_options = [\'-l\']\n (Pdb)\n\nrun [args ...]\nrestart [args ...]\n\n Restart the debugged Python program. If an argument is supplied,\n it is split with "shlex" and the result is used as the new\n "sys.argv". History, breakpoints, actions and debugger options are\n preserved. "restart" is an alias for "run".\n\nq(uit)\n\n Quit from the debugger. The program being executed is aborted.\n\n-[ Footnotes ]-\n\n[1] Whether a frame is considered to originate in a certain module\n is determined by the "__name__" in the frame globals.\n',
- 'del': u'\nThe "del" statement\n*******************\n\n del_stmt ::= "del" target_list\n\nDeletion is recursively defined very similar to the way assignment is\ndefined. Rather than spelling it out in full details, here are some\nhints.\n\nDeletion of a target list recursively deletes each target, from left\nto right.\n\nDeletion of a name removes the binding of that name from the local or\nglobal namespace, depending on whether the name occurs in a "global"\nstatement in the same code block. If the name is unbound, a\n"NameError" exception will be raised.\n\nDeletion of attribute references, subscriptions and slicings is passed\nto the primary object involved; deletion of a slicing is in general\nequivalent to assignment of an empty slice of the right type (but even\nthis is determined by the sliced object).\n\nChanged in version 3.2: Previously it was illegal to delete a name\nfrom the local namespace if it occurs as a free variable in a nested\nblock.\n',
- 'dict': u'\nDictionary displays\n*******************\n\nA dictionary display is a possibly empty series of key/datum pairs\nenclosed in curly braces:\n\n dict_display ::= "{" [key_datum_list | dict_comprehension] "}"\n key_datum_list ::= key_datum ("," key_datum)* [","]\n key_datum ::= expression ":" expression | "**" or_expr\n dict_comprehension ::= expression ":" expression comp_for\n\nA dictionary display yields a new dictionary object.\n\nIf a comma-separated sequence of key/datum pairs is given, they are\nevaluated from left to right to define the entries of the dictionary:\neach key object is used as a key into the dictionary to store the\ncorresponding datum. This means that you can specify the same key\nmultiple times in the key/datum list, and the final dictionary\'s value\nfor that key will be the last one given.\n\nA double asterisk "**" denotes *dictionary unpacking*. Its operand\nmust be a *mapping*. Each mapping item is added to the new\ndictionary. Later values replace values already set by earlier\nkey/datum pairs and earlier dictionary unpackings.\n\nNew in version 3.5: Unpacking into dictionary displays, originally\nproposed by **PEP 448**.\n\nA dict comprehension, in contrast to list and set comprehensions,\nneeds two expressions separated with a colon followed by the usual\n"for" and "if" clauses. When the comprehension is run, the resulting\nkey and value elements are inserted in the new dictionary in the order\nthey are produced.\n\nRestrictions on the types of the key values are listed earlier in\nsection *The standard type hierarchy*. (To summarize, the key type\nshould be *hashable*, which excludes all mutable objects.) Clashes\nbetween duplicate keys are not detected; the last datum (textually\nrightmost in the display) stored for a given key value prevails.\n',
- 'dynamic-features': u'\nInteraction with dynamic features\n*********************************\n\nName resolution of free variables occurs at runtime, not at compile\ntime. This means that the following code will print 42:\n\n i = 10\n def f():\n print(i)\n i = 42\n f()\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nThe "eval()" and "exec()" functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe "exec()" and "eval()" functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n',
- 'else': u'\nThe "if" statement\n******************\n\nThe "if" statement is used for conditional execution:\n\n if_stmt ::= "if" expression ":" suite\n ( "elif" expression ":" suite )*\n ["else" ":" suite]\n\nIt selects exactly one of the suites by evaluating the expressions one\nby one until one is found to be true (see section *Boolean operations*\nfor the definition of true and false); then that suite is executed\n(and no other part of the "if" statement is executed or evaluated).\nIf all expressions are false, the suite of the "else" clause, if\npresent, is executed.\n',
- 'exceptions': u'\nExceptions\n**********\n\nExceptions are a means of breaking out of the normal flow of control\nof a code block in order to handle errors or other exceptional\nconditions. An exception is *raised* at the point where the error is\ndetected; it may be *handled* by the surrounding code block or by any\ncode block that directly or indirectly invoked the code block where\nthe error occurred.\n\nThe Python interpreter raises an exception when it detects a run-time\nerror (such as division by zero). A Python program can also\nexplicitly raise an exception with the "raise" statement. Exception\nhandlers are specified with the "try" ... "except" statement. The\n"finally" clause of such a statement can be used to specify cleanup\ncode which does not handle the exception, but is executed whether an\nexception occurred or not in the preceding code.\n\nPython uses the "termination" model of error handling: an exception\nhandler can find out what happened and continue execution at an outer\nlevel, but it cannot repair the cause of the error and retry the\nfailing operation (except by re-entering the offending piece of code\nfrom the top).\n\nWhen an exception is not handled at all, the interpreter terminates\nexecution of the program, or returns to its interactive main loop. In\neither case, it prints a stack backtrace, except when the exception is\n"SystemExit".\n\nExceptions are identified by class instances. The "except" clause is\nselected depending on the class of the instance: it must reference the\nclass of the instance or a base class thereof. The instance can be\nreceived by the handler and can carry additional information about the\nexceptional condition.\n\nNote: Exception messages are not part of the Python API. Their\n contents may change from one version of Python to the next without\n warning and should not be relied on by code which will run under\n multiple versions of the interpreter.\n\nSee also the description of the "try" statement in section *The try\nstatement* and "raise" statement in section *The raise statement*.\n\n-[ Footnotes ]-\n\n[1] This limitation occurs because the code that is executed by\n these operations is not available at the time the module is\n compiled.\n',
- 'execmodel': u'\nExecution model\n***************\n\n\nStructure of a program\n======================\n\nA Python program is constructed from code blocks. A *block* is a piece\nof Python program text that is executed as a unit. The following are\nblocks: a module, a function body, and a class definition. Each\ncommand typed interactively is a block. A script file (a file given\nas standard input to the interpreter or specified as a command line\nargument to the interpreter) is a code block. A script command (a\ncommand specified on the interpreter command line with the \'**-c**\'\noption) is a code block. The string argument passed to the built-in\nfunctions "eval()" and "exec()" is a code block.\n\nA code block is executed in an *execution frame*. A frame contains\nsome administrative information (used for debugging) and determines\nwhere and how execution continues after the code block\'s execution has\ncompleted.\n\n\nNaming and binding\n==================\n\n\nBinding of names\n----------------\n\n*Names* refer to objects. Names are introduced by name binding\noperations.\n\nThe following constructs bind names: formal parameters to functions,\n"import" statements, class and function definitions (these bind the\nclass or function name in the defining block), and targets that are\nidentifiers if occurring in an assignment, "for" loop header, or after\n"as" in a "with" statement or "except" clause. The "import" statement\nof the form "from ... import *" binds all names defined in the\nimported module, except those beginning with an underscore. This form\nmay only be used at the module level.\n\nA target occurring in a "del" statement is also considered bound for\nthis purpose (though the actual semantics are to unbind the name).\n\nEach assignment or import statement occurs within a block defined by a\nclass or function definition or at the module level (the top-level\ncode block).\n\nIf a name is bound in a block, it is a local variable of that block,\nunless declared as "nonlocal" or "global". If a name is bound at the\nmodule level, it is a global variable. (The variables of the module\ncode block are local and global.) If a variable is used in a code\nblock but not defined there, it is a *free variable*.\n\nEach occurrence of a name in the program text refers to the *binding*\nof that name established by the following name resolution rules.\n\n\nResolution of names\n-------------------\n\nA *scope* defines the visibility of a name within a block. If a local\nvariable is defined in a block, its scope includes that block. If the\ndefinition occurs in a function block, the scope extends to any blocks\ncontained within the defining one, unless a contained block introduces\na different binding for the name.\n\nWhen a name is used in a code block, it is resolved using the nearest\nenclosing scope. The set of all such scopes visible to a code block\nis called the block\'s *environment*.\n\nWhen a name is not found at all, a "NameError" exception is raised. If\nthe current scope is a function scope, and the name refers to a local\nvariable that has not yet been bound to a value at the point where the\nname is used, an "UnboundLocalError" exception is raised.\n"UnboundLocalError" is a subclass of "NameError".\n\nIf a name binding operation occurs anywhere within a code block, all\nuses of the name within the block are treated as references to the\ncurrent block. This can lead to errors when a name is used within a\nblock before it is bound. This rule is subtle. Python lacks\ndeclarations and allows name binding operations to occur anywhere\nwithin a code block. The local variables of a code block can be\ndetermined by scanning the entire text of the block for name binding\noperations.\n\nIf the "global" statement occurs within a block, all uses of the name\nspecified in the statement refer to the binding of that name in the\ntop-level namespace. Names are resolved in the top-level namespace by\nsearching the global namespace, i.e. the namespace of the module\ncontaining the code block, and the builtins namespace, the namespace\nof the module "builtins". The global namespace is searched first. If\nthe name is not found there, the builtins namespace is searched. The\n"global" statement must precede all uses of the name.\n\nThe "global" statement has the same scope as a name binding operation\nin the same block. If the nearest enclosing scope for a free variable\ncontains a global statement, the free variable is treated as a global.\n\nThe "nonlocal" statement causes corresponding names to refer to\npreviously bound variables in the nearest enclosing function scope.\n"SyntaxError" is raised at compile time if the given name does not\nexist in any enclosing function scope.\n\nThe namespace for a module is automatically created the first time a\nmodule is imported. The main module for a script is always called\n"__main__".\n\nClass definition blocks and arguments to "exec()" and "eval()" are\nspecial in the context of name resolution. A class definition is an\nexecutable statement that may use and define names. These references\nfollow the normal rules for name resolution with an exception that\nunbound local variables are looked up in the global namespace. The\nnamespace of the class definition becomes the attribute dictionary of\nthe class. The scope of names defined in a class block is limited to\nthe class block; it does not extend to the code blocks of methods --\nthis includes comprehensions and generator expressions since they are\nimplemented using a function scope. This means that the following\nwill fail:\n\n class A:\n a = 42\n b = list(a + i for i in range(10))\n\n\nBuiltins and restricted execution\n---------------------------------\n\nThe builtins namespace associated with the execution of a code block\nis actually found by looking up the name "__builtins__" in its global\nnamespace; this should be a dictionary or a module (in the latter case\nthe module\'s dictionary is used). By default, when in the "__main__"\nmodule, "__builtins__" is the built-in module "builtins"; when in any\nother module, "__builtins__" is an alias for the dictionary of the\n"builtins" module itself. "__builtins__" can be set to a user-created\ndictionary to create a weak form of restricted execution.\n\n**CPython implementation detail:** Users should not touch\n"__builtins__"; it is strictly an implementation detail. Users\nwanting to override values in the builtins namespace should "import"\nthe "builtins" module and modify its attributes appropriately.\n\n\nInteraction with dynamic features\n---------------------------------\n\nName resolution of free variables occurs at runtime, not at compile\ntime. This means that the following code will print 42:\n\n i = 10\n def f():\n print(i)\n i = 42\n f()\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nThe "eval()" and "exec()" functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe "exec()" and "eval()" functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n\n\nExceptions\n==========\n\nExceptions are a means of breaking out of the normal flow of control\nof a code block in order to handle errors or other exceptional\nconditions. An exception is *raised* at the point where the error is\ndetected; it may be *handled* by the surrounding code block or by any\ncode block that directly or indirectly invoked the code block where\nthe error occurred.\n\nThe Python interpreter raises an exception when it detects a run-time\nerror (such as division by zero). A Python program can also\nexplicitly raise an exception with the "raise" statement. Exception\nhandlers are specified with the "try" ... "except" statement. The\n"finally" clause of such a statement can be used to specify cleanup\ncode which does not handle the exception, but is executed whether an\nexception occurred or not in the preceding code.\n\nPython uses the "termination" model of error handling: an exception\nhandler can find out what happened and continue execution at an outer\nlevel, but it cannot repair the cause of the error and retry the\nfailing operation (except by re-entering the offending piece of code\nfrom the top).\n\nWhen an exception is not handled at all, the interpreter terminates\nexecution of the program, or returns to its interactive main loop. In\neither case, it prints a stack backtrace, except when the exception is\n"SystemExit".\n\nExceptions are identified by class instances. The "except" clause is\nselected depending on the class of the instance: it must reference the\nclass of the instance or a base class thereof. The instance can be\nreceived by the handler and can carry additional information about the\nexceptional condition.\n\nNote: Exception messages are not part of the Python API. Their\n contents may change from one version of Python to the next without\n warning and should not be relied on by code which will run under\n multiple versions of the interpreter.\n\nSee also the description of the "try" statement in section *The try\nstatement* and "raise" statement in section *The raise statement*.\n\n-[ Footnotes ]-\n\n[1] This limitation occurs because the code that is executed by\n these operations is not available at the time the module is\n compiled.\n',
- 'exprlists': u'\nExpression lists\n****************\n\n expression_list ::= expression ( "," expression )* [","]\n starred_list ::= starred_item ( "," starred_item )* [","]\n starred_expression ::= expression | ( starred_item "," )* [starred_item]\n starred_item ::= expression | "*" or_expr\n\nExcept when part of a list or set display, an expression list\ncontaining at least one comma yields a tuple. The length of the tuple\nis the number of expressions in the list. The expressions are\nevaluated from left to right.\n\nAn asterisk "*" denotes *iterable unpacking*. Its operand must be an\n*iterable*. The iterable is expanded into a sequence of items, which\nare included in the new tuple, list, or set, at the site of the\nunpacking.\n\nNew in version 3.5: Iterable unpacking in expression lists, originally\nproposed by **PEP 448**.\n\nThe trailing comma is required only to create a single tuple (a.k.a. a\n*singleton*); it is optional in all other cases. A single expression\nwithout a trailing comma doesn\'t create a tuple, but rather yields the\nvalue of that expression. (To create an empty tuple, use an empty pair\nof parentheses: "()".)\n',
- 'floating': u'\nFloating point literals\n***********************\n\nFloating point literals are described by the following lexical\ndefinitions:\n\n floatnumber ::= pointfloat | exponentfloat\n pointfloat ::= [intpart] fraction | intpart "."\n exponentfloat ::= (intpart | pointfloat) exponent\n intpart ::= digit+\n fraction ::= "." digit+\n exponent ::= ("e" | "E") ["+" | "-"] digit+\n\nNote that the integer and exponent parts are always interpreted using\nradix 10. For example, "077e010" is legal, and denotes the same number\nas "77e10". The allowed range of floating point literals is\nimplementation-dependent. Some examples of floating point literals:\n\n 3.14 10. .001 1e100 3.14e-10 0e0\n\nNote that numeric literals do not include a sign; a phrase like "-1"\nis actually an expression composed of the unary operator "-" and the\nliteral "1".\n',
- 'for': u'\nThe "for" statement\n*******************\n\nThe "for" statement is used to iterate over the elements of a sequence\n(such as a string, tuple or list) or other iterable object:\n\n for_stmt ::= "for" target_list "in" expression_list ":" suite\n ["else" ":" suite]\n\nThe expression list is evaluated once; it should yield an iterable\nobject. An iterator is created for the result of the\n"expression_list". The suite is then executed once for each item\nprovided by the iterator, in the order returned by the iterator. Each\nitem in turn is assigned to the target list using the standard rules\nfor assignments (see *Assignment statements*), and then the suite is\nexecuted. When the items are exhausted (which is immediately when the\nsequence is empty or an iterator raises a "StopIteration" exception),\nthe suite in the "else" clause, if present, is executed, and the loop\nterminates.\n\nA "break" statement executed in the first suite terminates the loop\nwithout executing the "else" clause\'s suite. A "continue" statement\nexecuted in the first suite skips the rest of the suite and continues\nwith the next item, or with the "else" clause if there is no next\nitem.\n\nThe for-loop makes assignments to the variables(s) in the target list.\nThis overwrites all previous assignments to those variables including\nthose made in the suite of the for-loop:\n\n for i in range(10):\n print(i)\n i = 5 # this will not affect the for-loop\n # because i will be overwritten with the next\n # index in the range\n\nNames in the target list are not deleted when the loop is finished,\nbut if the sequence is empty, they will not have been assigned to at\nall by the loop. Hint: the built-in function "range()" returns an\niterator of integers suitable to emulate the effect of Pascal\'s "for i\n:= a to b do"; e.g., "list(range(3))" returns the list "[0, 1, 2]".\n\nNote: There is a subtlety when the sequence is being modified by the\n loop (this can only occur for mutable sequences, i.e. lists). An\n internal counter is used to keep track of which item is used next,\n and this is incremented on each iteration. When this counter has\n reached the length of the sequence the loop terminates. This means\n that if the suite deletes the current (or a previous) item from the\n sequence, the next item will be skipped (since it gets the index of\n the current item which has already been treated). Likewise, if the\n suite inserts an item in the sequence before the current item, the\n current item will be treated again the next time through the loop.\n This can lead to nasty bugs that can be avoided by making a\n temporary copy using a slice of the whole sequence, e.g.,\n\n for x in a[:]:\n if x < 0: a.remove(x)\n',
- 'formatstrings': u'\nFormat String Syntax\n********************\n\nThe "str.format()" method and the "Formatter" class share the same\nsyntax for format strings (although in the case of "Formatter",\nsubclasses can define their own format string syntax).\n\nFormat strings contain "replacement fields" surrounded by curly braces\n"{}". Anything that is not contained in braces is considered literal\ntext, which is copied unchanged to the output. If you need to include\na brace character in the literal text, it can be escaped by doubling:\n"{{" and "}}".\n\nThe grammar for a replacement field is as follows:\n\n replacement_field ::= "{" [field_name] ["!" conversion] [":" format_spec] "}"\n field_name ::= arg_name ("." attribute_name | "[" element_index "]")*\n arg_name ::= [identifier | integer]\n attribute_name ::= identifier\n element_index ::= integer | index_string\n index_string ::= <any source character except "]"> +\n conversion ::= "r" | "s" | "a"\n format_spec ::= <described in the next section>\n\nIn less formal terms, the replacement field can start with a\n*field_name* that specifies the object whose value is to be formatted\nand inserted into the output instead of the replacement field. The\n*field_name* is optionally followed by a *conversion* field, which is\npreceded by an exclamation point "\'!\'", and a *format_spec*, which is\npreceded by a colon "\':\'". These specify a non-default format for the\nreplacement value.\n\nSee also the *Format Specification Mini-Language* section.\n\nThe *field_name* itself begins with an *arg_name* that is either a\nnumber or a keyword. If it\'s a number, it refers to a positional\nargument, and if it\'s a keyword, it refers to a named keyword\nargument. If the numerical arg_names in a format string are 0, 1, 2,\n... in sequence, they can all be omitted (not just some) and the\nnumbers 0, 1, 2, ... will be automatically inserted in that order.\nBecause *arg_name* is not quote-delimited, it is not possible to\nspecify arbitrary dictionary keys (e.g., the strings "\'10\'" or\n"\':-]\'") within a format string. The *arg_name* can be followed by any\nnumber of index or attribute expressions. An expression of the form\n"\'.name\'" selects the named attribute using "getattr()", while an\nexpression of the form "\'[index]\'" does an index lookup using\n"__getitem__()".\n\nChanged in version 3.1: The positional argument specifiers can be\nomitted, so "\'{} {}\'" is equivalent to "\'{0} {1}\'".\n\nSome simple format string examples:\n\n "First, thou shalt count to {0}" # References first positional argument\n "Bring me a {}" # Implicitly references the first positional argument\n "From {} to {}" # Same as "From {0} to {1}"\n "My quest is {name}" # References keyword argument \'name\'\n "Weight in tons {0.weight}" # \'weight\' attribute of first positional arg\n "Units destroyed: {players[0]}" # First element of keyword argument \'players\'.\n\nThe *conversion* field causes a type coercion before formatting.\nNormally, the job of formatting a value is done by the "__format__()"\nmethod of the value itself. However, in some cases it is desirable to\nforce a type to be formatted as a string, overriding its own\ndefinition of formatting. By converting the value to a string before\ncalling "__format__()", the normal formatting logic is bypassed.\n\nThree conversion flags are currently supported: "\'!s\'" which calls\n"str()" on the value, "\'!r\'" which calls "repr()" and "\'!a\'" which\ncalls "ascii()".\n\nSome examples:\n\n "Harold\'s a clever {0!s}" # Calls str() on the argument first\n "Bring out the holy {name!r}" # Calls repr() on the argument first\n "More {!a}" # Calls ascii() on the argument first\n\nThe *format_spec* field contains a specification of how the value\nshould be presented, including such details as field width, alignment,\npadding, decimal precision and so on. Each value type can define its\nown "formatting mini-language" or interpretation of the *format_spec*.\n\nMost built-in types support a common formatting mini-language, which\nis described in the next section.\n\nA *format_spec* field can also include nested replacement fields\nwithin it. These nested replacement fields may contain a field name,\nconversion flag and format specification, but deeper nesting is not\nallowed. The replacement fields within the format_spec are\nsubstituted before the *format_spec* string is interpreted. This\nallows the formatting of a value to be dynamically specified.\n\nSee the *Format examples* section for some examples.\n\n\nFormat Specification Mini-Language\n==================================\n\n"Format specifications" are used within replacement fields contained\nwithin a format string to define how individual values are presented\n(see *Format String Syntax*). They can also be passed directly to the\nbuilt-in "format()" function. Each formattable type may define how\nthe format specification is to be interpreted.\n\nMost built-in types implement the following options for format\nspecifications, although some of the formatting options are only\nsupported by the numeric types.\n\nA general convention is that an empty format string ("""") produces\nthe same result as if you had called "str()" on the value. A non-empty\nformat string typically modifies the result.\n\nThe general form of a *standard format specifier* is:\n\n format_spec ::= [[fill]align][sign][#][0][width][,][.precision][type]\n fill ::= <any character>\n align ::= "<" | ">" | "=" | "^"\n sign ::= "+" | "-" | " "\n width ::= integer\n precision ::= integer\n type ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"\n\nIf a valid *align* value is specified, it can be preceded by a *fill*\ncharacter that can be any character and defaults to a space if\nomitted. It is not possible to use a literal curly brace (""{"" or\n""}"") as the *fill* character when using the "str.format()" method.\nHowever, it is possible to insert a curly brace with a nested\nreplacement field. This limitation doesn\'t affect the "format()"\nfunction.\n\nThe meaning of the various alignment options is as follows:\n\n +-----------+------------------------------------------------------------+\n | Option | Meaning |\n +===========+============================================================+\n | "\'<\'" | Forces the field to be left-aligned within the available |\n | | space (this is the default for most objects). |\n +-----------+------------------------------------------------------------+\n | "\'>\'" | Forces the field to be right-aligned within the available |\n | | space (this is the default for numbers). |\n +-----------+------------------------------------------------------------+\n | "\'=\'" | Forces the padding to be placed after the sign (if any) |\n | | but before the digits. This is used for printing fields |\n | | in the form \'+000000120\'. This alignment option is only |\n | | valid for numeric types. It becomes the default when \'0\' |\n | | immediately precedes the field width. |\n +-----------+------------------------------------------------------------+\n | "\'^\'" | Forces the field to be centered within the available |\n | | space. |\n +-----------+------------------------------------------------------------+\n\nNote that unless a minimum field width is defined, the field width\nwill always be the same size as the data to fill it, so that the\nalignment option has no meaning in this case.\n\nThe *sign* option is only valid for number types, and can be one of\nthe following:\n\n +-----------+------------------------------------------------------------+\n | Option | Meaning |\n +===========+============================================================+\n | "\'+\'" | indicates that a sign should be used for both positive as |\n | | well as negative numbers. |\n +-----------+------------------------------------------------------------+\n | "\'-\'" | indicates that a sign should be used only for negative |\n | | numbers (this is the default behavior). |\n +-----------+------------------------------------------------------------+\n | space | indicates that a leading space should be used on positive |\n | | numbers, and a minus sign on negative numbers. |\n +-----------+------------------------------------------------------------+\n\nThe "\'#\'" option causes the "alternate form" to be used for the\nconversion. The alternate form is defined differently for different\ntypes. This option is only valid for integer, float, complex and\nDecimal types. For integers, when binary, octal, or hexadecimal output\nis used, this option adds the prefix respective "\'0b\'", "\'0o\'", or\n"\'0x\'" to the output value. For floats, complex and Decimal the\nalternate form causes the result of the conversion to always contain a\ndecimal-point character, even if no digits follow it. Normally, a\ndecimal-point character appears in the result of these conversions\nonly if a digit follows it. In addition, for "\'g\'" and "\'G\'"\nconversions, trailing zeros are not removed from the result.\n\nThe "\',\'" option signals the use of a comma for a thousands separator.\nFor a locale aware separator, use the "\'n\'" integer presentation type\ninstead.\n\nChanged in version 3.1: Added the "\',\'" option (see also **PEP 378**).\n\n*width* is a decimal integer defining the minimum field width. If not\nspecified, then the field width will be determined by the content.\n\nWhen no explicit alignment is given, preceding the *width* field by a\nzero ("\'0\'") character enables sign-aware zero-padding for numeric\ntypes. This is equivalent to a *fill* character of "\'0\'" with an\n*alignment* type of "\'=\'".\n\nThe *precision* is a decimal number indicating how many digits should\nbe displayed after the decimal point for a floating point value\nformatted with "\'f\'" and "\'F\'", or before and after the decimal point\nfor a floating point value formatted with "\'g\'" or "\'G\'". For non-\nnumber types the field indicates the maximum field size - in other\nwords, how many characters will be used from the field content. The\n*precision* is not allowed for integer values.\n\nFinally, the *type* determines how the data should be presented.\n\nThe available string presentation types are:\n\n +-----------+------------------------------------------------------------+\n | Type | Meaning |\n +===========+============================================================+\n | "\'s\'" | String format. This is the default type for strings and |\n | | may be omitted. |\n +-----------+------------------------------------------------------------+\n | None | The same as "\'s\'". |\n +-----------+------------------------------------------------------------+\n\nThe available integer presentation types are:\n\n +-----------+------------------------------------------------------------+\n | Type | Meaning |\n +===========+============================================================+\n | "\'b\'" | Binary format. Outputs the number in base 2. |\n +-----------+------------------------------------------------------------+\n | "\'c\'" | Character. Converts the integer to the corresponding |\n | | unicode character before printing. |\n +-----------+------------------------------------------------------------+\n | "\'d\'" | Decimal Integer. Outputs the number in base 10. |\n +-----------+------------------------------------------------------------+\n | "\'o\'" | Octal format. Outputs the number in base 8. |\n +-----------+------------------------------------------------------------+\n | "\'x\'" | Hex format. Outputs the number in base 16, using lower- |\n | | case letters for the digits above 9. |\n +-----------+------------------------------------------------------------+\n | "\'X\'" | Hex format. Outputs the number in base 16, using upper- |\n | | case letters for the digits above 9. |\n +-----------+------------------------------------------------------------+\n | "\'n\'" | Number. This is the same as "\'d\'", except that it uses the |\n | | current locale setting to insert the appropriate number |\n | | separator characters. |\n +-----------+------------------------------------------------------------+\n | None | The same as "\'d\'". |\n +-----------+------------------------------------------------------------+\n\nIn addition to the above presentation types, integers can be formatted\nwith the floating point presentation types listed below (except "\'n\'"\nand None). When doing so, "float()" is used to convert the integer to\na floating point number before formatting.\n\nThe available presentation types for floating point and decimal values\nare:\n\n +-----------+------------------------------------------------------------+\n | Type | Meaning |\n +===========+============================================================+\n | "\'e\'" | Exponent notation. Prints the number in scientific |\n | | notation using the letter \'e\' to indicate the exponent. |\n | | The default precision is "6". |\n +-----------+------------------------------------------------------------+\n | "\'E\'" | Exponent notation. Same as "\'e\'" except it uses an upper |\n | | case \'E\' as the separator character. |\n +-----------+------------------------------------------------------------+\n | "\'f\'" | Fixed point. Displays the number as a fixed-point number. |\n | | The default precision is "6". |\n +-----------+------------------------------------------------------------+\n | "\'F\'" | Fixed point. Same as "\'f\'", but converts "nan" to "NAN" |\n | | and "inf" to "INF". |\n +-----------+------------------------------------------------------------+\n | "\'g\'" | General format. For a given precision "p >= 1", this |\n | | rounds the number to "p" significant digits and then |\n | | formats the result in either fixed-point format or in |\n | | scientific notation, depending on its magnitude. The |\n | | precise rules are as follows: suppose that the result |\n | | formatted with presentation type "\'e\'" and precision "p-1" |\n | | would have exponent "exp". Then if "-4 <= exp < p", the |\n | | number is formatted with presentation type "\'f\'" and |\n | | precision "p-1-exp". Otherwise, the number is formatted |\n | | with presentation type "\'e\'" and precision "p-1". In both |\n | | cases insignificant trailing zeros are removed from the |\n | | significand, and the decimal point is also removed if |\n | | there are no remaining digits following it. Positive and |\n | | negative infinity, positive and negative zero, and nans, |\n | | are formatted as "inf", "-inf", "0", "-0" and "nan" |\n | | respectively, regardless of the precision. A precision of |\n | | "0" is treated as equivalent to a precision of "1". The |\n | | default precision is "6". |\n +-----------+------------------------------------------------------------+\n | "\'G\'" | General format. Same as "\'g\'" except switches to "\'E\'" if |\n | | the number gets too large. The representations of infinity |\n | | and NaN are uppercased, too. |\n +-----------+------------------------------------------------------------+\n | "\'n\'" | Number. This is the same as "\'g\'", except that it uses the |\n | | current locale setting to insert the appropriate number |\n | | separator characters. |\n +-----------+------------------------------------------------------------+\n | "\'%\'" | Percentage. Multiplies the number by 100 and displays in |\n | | fixed ("\'f\'") format, followed by a percent sign. |\n +-----------+------------------------------------------------------------+\n | None | Similar to "\'g\'", except that fixed-point notation, when |\n | | used, has at least one digit past the decimal point. The |\n | | default precision is as high as needed to represent the |\n | | particular value. The overall effect is to match the |\n | | output of "str()" as altered by the other format |\n | | modifiers. |\n +-----------+------------------------------------------------------------+\n\n\nFormat examples\n===============\n\nThis section contains examples of the "str.format()" syntax and\ncomparison with the old "%"-formatting.\n\nIn most of the cases the syntax is similar to the old "%"-formatting,\nwith the addition of the "{}" and with ":" used instead of "%". For\nexample, "\'%03.2f\'" can be translated to "\'{:03.2f}\'".\n\nThe new format syntax also supports new and different options, shown\nin the follow examples.\n\nAccessing arguments by position:\n\n >>> \'{0}, {1}, {2}\'.format(\'a\', \'b\', \'c\')\n \'a, b, c\'\n >>> \'{}, {}, {}\'.format(\'a\', \'b\', \'c\') # 3.1+ only\n \'a, b, c\'\n >>> \'{2}, {1}, {0}\'.format(\'a\', \'b\', \'c\')\n \'c, b, a\'\n >>> \'{2}, {1}, {0}\'.format(*\'abc\') # unpacking argument sequence\n \'c, b, a\'\n >>> \'{0}{1}{0}\'.format(\'abra\', \'cad\') # arguments\' indices can be repeated\n \'abracadabra\'\n\nAccessing arguments by name:\n\n >>> \'Coordinates: {latitude}, {longitude}\'.format(latitude=\'37.24N\', longitude=\'-115.81W\')\n \'Coordinates: 37.24N, -115.81W\'\n >>> coord = {\'latitude\': \'37.24N\', \'longitude\': \'-115.81W\'}\n >>> \'Coordinates: {latitude}, {longitude}\'.format(**coord)\n \'Coordinates: 37.24N, -115.81W\'\n\nAccessing arguments\' attributes:\n\n >>> c = 3-5j\n >>> (\'The complex number {0} is formed from the real part {0.real} \'\n ... \'and the imaginary part {0.imag}.\').format(c)\n \'The complex number (3-5j) is formed from the real part 3.0 and the imaginary part -5.0.\'\n >>> class Point:\n ... def __init__(self, x, y):\n ... self.x, self.y = x, y\n ... def __str__(self):\n ... return \'Point({self.x}, {self.y})\'.format(self=self)\n ...\n >>> str(Point(4, 2))\n \'Point(4, 2)\'\n\nAccessing arguments\' items:\n\n >>> coord = (3, 5)\n >>> \'X: {0[0]}; Y: {0[1]}\'.format(coord)\n \'X: 3; Y: 5\'\n\nReplacing "%s" and "%r":\n\n >>> "repr() shows quotes: {!r}; str() doesn\'t: {!s}".format(\'test1\', \'test2\')\n "repr() shows quotes: \'test1\'; str() doesn\'t: test2"\n\nAligning the text and specifying a width:\n\n >>> \'{:<30}\'.format(\'left aligned\')\n \'left aligned \'\n >>> \'{:>30}\'.format(\'right aligned\')\n \' right aligned\'\n >>> \'{:^30}\'.format(\'centered\')\n \' centered \'\n >>> \'{:*^30}\'.format(\'centered\') # use \'*\' as a fill char\n \'***********centered***********\'\n\nReplacing "%+f", "%-f", and "% f" and specifying a sign:\n\n >>> \'{:+f}; {:+f}\'.format(3.14, -3.14) # show it always\n \'+3.140000; -3.140000\'\n >>> \'{: f}; {: f}\'.format(3.14, -3.14) # show a space for positive numbers\n \' 3.140000; -3.140000\'\n >>> \'{:-f}; {:-f}\'.format(3.14, -3.14) # show only the minus -- same as \'{:f}; {:f}\'\n \'3.140000; -3.140000\'\n\nReplacing "%x" and "%o" and converting the value to different bases:\n\n >>> # format also supports binary numbers\n >>> "int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}".format(42)\n \'int: 42; hex: 2a; oct: 52; bin: 101010\'\n >>> # with 0x, 0o, or 0b as prefix:\n >>> "int: {0:d}; hex: {0:#x}; oct: {0:#o}; bin: {0:#b}".format(42)\n \'int: 42; hex: 0x2a; oct: 0o52; bin: 0b101010\'\n\nUsing the comma as a thousands separator:\n\n >>> \'{:,}\'.format(1234567890)\n \'1,234,567,890\'\n\nExpressing a percentage:\n\n >>> points = 19\n >>> total = 22\n >>> \'Correct answers: {:.2%}\'.format(points/total)\n \'Correct answers: 86.36%\'\n\nUsing type-specific formatting:\n\n >>> import datetime\n >>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)\n >>> \'{:%Y-%m-%d %H:%M:%S}\'.format(d)\n \'2010-07-04 12:15:58\'\n\nNesting arguments and more complex examples:\n\n >>> for align, text in zip(\'<^>\', [\'left\', \'center\', \'right\']):\n ... \'{0:{fill}{align}16}\'.format(text, fill=align, align=align)\n ...\n \'left<<<<<<<<<<<<\'\n \'^^^^^center^^^^^\'\n \'>>>>>>>>>>>right\'\n >>>\n >>> octets = [192, 168, 0, 1]\n >>> \'{:02X}{:02X}{:02X}{:02X}\'.format(*octets)\n \'C0A80001\'\n >>> int(_, 16)\n 3232235521\n >>>\n >>> width = 5\n >>> for num in range(5,12): #doctest: +NORMALIZE_WHITESPACE\n ... for base in \'dXob\':\n ... print(\'{0:{width}{base}}\'.format(num, base=base, width=width), end=\' \')\n ... print()\n ...\n 5 5 5 101\n 6 6 6 110\n 7 7 7 111\n 8 8 10 1000\n 9 9 11 1001\n 10 A 12 1010\n 11 B 13 1011\n',
- 'function': u'\nFunction definitions\n********************\n\nA function definition defines a user-defined function object (see\nsection *The standard type hierarchy*):\n\n funcdef ::= [decorators] "def" funcname "(" [parameter_list] ")" ["->" expression] ":" suite\n decorators ::= decorator+\n decorator ::= "@" dotted_name ["(" [argument_list [","]] ")"] NEWLINE\n dotted_name ::= identifier ("." identifier)*\n parameter_list ::= (defparameter ",")*\n | "*" [parameter] ("," defparameter)* ["," "**" parameter]\n | "**" parameter\n | defparameter [","] )\n parameter ::= identifier [":" expression]\n defparameter ::= parameter ["=" expression]\n funcname ::= identifier\n\nA function definition is an executable statement. Its execution binds\nthe function name in the current local namespace to a function object\n(a wrapper around the executable code for the function). This\nfunction object contains a reference to the current global namespace\nas the global namespace to be used when the function is called.\n\nThe function definition does not execute the function body; this gets\nexecuted only when the function is called. [3]\n\nA function definition may be wrapped by one or more *decorator*\nexpressions. Decorator expressions are evaluated when the function is\ndefined, in the scope that contains the function definition. The\nresult must be a callable, which is invoked with the function object\nas the only argument. The returned value is bound to the function name\ninstead of the function object. Multiple decorators are applied in\nnested fashion. For example, the following code\n\n @f1(arg)\n @f2\n def func(): pass\n\nis equivalent to\n\n def func(): pass\n func = f1(arg)(f2(func))\n\nWhen one or more *parameters* have the form *parameter* "="\n*expression*, the function is said to have "default parameter values."\nFor a parameter with a default value, the corresponding *argument* may\nbe omitted from a call, in which case the parameter\'s default value is\nsubstituted. If a parameter has a default value, all following\nparameters up until the ""*"" must also have a default value --- this\nis a syntactic restriction that is not expressed by the grammar.\n\n**Default parameter values are evaluated from left to right when the\nfunction definition is executed.** This means that the expression is\nevaluated once, when the function is defined, and that the same "pre-\ncomputed" value is used for each call. This is especially important\nto understand when a default parameter is a mutable object, such as a\nlist or a dictionary: if the function modifies the object (e.g. by\nappending an item to a list), the default value is in effect modified.\nThis is generally not what was intended. A way around this is to use\n"None" as the default, and explicitly test for it in the body of the\nfunction, e.g.:\n\n def whats_on_the_telly(penguin=None):\n if penguin is None:\n penguin = []\n penguin.append("property of the zoo")\n return penguin\n\nFunction call semantics are described in more detail in section\n*Calls*. A function call always assigns values to all parameters\nmentioned in the parameter list, either from position arguments, from\nkeyword arguments, or from default values. If the form\n""*identifier"" is present, it is initialized to a tuple receiving any\nexcess positional parameters, defaulting to the empty tuple. If the\nform ""**identifier"" is present, it is initialized to a new\ndictionary receiving any excess keyword arguments, defaulting to a new\nempty dictionary. Parameters after ""*"" or ""*identifier"" are\nkeyword-only parameters and may only be passed used keyword arguments.\n\nParameters may have annotations of the form "": expression"" following\nthe parameter name. Any parameter may have an annotation even those\nof the form "*identifier" or "**identifier". Functions may have\n"return" annotation of the form ""-> expression"" after the parameter\nlist. These annotations can be any valid Python expression and are\nevaluated when the function definition is executed. Annotations may\nbe evaluated in a different order than they appear in the source code.\nThe presence of annotations does not change the semantics of a\nfunction. The annotation values are available as values of a\ndictionary keyed by the parameters\' names in the "__annotations__"\nattribute of the function object.\n\nIt is also possible to create anonymous functions (functions not bound\nto a name), for immediate use in expressions. This uses lambda\nexpressions, described in section *Lambdas*. Note that the lambda\nexpression is merely a shorthand for a simplified function definition;\na function defined in a ""def"" statement can be passed around or\nassigned to another name just like a function defined by a lambda\nexpression. The ""def"" form is actually more powerful since it\nallows the execution of multiple statements and annotations.\n\n**Programmer\'s note:** Functions are first-class objects. A ""def""\nstatement executed inside a function definition defines a local\nfunction that can be returned or passed around. Free variables used\nin the nested function can access the local variables of the function\ncontaining the def. See section *Naming and binding* for details.\n\nSee also: **PEP 3107** - Function Annotations\n\n The original specification for function annotations.\n',
- 'global': u'\nThe "global" statement\n**********************\n\n global_stmt ::= "global" identifier ("," identifier)*\n\nThe "global" statement is a declaration which holds for the entire\ncurrent code block. It means that the listed identifiers are to be\ninterpreted as globals. It would be impossible to assign to a global\nvariable without "global", although free variables may refer to\nglobals without being declared global.\n\nNames listed in a "global" statement must not be used in the same code\nblock textually preceding that "global" statement.\n\nNames listed in a "global" statement must not be defined as formal\nparameters or in a "for" loop control target, "class" definition,\nfunction definition, or "import" statement.\n\n**CPython implementation detail:** The current implementation does not\nenforce the two restrictions, but programs should not abuse this\nfreedom, as future implementations may enforce them or silently change\nthe meaning of the program.\n\n**Programmer\'s note:** the "global" is a directive to the parser. It\napplies only to code parsed at the same time as the "global"\nstatement. In particular, a "global" statement contained in a string\nor code object supplied to the built-in "exec()" function does not\naffect the code block *containing* the function call, and code\ncontained in such a string is unaffected by "global" statements in the\ncode containing the function call. The same applies to the "eval()"\nand "compile()" functions.\n',
- 'id-classes': u'\nReserved classes of identifiers\n*******************************\n\nCertain classes of identifiers (besides keywords) have special\nmeanings. These classes are identified by the patterns of leading and\ntrailing underscore characters:\n\n"_*"\n Not imported by "from module import *". The special identifier "_"\n is used in the interactive interpreter to store the result of the\n last evaluation; it is stored in the "builtins" module. When not\n in interactive mode, "_" has no special meaning and is not defined.\n See section *The import statement*.\n\n Note: The name "_" is often used in conjunction with\n internationalization; refer to the documentation for the\n "gettext" module for more information on this convention.\n\n"__*__"\n System-defined names. These names are defined by the interpreter\n and its implementation (including the standard library). Current\n system names are discussed in the *Special method names* section\n and elsewhere. More will likely be defined in future versions of\n Python. *Any* use of "__*__" names, in any context, that does not\n follow explicitly documented use, is subject to breakage without\n warning.\n\n"__*"\n Class-private names. Names in this category, when used within the\n context of a class definition, are re-written to use a mangled form\n to help avoid name clashes between "private" attributes of base and\n derived classes. See section *Identifiers (Names)*.\n',
- 'identifiers': u'\nIdentifiers and keywords\n************************\n\nIdentifiers (also referred to as *names*) are described by the\nfollowing lexical definitions.\n\nThe syntax of identifiers in Python is based on the Unicode standard\nannex UAX-31, with elaboration and changes as defined below; see also\n**PEP 3131** for further details.\n\nWithin the ASCII range (U+0001..U+007F), the valid characters for\nidentifiers are the same as in Python 2.x: the uppercase and lowercase\nletters "A" through "Z", the underscore "_" and, except for the first\ncharacter, the digits "0" through "9".\n\nPython 3.0 introduces additional characters from outside the ASCII\nrange (see **PEP 3131**). For these characters, the classification\nuses the version of the Unicode Character Database as included in the\n"unicodedata" module.\n\nIdentifiers are unlimited in length. Case is significant.\n\n identifier ::= xid_start xid_continue*\n id_start ::= <all characters in general categories Lu, Ll, Lt, Lm, Lo, Nl, the underscore, and characters with the Other_ID_Start property>\n id_continue ::= <all characters in id_start, plus characters in the categories Mn, Mc, Nd, Pc and others with the Other_ID_Continue property>\n xid_start ::= <all characters in id_start whose NFKC normalization is in "id_start xid_continue*">\n xid_continue ::= <all characters in id_continue whose NFKC normalization is in "id_continue*">\n\nThe Unicode category codes mentioned above stand for:\n\n* *Lu* - uppercase letters\n\n* *Ll* - lowercase letters\n\n* *Lt* - titlecase letters\n\n* *Lm* - modifier letters\n\n* *Lo* - other letters\n\n* *Nl* - letter numbers\n\n* *Mn* - nonspacing marks\n\n* *Mc* - spacing combining marks\n\n* *Nd* - decimal numbers\n\n* *Pc* - connector punctuations\n\n* *Other_ID_Start* - explicit list of characters in PropList.txt to\n support backwards compatibility\n\n* *Other_ID_Continue* - likewise\n\nAll identifiers are converted into the normal form NFKC while parsing;\ncomparison of identifiers is based on NFKC.\n\nA non-normative HTML file listing all valid identifier characters for\nUnicode 4.1 can be found at https://www.dcl.hpi.uni-\npotsdam.de/home/loewis/table-3131.html.\n\n\nKeywords\n========\n\nThe following identifiers are used as reserved words, or *keywords* of\nthe language, and cannot be used as ordinary identifiers. They must\nbe spelled exactly as written here:\n\n False class finally is return\n None continue for lambda try\n True def from nonlocal while\n and del global not with\n as elif if or yield\n assert else import pass\n break except in raise\n\n\nReserved classes of identifiers\n===============================\n\nCertain classes of identifiers (besides keywords) have special\nmeanings. These classes are identified by the patterns of leading and\ntrailing underscore characters:\n\n"_*"\n Not imported by "from module import *". The special identifier "_"\n is used in the interactive interpreter to store the result of the\n last evaluation; it is stored in the "builtins" module. When not\n in interactive mode, "_" has no special meaning and is not defined.\n See section *The import statement*.\n\n Note: The name "_" is often used in conjunction with\n internationalization; refer to the documentation for the\n "gettext" module for more information on this convention.\n\n"__*__"\n System-defined names. These names are defined by the interpreter\n and its implementation (including the standard library). Current\n system names are discussed in the *Special method names* section\n and elsewhere. More will likely be defined in future versions of\n Python. *Any* use of "__*__" names, in any context, that does not\n follow explicitly documented use, is subject to breakage without\n warning.\n\n"__*"\n Class-private names. Names in this category, when used within the\n context of a class definition, are re-written to use a mangled form\n to help avoid name clashes between "private" attributes of base and\n derived classes. See section *Identifiers (Names)*.\n',
- 'if': u'\nThe "if" statement\n******************\n\nThe "if" statement is used for conditional execution:\n\n if_stmt ::= "if" expression ":" suite\n ( "elif" expression ":" suite )*\n ["else" ":" suite]\n\nIt selects exactly one of the suites by evaluating the expressions one\nby one until one is found to be true (see section *Boolean operations*\nfor the definition of true and false); then that suite is executed\n(and no other part of the "if" statement is executed or evaluated).\nIf all expressions are false, the suite of the "else" clause, if\npresent, is executed.\n',
- 'imaginary': u'\nImaginary literals\n******************\n\nImaginary literals are described by the following lexical definitions:\n\n imagnumber ::= (floatnumber | intpart) ("j" | "J")\n\nAn imaginary literal yields a complex number with a real part of 0.0.\nComplex numbers are represented as a pair of floating point numbers\nand have the same restrictions on their range. To create a complex\nnumber with a nonzero real part, add a floating point number to it,\ne.g., "(3+4j)". Some examples of imaginary literals:\n\n 3.14j 10.j 10j .001j 1e100j 3.14e-10j\n',
- 'import': u'\nThe "import" statement\n**********************\n\n import_stmt ::= "import" module ["as" name] ( "," module ["as" name] )*\n | "from" relative_module "import" identifier ["as" name]\n ( "," identifier ["as" name] )*\n | "from" relative_module "import" "(" identifier ["as" name]\n ( "," identifier ["as" name] )* [","] ")"\n | "from" module "import" "*"\n module ::= (identifier ".")* identifier\n relative_module ::= "."* module | "."+\n name ::= identifier\n\nThe basic import statement (no "from" clause) is executed in two\nsteps:\n\n1. find a module, loading and initializing it if necessary\n\n2. define a name or names in the local namespace for the scope\n where the "import" statement occurs.\n\nWhen the statement contains multiple clauses (separated by commas) the\ntwo steps are carried out separately for each clause, just as though\nthe clauses had been separated out into individual import statements.\n\nThe details of the first step, finding and loading modules are\ndescribed in greater detail in the section on the *import system*,\nwhich also describes the various types of packages and modules that\ncan be imported, as well as all the hooks that can be used to\ncustomize the import system. Note that failures in this step may\nindicate either that the module could not be located, *or* that an\nerror occurred while initializing the module, which includes execution\nof the module\'s code.\n\nIf the requested module is retrieved successfully, it will be made\navailable in the local namespace in one of three ways:\n\n* If the module name is followed by "as", then the name following\n "as" is bound directly to the imported module.\n\n* If no other name is specified, and the module being imported is a\n top level module, the module\'s name is bound in the local namespace\n as a reference to the imported module\n\n* If the module being imported is *not* a top level module, then the\n name of the top level package that contains the module is bound in\n the local namespace as a reference to the top level package. The\n imported module must be accessed using its full qualified name\n rather than directly\n\nThe "from" form uses a slightly more complex process:\n\n1. find the module specified in the "from" clause, loading and\n initializing it if necessary;\n\n2. for each of the identifiers specified in the "import" clauses:\n\n 1. check if the imported module has an attribute by that name\n\n 2. if not, attempt to import a submodule with that name and then\n check the imported module again for that attribute\n\n 3. if the attribute is not found, "ImportError" is raised.\n\n 4. otherwise, a reference to that value is stored in the local\n namespace, using the name in the "as" clause if it is present,\n otherwise using the attribute name\n\nExamples:\n\n import foo # foo imported and bound locally\n import foo.bar.baz # foo.bar.baz imported, foo bound locally\n import foo.bar.baz as fbb # foo.bar.baz imported and bound as fbb\n from foo.bar import baz # foo.bar.baz imported and bound as baz\n from foo import attr # foo imported and foo.attr bound as attr\n\nIf the list of identifiers is replaced by a star ("\'*\'"), all public\nnames defined in the module are bound in the local namespace for the\nscope where the "import" statement occurs.\n\nThe *public names* defined by a module are determined by checking the\nmodule\'s namespace for a variable named "__all__"; if defined, it must\nbe a sequence of strings which are names defined or imported by that\nmodule. The names given in "__all__" are all considered public and\nare required to exist. If "__all__" is not defined, the set of public\nnames includes all names found in the module\'s namespace which do not\nbegin with an underscore character ("\'_\'"). "__all__" should contain\nthe entire public API. It is intended to avoid accidentally exporting\nitems that are not part of the API (such as library modules which were\nimported and used within the module).\n\nThe wild card form of import --- "from module import *" --- is only\nallowed at the module level. Attempting to use it in class or\nfunction definitions will raise a "SyntaxError".\n\nWhen specifying what module to import you do not have to specify the\nabsolute name of the module. When a module or package is contained\nwithin another package it is possible to make a relative import within\nthe same top package without having to mention the package name. By\nusing leading dots in the specified module or package after "from" you\ncan specify how high to traverse up the current package hierarchy\nwithout specifying exact names. One leading dot means the current\npackage where the module making the import exists. Two dots means up\none package level. Three dots is up two levels, etc. So if you execute\n"from . import mod" from a module in the "pkg" package then you will\nend up importing "pkg.mod". If you execute "from ..subpkg2 import mod"\nfrom within "pkg.subpkg1" you will import "pkg.subpkg2.mod". The\nspecification for relative imports is contained within **PEP 328**.\n\n"importlib.import_module()" is provided to support applications that\ndetermine dynamically the modules to be loaded.\n\n\nFuture statements\n=================\n\nA *future statement* is a directive to the compiler that a particular\nmodule should be compiled using syntax or semantics that will be\navailable in a specified future release of Python where the feature\nbecomes standard.\n\nThe future statement is intended to ease migration to future versions\nof Python that introduce incompatible changes to the language. It\nallows use of the new features on a per-module basis before the\nrelease in which the feature becomes standard.\n\n future_statement ::= "from" "__future__" "import" feature ["as" name]\n ("," feature ["as" name])*\n | "from" "__future__" "import" "(" feature ["as" name]\n ("," feature ["as" name])* [","] ")"\n feature ::= identifier\n name ::= identifier\n\nA future statement must appear near the top of the module. The only\nlines that can appear before a future statement are:\n\n* the module docstring (if any),\n\n* comments,\n\n* blank lines, and\n\n* other future statements.\n\nThe features recognized by Python 3.0 are "absolute_import",\n"division", "generators", "unicode_literals", "print_function",\n"nested_scopes" and "with_statement". They are all redundant because\nthey are always enabled, and only kept for backwards compatibility.\n\nA future statement is recognized and treated specially at compile\ntime: Changes to the semantics of core constructs are often\nimplemented by generating different code. It may even be the case\nthat a new feature introduces new incompatible syntax (such as a new\nreserved word), in which case the compiler may need to parse the\nmodule differently. Such decisions cannot be pushed off until\nruntime.\n\nFor any given release, the compiler knows which feature names have\nbeen defined, and raises a compile-time error if a future statement\ncontains a feature not known to it.\n\nThe direct runtime semantics are the same as for any import statement:\nthere is a standard module "__future__", described later, and it will\nbe imported in the usual way at the time the future statement is\nexecuted.\n\nThe interesting runtime semantics depend on the specific feature\nenabled by the future statement.\n\nNote that there is nothing special about the statement:\n\n import __future__ [as name]\n\nThat is not a future statement; it\'s an ordinary import statement with\nno special semantics or syntax restrictions.\n\nCode compiled by calls to the built-in functions "exec()" and\n"compile()" that occur in a module "M" containing a future statement\nwill, by default, use the new syntax or semantics associated with the\nfuture statement. This can be controlled by optional arguments to\n"compile()" --- see the documentation of that function for details.\n\nA future statement typed at an interactive interpreter prompt will\ntake effect for the rest of the interpreter session. If an\ninterpreter is started with the *-i* option, is passed a script name\nto execute, and the script includes a future statement, it will be in\neffect in the interactive session started after the script is\nexecuted.\n\nSee also: **PEP 236** - Back to the __future__\n\n The original proposal for the __future__ mechanism.\n',
- 'in': u'\nMembership test operations\n**************************\n\nThe operators "in" and "not in" test for membership. "x in s"\nevaluates to true if *x* is a member of *s*, and false otherwise. "x\nnot in s" returns the negation of "x in s". All built-in sequences\nand set types support this as well as dictionary, for which "in" tests\nwhether the dictionary has a given key. For container types such as\nlist, tuple, set, frozenset, dict, or collections.deque, the\nexpression "x in y" is equivalent to "any(x is e or x == e for e in\ny)".\n\nFor the string and bytes types, "x in y" is true if and only if *x* is\na substring of *y*. An equivalent test is "y.find(x) != -1". Empty\nstrings are always considered to be a substring of any other string,\nso """ in "abc"" will return "True".\n\nFor user-defined classes which define the "__contains__()" method, "x\nin y" is true if and only if "y.__contains__(x)" is true.\n\nFor user-defined classes which do not define "__contains__()" but do\ndefine "__iter__()", "x in y" is true if some value "z" with "x == z"\nis produced while iterating over "y". If an exception is raised\nduring the iteration, it is as if "in" raised that exception.\n\nLastly, the old-style iteration protocol is tried: if a class defines\n"__getitem__()", "x in y" is true if and only if there is a non-\nnegative integer index *i* such that "x == y[i]", and all lower\ninteger indices do not raise "IndexError" exception. (If any other\nexception is raised, it is as if "in" raised that exception).\n\nThe operator "not in" is defined to have the inverse true value of\n"in".\n',
- 'integers': u'\nInteger literals\n****************\n\nInteger literals are described by the following lexical definitions:\n\n integer ::= decimalinteger | octinteger | hexinteger | bininteger\n decimalinteger ::= nonzerodigit digit* | "0"+\n nonzerodigit ::= "1"..."9"\n digit ::= "0"..."9"\n octinteger ::= "0" ("o" | "O") octdigit+\n hexinteger ::= "0" ("x" | "X") hexdigit+\n bininteger ::= "0" ("b" | "B") bindigit+\n octdigit ::= "0"..."7"\n hexdigit ::= digit | "a"..."f" | "A"..."F"\n bindigit ::= "0" | "1"\n\nThere is no limit for the length of integer literals apart from what\ncan be stored in available memory.\n\nNote that leading zeros in a non-zero decimal number are not allowed.\nThis is for disambiguation with C-style octal literals, which Python\nused before version 3.0.\n\nSome examples of integer literals:\n\n 7 2147483647 0o177 0b100110111\n 3 79228162514264337593543950336 0o377 0xdeadbeef\n',
- 'lambda': u'\nLambdas\n*******\n\n lambda_expr ::= "lambda" [parameter_list]: expression\n lambda_expr_nocond ::= "lambda" [parameter_list]: expression_nocond\n\nLambda expressions (sometimes called lambda forms) are used to create\nanonymous functions. The expression "lambda arguments: expression"\nyields a function object. The unnamed object behaves like a function\nobject defined with\n\n def <lambda>(arguments):\n return expression\n\nSee section *Function definitions* for the syntax of parameter lists.\nNote that functions created with lambda expressions cannot contain\nstatements or annotations.\n',
- 'lists': u'\nList displays\n*************\n\nA list display is a possibly empty series of expressions enclosed in\nsquare brackets:\n\n list_display ::= "[" [starred_list | comprehension] "]"\n\nA list display yields a new list object, the contents being specified\nby either a list of expressions or a comprehension. When a comma-\nseparated list of expressions is supplied, its elements are evaluated\nfrom left to right and placed into the list object in that order.\nWhen a comprehension is supplied, the list is constructed from the\nelements resulting from the comprehension.\n',
- 'naming': u'\nNaming and binding\n******************\n\n\nBinding of names\n================\n\n*Names* refer to objects. Names are introduced by name binding\noperations.\n\nThe following constructs bind names: formal parameters to functions,\n"import" statements, class and function definitions (these bind the\nclass or function name in the defining block), and targets that are\nidentifiers if occurring in an assignment, "for" loop header, or after\n"as" in a "with" statement or "except" clause. The "import" statement\nof the form "from ... import *" binds all names defined in the\nimported module, except those beginning with an underscore. This form\nmay only be used at the module level.\n\nA target occurring in a "del" statement is also considered bound for\nthis purpose (though the actual semantics are to unbind the name).\n\nEach assignment or import statement occurs within a block defined by a\nclass or function definition or at the module level (the top-level\ncode block).\n\nIf a name is bound in a block, it is a local variable of that block,\nunless declared as "nonlocal" or "global". If a name is bound at the\nmodule level, it is a global variable. (The variables of the module\ncode block are local and global.) If a variable is used in a code\nblock but not defined there, it is a *free variable*.\n\nEach occurrence of a name in the program text refers to the *binding*\nof that name established by the following name resolution rules.\n\n\nResolution of names\n===================\n\nA *scope* defines the visibility of a name within a block. If a local\nvariable is defined in a block, its scope includes that block. If the\ndefinition occurs in a function block, the scope extends to any blocks\ncontained within the defining one, unless a contained block introduces\na different binding for the name.\n\nWhen a name is used in a code block, it is resolved using the nearest\nenclosing scope. The set of all such scopes visible to a code block\nis called the block\'s *environment*.\n\nWhen a name is not found at all, a "NameError" exception is raised. If\nthe current scope is a function scope, and the name refers to a local\nvariable that has not yet been bound to a value at the point where the\nname is used, an "UnboundLocalError" exception is raised.\n"UnboundLocalError" is a subclass of "NameError".\n\nIf a name binding operation occurs anywhere within a code block, all\nuses of the name within the block are treated as references to the\ncurrent block. This can lead to errors when a name is used within a\nblock before it is bound. This rule is subtle. Python lacks\ndeclarations and allows name binding operations to occur anywhere\nwithin a code block. The local variables of a code block can be\ndetermined by scanning the entire text of the block for name binding\noperations.\n\nIf the "global" statement occurs within a block, all uses of the name\nspecified in the statement refer to the binding of that name in the\ntop-level namespace. Names are resolved in the top-level namespace by\nsearching the global namespace, i.e. the namespace of the module\ncontaining the code block, and the builtins namespace, the namespace\nof the module "builtins". The global namespace is searched first. If\nthe name is not found there, the builtins namespace is searched. The\n"global" statement must precede all uses of the name.\n\nThe "global" statement has the same scope as a name binding operation\nin the same block. If the nearest enclosing scope for a free variable\ncontains a global statement, the free variable is treated as a global.\n\nThe "nonlocal" statement causes corresponding names to refer to\npreviously bound variables in the nearest enclosing function scope.\n"SyntaxError" is raised at compile time if the given name does not\nexist in any enclosing function scope.\n\nThe namespace for a module is automatically created the first time a\nmodule is imported. The main module for a script is always called\n"__main__".\n\nClass definition blocks and arguments to "exec()" and "eval()" are\nspecial in the context of name resolution. A class definition is an\nexecutable statement that may use and define names. These references\nfollow the normal rules for name resolution with an exception that\nunbound local variables are looked up in the global namespace. The\nnamespace of the class definition becomes the attribute dictionary of\nthe class. The scope of names defined in a class block is limited to\nthe class block; it does not extend to the code blocks of methods --\nthis includes comprehensions and generator expressions since they are\nimplemented using a function scope. This means that the following\nwill fail:\n\n class A:\n a = 42\n b = list(a + i for i in range(10))\n\n\nBuiltins and restricted execution\n=================================\n\nThe builtins namespace associated with the execution of a code block\nis actually found by looking up the name "__builtins__" in its global\nnamespace; this should be a dictionary or a module (in the latter case\nthe module\'s dictionary is used). By default, when in the "__main__"\nmodule, "__builtins__" is the built-in module "builtins"; when in any\nother module, "__builtins__" is an alias for the dictionary of the\n"builtins" module itself. "__builtins__" can be set to a user-created\ndictionary to create a weak form of restricted execution.\n\n**CPython implementation detail:** Users should not touch\n"__builtins__"; it is strictly an implementation detail. Users\nwanting to override values in the builtins namespace should "import"\nthe "builtins" module and modify its attributes appropriately.\n\n\nInteraction with dynamic features\n=================================\n\nName resolution of free variables occurs at runtime, not at compile\ntime. This means that the following code will print 42:\n\n i = 10\n def f():\n print(i)\n i = 42\n f()\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nThe "eval()" and "exec()" functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe "exec()" and "eval()" functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n',
- 'nonlocal': u'\nThe "nonlocal" statement\n************************\n\n nonlocal_stmt ::= "nonlocal" identifier ("," identifier)*\n\nThe "nonlocal" statement causes the listed identifiers to refer to\npreviously bound variables in the nearest enclosing scope excluding\nglobals. This is important because the default behavior for binding is\nto search the local namespace first. The statement allows\nencapsulated code to rebind variables outside of the local scope\nbesides the global (module) scope.\n\nNames listed in a "nonlocal" statement, unlike those listed in a\n"global" statement, must refer to pre-existing bindings in an\nenclosing scope (the scope in which a new binding should be created\ncannot be determined unambiguously).\n\nNames listed in a "nonlocal" statement must not collide with pre-\nexisting bindings in the local scope.\n\nSee also: **PEP 3104** - Access to Names in Outer Scopes\n\n The specification for the "nonlocal" statement.\n',
- 'numbers': u'\nNumeric literals\n****************\n\nThere are three types of numeric literals: integers, floating point\nnumbers, and imaginary numbers. There are no complex literals\n(complex numbers can be formed by adding a real number and an\nimaginary number).\n\nNote that numeric literals do not include a sign; a phrase like "-1"\nis actually an expression composed of the unary operator \'"-"\' and the\nliteral "1".\n',
- 'numeric-types': u'\nEmulating numeric types\n***********************\n\nThe following methods can be defined to emulate numeric objects.\nMethods corresponding to operations that are not supported by the\nparticular kind of number implemented (e.g., bitwise operations for\nnon-integral numbers) should be left undefined.\n\nobject.__add__(self, other)\nobject.__sub__(self, other)\nobject.__mul__(self, other)\nobject.__matmul__(self, other)\nobject.__truediv__(self, other)\nobject.__floordiv__(self, other)\nobject.__mod__(self, other)\nobject.__divmod__(self, other)\nobject.__pow__(self, other[, modulo])\nobject.__lshift__(self, other)\nobject.__rshift__(self, other)\nobject.__and__(self, other)\nobject.__xor__(self, other)\nobject.__or__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations ("+", "-", "*", "@", "/", "//", "%", "divmod()",\n "pow()", "**", "<<", ">>", "&", "^", "|"). For instance, to\n evaluate the expression "x + y", where *x* is an instance of a\n class that has an "__add__()" method, "x.__add__(y)" is called.\n The "__divmod__()" method should be the equivalent to using\n "__floordiv__()" and "__mod__()"; it should not be related to\n "__truediv__()". Note that "__pow__()" should be defined to accept\n an optional third argument if the ternary version of the built-in\n "pow()" function is to be supported.\n\n If one of those methods does not support the operation with the\n supplied arguments, it should return "NotImplemented".\n\nobject.__radd__(self, other)\nobject.__rsub__(self, other)\nobject.__rmul__(self, other)\nobject.__rmatmul__(self, other)\nobject.__rtruediv__(self, other)\nobject.__rfloordiv__(self, other)\nobject.__rmod__(self, other)\nobject.__rdivmod__(self, other)\nobject.__rpow__(self, other)\nobject.__rlshift__(self, other)\nobject.__rrshift__(self, other)\nobject.__rand__(self, other)\nobject.__rxor__(self, other)\nobject.__ror__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations ("+", "-", "*", "@", "/", "//", "%", "divmod()",\n "pow()", "**", "<<", ">>", "&", "^", "|") with reflected (swapped)\n operands. These functions are only called if the left operand does\n not support the corresponding operation and the operands are of\n different types. [2] For instance, to evaluate the expression "x -\n y", where *y* is an instance of a class that has an "__rsub__()"\n method, "y.__rsub__(x)" is called if "x.__sub__(y)" returns\n *NotImplemented*.\n\n Note that ternary "pow()" will not try calling "__rpow__()" (the\n coercion rules would become too complicated).\n\n Note: If the right operand\'s type is a subclass of the left\n operand\'s type and that subclass provides the reflected method\n for the operation, this method will be called before the left\n operand\'s non-reflected method. This behavior allows subclasses\n to override their ancestors\' operations.\n\nobject.__iadd__(self, other)\nobject.__isub__(self, other)\nobject.__imul__(self, other)\nobject.__imatmul__(self, other)\nobject.__itruediv__(self, other)\nobject.__ifloordiv__(self, other)\nobject.__imod__(self, other)\nobject.__ipow__(self, other[, modulo])\nobject.__ilshift__(self, other)\nobject.__irshift__(self, other)\nobject.__iand__(self, other)\nobject.__ixor__(self, other)\nobject.__ior__(self, other)\n\n These methods are called to implement the augmented arithmetic\n assignments ("+=", "-=", "*=", "@=", "/=", "//=", "%=", "**=",\n "<<=", ">>=", "&=", "^=", "|="). These methods should attempt to\n do the operation in-place (modifying *self*) and return the result\n (which could be, but does not have to be, *self*). If a specific\n method is not defined, the augmented assignment falls back to the\n normal methods. For instance, if *x* is an instance of a class\n with an "__iadd__()" method, "x += y" is equivalent to "x =\n x.__iadd__(y)" . Otherwise, "x.__add__(y)" and "y.__radd__(x)" are\n considered, as with the evaluation of "x + y". In certain\n situations, augmented assignment can result in unexpected errors\n (see *Why does a_tuple[i] += [\'item\'] raise an exception when the\n addition works?*), but this behavior is in fact part of the data\n model.\n\nobject.__neg__(self)\nobject.__pos__(self)\nobject.__abs__(self)\nobject.__invert__(self)\n\n Called to implement the unary arithmetic operations ("-", "+",\n "abs()" and "~").\n\nobject.__complex__(self)\nobject.__int__(self)\nobject.__float__(self)\nobject.__round__(self[, n])\n\n Called to implement the built-in functions "complex()", "int()",\n "float()" and "round()". Should return a value of the appropriate\n type.\n\nobject.__index__(self)\n\n Called to implement "operator.index()", and whenever Python needs\n to losslessly convert the numeric object to an integer object (such\n as in slicing, or in the built-in "bin()", "hex()" and "oct()"\n functions). Presence of this method indicates that the numeric\n object is an integer type. Must return an integer.\n\n Note: In order to have a coherent integer type class, when\n "__index__()" is defined "__int__()" should also be defined, and\n both should return the same value.\n',
- 'objects': u'\nObjects, values and types\n*************************\n\n*Objects* are Python\'s abstraction for data. All data in a Python\nprogram is represented by objects or by relations between objects. (In\na sense, and in conformance to Von Neumann\'s model of a "stored\nprogram computer," code is also represented by objects.)\n\nEvery object has an identity, a type and a value. An object\'s\n*identity* never changes once it has been created; you may think of it\nas the object\'s address in memory. The \'"is"\' operator compares the\nidentity of two objects; the "id()" function returns an integer\nrepresenting its identity.\n\n**CPython implementation detail:** For CPython, "id(x)" is the memory\naddress where "x" is stored.\n\nAn object\'s type determines the operations that the object supports\n(e.g., "does it have a length?") and also defines the possible values\nfor objects of that type. The "type()" function returns an object\'s\ntype (which is an object itself). Like its identity, an object\'s\n*type* is also unchangeable. [1]\n\nThe *value* of some objects can change. Objects whose value can\nchange are said to be *mutable*; objects whose value is unchangeable\nonce they are created are called *immutable*. (The value of an\nimmutable container object that contains a reference to a mutable\nobject can change when the latter\'s value is changed; however the\ncontainer is still considered immutable, because the collection of\nobjects it contains cannot be changed. So, immutability is not\nstrictly the same as having an unchangeable value, it is more subtle.)\nAn object\'s mutability is determined by its type; for instance,\nnumbers, strings and tuples are immutable, while dictionaries and\nlists are mutable.\n\nObjects are never explicitly destroyed; however, when they become\nunreachable they may be garbage-collected. An implementation is\nallowed to postpone garbage collection or omit it altogether --- it is\na matter of implementation quality how garbage collection is\nimplemented, as long as no objects are collected that are still\nreachable.\n\n**CPython implementation detail:** CPython currently uses a reference-\ncounting scheme with (optional) delayed detection of cyclically linked\ngarbage, which collects most objects as soon as they become\nunreachable, but is not guaranteed to collect garbage containing\ncircular references. See the documentation of the "gc" module for\ninformation on controlling the collection of cyclic garbage. Other\nimplementations act differently and CPython may change. Do not depend\non immediate finalization of objects when they become unreachable (so\nyou should always close files explicitly).\n\nNote that the use of the implementation\'s tracing or debugging\nfacilities may keep objects alive that would normally be collectable.\nAlso note that catching an exception with a \'"try"..."except"\'\nstatement may keep objects alive.\n\nSome objects contain references to "external" resources such as open\nfiles or windows. It is understood that these resources are freed\nwhen the object is garbage-collected, but since garbage collection is\nnot guaranteed to happen, such objects also provide an explicit way to\nrelease the external resource, usually a "close()" method. Programs\nare strongly recommended to explicitly close such objects. The\n\'"try"..."finally"\' statement and the \'"with"\' statement provide\nconvenient ways to do this.\n\nSome objects contain references to other objects; these are called\n*containers*. Examples of containers are tuples, lists and\ndictionaries. The references are part of a container\'s value. In\nmost cases, when we talk about the value of a container, we imply the\nvalues, not the identities of the contained objects; however, when we\ntalk about the mutability of a container, only the identities of the\nimmediately contained objects are implied. So, if an immutable\ncontainer (like a tuple) contains a reference to a mutable object, its\nvalue changes if that mutable object is changed.\n\nTypes affect almost all aspects of object behavior. Even the\nimportance of object identity is affected in some sense: for immutable\ntypes, operations that compute new values may actually return a\nreference to any existing object with the same type and value, while\nfor mutable objects this is not allowed. E.g., after "a = 1; b = 1",\n"a" and "b" may or may not refer to the same object with the value\none, depending on the implementation, but after "c = []; d = []", "c"\nand "d" are guaranteed to refer to two different, unique, newly\ncreated empty lists. (Note that "c = d = []" assigns the same object\nto both "c" and "d".)\n',
- 'operator-summary': u'\nOperator precedence\n*******************\n\nThe following table summarizes the operator precedence in Python, from\nlowest precedence (least binding) to highest precedence (most\nbinding). Operators in the same box have the same precedence. Unless\nthe syntax is explicitly given, operators are binary. Operators in\nthe same box group left to right (except for exponentiation, which\ngroups from right to left).\n\nNote that comparisons, membership tests, and identity tests, all have\nthe same precedence and have a left-to-right chaining feature as\ndescribed in the *Comparisons* section.\n\n+-------------------------------------------------+---------------------------------------+\n| Operator | Description |\n+=================================================+=======================================+\n| "lambda" | Lambda expression |\n+-------------------------------------------------+---------------------------------------+\n| "if" -- "else" | Conditional expression |\n+-------------------------------------------------+---------------------------------------+\n| "or" | Boolean OR |\n+-------------------------------------------------+---------------------------------------+\n| "and" | Boolean AND |\n+-------------------------------------------------+---------------------------------------+\n| "not" "x" | Boolean NOT |\n+-------------------------------------------------+---------------------------------------+\n| "in", "not in", "is", "is not", "<", "<=", ">", | Comparisons, including membership |\n| ">=", "!=", "==" | tests and identity tests |\n+-------------------------------------------------+---------------------------------------+\n| "|" | Bitwise OR |\n+-------------------------------------------------+---------------------------------------+\n| "^" | Bitwise XOR |\n+-------------------------------------------------+---------------------------------------+\n| "&" | Bitwise AND |\n+-------------------------------------------------+---------------------------------------+\n| "<<", ">>" | Shifts |\n+-------------------------------------------------+---------------------------------------+\n| "+", "-" | Addition and subtraction |\n+-------------------------------------------------+---------------------------------------+\n| "*", "@", "/", "//", "%" | Multiplication, matrix multiplication |\n| | division, remainder [5] |\n+-------------------------------------------------+---------------------------------------+\n| "+x", "-x", "~x" | Positive, negative, bitwise NOT |\n+-------------------------------------------------+---------------------------------------+\n| "**" | Exponentiation [6] |\n+-------------------------------------------------+---------------------------------------+\n| "await" "x" | Await expression |\n+-------------------------------------------------+---------------------------------------+\n| "x[index]", "x[index:index]", | Subscription, slicing, call, |\n| "x(arguments...)", "x.attribute" | attribute reference |\n+-------------------------------------------------+---------------------------------------+\n| "(expressions...)", "[expressions...]", "{key: | Binding or tuple display, list |\n| value...}", "{expressions...}" | display, dictionary display, set |\n| | display |\n+-------------------------------------------------+---------------------------------------+\n\n-[ Footnotes ]-\n\n[1] While "abs(x%y) < abs(y)" is true mathematically, for floats\n it may not be true numerically due to roundoff. For example, and\n assuming a platform on which a Python float is an IEEE 754 double-\n precision number, in order that "-1e-100 % 1e100" have the same\n sign as "1e100", the computed result is "-1e-100 + 1e100", which\n is numerically exactly equal to "1e100". The function\n "math.fmod()" returns a result whose sign matches the sign of the\n first argument instead, and so returns "-1e-100" in this case.\n Which approach is more appropriate depends on the application.\n\n[2] If x is very close to an exact integer multiple of y, it\'s\n possible for "x//y" to be one larger than "(x-x%y)//y" due to\n rounding. In such cases, Python returns the latter result, in\n order to preserve that "divmod(x,y)[0] * y + x % y" be very close\n to "x".\n\n[3] The Unicode standard distinguishes between *code points* (e.g.\n U+0041) and *abstract characters* (e.g. "LATIN CAPITAL LETTER A").\n While most abstract characters in Unicode are only represented\n using one code point, there is a number of abstract characters\n that can in addition be represented using a sequence of more than\n one code point. For example, the abstract character "LATIN\n CAPITAL LETTER C WITH CEDILLA" can be represented as a single\n *precomposed character* at code position U+00C7, or as a sequence\n of a *base character* at code position U+0043 (LATIN CAPITAL\n LETTER C), followed by a *combining character* at code position\n U+0327 (COMBINING CEDILLA).\n\n The comparison operators on strings compare at the level of\n Unicode code points. This may be counter-intuitive to humans. For\n example, ""\\u00C7" == "\\u0043\\u0327"" is "False", even though both\n strings represent the same abstract character "LATIN CAPITAL\n LETTER C WITH CEDILLA".\n\n To compare strings at the level of abstract characters (that is,\n in a way intuitive to humans), use "unicodedata.normalize()".\n\n[4] Due to automatic garbage-collection, free lists, and the\n dynamic nature of descriptors, you may notice seemingly unusual\n behaviour in certain uses of the "is" operator, like those\n involving comparisons between instance methods, or constants.\n Check their documentation for more info.\n\n[5] The "%" operator is also used for string formatting; the same\n precedence applies.\n\n[6] The power operator "**" binds less tightly than an arithmetic\n or bitwise unary operator on its right, that is, "2**-1" is "0.5".\n',
- 'pass': u'\nThe "pass" statement\n********************\n\n pass_stmt ::= "pass"\n\n"pass" is a null operation --- when it is executed, nothing happens.\nIt is useful as a placeholder when a statement is required\nsyntactically, but no code needs to be executed, for example:\n\n def f(arg): pass # a function that does nothing (yet)\n\n class C: pass # a class with no methods (yet)\n',
- 'power': u'\nThe power operator\n******************\n\nThe power operator binds more tightly than unary operators on its\nleft; it binds less tightly than unary operators on its right. The\nsyntax is:\n\n power ::= ( await_expr | primary ) ["**" u_expr]\n\nThus, in an unparenthesized sequence of power and unary operators, the\noperators are evaluated from right to left (this does not constrain\nthe evaluation order for the operands): "-1**2" results in "-1".\n\nThe power operator has the same semantics as the built-in "pow()"\nfunction, when called with two arguments: it yields its left argument\nraised to the power of its right argument. The numeric arguments are\nfirst converted to a common type, and the result is of that type.\n\nFor int operands, the result has the same type as the operands unless\nthe second argument is negative; in that case, all arguments are\nconverted to float and a float result is delivered. For example,\n"10**2" returns "100", but "10**-2" returns "0.01".\n\nRaising "0.0" to a negative power results in a "ZeroDivisionError".\nRaising a negative number to a fractional power results in a "complex"\nnumber. (In earlier versions it raised a "ValueError".)\n',
- 'raise': u'\nThe "raise" statement\n*********************\n\n raise_stmt ::= "raise" [expression ["from" expression]]\n\nIf no expressions are present, "raise" re-raises the last exception\nthat was active in the current scope. If no exception is active in\nthe current scope, a "RuntimeError" exception is raised indicating\nthat this is an error.\n\nOtherwise, "raise" evaluates the first expression as the exception\nobject. It must be either a subclass or an instance of\n"BaseException". If it is a class, the exception instance will be\nobtained when needed by instantiating the class with no arguments.\n\nThe *type* of the exception is the exception instance\'s class, the\n*value* is the instance itself.\n\nA traceback object is normally created automatically when an exception\nis raised and attached to it as the "__traceback__" attribute, which\nis writable. You can create an exception and set your own traceback in\none step using the "with_traceback()" exception method (which returns\nthe same exception instance, with its traceback set to its argument),\nlike so:\n\n raise Exception("foo occurred").with_traceback(tracebackobj)\n\nThe "from" clause is used for exception chaining: if given, the second\n*expression* must be another exception class or instance, which will\nthen be attached to the raised exception as the "__cause__" attribute\n(which is writable). If the raised exception is not handled, both\nexceptions will be printed:\n\n >>> try:\n ... print(1 / 0)\n ... except Exception as exc:\n ... raise RuntimeError("Something bad happened") from exc\n ...\n Traceback (most recent call last):\n File "<stdin>", line 2, in <module>\n ZeroDivisionError: int division or modulo by zero\n\n The above exception was the direct cause of the following exception:\n\n Traceback (most recent call last):\n File "<stdin>", line 4, in <module>\n RuntimeError: Something bad happened\n\nA similar mechanism works implicitly if an exception is raised inside\nan exception handler or a "finally" clause: the previous exception is\nthen attached as the new exception\'s "__context__" attribute:\n\n >>> try:\n ... print(1 / 0)\n ... except:\n ... raise RuntimeError("Something bad happened")\n ...\n Traceback (most recent call last):\n File "<stdin>", line 2, in <module>\n ZeroDivisionError: int division or modulo by zero\n\n During handling of the above exception, another exception occurred:\n\n Traceback (most recent call last):\n File "<stdin>", line 4, in <module>\n RuntimeError: Something bad happened\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information about handling exceptions is in section\n*The try statement*.\n',
- 'return': u'\nThe "return" statement\n**********************\n\n return_stmt ::= "return" [expression_list]\n\n"return" may only occur syntactically nested in a function definition,\nnot within a nested class definition.\n\nIf an expression list is present, it is evaluated, else "None" is\nsubstituted.\n\n"return" leaves the current function call with the expression list (or\n"None") as return value.\n\nWhen "return" passes control out of a "try" statement with a "finally"\nclause, that "finally" clause is executed before really leaving the\nfunction.\n\nIn a generator function, the "return" statement indicates that the\ngenerator is done and will cause "StopIteration" to be raised. The\nreturned value (if any) is used as an argument to construct\n"StopIteration" and becomes the "StopIteration.value" attribute.\n',
- 'sequence-types': u'\nEmulating container types\n*************************\n\nThe following methods can be defined to implement container objects.\nContainers usually are sequences (such as lists or tuples) or mappings\n(like dictionaries), but can represent other containers as well. The\nfirst set of methods is used either to emulate a sequence or to\nemulate a mapping; the difference is that for a sequence, the\nallowable keys should be the integers *k* for which "0 <= k < N" where\n*N* is the length of the sequence, or slice objects, which define a\nrange of items. It is also recommended that mappings provide the\nmethods "keys()", "values()", "items()", "get()", "clear()",\n"setdefault()", "pop()", "popitem()", "copy()", and "update()"\nbehaving similar to those for Python\'s standard dictionary objects.\nThe "collections" module provides a "MutableMapping" abstract base\nclass to help create those methods from a base set of "__getitem__()",\n"__setitem__()", "__delitem__()", and "keys()". Mutable sequences\nshould provide methods "append()", "count()", "index()", "extend()",\n"insert()", "pop()", "remove()", "reverse()" and "sort()", like Python\nstandard list objects. Finally, sequence types should implement\naddition (meaning concatenation) and multiplication (meaning\nrepetition) by defining the methods "__add__()", "__radd__()",\n"__iadd__()", "__mul__()", "__rmul__()" and "__imul__()" described\nbelow; they should not define other numerical operators. It is\nrecommended that both mappings and sequences implement the\n"__contains__()" method to allow efficient use of the "in" operator;\nfor mappings, "in" should search the mapping\'s keys; for sequences, it\nshould search through the values. It is further recommended that both\nmappings and sequences implement the "__iter__()" method to allow\nefficient iteration through the container; for mappings, "__iter__()"\nshould be the same as "keys()"; for sequences, it should iterate\nthrough the values.\n\nobject.__len__(self)\n\n Called to implement the built-in function "len()". Should return\n the length of the object, an integer ">=" 0. Also, an object that\n doesn\'t define a "__bool__()" method and whose "__len__()" method\n returns zero is considered to be false in a Boolean context.\n\nobject.__length_hint__(self)\n\n Called to implement "operator.length_hint()". Should return an\n estimated length for the object (which may be greater or less than\n the actual length). The length must be an integer ">=" 0. This\n method is purely an optimization and is never required for\n correctness.\n\n New in version 3.4.\n\nNote: Slicing is done exclusively with the following three methods.\n A call like\n\n a[1:2] = b\n\n is translated to\n\n a[slice(1, 2, None)] = b\n\n and so forth. Missing slice items are always filled in with "None".\n\nobject.__getitem__(self, key)\n\n Called to implement evaluation of "self[key]". For sequence types,\n the accepted keys should be integers and slice objects. Note that\n the special interpretation of negative indexes (if the class wishes\n to emulate a sequence type) is up to the "__getitem__()" method. If\n *key* is of an inappropriate type, "TypeError" may be raised; if of\n a value outside the set of indexes for the sequence (after any\n special interpretation of negative values), "IndexError" should be\n raised. For mapping types, if *key* is missing (not in the\n container), "KeyError" should be raised.\n\n Note: "for" loops expect that an "IndexError" will be raised for\n illegal indexes to allow proper detection of the end of the\n sequence.\n\nobject.__missing__(self, key)\n\n Called by "dict"."__getitem__()" to implement "self[key]" for dict\n subclasses when key is not in the dictionary.\n\nobject.__setitem__(self, key, value)\n\n Called to implement assignment to "self[key]". Same note as for\n "__getitem__()". This should only be implemented for mappings if\n the objects support changes to the values for keys, or if new keys\n can be added, or for sequences if elements can be replaced. The\n same exceptions should be raised for improper *key* values as for\n the "__getitem__()" method.\n\nobject.__delitem__(self, key)\n\n Called to implement deletion of "self[key]". Same note as for\n "__getitem__()". This should only be implemented for mappings if\n the objects support removal of keys, or for sequences if elements\n can be removed from the sequence. The same exceptions should be\n raised for improper *key* values as for the "__getitem__()" method.\n\nobject.__iter__(self)\n\n This method is called when an iterator is required for a container.\n This method should return a new iterator object that can iterate\n over all the objects in the container. For mappings, it should\n iterate over the keys of the container.\n\n Iterator objects also need to implement this method; they are\n required to return themselves. For more information on iterator\n objects, see *Iterator Types*.\n\nobject.__reversed__(self)\n\n Called (if present) by the "reversed()" built-in to implement\n reverse iteration. It should return a new iterator object that\n iterates over all the objects in the container in reverse order.\n\n If the "__reversed__()" method is not provided, the "reversed()"\n built-in will fall back to using the sequence protocol ("__len__()"\n and "__getitem__()"). Objects that support the sequence protocol\n should only provide "__reversed__()" if they can provide an\n implementation that is more efficient than the one provided by\n "reversed()".\n\nThe membership test operators ("in" and "not in") are normally\nimplemented as an iteration through a sequence. However, container\nobjects can supply the following special method with a more efficient\nimplementation, which also does not require the object be a sequence.\n\nobject.__contains__(self, item)\n\n Called to implement membership test operators. Should return true\n if *item* is in *self*, false otherwise. For mapping objects, this\n should consider the keys of the mapping rather than the values or\n the key-item pairs.\n\n For objects that don\'t define "__contains__()", the membership test\n first tries iteration via "__iter__()", then the old sequence\n iteration protocol via "__getitem__()", see *this section in the\n language reference*.\n',
- 'shifting': u'\nShifting operations\n*******************\n\nThe shifting operations have lower priority than the arithmetic\noperations:\n\n shift_expr ::= a_expr | shift_expr ( "<<" | ">>" ) a_expr\n\nThese operators accept integers as arguments. They shift the first\nargument to the left or right by the number of bits given by the\nsecond argument.\n\nA right shift by *n* bits is defined as floor division by "pow(2,n)".\nA left shift by *n* bits is defined as multiplication with "pow(2,n)".\n\nNote: In the current implementation, the right-hand operand is\n required to be at most "sys.maxsize". If the right-hand operand is\n larger than "sys.maxsize" an "OverflowError" exception is raised.\n',
- 'slicings': u'\nSlicings\n********\n\nA slicing selects a range of items in a sequence object (e.g., a\nstring, tuple or list). Slicings may be used as expressions or as\ntargets in assignment or "del" statements. The syntax for a slicing:\n\n slicing ::= primary "[" slice_list "]"\n slice_list ::= slice_item ("," slice_item)* [","]\n slice_item ::= expression | proper_slice\n proper_slice ::= [lower_bound] ":" [upper_bound] [ ":" [stride] ]\n lower_bound ::= expression\n upper_bound ::= expression\n stride ::= expression\n\nThere is ambiguity in the formal syntax here: anything that looks like\nan expression list also looks like a slice list, so any subscription\ncan be interpreted as a slicing. Rather than further complicating the\nsyntax, this is disambiguated by defining that in this case the\ninterpretation as a subscription takes priority over the\ninterpretation as a slicing (this is the case if the slice list\ncontains no proper slice).\n\nThe semantics for a slicing are as follows. The primary is indexed\n(using the same "__getitem__()" method as normal subscription) with a\nkey that is constructed from the slice list, as follows. If the slice\nlist contains at least one comma, the key is a tuple containing the\nconversion of the slice items; otherwise, the conversion of the lone\nslice item is the key. The conversion of a slice item that is an\nexpression is that expression. The conversion of a proper slice is a\nslice object (see section *The standard type hierarchy*) whose\n"start", "stop" and "step" attributes are the values of the\nexpressions given as lower bound, upper bound and stride,\nrespectively, substituting "None" for missing expressions.\n',
- 'specialattrs': u'\nSpecial Attributes\n******************\n\nThe implementation adds a few special read-only attributes to several\nobject types, where they are relevant. Some of these are not reported\nby the "dir()" built-in function.\n\nobject.__dict__\n\n A dictionary or other mapping object used to store an object\'s\n (writable) attributes.\n\ninstance.__class__\n\n The class to which a class instance belongs.\n\nclass.__bases__\n\n The tuple of base classes of a class object.\n\nclass.__name__\n\n The name of the class or type.\n\nclass.__qualname__\n\n The *qualified name* of the class or type.\n\n New in version 3.3.\n\nclass.__mro__\n\n This attribute is a tuple of classes that are considered when\n looking for base classes during method resolution.\n\nclass.mro()\n\n This method can be overridden by a metaclass to customize the\n method resolution order for its instances. It is called at class\n instantiation, and its result is stored in "__mro__".\n\nclass.__subclasses__()\n\n Each class keeps a list of weak references to its immediate\n subclasses. This method returns a list of all those references\n still alive. Example:\n\n >>> int.__subclasses__()\n [<class \'bool\'>]\n\n-[ Footnotes ]-\n\n[1] Additional information on these special methods may be found\n in the Python Reference Manual (*Basic customization*).\n\n[2] As a consequence, the list "[1, 2]" is considered equal to\n "[1.0, 2.0]", and similarly for tuples.\n\n[3] They must have since the parser can\'t tell the type of the\n operands.\n\n[4] Cased characters are those with general category property\n being one of "Lu" (Letter, uppercase), "Ll" (Letter, lowercase),\n or "Lt" (Letter, titlecase).\n\n[5] To format only a tuple you should therefore provide a\n singleton tuple whose only element is the tuple to be formatted.\n',
- 'specialnames': u'\nSpecial method names\n********************\n\nA class can implement certain operations that are invoked by special\nsyntax (such as arithmetic operations or subscripting and slicing) by\ndefining methods with special names. This is Python\'s approach to\n*operator overloading*, allowing classes to define their own behavior\nwith respect to language operators. For instance, if a class defines\na method named "__getitem__()", and "x" is an instance of this class,\nthen "x[i]" is roughly equivalent to "type(x).__getitem__(x, i)".\nExcept where mentioned, attempts to execute an operation raise an\nexception when no appropriate method is defined (typically\n"AttributeError" or "TypeError").\n\nWhen implementing a class that emulates any built-in type, it is\nimportant that the emulation only be implemented to the degree that it\nmakes sense for the object being modelled. For example, some\nsequences may work well with retrieval of individual elements, but\nextracting a slice may not make sense. (One example of this is the\n"NodeList" interface in the W3C\'s Document Object Model.)\n\n\nBasic customization\n===================\n\nobject.__new__(cls[, ...])\n\n Called to create a new instance of class *cls*. "__new__()" is a\n static method (special-cased so you need not declare it as such)\n that takes the class of which an instance was requested as its\n first argument. The remaining arguments are those passed to the\n object constructor expression (the call to the class). The return\n value of "__new__()" should be the new object instance (usually an\n instance of *cls*).\n\n Typical implementations create a new instance of the class by\n invoking the superclass\'s "__new__()" method using\n "super(currentclass, cls).__new__(cls[, ...])" with appropriate\n arguments and then modifying the newly-created instance as\n necessary before returning it.\n\n If "__new__()" returns an instance of *cls*, then the new\n instance\'s "__init__()" method will be invoked like\n "__init__(self[, ...])", where *self* is the new instance and the\n remaining arguments are the same as were passed to "__new__()".\n\n If "__new__()" does not return an instance of *cls*, then the new\n instance\'s "__init__()" method will not be invoked.\n\n "__new__()" is intended mainly to allow subclasses of immutable\n types (like int, str, or tuple) to customize instance creation. It\n is also commonly overridden in custom metaclasses in order to\n customize class creation.\n\nobject.__init__(self[, ...])\n\n Called after the instance has been created (by "__new__()"), but\n before it is returned to the caller. The arguments are those\n passed to the class constructor expression. If a base class has an\n "__init__()" method, the derived class\'s "__init__()" method, if\n any, must explicitly call it to ensure proper initialization of the\n base class part of the instance; for example:\n "BaseClass.__init__(self, [args...])".\n\n Because "__new__()" and "__init__()" work together in constructing\n objects ("__new__()" to create it, and "__init__()" to customise\n it), no non-"None" value may be returned by "__init__()"; doing so\n will cause a "TypeError" to be raised at runtime.\n\nobject.__del__(self)\n\n Called when the instance is about to be destroyed. This is also\n called a destructor. If a base class has a "__del__()" method, the\n derived class\'s "__del__()" method, if any, must explicitly call it\n to ensure proper deletion of the base class part of the instance.\n Note that it is possible (though not recommended!) for the\n "__del__()" method to postpone destruction of the instance by\n creating a new reference to it. It may then be called at a later\n time when this new reference is deleted. It is not guaranteed that\n "__del__()" methods are called for objects that still exist when\n the interpreter exits.\n\n Note: "del x" doesn\'t directly call "x.__del__()" --- the former\n decrements the reference count for "x" by one, and the latter is\n only called when "x"\'s reference count reaches zero. Some common\n situations that may prevent the reference count of an object from\n going to zero include: circular references between objects (e.g.,\n a doubly-linked list or a tree data structure with parent and\n child pointers); a reference to the object on the stack frame of\n a function that caught an exception (the traceback stored in\n "sys.exc_info()[2]" keeps the stack frame alive); or a reference\n to the object on the stack frame that raised an unhandled\n exception in interactive mode (the traceback stored in\n "sys.last_traceback" keeps the stack frame alive). The first\n situation can only be remedied by explicitly breaking the cycles;\n the second can be resolved by freeing the reference to the\n traceback object when it is no longer useful, and the third can\n be resolved by storing "None" in "sys.last_traceback". Circular\n references which are garbage are detected and cleaned up when the\n cyclic garbage collector is enabled (it\'s on by default). Refer\n to the documentation for the "gc" module for more information\n about this topic.\n\n Warning: Due to the precarious circumstances under which\n "__del__()" methods are invoked, exceptions that occur during\n their execution are ignored, and a warning is printed to\n "sys.stderr" instead. Also, when "__del__()" is invoked in\n response to a module being deleted (e.g., when execution of the\n program is done), other globals referenced by the "__del__()"\n method may already have been deleted or in the process of being\n torn down (e.g. the import machinery shutting down). For this\n reason, "__del__()" methods should do the absolute minimum needed\n to maintain external invariants. Starting with version 1.5,\n Python guarantees that globals whose name begins with a single\n underscore are deleted from their module before other globals are\n deleted; if no other references to such globals exist, this may\n help in assuring that imported modules are still available at the\n time when the "__del__()" method is called.\n\nobject.__repr__(self)\n\n Called by the "repr()" built-in function to compute the "official"\n string representation of an object. If at all possible, this\n should look like a valid Python expression that could be used to\n recreate an object with the same value (given an appropriate\n environment). If this is not possible, a string of the form\n "<...some useful description...>" should be returned. The return\n value must be a string object. If a class defines "__repr__()" but\n not "__str__()", then "__repr__()" is also used when an "informal"\n string representation of instances of that class is required.\n\n This is typically used for debugging, so it is important that the\n representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n Called by "str(object)" and the built-in functions "format()" and\n "print()" to compute the "informal" or nicely printable string\n representation of an object. The return value must be a *string*\n object.\n\n This method differs from "object.__repr__()" in that there is no\n expectation that "__str__()" return a valid Python expression: a\n more convenient or concise representation can be used.\n\n The default implementation defined by the built-in type "object"\n calls "object.__repr__()".\n\nobject.__bytes__(self)\n\n Called by "bytes()" to compute a byte-string representation of an\n object. This should return a "bytes" object.\n\nobject.__format__(self, format_spec)\n\n Called by the "format()" built-in function (and by extension, the\n "str.format()" method of class "str") to produce a "formatted"\n string representation of an object. The "format_spec" argument is a\n string that contains a description of the formatting options\n desired. The interpretation of the "format_spec" argument is up to\n the type implementing "__format__()", however most classes will\n either delegate formatting to one of the built-in types, or use a\n similar formatting option syntax.\n\n See *Format Specification Mini-Language* for a description of the\n standard formatting syntax.\n\n The return value must be a string object.\n\n Changed in version 3.4: The __format__ method of "object" itself\n raises a "TypeError" if passed any non-empty string.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n These are the so-called "rich comparison" methods. The\n correspondence between operator symbols and method names is as\n follows: "x<y" calls "x.__lt__(y)", "x<=y" calls "x.__le__(y)",\n "x==y" calls "x.__eq__(y)", "x!=y" calls "x.__ne__(y)", "x>y" calls\n "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".\n\n A rich comparison method may return the singleton "NotImplemented"\n if it does not implement the operation for a given pair of\n arguments. By convention, "False" and "True" are returned for a\n successful comparison. However, these methods can return any value,\n so if the comparison operator is used in a Boolean context (e.g.,\n in the condition of an "if" statement), Python will call "bool()"\n on the value to determine if the result is true or false.\n\n By default, "__ne__()" delegates to "__eq__()" and inverts the\n result unless it is "NotImplemented". There are no other implied\n relationships among the comparison operators, for example, the\n truth of "(x<y or x==y)" does not imply "x<=y". To automatically\n generate ordering operations from a single root operation, see\n "functools.total_ordering()".\n\n See the paragraph on "__hash__()" for some important notes on\n creating *hashable* objects which support custom comparison\n operations and are usable as dictionary keys.\n\n There are no swapped-argument versions of these methods (to be used\n when the left argument does not support the operation but the right\n argument does); rather, "__lt__()" and "__gt__()" are each other\'s\n reflection, "__le__()" and "__ge__()" are each other\'s reflection,\n and "__eq__()" and "__ne__()" are their own reflection. If the\n operands are of different types, and right operand\'s type is a\n direct or indirect subclass of the left operand\'s type, the\n reflected method of the right operand has priority, otherwise the\n left operand\'s method has priority. Virtual subclassing is not\n considered.\n\nobject.__hash__(self)\n\n Called by built-in function "hash()" and for operations on members\n of hashed collections including "set", "frozenset", and "dict".\n "__hash__()" should return an integer. The only required property\n is that objects which compare equal have the same hash value; it is\n advised to somehow mix together (e.g. using exclusive or) the hash\n values for the components of the object that also play a part in\n comparison of objects.\n\n Note: "hash()" truncates the value returned from an object\'s\n custom "__hash__()" method to the size of a "Py_ssize_t". This\n is typically 8 bytes on 64-bit builds and 4 bytes on 32-bit\n builds. If an object\'s "__hash__()" must interoperate on builds\n of different bit sizes, be sure to check the width on all\n supported builds. An easy way to do this is with "python -c\n "import sys; print(sys.hash_info.width)"".\n\n If a class does not define an "__eq__()" method it should not\n define a "__hash__()" operation either; if it defines "__eq__()"\n but not "__hash__()", its instances will not be usable as items in\n hashable collections. If a class defines mutable objects and\n implements an "__eq__()" method, it should not implement\n "__hash__()", since the implementation of hashable collections\n requires that a key\'s hash value is immutable (if the object\'s hash\n value changes, it will be in the wrong hash bucket).\n\n User-defined classes have "__eq__()" and "__hash__()" methods by\n default; with them, all objects compare unequal (except with\n themselves) and "x.__hash__()" returns an appropriate value such\n that "x == y" implies both that "x is y" and "hash(x) == hash(y)".\n\n A class that overrides "__eq__()" and does not define "__hash__()"\n will have its "__hash__()" implicitly set to "None". When the\n "__hash__()" method of a class is "None", instances of the class\n will raise an appropriate "TypeError" when a program attempts to\n retrieve their hash value, and will also be correctly identified as\n unhashable when checking "isinstance(obj, collections.Hashable)".\n\n If a class that overrides "__eq__()" needs to retain the\n implementation of "__hash__()" from a parent class, the interpreter\n must be told this explicitly by setting "__hash__ =\n <ParentClass>.__hash__".\n\n If a class that does not override "__eq__()" wishes to suppress\n hash support, it should include "__hash__ = None" in the class\n definition. A class which defines its own "__hash__()" that\n explicitly raises a "TypeError" would be incorrectly identified as\n hashable by an "isinstance(obj, collections.Hashable)" call.\n\n Note: By default, the "__hash__()" values of str, bytes and\n datetime objects are "salted" with an unpredictable random value.\n Although they remain constant within an individual Python\n process, they are not predictable between repeated invocations of\n Python.This is intended to provide protection against a denial-\n of-service caused by carefully-chosen inputs that exploit the\n worst case performance of a dict insertion, O(n^2) complexity.\n See http://www.ocert.org/advisories/ocert-2011-003.html for\n details.Changing hash values affects the iteration order of\n dicts, sets and other mappings. Python has never made guarantees\n about this ordering (and it typically varies between 32-bit and\n 64-bit builds).See also "PYTHONHASHSEED".\n\n Changed in version 3.3: Hash randomization is enabled by default.\n\nobject.__bool__(self)\n\n Called to implement truth value testing and the built-in operation\n "bool()"; should return "False" or "True". When this method is not\n defined, "__len__()" is called, if it is defined, and the object is\n considered true if its result is nonzero. If a class defines\n neither "__len__()" nor "__bool__()", all its instances are\n considered true.\n\n\nCustomizing attribute access\n============================\n\nThe following methods can be defined to customize the meaning of\nattribute access (use of, assignment to, or deletion of "x.name") for\nclass instances.\n\nobject.__getattr__(self, name)\n\n Called when an attribute lookup has not found the attribute in the\n usual places (i.e. it is not an instance attribute nor is it found\n in the class tree for "self"). "name" is the attribute name. This\n method should return the (computed) attribute value or raise an\n "AttributeError" exception.\n\n Note that if the attribute is found through the normal mechanism,\n "__getattr__()" is not called. (This is an intentional asymmetry\n between "__getattr__()" and "__setattr__()".) This is done both for\n efficiency reasons and because otherwise "__getattr__()" would have\n no way to access other attributes of the instance. Note that at\n least for instance variables, you can fake total control by not\n inserting any values in the instance attribute dictionary (but\n instead inserting them in another object). See the\n "__getattribute__()" method below for a way to actually get total\n control over attribute access.\n\nobject.__getattribute__(self, name)\n\n Called unconditionally to implement attribute accesses for\n instances of the class. If the class also defines "__getattr__()",\n the latter will not be called unless "__getattribute__()" either\n calls it explicitly or raises an "AttributeError". This method\n should return the (computed) attribute value or raise an\n "AttributeError" exception. In order to avoid infinite recursion in\n this method, its implementation should always call the base class\n method with the same name to access any attributes it needs, for\n example, "object.__getattribute__(self, name)".\n\n Note: This method may still be bypassed when looking up special\n methods as the result of implicit invocation via language syntax\n or built-in functions. See *Special method lookup*.\n\nobject.__setattr__(self, name, value)\n\n Called when an attribute assignment is attempted. This is called\n instead of the normal mechanism (i.e. store the value in the\n instance dictionary). *name* is the attribute name, *value* is the\n value to be assigned to it.\n\n If "__setattr__()" wants to assign to an instance attribute, it\n should call the base class method with the same name, for example,\n "object.__setattr__(self, name, value)".\n\nobject.__delattr__(self, name)\n\n Like "__setattr__()" but for attribute deletion instead of\n assignment. This should only be implemented if "del obj.name" is\n meaningful for the object.\n\nobject.__dir__(self)\n\n Called when "dir()" is called on the object. A sequence must be\n returned. "dir()" converts the returned sequence to a list and\n sorts it.\n\n\nImplementing Descriptors\n------------------------\n\nThe following methods only apply when an instance of the class\ncontaining the method (a so-called *descriptor* class) appears in an\n*owner* class (the descriptor must be in either the owner\'s class\ndictionary or in the class dictionary for one of its parents). In the\nexamples below, "the attribute" refers to the attribute whose name is\nthe key of the property in the owner class\' "__dict__".\n\nobject.__get__(self, instance, owner)\n\n Called to get the attribute of the owner class (class attribute\n access) or of an instance of that class (instance attribute\n access). *owner* is always the owner class, while *instance* is the\n instance that the attribute was accessed through, or "None" when\n the attribute is accessed through the *owner*. This method should\n return the (computed) attribute value or raise an "AttributeError"\n exception.\n\nobject.__set__(self, instance, value)\n\n Called to set the attribute on an instance *instance* of the owner\n class to a new value, *value*.\n\nobject.__delete__(self, instance)\n\n Called to delete the attribute on an instance *instance* of the\n owner class.\n\nThe attribute "__objclass__" is interpreted by the "inspect" module as\nspecifying the class where this object was defined (setting this\nappropriately can assist in runtime introspection of dynamic class\nattributes). For callables, it may indicate that an instance of the\ngiven type (or a subclass) is expected or required as the first\npositional argument (for example, CPython sets this attribute for\nunbound methods that are implemented in C).\n\n\nInvoking Descriptors\n--------------------\n\nIn general, a descriptor is an object attribute with "binding\nbehavior", one whose attribute access has been overridden by methods\nin the descriptor protocol: "__get__()", "__set__()", and\n"__delete__()". If any of those methods are defined for an object, it\nis said to be a descriptor.\n\nThe default behavior for attribute access is to get, set, or delete\nthe attribute from an object\'s dictionary. For instance, "a.x" has a\nlookup chain starting with "a.__dict__[\'x\']", then\n"type(a).__dict__[\'x\']", and continuing through the base classes of\n"type(a)" excluding metaclasses.\n\nHowever, if the looked-up value is an object defining one of the\ndescriptor methods, then Python may override the default behavior and\ninvoke the descriptor method instead. Where this occurs in the\nprecedence chain depends on which descriptor methods were defined and\nhow they were called.\n\nThe starting point for descriptor invocation is a binding, "a.x". How\nthe arguments are assembled depends on "a":\n\nDirect Call\n The simplest and least common call is when user code directly\n invokes a descriptor method: "x.__get__(a)".\n\nInstance Binding\n If binding to an object instance, "a.x" is transformed into the\n call: "type(a).__dict__[\'x\'].__get__(a, type(a))".\n\nClass Binding\n If binding to a class, "A.x" is transformed into the call:\n "A.__dict__[\'x\'].__get__(None, A)".\n\nSuper Binding\n If "a" is an instance of "super", then the binding "super(B,\n obj).m()" searches "obj.__class__.__mro__" for the base class "A"\n immediately preceding "B" and then invokes the descriptor with the\n call: "A.__dict__[\'m\'].__get__(obj, obj.__class__)".\n\nFor instance bindings, the precedence of descriptor invocation depends\non the which descriptor methods are defined. A descriptor can define\nany combination of "__get__()", "__set__()" and "__delete__()". If it\ndoes not define "__get__()", then accessing the attribute will return\nthe descriptor object itself unless there is a value in the object\'s\ninstance dictionary. If the descriptor defines "__set__()" and/or\n"__delete__()", it is a data descriptor; if it defines neither, it is\na non-data descriptor. Normally, data descriptors define both\n"__get__()" and "__set__()", while non-data descriptors have just the\n"__get__()" method. Data descriptors with "__set__()" and "__get__()"\ndefined always override a redefinition in an instance dictionary. In\ncontrast, non-data descriptors can be overridden by instances.\n\nPython methods (including "staticmethod()" and "classmethod()") are\nimplemented as non-data descriptors. Accordingly, instances can\nredefine and override methods. This allows individual instances to\nacquire behaviors that differ from other instances of the same class.\n\nThe "property()" function is implemented as a data descriptor.\nAccordingly, instances cannot override the behavior of a property.\n\n\n__slots__\n---------\n\nBy default, instances of classes have a dictionary for attribute\nstorage. This wastes space for objects having very few instance\nvariables. The space consumption can become acute when creating large\nnumbers of instances.\n\nThe default can be overridden by defining *__slots__* in a class\ndefinition. The *__slots__* declaration takes a sequence of instance\nvariables and reserves just enough space in each instance to hold a\nvalue for each variable. Space is saved because *__dict__* is not\ncreated for each instance.\n\nobject.__slots__\n\n This class variable can be assigned a string, iterable, or sequence\n of strings with variable names used by instances. *__slots__*\n reserves space for the declared variables and prevents the\n automatic creation of *__dict__* and *__weakref__* for each\n instance.\n\n\nNotes on using *__slots__*\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n* When inheriting from a class without *__slots__*, the *__dict__*\n attribute of that class will always be accessible, so a *__slots__*\n definition in the subclass is meaningless.\n\n* Without a *__dict__* variable, instances cannot be assigned new\n variables not listed in the *__slots__* definition. Attempts to\n assign to an unlisted variable name raises "AttributeError". If\n dynamic assignment of new variables is desired, then add\n "\'__dict__\'" to the sequence of strings in the *__slots__*\n declaration.\n\n* Without a *__weakref__* variable for each instance, classes\n defining *__slots__* do not support weak references to its\n instances. If weak reference support is needed, then add\n "\'__weakref__\'" to the sequence of strings in the *__slots__*\n declaration.\n\n* *__slots__* are implemented at the class level by creating\n descriptors (*Implementing Descriptors*) for each variable name. As\n a result, class attributes cannot be used to set default values for\n instance variables defined by *__slots__*; otherwise, the class\n attribute would overwrite the descriptor assignment.\n\n* The action of a *__slots__* declaration is limited to the class\n where it is defined. As a result, subclasses will have a *__dict__*\n unless they also define *__slots__* (which must only contain names\n of any *additional* slots).\n\n* If a class defines a slot also defined in a base class, the\n instance variable defined by the base class slot is inaccessible\n (except by retrieving its descriptor directly from the base class).\n This renders the meaning of the program undefined. In the future, a\n check may be added to prevent this.\n\n* Nonempty *__slots__* does not work for classes derived from\n "variable-length" built-in types such as "int", "bytes" and "tuple".\n\n* Any non-string iterable may be assigned to *__slots__*. Mappings\n may also be used; however, in the future, special meaning may be\n assigned to the values corresponding to each key.\n\n* *__class__* assignment works only if both classes have the same\n *__slots__*.\n\n\nCustomizing class creation\n==========================\n\nBy default, classes are constructed using "type()". The class body is\nexecuted in a new namespace and the class name is bound locally to the\nresult of "type(name, bases, namespace)".\n\nThe class creation process can be customised by passing the\n"metaclass" keyword argument in the class definition line, or by\ninheriting from an existing class that included such an argument. In\nthe following example, both "MyClass" and "MySubclass" are instances\nof "Meta":\n\n class Meta(type):\n pass\n\n class MyClass(metaclass=Meta):\n pass\n\n class MySubclass(MyClass):\n pass\n\nAny other keyword arguments that are specified in the class definition\nare passed through to all metaclass operations described below.\n\nWhen a class definition is executed, the following steps occur:\n\n* the appropriate metaclass is determined\n\n* the class namespace is prepared\n\n* the class body is executed\n\n* the class object is created\n\n\nDetermining the appropriate metaclass\n-------------------------------------\n\nThe appropriate metaclass for a class definition is determined as\nfollows:\n\n* if no bases and no explicit metaclass are given, then "type()" is\n used\n\n* if an explicit metaclass is given and it is *not* an instance of\n "type()", then it is used directly as the metaclass\n\n* if an instance of "type()" is given as the explicit metaclass, or\n bases are defined, then the most derived metaclass is used\n\nThe most derived metaclass is selected from the explicitly specified\nmetaclass (if any) and the metaclasses (i.e. "type(cls)") of all\nspecified base classes. The most derived metaclass is one which is a\nsubtype of *all* of these candidate metaclasses. If none of the\ncandidate metaclasses meets that criterion, then the class definition\nwill fail with "TypeError".\n\n\nPreparing the class namespace\n-----------------------------\n\nOnce the appropriate metaclass has been identified, then the class\nnamespace is prepared. If the metaclass has a "__prepare__" attribute,\nit is called as "namespace = metaclass.__prepare__(name, bases,\n**kwds)" (where the additional keyword arguments, if any, come from\nthe class definition).\n\nIf the metaclass has no "__prepare__" attribute, then the class\nnamespace is initialised as an empty "dict()" instance.\n\nSee also: **PEP 3115** - Metaclasses in Python 3000\n\n Introduced the "__prepare__" namespace hook\n\n\nExecuting the class body\n------------------------\n\nThe class body is executed (approximately) as "exec(body, globals(),\nnamespace)". The key difference from a normal call to "exec()" is that\nlexical scoping allows the class body (including any methods) to\nreference names from the current and outer scopes when the class\ndefinition occurs inside a function.\n\nHowever, even when the class definition occurs inside the function,\nmethods defined inside the class still cannot see names defined at the\nclass scope. Class variables must be accessed through the first\nparameter of instance or class methods, and cannot be accessed at all\nfrom static methods.\n\n\nCreating the class object\n-------------------------\n\nOnce the class namespace has been populated by executing the class\nbody, the class object is created by calling "metaclass(name, bases,\nnamespace, **kwds)" (the additional keywords passed here are the same\nas those passed to "__prepare__").\n\nThis class object is the one that will be referenced by the zero-\nargument form of "super()". "__class__" is an implicit closure\nreference created by the compiler if any methods in a class body refer\nto either "__class__" or "super". This allows the zero argument form\nof "super()" to correctly identify the class being defined based on\nlexical scoping, while the class or instance that was used to make the\ncurrent call is identified based on the first argument passed to the\nmethod.\n\nAfter the class object is created, it is passed to the class\ndecorators included in the class definition (if any) and the resulting\nobject is bound in the local namespace as the defined class.\n\nWhen a new class is created by "type.__new__", the object provided as\nthe namespace parameter is copied to a standard Python dictionary and\nthe original object is discarded. The new copy becomes the "__dict__"\nattribute of the class object.\n\nSee also: **PEP 3135** - New super\n\n Describes the implicit "__class__" closure reference\n\n\nMetaclass example\n-----------------\n\nThe potential uses for metaclasses are boundless. Some ideas that have\nbeen explored include logging, interface checking, automatic\ndelegation, automatic property creation, proxies, frameworks, and\nautomatic resource locking/synchronization.\n\nHere is an example of a metaclass that uses an\n"collections.OrderedDict" to remember the order that class variables\nare defined:\n\n class OrderedClass(type):\n\n @classmethod\n def __prepare__(metacls, name, bases, **kwds):\n return collections.OrderedDict()\n\n def __new__(cls, name, bases, namespace, **kwds):\n result = type.__new__(cls, name, bases, dict(namespace))\n result.members = tuple(namespace)\n return result\n\n class A(metaclass=OrderedClass):\n def one(self): pass\n def two(self): pass\n def three(self): pass\n def four(self): pass\n\n >>> A.members\n (\'__module__\', \'one\', \'two\', \'three\', \'four\')\n\nWhen the class definition for *A* gets executed, the process begins\nwith calling the metaclass\'s "__prepare__()" method which returns an\nempty "collections.OrderedDict". That mapping records the methods and\nattributes of *A* as they are defined within the body of the class\nstatement. Once those definitions are executed, the ordered dictionary\nis fully populated and the metaclass\'s "__new__()" method gets\ninvoked. That method builds the new type and it saves the ordered\ndictionary keys in an attribute called "members".\n\n\nCustomizing instance and subclass checks\n========================================\n\nThe following methods are used to override the default behavior of the\n"isinstance()" and "issubclass()" built-in functions.\n\nIn particular, the metaclass "abc.ABCMeta" implements these methods in\norder to allow the addition of Abstract Base Classes (ABCs) as\n"virtual base classes" to any class or type (including built-in\ntypes), including other ABCs.\n\nclass.__instancecheck__(self, instance)\n\n Return true if *instance* should be considered a (direct or\n indirect) instance of *class*. If defined, called to implement\n "isinstance(instance, class)".\n\nclass.__subclasscheck__(self, subclass)\n\n Return true if *subclass* should be considered a (direct or\n indirect) subclass of *class*. If defined, called to implement\n "issubclass(subclass, class)".\n\nNote that these methods are looked up on the type (metaclass) of a\nclass. They cannot be defined as class methods in the actual class.\nThis is consistent with the lookup of special methods that are called\non instances, only in this case the instance is itself a class.\n\nSee also: **PEP 3119** - Introducing Abstract Base Classes\n\n Includes the specification for customizing "isinstance()" and\n "issubclass()" behavior through "__instancecheck__()" and\n "__subclasscheck__()", with motivation for this functionality in\n the context of adding Abstract Base Classes (see the "abc"\n module) to the language.\n\n\nEmulating callable objects\n==========================\n\nobject.__call__(self[, args...])\n\n Called when the instance is "called" as a function; if this method\n is defined, "x(arg1, arg2, ...)" is a shorthand for\n "x.__call__(arg1, arg2, ...)".\n\n\nEmulating container types\n=========================\n\nThe following methods can be defined to implement container objects.\nContainers usually are sequences (such as lists or tuples) or mappings\n(like dictionaries), but can represent other containers as well. The\nfirst set of methods is used either to emulate a sequence or to\nemulate a mapping; the difference is that for a sequence, the\nallowable keys should be the integers *k* for which "0 <= k < N" where\n*N* is the length of the sequence, or slice objects, which define a\nrange of items. It is also recommended that mappings provide the\nmethods "keys()", "values()", "items()", "get()", "clear()",\n"setdefault()", "pop()", "popitem()", "copy()", and "update()"\nbehaving similar to those for Python\'s standard dictionary objects.\nThe "collections" module provides a "MutableMapping" abstract base\nclass to help create those methods from a base set of "__getitem__()",\n"__setitem__()", "__delitem__()", and "keys()". Mutable sequences\nshould provide methods "append()", "count()", "index()", "extend()",\n"insert()", "pop()", "remove()", "reverse()" and "sort()", like Python\nstandard list objects. Finally, sequence types should implement\naddition (meaning concatenation) and multiplication (meaning\nrepetition) by defining the methods "__add__()", "__radd__()",\n"__iadd__()", "__mul__()", "__rmul__()" and "__imul__()" described\nbelow; they should not define other numerical operators. It is\nrecommended that both mappings and sequences implement the\n"__contains__()" method to allow efficient use of the "in" operator;\nfor mappings, "in" should search the mapping\'s keys; for sequences, it\nshould search through the values. It is further recommended that both\nmappings and sequences implement the "__iter__()" method to allow\nefficient iteration through the container; for mappings, "__iter__()"\nshould be the same as "keys()"; for sequences, it should iterate\nthrough the values.\n\nobject.__len__(self)\n\n Called to implement the built-in function "len()". Should return\n the length of the object, an integer ">=" 0. Also, an object that\n doesn\'t define a "__bool__()" method and whose "__len__()" method\n returns zero is considered to be false in a Boolean context.\n\nobject.__length_hint__(self)\n\n Called to implement "operator.length_hint()". Should return an\n estimated length for the object (which may be greater or less than\n the actual length). The length must be an integer ">=" 0. This\n method is purely an optimization and is never required for\n correctness.\n\n New in version 3.4.\n\nNote: Slicing is done exclusively with the following three methods.\n A call like\n\n a[1:2] = b\n\n is translated to\n\n a[slice(1, 2, None)] = b\n\n and so forth. Missing slice items are always filled in with "None".\n\nobject.__getitem__(self, key)\n\n Called to implement evaluation of "self[key]". For sequence types,\n the accepted keys should be integers and slice objects. Note that\n the special interpretation of negative indexes (if the class wishes\n to emulate a sequence type) is up to the "__getitem__()" method. If\n *key* is of an inappropriate type, "TypeError" may be raised; if of\n a value outside the set of indexes for the sequence (after any\n special interpretation of negative values), "IndexError" should be\n raised. For mapping types, if *key* is missing (not in the\n container), "KeyError" should be raised.\n\n Note: "for" loops expect that an "IndexError" will be raised for\n illegal indexes to allow proper detection of the end of the\n sequence.\n\nobject.__missing__(self, key)\n\n Called by "dict"."__getitem__()" to implement "self[key]" for dict\n subclasses when key is not in the dictionary.\n\nobject.__setitem__(self, key, value)\n\n Called to implement assignment to "self[key]". Same note as for\n "__getitem__()". This should only be implemented for mappings if\n the objects support changes to the values for keys, or if new keys\n can be added, or for sequences if elements can be replaced. The\n same exceptions should be raised for improper *key* values as for\n the "__getitem__()" method.\n\nobject.__delitem__(self, key)\n\n Called to implement deletion of "self[key]". Same note as for\n "__getitem__()". This should only be implemented for mappings if\n the objects support removal of keys, or for sequences if elements\n can be removed from the sequence. The same exceptions should be\n raised for improper *key* values as for the "__getitem__()" method.\n\nobject.__iter__(self)\n\n This method is called when an iterator is required for a container.\n This method should return a new iterator object that can iterate\n over all the objects in the container. For mappings, it should\n iterate over the keys of the container.\n\n Iterator objects also need to implement this method; they are\n required to return themselves. For more information on iterator\n objects, see *Iterator Types*.\n\nobject.__reversed__(self)\n\n Called (if present) by the "reversed()" built-in to implement\n reverse iteration. It should return a new iterator object that\n iterates over all the objects in the container in reverse order.\n\n If the "__reversed__()" method is not provided, the "reversed()"\n built-in will fall back to using the sequence protocol ("__len__()"\n and "__getitem__()"). Objects that support the sequence protocol\n should only provide "__reversed__()" if they can provide an\n implementation that is more efficient than the one provided by\n "reversed()".\n\nThe membership test operators ("in" and "not in") are normally\nimplemented as an iteration through a sequence. However, container\nobjects can supply the following special method with a more efficient\nimplementation, which also does not require the object be a sequence.\n\nobject.__contains__(self, item)\n\n Called to implement membership test operators. Should return true\n if *item* is in *self*, false otherwise. For mapping objects, this\n should consider the keys of the mapping rather than the values or\n the key-item pairs.\n\n For objects that don\'t define "__contains__()", the membership test\n first tries iteration via "__iter__()", then the old sequence\n iteration protocol via "__getitem__()", see *this section in the\n language reference*.\n\n\nEmulating numeric types\n=======================\n\nThe following methods can be defined to emulate numeric objects.\nMethods corresponding to operations that are not supported by the\nparticular kind of number implemented (e.g., bitwise operations for\nnon-integral numbers) should be left undefined.\n\nobject.__add__(self, other)\nobject.__sub__(self, other)\nobject.__mul__(self, other)\nobject.__matmul__(self, other)\nobject.__truediv__(self, other)\nobject.__floordiv__(self, other)\nobject.__mod__(self, other)\nobject.__divmod__(self, other)\nobject.__pow__(self, other[, modulo])\nobject.__lshift__(self, other)\nobject.__rshift__(self, other)\nobject.__and__(self, other)\nobject.__xor__(self, other)\nobject.__or__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations ("+", "-", "*", "@", "/", "//", "%", "divmod()",\n "pow()", "**", "<<", ">>", "&", "^", "|"). For instance, to\n evaluate the expression "x + y", where *x* is an instance of a\n class that has an "__add__()" method, "x.__add__(y)" is called.\n The "__divmod__()" method should be the equivalent to using\n "__floordiv__()" and "__mod__()"; it should not be related to\n "__truediv__()". Note that "__pow__()" should be defined to accept\n an optional third argument if the ternary version of the built-in\n "pow()" function is to be supported.\n\n If one of those methods does not support the operation with the\n supplied arguments, it should return "NotImplemented".\n\nobject.__radd__(self, other)\nobject.__rsub__(self, other)\nobject.__rmul__(self, other)\nobject.__rmatmul__(self, other)\nobject.__rtruediv__(self, other)\nobject.__rfloordiv__(self, other)\nobject.__rmod__(self, other)\nobject.__rdivmod__(self, other)\nobject.__rpow__(self, other)\nobject.__rlshift__(self, other)\nobject.__rrshift__(self, other)\nobject.__rand__(self, other)\nobject.__rxor__(self, other)\nobject.__ror__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations ("+", "-", "*", "@", "/", "//", "%", "divmod()",\n "pow()", "**", "<<", ">>", "&", "^", "|") with reflected (swapped)\n operands. These functions are only called if the left operand does\n not support the corresponding operation and the operands are of\n different types. [2] For instance, to evaluate the expression "x -\n y", where *y* is an instance of a class that has an "__rsub__()"\n method, "y.__rsub__(x)" is called if "x.__sub__(y)" returns\n *NotImplemented*.\n\n Note that ternary "pow()" will not try calling "__rpow__()" (the\n coercion rules would become too complicated).\n\n Note: If the right operand\'s type is a subclass of the left\n operand\'s type and that subclass provides the reflected method\n for the operation, this method will be called before the left\n operand\'s non-reflected method. This behavior allows subclasses\n to override their ancestors\' operations.\n\nobject.__iadd__(self, other)\nobject.__isub__(self, other)\nobject.__imul__(self, other)\nobject.__imatmul__(self, other)\nobject.__itruediv__(self, other)\nobject.__ifloordiv__(self, other)\nobject.__imod__(self, other)\nobject.__ipow__(self, other[, modulo])\nobject.__ilshift__(self, other)\nobject.__irshift__(self, other)\nobject.__iand__(self, other)\nobject.__ixor__(self, other)\nobject.__ior__(self, other)\n\n These methods are called to implement the augmented arithmetic\n assignments ("+=", "-=", "*=", "@=", "/=", "//=", "%=", "**=",\n "<<=", ">>=", "&=", "^=", "|="). These methods should attempt to\n do the operation in-place (modifying *self*) and return the result\n (which could be, but does not have to be, *self*). If a specific\n method is not defined, the augmented assignment falls back to the\n normal methods. For instance, if *x* is an instance of a class\n with an "__iadd__()" method, "x += y" is equivalent to "x =\n x.__iadd__(y)" . Otherwise, "x.__add__(y)" and "y.__radd__(x)" are\n considered, as with the evaluation of "x + y". In certain\n situations, augmented assignment can result in unexpected errors\n (see *Why does a_tuple[i] += [\'item\'] raise an exception when the\n addition works?*), but this behavior is in fact part of the data\n model.\n\nobject.__neg__(self)\nobject.__pos__(self)\nobject.__abs__(self)\nobject.__invert__(self)\n\n Called to implement the unary arithmetic operations ("-", "+",\n "abs()" and "~").\n\nobject.__complex__(self)\nobject.__int__(self)\nobject.__float__(self)\nobject.__round__(self[, n])\n\n Called to implement the built-in functions "complex()", "int()",\n "float()" and "round()". Should return a value of the appropriate\n type.\n\nobject.__index__(self)\n\n Called to implement "operator.index()", and whenever Python needs\n to losslessly convert the numeric object to an integer object (such\n as in slicing, or in the built-in "bin()", "hex()" and "oct()"\n functions). Presence of this method indicates that the numeric\n object is an integer type. Must return an integer.\n\n Note: In order to have a coherent integer type class, when\n "__index__()" is defined "__int__()" should also be defined, and\n both should return the same value.\n\n\nWith Statement Context Managers\n===============================\n\nA *context manager* is an object that defines the runtime context to\nbe established when executing a "with" statement. The context manager\nhandles the entry into, and the exit from, the desired runtime context\nfor the execution of the block of code. Context managers are normally\ninvoked using the "with" statement (described in section *The with\nstatement*), but can also be used by directly invoking their methods.\n\nTypical uses of context managers include saving and restoring various\nkinds of global state, locking and unlocking resources, closing opened\nfiles, etc.\n\nFor more information on context managers, see *Context Manager Types*.\n\nobject.__enter__(self)\n\n Enter the runtime context related to this object. The "with"\n statement will bind this method\'s return value to the target(s)\n specified in the "as" clause of the statement, if any.\n\nobject.__exit__(self, exc_type, exc_value, traceback)\n\n Exit the runtime context related to this object. The parameters\n describe the exception that caused the context to be exited. If the\n context was exited without an exception, all three arguments will\n be "None".\n\n If an exception is supplied, and the method wishes to suppress the\n exception (i.e., prevent it from being propagated), it should\n return a true value. Otherwise, the exception will be processed\n normally upon exit from this method.\n\n Note that "__exit__()" methods should not reraise the passed-in\n exception; this is the caller\'s responsibility.\n\nSee also: **PEP 343** - The "with" statement\n\n The specification, background, and examples for the Python "with"\n statement.\n\n\nSpecial method lookup\n=====================\n\nFor custom classes, implicit invocations of special methods are only\nguaranteed to work correctly if defined on an object\'s type, not in\nthe object\'s instance dictionary. That behaviour is the reason why\nthe following code raises an exception:\n\n >>> class C:\n ... pass\n ...\n >>> c = C()\n >>> c.__len__ = lambda: 5\n >>> len(c)\n Traceback (most recent call last):\n File "<stdin>", line 1, in <module>\n TypeError: object of type \'C\' has no len()\n\nThe rationale behind this behaviour lies with a number of special\nmethods such as "__hash__()" and "__repr__()" that are implemented by\nall objects, including type objects. If the implicit lookup of these\nmethods used the conventional lookup process, they would fail when\ninvoked on the type object itself:\n\n >>> 1 .__hash__() == hash(1)\n True\n >>> int.__hash__() == hash(int)\n Traceback (most recent call last):\n File "<stdin>", line 1, in <module>\n TypeError: descriptor \'__hash__\' of \'int\' object needs an argument\n\nIncorrectly attempting to invoke an unbound method of a class in this\nway is sometimes referred to as \'metaclass confusion\', and is avoided\nby bypassing the instance when looking up special methods:\n\n >>> type(1).__hash__(1) == hash(1)\n True\n >>> type(int).__hash__(int) == hash(int)\n True\n\nIn addition to bypassing any instance attributes in the interest of\ncorrectness, implicit special method lookup generally also bypasses\nthe "__getattribute__()" method even of the object\'s metaclass:\n\n >>> class Meta(type):\n ... def __getattribute__(*args):\n ... print("Metaclass getattribute invoked")\n ... return type.__getattribute__(*args)\n ...\n >>> class C(object, metaclass=Meta):\n ... def __len__(self):\n ... return 10\n ... def __getattribute__(*args):\n ... print("Class getattribute invoked")\n ... return object.__getattribute__(*args)\n ...\n >>> c = C()\n >>> c.__len__() # Explicit lookup via instance\n Class getattribute invoked\n 10\n >>> type(c).__len__(c) # Explicit lookup via type\n Metaclass getattribute invoked\n 10\n >>> len(c) # Implicit lookup\n 10\n\nBypassing the "__getattribute__()" machinery in this fashion provides\nsignificant scope for speed optimisations within the interpreter, at\nthe cost of some flexibility in the handling of special methods (the\nspecial method *must* be set on the class object itself in order to be\nconsistently invoked by the interpreter).\n',
- 'string-methods': u'\nString Methods\n**************\n\nStrings implement all of the *common* sequence operations, along with\nthe additional methods described below.\n\nStrings also support two styles of string formatting, one providing a\nlarge degree of flexibility and customization (see "str.format()",\n*Format String Syntax* and *Custom String Formatting*) and the other\nbased on C "printf" style formatting that handles a narrower range of\ntypes and is slightly harder to use correctly, but is often faster for\nthe cases it can handle (*printf-style String Formatting*).\n\nThe *Text Processing Services* section of the standard library covers\na number of other modules that provide various text related utilities\n(including regular expression support in the "re" module).\n\nstr.capitalize()\n\n Return a copy of the string with its first character capitalized\n and the rest lowercased.\n\nstr.casefold()\n\n Return a casefolded copy of the string. Casefolded strings may be\n used for caseless matching.\n\n Casefolding is similar to lowercasing but more aggressive because\n it is intended to remove all case distinctions in a string. For\n example, the German lowercase letter "\'\xdf\'" is equivalent to ""ss"".\n Since it is already lowercase, "lower()" would do nothing to "\'\xdf\'";\n "casefold()" converts it to ""ss"".\n\n The casefolding algorithm is described in section 3.13 of the\n Unicode Standard.\n\n New in version 3.3.\n\nstr.center(width[, fillchar])\n\n Return centered in a string of length *width*. Padding is done\n using the specified *fillchar* (default is an ASCII space). The\n original string is returned if *width* is less than or equal to\n "len(s)".\n\nstr.count(sub[, start[, end]])\n\n Return the number of non-overlapping occurrences of substring *sub*\n in the range [*start*, *end*]. Optional arguments *start* and\n *end* are interpreted as in slice notation.\n\nstr.encode(encoding="utf-8", errors="strict")\n\n Return an encoded version of the string as a bytes object. Default\n encoding is "\'utf-8\'". *errors* may be given to set a different\n error handling scheme. The default for *errors* is "\'strict\'",\n meaning that encoding errors raise a "UnicodeError". Other possible\n values are "\'ignore\'", "\'replace\'", "\'xmlcharrefreplace\'",\n "\'backslashreplace\'" and any other name registered via\n "codecs.register_error()", see section *Error Handlers*. For a list\n of possible encodings, see section *Standard Encodings*.\n\n Changed in version 3.1: Support for keyword arguments added.\n\nstr.endswith(suffix[, start[, end]])\n\n Return "True" if the string ends with the specified *suffix*,\n otherwise return "False". *suffix* can also be a tuple of suffixes\n to look for. With optional *start*, test beginning at that\n position. With optional *end*, stop comparing at that position.\n\nstr.expandtabs(tabsize=8)\n\n Return a copy of the string where all tab characters are replaced\n by one or more spaces, depending on the current column and the\n given tab size. Tab positions occur every *tabsize* characters\n (default is 8, giving tab positions at columns 0, 8, 16 and so on).\n To expand the string, the current column is set to zero and the\n string is examined character by character. If the character is a\n tab ("\\t"), one or more space characters are inserted in the result\n until the current column is equal to the next tab position. (The\n tab character itself is not copied.) If the character is a newline\n ("\\n") or return ("\\r"), it is copied and the current column is\n reset to zero. Any other character is copied unchanged and the\n current column is incremented by one regardless of how the\n character is represented when printed.\n\n >>> \'01\\t012\\t0123\\t01234\'.expandtabs()\n \'01 012 0123 01234\'\n >>> \'01\\t012\\t0123\\t01234\'.expandtabs(4)\n \'01 012 0123 01234\'\n\nstr.find(sub[, start[, end]])\n\n Return the lowest index in the string where substring *sub* is\n found within the slice "s[start:end]". Optional arguments *start*\n and *end* are interpreted as in slice notation. Return "-1" if\n *sub* is not found.\n\n Note: The "find()" method should be used only if you need to know\n the position of *sub*. To check if *sub* is a substring or not,\n use the "in" operator:\n\n >>> \'Py\' in \'Python\'\n True\n\nstr.format(*args, **kwargs)\n\n Perform a string formatting operation. The string on which this\n method is called can contain literal text or replacement fields\n delimited by braces "{}". Each replacement field contains either\n the numeric index of a positional argument, or the name of a\n keyword argument. Returns a copy of the string where each\n replacement field is replaced with the string value of the\n corresponding argument.\n\n >>> "The sum of 1 + 2 is {0}".format(1+2)\n \'The sum of 1 + 2 is 3\'\n\n See *Format String Syntax* for a description of the various\n formatting options that can be specified in format strings.\n\nstr.format_map(mapping)\n\n Similar to "str.format(**mapping)", except that "mapping" is used\n directly and not copied to a "dict". This is useful if for example\n "mapping" is a dict subclass:\n\n >>> class Default(dict):\n ... def __missing__(self, key):\n ... return key\n ...\n >>> \'{name} was born in {country}\'.format_map(Default(name=\'Guido\'))\n \'Guido was born in country\'\n\n New in version 3.2.\n\nstr.index(sub[, start[, end]])\n\n Like "find()", but raise "ValueError" when the substring is not\n found.\n\nstr.isalnum()\n\n Return true if all characters in the string are alphanumeric and\n there is at least one character, false otherwise. A character "c"\n is alphanumeric if one of the following returns "True":\n "c.isalpha()", "c.isdecimal()", "c.isdigit()", or "c.isnumeric()".\n\nstr.isalpha()\n\n Return true if all characters in the string are alphabetic and\n there is at least one character, false otherwise. Alphabetic\n characters are those characters defined in the Unicode character\n database as "Letter", i.e., those with general category property\n being one of "Lm", "Lt", "Lu", "Ll", or "Lo". Note that this is\n different from the "Alphabetic" property defined in the Unicode\n Standard.\n\nstr.isdecimal()\n\n Return true if all characters in the string are decimal characters\n and there is at least one character, false otherwise. Decimal\n characters are those from general category "Nd". This category\n includes digit characters, and all characters that can be used to\n form decimal-radix numbers, e.g. U+0660, ARABIC-INDIC DIGIT ZERO.\n\nstr.isdigit()\n\n Return true if all characters in the string are digits and there is\n at least one character, false otherwise. Digits include decimal\n characters and digits that need special handling, such as the\n compatibility superscript digits. Formally, a digit is a character\n that has the property value Numeric_Type=Digit or\n Numeric_Type=Decimal.\n\nstr.isidentifier()\n\n Return true if the string is a valid identifier according to the\n language definition, section *Identifiers and keywords*.\n\n Use "keyword.iskeyword()" to test for reserved identifiers such as\n "def" and "class".\n\nstr.islower()\n\n Return true if all cased characters [4] in the string are lowercase\n and there is at least one cased character, false otherwise.\n\nstr.isnumeric()\n\n Return true if all characters in the string are numeric characters,\n and there is at least one character, false otherwise. Numeric\n characters include digit characters, and all characters that have\n the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION\n ONE FIFTH. Formally, numeric characters are those with the\n property value Numeric_Type=Digit, Numeric_Type=Decimal or\n Numeric_Type=Numeric.\n\nstr.isprintable()\n\n Return true if all characters in the string are printable or the\n string is empty, false otherwise. Nonprintable characters are\n those characters defined in the Unicode character database as\n "Other" or "Separator", excepting the ASCII space (0x20) which is\n considered printable. (Note that printable characters in this\n context are those which should not be escaped when "repr()" is\n invoked on a string. It has no bearing on the handling of strings\n written to "sys.stdout" or "sys.stderr".)\n\nstr.isspace()\n\n Return true if there are only whitespace characters in the string\n and there is at least one character, false otherwise. Whitespace\n characters are those characters defined in the Unicode character\n database as "Other" or "Separator" and those with bidirectional\n property being one of "WS", "B", or "S".\n\nstr.istitle()\n\n Return true if the string is a titlecased string and there is at\n least one character, for example uppercase characters may only\n follow uncased characters and lowercase characters only cased ones.\n Return false otherwise.\n\nstr.isupper()\n\n Return true if all cased characters [4] in the string are uppercase\n and there is at least one cased character, false otherwise.\n\nstr.join(iterable)\n\n Return a string which is the concatenation of the strings in the\n *iterable* *iterable*. A "TypeError" will be raised if there are\n any non-string values in *iterable*, including "bytes" objects.\n The separator between elements is the string providing this method.\n\nstr.ljust(width[, fillchar])\n\n Return the string left justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is an ASCII\n space). The original string is returned if *width* is less than or\n equal to "len(s)".\n\nstr.lower()\n\n Return a copy of the string with all the cased characters [4]\n converted to lowercase.\n\n The lowercasing algorithm used is described in section 3.13 of the\n Unicode Standard.\n\nstr.lstrip([chars])\n\n Return a copy of the string with leading characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or "None", the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a prefix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.lstrip()\n \'spacious \'\n >>> \'www.example.com\'.lstrip(\'cmowz.\')\n \'example.com\'\n\nstatic str.maketrans(x[, y[, z]])\n\n This static method returns a translation table usable for\n "str.translate()".\n\n If there is only one argument, it must be a dictionary mapping\n Unicode ordinals (integers) or characters (strings of length 1) to\n Unicode ordinals, strings (of arbitrary lengths) or None.\n Character keys will then be converted to ordinals.\n\n If there are two arguments, they must be strings of equal length,\n and in the resulting dictionary, each character in x will be mapped\n to the character at the same position in y. If there is a third\n argument, it must be a string, whose characters will be mapped to\n None in the result.\n\nstr.partition(sep)\n\n Split the string at the first occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing the string itself, followed by\n two empty strings.\n\nstr.replace(old, new[, count])\n\n Return a copy of the string with all occurrences of substring *old*\n replaced by *new*. If the optional argument *count* is given, only\n the first *count* occurrences are replaced.\n\nstr.rfind(sub[, start[, end]])\n\n Return the highest index in the string where substring *sub* is\n found, such that *sub* is contained within "s[start:end]".\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return "-1" on failure.\n\nstr.rindex(sub[, start[, end]])\n\n Like "rfind()" but raises "ValueError" when the substring *sub* is\n not found.\n\nstr.rjust(width[, fillchar])\n\n Return the string right justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is an ASCII\n space). The original string is returned if *width* is less than or\n equal to "len(s)".\n\nstr.rpartition(sep)\n\n Split the string at the last occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing two empty strings, followed by\n the string itself.\n\nstr.rsplit(sep=None, maxsplit=-1)\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit* splits\n are done, the *rightmost* ones. If *sep* is not specified or\n "None", any whitespace string is a separator. Except for splitting\n from the right, "rsplit()" behaves like "split()" which is\n described in detail below.\n\nstr.rstrip([chars])\n\n Return a copy of the string with trailing characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or "None", the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a suffix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.rstrip()\n \' spacious\'\n >>> \'mississippi\'.rstrip(\'ipz\')\n \'mississ\'\n\nstr.split(sep=None, maxsplit=-1)\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit*\n splits are done (thus, the list will have at most "maxsplit+1"\n elements). If *maxsplit* is not specified or "-1", then there is\n no limit on the number of splits (all possible splits are made).\n\n If *sep* is given, consecutive delimiters are not grouped together\n and are deemed to delimit empty strings (for example,\n "\'1,,2\'.split(\',\')" returns "[\'1\', \'\', \'2\']"). The *sep* argument\n may consist of multiple characters (for example,\n "\'1<>2<>3\'.split(\'<>\')" returns "[\'1\', \'2\', \'3\']"). Splitting an\n empty string with a specified separator returns "[\'\']".\n\n For example:\n\n >>> \'1,2,3\'.split(\',\')\n [\'1\', \'2\', \'3\']\n >>> \'1,2,3\'.split(\',\', maxsplit=1)\n [\'1\', \'2,3\']\n >>> \'1,2,,3,\'.split(\',\')\n [\'1\', \'2\', \'\', \'3\', \'\']\n\n If *sep* is not specified or is "None", a different splitting\n algorithm is applied: runs of consecutive whitespace are regarded\n as a single separator, and the result will contain no empty strings\n at the start or end if the string has leading or trailing\n whitespace. Consequently, splitting an empty string or a string\n consisting of just whitespace with a "None" separator returns "[]".\n\n For example:\n\n >>> \'1 2 3\'.split()\n [\'1\', \'2\', \'3\']\n >>> \'1 2 3\'.split(maxsplit=1)\n [\'1\', \'2 3\']\n >>> \' 1 2 3 \'.split()\n [\'1\', \'2\', \'3\']\n\nstr.splitlines([keepends])\n\n Return a list of the lines in the string, breaking at line\n boundaries. Line breaks are not included in the resulting list\n unless *keepends* is given and true.\n\n This method splits on the following line boundaries. In\n particular, the boundaries are a superset of *universal newlines*.\n\n +-------------------------+-------------------------------+\n | Representation | Description |\n +=========================+===============================+\n | "\\n" | Line Feed |\n +-------------------------+-------------------------------+\n | "\\r" | Carriage Return |\n +-------------------------+-------------------------------+\n | "\\r\\n" | Carriage Return + Line Feed |\n +-------------------------+-------------------------------+\n | "\\v" or "\\x0b" | Line Tabulation |\n +-------------------------+-------------------------------+\n | "\\f" or "\\x0c" | Form Feed |\n +-------------------------+-------------------------------+\n | "\\x1c" | File Separator |\n +-------------------------+-------------------------------+\n | "\\x1d" | Group Separator |\n +-------------------------+-------------------------------+\n | "\\x1e" | Record Separator |\n +-------------------------+-------------------------------+\n | "\\x85" | Next Line (C1 Control Code) |\n +-------------------------+-------------------------------+\n | "\\u2028" | Line Separator |\n +-------------------------+-------------------------------+\n | "\\u2029" | Paragraph Separator |\n +-------------------------+-------------------------------+\n\n Changed in version 3.2: "\\v" and "\\f" added to list of line\n boundaries.\n\n For example:\n\n >>> \'ab c\\n\\nde fg\\rkl\\r\\n\'.splitlines()\n [\'ab c\', \'\', \'de fg\', \'kl\']\n >>> \'ab c\\n\\nde fg\\rkl\\r\\n\'.splitlines(keepends=True)\n [\'ab c\\n\', \'\\n\', \'de fg\\r\', \'kl\\r\\n\']\n\n Unlike "split()" when a delimiter string *sep* is given, this\n method returns an empty list for the empty string, and a terminal\n line break does not result in an extra line:\n\n >>> "".splitlines()\n []\n >>> "One line\\n".splitlines()\n [\'One line\']\n\n For comparison, "split(\'\\n\')" gives:\n\n >>> \'\'.split(\'\\n\')\n [\'\']\n >>> \'Two lines\\n\'.split(\'\\n\')\n [\'Two lines\', \'\']\n\nstr.startswith(prefix[, start[, end]])\n\n Return "True" if string starts with the *prefix*, otherwise return\n "False". *prefix* can also be a tuple of prefixes to look for.\n With optional *start*, test string beginning at that position.\n With optional *end*, stop comparing string at that position.\n\nstr.strip([chars])\n\n Return a copy of the string with the leading and trailing\n characters removed. The *chars* argument is a string specifying the\n set of characters to be removed. If omitted or "None", the *chars*\n argument defaults to removing whitespace. The *chars* argument is\n not a prefix or suffix; rather, all combinations of its values are\n stripped:\n\n >>> \' spacious \'.strip()\n \'spacious\'\n >>> \'www.example.com\'.strip(\'cmowz.\')\n \'example\'\n\n The outermost leading and trailing *chars* argument values are\n stripped from the string. Characters are removed from the leading\n end until reaching a string character that is not contained in the\n set of characters in *chars*. A similar action takes place on the\n trailing end. For example:\n\n >>> comment_string = \'#....... Section 3.2.1 Issue #32 .......\'\n >>> comment_string.strip(\'.#! \')\n \'Section 3.2.1 Issue #32\'\n\nstr.swapcase()\n\n Return a copy of the string with uppercase characters converted to\n lowercase and vice versa. Note that it is not necessarily true that\n "s.swapcase().swapcase() == s".\n\nstr.title()\n\n Return a titlecased version of the string where words start with an\n uppercase character and the remaining characters are lowercase.\n\n For example:\n\n >>> \'Hello world\'.title()\n \'Hello World\'\n\n The algorithm uses a simple language-independent definition of a\n word as groups of consecutive letters. The definition works in\n many contexts but it means that apostrophes in contractions and\n possessives form word boundaries, which may not be the desired\n result:\n\n >>> "they\'re bill\'s friends from the UK".title()\n "They\'Re Bill\'S Friends From The Uk"\n\n A workaround for apostrophes can be constructed using regular\n expressions:\n\n >>> import re\n >>> def titlecase(s):\n ... return re.sub(r"[A-Za-z]+(\'[A-Za-z]+)?",\n ... lambda mo: mo.group(0)[0].upper() +\n ... mo.group(0)[1:].lower(),\n ... s)\n ...\n >>> titlecase("they\'re bill\'s friends.")\n "They\'re Bill\'s Friends."\n\nstr.translate(table)\n\n Return a copy of the string in which each character has been mapped\n through the given translation table. The table must be an object\n that implements indexing via "__getitem__()", typically a *mapping*\n or *sequence*. When indexed by a Unicode ordinal (an integer), the\n table object can do any of the following: return a Unicode ordinal\n or a string, to map the character to one or more other characters;\n return "None", to delete the character from the return string; or\n raise a "LookupError" exception, to map the character to itself.\n\n You can use "str.maketrans()" to create a translation map from\n character-to-character mappings in different formats.\n\n See also the "codecs" module for a more flexible approach to custom\n character mappings.\n\nstr.upper()\n\n Return a copy of the string with all the cased characters [4]\n converted to uppercase. Note that "str.upper().isupper()" might be\n "False" if "s" contains uncased characters or if the Unicode\n category of the resulting character(s) is not "Lu" (Letter,\n uppercase), but e.g. "Lt" (Letter, titlecase).\n\n The uppercasing algorithm used is described in section 3.13 of the\n Unicode Standard.\n\nstr.zfill(width)\n\n Return a copy of the string left filled with ASCII "\'0\'" digits to\n make a string of length *width*. A leading sign prefix\n ("\'+\'"/"\'-\'") is handled by inserting the padding *after* the sign\n character rather than before. The original string is returned if\n *width* is less than or equal to "len(s)".\n\n For example:\n\n >>> "42".zfill(5)\n \'00042\'\n >>> "-42".zfill(5)\n \'-0042\'\n',
- 'strings': u'\nString and Bytes literals\n*************************\n\nString literals are described by the following lexical definitions:\n\n stringliteral ::= [stringprefix](shortstring | longstring)\n stringprefix ::= "r" | "u" | "R" | "U"\n shortstring ::= "\'" shortstringitem* "\'" | \'"\' shortstringitem* \'"\'\n longstring ::= "\'\'\'" longstringitem* "\'\'\'" | \'"""\' longstringitem* \'"""\'\n shortstringitem ::= shortstringchar | stringescapeseq\n longstringitem ::= longstringchar | stringescapeseq\n shortstringchar ::= <any source character except "\\" or newline or the quote>\n longstringchar ::= <any source character except "\\">\n stringescapeseq ::= "\\" <any source character>\n\n bytesliteral ::= bytesprefix(shortbytes | longbytes)\n bytesprefix ::= "b" | "B" | "br" | "Br" | "bR" | "BR" | "rb" | "rB" | "Rb" | "RB"\n shortbytes ::= "\'" shortbytesitem* "\'" | \'"\' shortbytesitem* \'"\'\n longbytes ::= "\'\'\'" longbytesitem* "\'\'\'" | \'"""\' longbytesitem* \'"""\'\n shortbytesitem ::= shortbyteschar | bytesescapeseq\n longbytesitem ::= longbyteschar | bytesescapeseq\n shortbyteschar ::= <any ASCII character except "\\" or newline or the quote>\n longbyteschar ::= <any ASCII character except "\\">\n bytesescapeseq ::= "\\" <any ASCII character>\n\nOne syntactic restriction not indicated by these productions is that\nwhitespace is not allowed between the "stringprefix" or "bytesprefix"\nand the rest of the literal. The source character set is defined by\nthe encoding declaration; it is UTF-8 if no encoding declaration is\ngiven in the source file; see section *Encoding declarations*.\n\nIn plain English: Both types of literals can be enclosed in matching\nsingle quotes ("\'") or double quotes ("""). They can also be enclosed\nin matching groups of three single or double quotes (these are\ngenerally referred to as *triple-quoted strings*). The backslash\n("\\") character is used to escape characters that otherwise have a\nspecial meaning, such as newline, backslash itself, or the quote\ncharacter.\n\nBytes literals are always prefixed with "\'b\'" or "\'B\'"; they produce\nan instance of the "bytes" type instead of the "str" type. They may\nonly contain ASCII characters; bytes with a numeric value of 128 or\ngreater must be expressed with escapes.\n\nAs of Python 3.3 it is possible again to prefix string literals with a\n"u" prefix to simplify maintenance of dual 2.x and 3.x codebases.\n\nBoth string and bytes literals may optionally be prefixed with a\nletter "\'r\'" or "\'R\'"; such strings are called *raw strings* and treat\nbackslashes as literal characters. As a result, in string literals,\n"\'\\U\'" and "\'\\u\'" escapes in raw strings are not treated specially.\nGiven that Python 2.x\'s raw unicode literals behave differently than\nPython 3.x\'s the "\'ur\'" syntax is not supported.\n\nNew in version 3.3: The "\'rb\'" prefix of raw bytes literals has been\nadded as a synonym of "\'br\'".\n\nNew in version 3.3: Support for the unicode legacy literal\n("u\'value\'") was reintroduced to simplify the maintenance of dual\nPython 2.x and 3.x codebases. See **PEP 414** for more information.\n\nIn triple-quoted literals, unescaped newlines and quotes are allowed\n(and are retained), except that three unescaped quotes in a row\nterminate the literal. (A "quote" is the character used to open the\nliteral, i.e. either "\'" or """.)\n\nUnless an "\'r\'" or "\'R\'" prefix is present, escape sequences in string\nand bytes literals are interpreted according to rules similar to those\nused by Standard C. The recognized escape sequences are:\n\n+-------------------+-----------------------------------+---------+\n| Escape Sequence | Meaning | Notes |\n+===================+===================================+=========+\n| "\\newline" | Backslash and newline ignored | |\n+-------------------+-----------------------------------+---------+\n| "\\\\" | Backslash ("\\") | |\n+-------------------+-----------------------------------+---------+\n| "\\\'" | Single quote ("\'") | |\n+-------------------+-----------------------------------+---------+\n| "\\"" | Double quote (""") | |\n+-------------------+-----------------------------------+---------+\n| "\\a" | ASCII Bell (BEL) | |\n+-------------------+-----------------------------------+---------+\n| "\\b" | ASCII Backspace (BS) | |\n+-------------------+-----------------------------------+---------+\n| "\\f" | ASCII Formfeed (FF) | |\n+-------------------+-----------------------------------+---------+\n| "\\n" | ASCII Linefeed (LF) | |\n+-------------------+-----------------------------------+---------+\n| "\\r" | ASCII Carriage Return (CR) | |\n+-------------------+-----------------------------------+---------+\n| "\\t" | ASCII Horizontal Tab (TAB) | |\n+-------------------+-----------------------------------+---------+\n| "\\v" | ASCII Vertical Tab (VT) | |\n+-------------------+-----------------------------------+---------+\n| "\\ooo" | Character with octal value *ooo* | (1,3) |\n+-------------------+-----------------------------------+---------+\n| "\\xhh" | Character with hex value *hh* | (2,3) |\n+-------------------+-----------------------------------+---------+\n\nEscape sequences only recognized in string literals are:\n\n+-------------------+-----------------------------------+---------+\n| Escape Sequence | Meaning | Notes |\n+===================+===================================+=========+\n| "\\N{name}" | Character named *name* in the | (4) |\n| | Unicode database | |\n+-------------------+-----------------------------------+---------+\n| "\\uxxxx" | Character with 16-bit hex value | (5) |\n| | *xxxx* | |\n+-------------------+-----------------------------------+---------+\n| "\\Uxxxxxxxx" | Character with 32-bit hex value | (6) |\n| | *xxxxxxxx* | |\n+-------------------+-----------------------------------+---------+\n\nNotes:\n\n1. As in Standard C, up to three octal digits are accepted.\n\n2. Unlike in Standard C, exactly two hex digits are required.\n\n3. In a bytes literal, hexadecimal and octal escapes denote the\n byte with the given value. In a string literal, these escapes\n denote a Unicode character with the given value.\n\n4. Changed in version 3.3: Support for name aliases [1] has been\n added.\n\n5. Exactly four hex digits are required.\n\n6. Any Unicode character can be encoded this way. Exactly eight\n hex digits are required.\n\nUnlike Standard C, all unrecognized escape sequences are left in the\nstring unchanged, i.e., *the backslash is left in the result*. (This\nbehavior is useful when debugging: if an escape sequence is mistyped,\nthe resulting output is more easily recognized as broken.) It is also\nimportant to note that the escape sequences only recognized in string\nliterals fall into the category of unrecognized escapes for bytes\nliterals.\n\nEven in a raw literal, quotes can be escaped with a backslash, but the\nbackslash remains in the result; for example, "r"\\""" is a valid\nstring literal consisting of two characters: a backslash and a double\nquote; "r"\\"" is not a valid string literal (even a raw string cannot\nend in an odd number of backslashes). Specifically, *a raw literal\ncannot end in a single backslash* (since the backslash would escape\nthe following quote character). Note also that a single backslash\nfollowed by a newline is interpreted as those two characters as part\nof the literal, *not* as a line continuation.\n',
- 'subscriptions': u'\nSubscriptions\n*************\n\nA subscription selects an item of a sequence (string, tuple or list)\nor mapping (dictionary) object:\n\n subscription ::= primary "[" expression_list "]"\n\nThe primary must evaluate to an object that supports subscription\n(lists or dictionaries for example). User-defined objects can support\nsubscription by defining a "__getitem__()" method.\n\nFor built-in objects, there are two types of objects that support\nsubscription:\n\nIf the primary is a mapping, the expression list must evaluate to an\nobject whose value is one of the keys of the mapping, and the\nsubscription selects the value in the mapping that corresponds to that\nkey. (The expression list is a tuple except if it has exactly one\nitem.)\n\nIf the primary is a sequence, the expression (list) must evaluate to\nan integer or a slice (as discussed in the following section).\n\nThe formal syntax makes no special provision for negative indices in\nsequences; however, built-in sequences all provide a "__getitem__()"\nmethod that interprets negative indices by adding the length of the\nsequence to the index (so that "x[-1]" selects the last item of "x").\nThe resulting value must be a nonnegative integer less than the number\nof items in the sequence, and the subscription selects the item whose\nindex is that value (counting from zero). Since the support for\nnegative indices and slicing occurs in the object\'s "__getitem__()"\nmethod, subclasses overriding this method will need to explicitly add\nthat support.\n\nA string\'s items are characters. A character is not a separate data\ntype but a string of exactly one character.\n',
- 'truth': u'\nTruth Value Testing\n*******************\n\nAny object can be tested for truth value, for use in an "if" or\n"while" condition or as operand of the Boolean operations below. The\nfollowing values are considered false:\n\n* "None"\n\n* "False"\n\n* zero of any numeric type, for example, "0", "0.0", "0j".\n\n* any empty sequence, for example, "\'\'", "()", "[]".\n\n* any empty mapping, for example, "{}".\n\n* instances of user-defined classes, if the class defines a\n "__bool__()" or "__len__()" method, when that method returns the\n integer zero or "bool" value "False". [1]\n\nAll other values are considered true --- so objects of many types are\nalways true.\n\nOperations and built-in functions that have a Boolean result always\nreturn "0" or "False" for false and "1" or "True" for true, unless\notherwise stated. (Important exception: the Boolean operations "or"\nand "and" always return one of their operands.)\n',
- 'try': u'\nThe "try" statement\n*******************\n\nThe "try" statement specifies exception handlers and/or cleanup code\nfor a group of statements:\n\n try_stmt ::= try1_stmt | try2_stmt\n try1_stmt ::= "try" ":" suite\n ("except" [expression ["as" identifier]] ":" suite)+\n ["else" ":" suite]\n ["finally" ":" suite]\n try2_stmt ::= "try" ":" suite\n "finally" ":" suite\n\nThe "except" clause(s) specify one or more exception handlers. When no\nexception occurs in the "try" clause, no exception handler is\nexecuted. When an exception occurs in the "try" suite, a search for an\nexception handler is started. This search inspects the except clauses\nin turn until one is found that matches the exception. An expression-\nless except clause, if present, must be last; it matches any\nexception. For an except clause with an expression, that expression\nis evaluated, and the clause matches the exception if the resulting\nobject is "compatible" with the exception. An object is compatible\nwith an exception if it is the class or a base class of the exception\nobject or a tuple containing an item compatible with the exception.\n\nIf no except clause matches the exception, the search for an exception\nhandler continues in the surrounding code and on the invocation stack.\n[1]\n\nIf the evaluation of an expression in the header of an except clause\nraises an exception, the original search for a handler is canceled and\na search starts for the new exception in the surrounding code and on\nthe call stack (it is treated as if the entire "try" statement raised\nthe exception).\n\nWhen a matching except clause is found, the exception is assigned to\nthe target specified after the "as" keyword in that except clause, if\npresent, and the except clause\'s suite is executed. All except\nclauses must have an executable block. When the end of this block is\nreached, execution continues normally after the entire try statement.\n(This means that if two nested handlers exist for the same exception,\nand the exception occurs in the try clause of the inner handler, the\nouter handler will not handle the exception.)\n\nWhen an exception has been assigned using "as target", it is cleared\nat the end of the except clause. This is as if\n\n except E as N:\n foo\n\nwas translated to\n\n except E as N:\n try:\n foo\n finally:\n del N\n\nThis means the exception must be assigned to a different name to be\nable to refer to it after the except clause. Exceptions are cleared\nbecause with the traceback attached to them, they form a reference\ncycle with the stack frame, keeping all locals in that frame alive\nuntil the next garbage collection occurs.\n\nBefore an except clause\'s suite is executed, details about the\nexception are stored in the "sys" module and can be accessed via\n"sys.exc_info()". "sys.exc_info()" returns a 3-tuple consisting of the\nexception class, the exception instance and a traceback object (see\nsection *The standard type hierarchy*) identifying the point in the\nprogram where the exception occurred. "sys.exc_info()" values are\nrestored to their previous values (before the call) when returning\nfrom a function that handled an exception.\n\nThe optional "else" clause is executed if and when control flows off\nthe end of the "try" clause. [2] Exceptions in the "else" clause are\nnot handled by the preceding "except" clauses.\n\nIf "finally" is present, it specifies a \'cleanup\' handler. The "try"\nclause is executed, including any "except" and "else" clauses. If an\nexception occurs in any of the clauses and is not handled, the\nexception is temporarily saved. The "finally" clause is executed. If\nthere is a saved exception it is re-raised at the end of the "finally"\nclause. If the "finally" clause raises another exception, the saved\nexception is set as the context of the new exception. If the "finally"\nclause executes a "return" or "break" statement, the saved exception\nis discarded:\n\n >>> def f():\n ... try:\n ... 1/0\n ... finally:\n ... return 42\n ...\n >>> f()\n 42\n\nThe exception information is not available to the program during\nexecution of the "finally" clause.\n\nWhen a "return", "break" or "continue" statement is executed in the\n"try" suite of a "try"..."finally" statement, the "finally" clause is\nalso executed \'on the way out.\' A "continue" statement is illegal in\nthe "finally" clause. (The reason is a problem with the current\nimplementation --- this restriction may be lifted in the future).\n\nThe return value of a function is determined by the last "return"\nstatement executed. Since the "finally" clause always executes, a\n"return" statement executed in the "finally" clause will always be the\nlast one executed:\n\n >>> def foo():\n ... try:\n ... return \'try\'\n ... finally:\n ... return \'finally\'\n ...\n >>> foo()\n \'finally\'\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information on using the "raise" statement to\ngenerate exceptions may be found in section *The raise statement*.\n',
- 'types': u'\nThe standard type hierarchy\n***************************\n\nBelow is a list of the types that are built into Python. Extension\nmodules (written in C, Java, or other languages, depending on the\nimplementation) can define additional types. Future versions of\nPython may add types to the type hierarchy (e.g., rational numbers,\nefficiently stored arrays of integers, etc.), although such additions\nwill often be provided via the standard library instead.\n\nSome of the type descriptions below contain a paragraph listing\n\'special attributes.\' These are attributes that provide access to the\nimplementation and are not intended for general use. Their definition\nmay change in the future.\n\nNone\n This type has a single value. There is a single object with this\n value. This object is accessed through the built-in name "None". It\n is used to signify the absence of a value in many situations, e.g.,\n it is returned from functions that don\'t explicitly return\n anything. Its truth value is false.\n\nNotImplemented\n This type has a single value. There is a single object with this\n value. This object is accessed through the built-in name\n "NotImplemented". Numeric methods and rich comparison methods\n should return this value if they do not implement the operation for\n the operands provided. (The interpreter will then try the\n reflected operation, or some other fallback, depending on the\n operator.) Its truth value is true.\n\n See *Implementing the arithmetic operations* for more details.\n\nEllipsis\n This type has a single value. There is a single object with this\n value. This object is accessed through the literal "..." or the\n built-in name "Ellipsis". Its truth value is true.\n\n"numbers.Number"\n These are created by numeric literals and returned as results by\n arithmetic operators and arithmetic built-in functions. Numeric\n objects are immutable; once created their value never changes.\n Python numbers are of course strongly related to mathematical\n numbers, but subject to the limitations of numerical representation\n in computers.\n\n Python distinguishes between integers, floating point numbers, and\n complex numbers:\n\n "numbers.Integral"\n These represent elements from the mathematical set of integers\n (positive and negative).\n\n There are two types of integers:\n\n Integers ("int")\n\n These represent numbers in an unlimited range, subject to\n available (virtual) memory only. For the purpose of shift\n and mask operations, a binary representation is assumed, and\n negative numbers are represented in a variant of 2\'s\n complement which gives the illusion of an infinite string of\n sign bits extending to the left.\n\n Booleans ("bool")\n These represent the truth values False and True. The two\n objects representing the values "False" and "True" are the\n only Boolean objects. The Boolean type is a subtype of the\n integer type, and Boolean values behave like the values 0 and\n 1, respectively, in almost all contexts, the exception being\n that when converted to a string, the strings ""False"" or\n ""True"" are returned, respectively.\n\n The rules for integer representation are intended to give the\n most meaningful interpretation of shift and mask operations\n involving negative integers.\n\n "numbers.Real" ("float")\n These represent machine-level double precision floating point\n numbers. You are at the mercy of the underlying machine\n architecture (and C or Java implementation) for the accepted\n range and handling of overflow. Python does not support single-\n precision floating point numbers; the savings in processor and\n memory usage that are usually the reason for using these are\n dwarfed by the overhead of using objects in Python, so there is\n no reason to complicate the language with two kinds of floating\n point numbers.\n\n "numbers.Complex" ("complex")\n These represent complex numbers as a pair of machine-level\n double precision floating point numbers. The same caveats apply\n as for floating point numbers. The real and imaginary parts of a\n complex number "z" can be retrieved through the read-only\n attributes "z.real" and "z.imag".\n\nSequences\n These represent finite ordered sets indexed by non-negative\n numbers. The built-in function "len()" returns the number of items\n of a sequence. When the length of a sequence is *n*, the index set\n contains the numbers 0, 1, ..., *n*-1. Item *i* of sequence *a* is\n selected by "a[i]".\n\n Sequences also support slicing: "a[i:j]" selects all items with\n index *k* such that *i* "<=" *k* "<" *j*. When used as an\n expression, a slice is a sequence of the same type. This implies\n that the index set is renumbered so that it starts at 0.\n\n Some sequences also support "extended slicing" with a third "step"\n parameter: "a[i:j:k]" selects all items of *a* with index *x* where\n "x = i + n*k", *n* ">=" "0" and *i* "<=" *x* "<" *j*.\n\n Sequences are distinguished according to their mutability:\n\n Immutable sequences\n An object of an immutable sequence type cannot change once it is\n created. (If the object contains references to other objects,\n these other objects may be mutable and may be changed; however,\n the collection of objects directly referenced by an immutable\n object cannot change.)\n\n The following types are immutable sequences:\n\n Strings\n A string is a sequence of values that represent Unicode code\n points. All the code points in the range "U+0000 - U+10FFFF"\n can be represented in a string. Python doesn\'t have a "char"\n type; instead, every code point in the string is represented\n as a string object with length "1". The built-in function\n "ord()" converts a code point from its string form to an\n integer in the range "0 - 10FFFF"; "chr()" converts an\n integer in the range "0 - 10FFFF" to the corresponding length\n "1" string object. "str.encode()" can be used to convert a\n "str" to "bytes" using the given text encoding, and\n "bytes.decode()" can be used to achieve the opposite.\n\n Tuples\n The items of a tuple are arbitrary Python objects. Tuples of\n two or more items are formed by comma-separated lists of\n expressions. A tuple of one item (a \'singleton\') can be\n formed by affixing a comma to an expression (an expression by\n itself does not create a tuple, since parentheses must be\n usable for grouping of expressions). An empty tuple can be\n formed by an empty pair of parentheses.\n\n Bytes\n A bytes object is an immutable array. The items are 8-bit\n bytes, represented by integers in the range 0 <= x < 256.\n Bytes literals (like "b\'abc\'") and the built-in function\n "bytes()" can be used to construct bytes objects. Also,\n bytes objects can be decoded to strings via the "decode()"\n method.\n\n Mutable sequences\n Mutable sequences can be changed after they are created. The\n subscription and slicing notations can be used as the target of\n assignment and "del" (delete) statements.\n\n There are currently two intrinsic mutable sequence types:\n\n Lists\n The items of a list are arbitrary Python objects. Lists are\n formed by placing a comma-separated list of expressions in\n square brackets. (Note that there are no special cases needed\n to form lists of length 0 or 1.)\n\n Byte Arrays\n A bytearray object is a mutable array. They are created by\n the built-in "bytearray()" constructor. Aside from being\n mutable (and hence unhashable), byte arrays otherwise provide\n the same interface and functionality as immutable bytes\n objects.\n\n The extension module "array" provides an additional example of a\n mutable sequence type, as does the "collections" module.\n\nSet types\n These represent unordered, finite sets of unique, immutable\n objects. As such, they cannot be indexed by any subscript. However,\n they can be iterated over, and the built-in function "len()"\n returns the number of items in a set. Common uses for sets are fast\n membership testing, removing duplicates from a sequence, and\n computing mathematical operations such as intersection, union,\n difference, and symmetric difference.\n\n For set elements, the same immutability rules apply as for\n dictionary keys. Note that numeric types obey the normal rules for\n numeric comparison: if two numbers compare equal (e.g., "1" and\n "1.0"), only one of them can be contained in a set.\n\n There are currently two intrinsic set types:\n\n Sets\n These represent a mutable set. They are created by the built-in\n "set()" constructor and can be modified afterwards by several\n methods, such as "add()".\n\n Frozen sets\n These represent an immutable set. They are created by the\n built-in "frozenset()" constructor. As a frozenset is immutable\n and *hashable*, it can be used again as an element of another\n set, or as a dictionary key.\n\nMappings\n These represent finite sets of objects indexed by arbitrary index\n sets. The subscript notation "a[k]" selects the item indexed by "k"\n from the mapping "a"; this can be used in expressions and as the\n target of assignments or "del" statements. The built-in function\n "len()" returns the number of items in a mapping.\n\n There is currently a single intrinsic mapping type:\n\n Dictionaries\n These represent finite sets of objects indexed by nearly\n arbitrary values. The only types of values not acceptable as\n keys are values containing lists or dictionaries or other\n mutable types that are compared by value rather than by object\n identity, the reason being that the efficient implementation of\n dictionaries requires a key\'s hash value to remain constant.\n Numeric types used for keys obey the normal rules for numeric\n comparison: if two numbers compare equal (e.g., "1" and "1.0")\n then they can be used interchangeably to index the same\n dictionary entry.\n\n Dictionaries are mutable; they can be created by the "{...}"\n notation (see section *Dictionary displays*).\n\n The extension modules "dbm.ndbm" and "dbm.gnu" provide\n additional examples of mapping types, as does the "collections"\n module.\n\nCallable types\n These are the types to which the function call operation (see\n section *Calls*) can be applied:\n\n User-defined functions\n A user-defined function object is created by a function\n definition (see section *Function definitions*). It should be\n called with an argument list containing the same number of items\n as the function\'s formal parameter list.\n\n Special attributes:\n\n +---------------------------+---------------------------------+-------------+\n | Attribute | Meaning | |\n +===========================+=================================+=============+\n | "__doc__" | The function\'s documentation | Writable |\n | | string, or "None" if | |\n | | unavailable; not inherited by | |\n | | subclasses | |\n +---------------------------+---------------------------------+-------------+\n | "__name__" | The function\'s name | Writable |\n +---------------------------+---------------------------------+-------------+\n | "__qualname__" | The function\'s *qualified name* | Writable |\n | | New in version 3.3. | |\n +---------------------------+---------------------------------+-------------+\n | "__module__" | The name of the module the | Writable |\n | | function was defined in, or | |\n | | "None" if unavailable. | |\n +---------------------------+---------------------------------+-------------+\n | "__defaults__" | A tuple containing default | Writable |\n | | argument values for those | |\n | | arguments that have defaults, | |\n | | or "None" if no arguments have | |\n | | a default value | |\n +---------------------------+---------------------------------+-------------+\n | "__code__" | The code object representing | Writable |\n | | the compiled function body. | |\n +---------------------------+---------------------------------+-------------+\n | "__globals__" | A reference to the dictionary | Read-only |\n | | that holds the function\'s | |\n | | global variables --- the global | |\n | | namespace of the module in | |\n | | which the function was defined. | |\n +---------------------------+---------------------------------+-------------+\n | "__dict__" | The namespace supporting | Writable |\n | | arbitrary function attributes. | |\n +---------------------------+---------------------------------+-------------+\n | "__closure__" | "None" or a tuple of cells that | Read-only |\n | | contain bindings for the | |\n | | function\'s free variables. | |\n +---------------------------+---------------------------------+-------------+\n | "__annotations__" | A dict containing annotations | Writable |\n | | of parameters. The keys of the | |\n | | dict are the parameter names, | |\n | | and "\'return\'" for the return | |\n | | annotation, if provided. | |\n +---------------------------+---------------------------------+-------------+\n | "__kwdefaults__" | A dict containing defaults for | Writable |\n | | keyword-only parameters. | |\n +---------------------------+---------------------------------+-------------+\n\n Most of the attributes labelled "Writable" check the type of the\n assigned value.\n\n Function objects also support getting and setting arbitrary\n attributes, which can be used, for example, to attach metadata\n to functions. Regular attribute dot-notation is used to get and\n set such attributes. *Note that the current implementation only\n supports function attributes on user-defined functions. Function\n attributes on built-in functions may be supported in the\n future.*\n\n Additional information about a function\'s definition can be\n retrieved from its code object; see the description of internal\n types below.\n\n Instance methods\n An instance method object combines a class, a class instance and\n any callable object (normally a user-defined function).\n\n Special read-only attributes: "__self__" is the class instance\n object, "__func__" is the function object; "__doc__" is the\n method\'s documentation (same as "__func__.__doc__"); "__name__"\n is the method name (same as "__func__.__name__"); "__module__"\n is the name of the module the method was defined in, or "None"\n if unavailable.\n\n Methods also support accessing (but not setting) the arbitrary\n function attributes on the underlying function object.\n\n User-defined method objects may be created when getting an\n attribute of a class (perhaps via an instance of that class), if\n that attribute is a user-defined function object or a class\n method object.\n\n When an instance method object is created by retrieving a user-\n defined function object from a class via one of its instances,\n its "__self__" attribute is the instance, and the method object\n is said to be bound. The new method\'s "__func__" attribute is\n the original function object.\n\n When a user-defined method object is created by retrieving\n another method object from a class or instance, the behaviour is\n the same as for a function object, except that the "__func__"\n attribute of the new instance is not the original method object\n but its "__func__" attribute.\n\n When an instance method object is created by retrieving a class\n method object from a class or instance, its "__self__" attribute\n is the class itself, and its "__func__" attribute is the\n function object underlying the class method.\n\n When an instance method object is called, the underlying\n function ("__func__") is called, inserting the class instance\n ("__self__") in front of the argument list. For instance, when\n "C" is a class which contains a definition for a function "f()",\n and "x" is an instance of "C", calling "x.f(1)" is equivalent to\n calling "C.f(x, 1)".\n\n When an instance method object is derived from a class method\n object, the "class instance" stored in "__self__" will actually\n be the class itself, so that calling either "x.f(1)" or "C.f(1)"\n is equivalent to calling "f(C,1)" where "f" is the underlying\n function.\n\n Note that the transformation from function object to instance\n method object happens each time the attribute is retrieved from\n the instance. In some cases, a fruitful optimization is to\n assign the attribute to a local variable and call that local\n variable. Also notice that this transformation only happens for\n user-defined functions; other callable objects (and all non-\n callable objects) are retrieved without transformation. It is\n also important to note that user-defined functions which are\n attributes of a class instance are not converted to bound\n methods; this *only* happens when the function is an attribute\n of the class.\n\n Generator functions\n A function or method which uses the "yield" statement (see\n section *The yield statement*) is called a *generator function*.\n Such a function, when called, always returns an iterator object\n which can be used to execute the body of the function: calling\n the iterator\'s "iterator.__next__()" method will cause the\n function to execute until it provides a value using the "yield"\n statement. When the function executes a "return" statement or\n falls off the end, a "StopIteration" exception is raised and the\n iterator will have reached the end of the set of values to be\n returned.\n\n Coroutine functions\n A function or method which is defined using "async def" is\n called a *coroutine function*. Such a function, when called,\n returns a *coroutine* object. It may contain "await"\n expressions, as well as "async with" and "async for" statements.\n See also the *Coroutine Objects* section.\n\n Built-in functions\n A built-in function object is a wrapper around a C function.\n Examples of built-in functions are "len()" and "math.sin()"\n ("math" is a standard built-in module). The number and type of\n the arguments are determined by the C function. Special read-\n only attributes: "__doc__" is the function\'s documentation\n string, or "None" if unavailable; "__name__" is the function\'s\n name; "__self__" is set to "None" (but see the next item);\n "__module__" is the name of the module the function was defined\n in or "None" if unavailable.\n\n Built-in methods\n This is really a different disguise of a built-in function, this\n time containing an object passed to the C function as an\n implicit extra argument. An example of a built-in method is\n "alist.append()", assuming *alist* is a list object. In this\n case, the special read-only attribute "__self__" is set to the\n object denoted by *alist*.\n\n Classes\n Classes are callable. These objects normally act as factories\n for new instances of themselves, but variations are possible for\n class types that override "__new__()". The arguments of the\n call are passed to "__new__()" and, in the typical case, to\n "__init__()" to initialize the new instance.\n\n Class Instances\n Instances of arbitrary classes can be made callable by defining\n a "__call__()" method in their class.\n\nModules\n Modules are a basic organizational unit of Python code, and are\n created by the *import system* as invoked either by the "import"\n statement (see "import"), or by calling functions such as\n "importlib.import_module()" and built-in "__import__()". A module\n object has a namespace implemented by a dictionary object (this is\n the dictionary referenced by the "__globals__" attribute of\n functions defined in the module). Attribute references are\n translated to lookups in this dictionary, e.g., "m.x" is equivalent\n to "m.__dict__["x"]". A module object does not contain the code\n object used to initialize the module (since it isn\'t needed once\n the initialization is done).\n\n Attribute assignment updates the module\'s namespace dictionary,\n e.g., "m.x = 1" is equivalent to "m.__dict__["x"] = 1".\n\n Special read-only attribute: "__dict__" is the module\'s namespace\n as a dictionary object.\n\n **CPython implementation detail:** Because of the way CPython\n clears module dictionaries, the module dictionary will be cleared\n when the module falls out of scope even if the dictionary still has\n live references. To avoid this, copy the dictionary or keep the\n module around while using its dictionary directly.\n\n Predefined (writable) attributes: "__name__" is the module\'s name;\n "__doc__" is the module\'s documentation string, or "None" if\n unavailable; "__file__" is the pathname of the file from which the\n module was loaded, if it was loaded from a file. The "__file__"\n attribute may be missing for certain types of modules, such as C\n modules that are statically linked into the interpreter; for\n extension modules loaded dynamically from a shared library, it is\n the pathname of the shared library file.\n\nCustom classes\n Custom class types are typically created by class definitions (see\n section *Class definitions*). A class has a namespace implemented\n by a dictionary object. Class attribute references are translated\n to lookups in this dictionary, e.g., "C.x" is translated to\n "C.__dict__["x"]" (although there are a number of hooks which allow\n for other means of locating attributes). When the attribute name is\n not found there, the attribute search continues in the base\n classes. This search of the base classes uses the C3 method\n resolution order which behaves correctly even in the presence of\n \'diamond\' inheritance structures where there are multiple\n inheritance paths leading back to a common ancestor. Additional\n details on the C3 MRO used by Python can be found in the\n documentation accompanying the 2.3 release at\n https://www.python.org/download/releases/2.3/mro/.\n\n When a class attribute reference (for class "C", say) would yield a\n class method object, it is transformed into an instance method\n object whose "__self__" attributes is "C". When it would yield a\n static method object, it is transformed into the object wrapped by\n the static method object. See section *Implementing Descriptors*\n for another way in which attributes retrieved from a class may\n differ from those actually contained in its "__dict__".\n\n Class attribute assignments update the class\'s dictionary, never\n the dictionary of a base class.\n\n A class object can be called (see above) to yield a class instance\n (see below).\n\n Special attributes: "__name__" is the class name; "__module__" is\n the module name in which the class was defined; "__dict__" is the\n dictionary containing the class\'s namespace; "__bases__" is a tuple\n (possibly empty or a singleton) containing the base classes, in the\n order of their occurrence in the base class list; "__doc__" is the\n class\'s documentation string, or None if undefined.\n\nClass instances\n A class instance is created by calling a class object (see above).\n A class instance has a namespace implemented as a dictionary which\n is the first place in which attribute references are searched.\n When an attribute is not found there, and the instance\'s class has\n an attribute by that name, the search continues with the class\n attributes. If a class attribute is found that is a user-defined\n function object, it is transformed into an instance method object\n whose "__self__" attribute is the instance. Static method and\n class method objects are also transformed; see above under\n "Classes". See section *Implementing Descriptors* for another way\n in which attributes of a class retrieved via its instances may\n differ from the objects actually stored in the class\'s "__dict__".\n If no class attribute is found, and the object\'s class has a\n "__getattr__()" method, that is called to satisfy the lookup.\n\n Attribute assignments and deletions update the instance\'s\n dictionary, never a class\'s dictionary. If the class has a\n "__setattr__()" or "__delattr__()" method, this is called instead\n of updating the instance dictionary directly.\n\n Class instances can pretend to be numbers, sequences, or mappings\n if they have methods with certain special names. See section\n *Special method names*.\n\n Special attributes: "__dict__" is the attribute dictionary;\n "__class__" is the instance\'s class.\n\nI/O objects (also known as file objects)\n A *file object* represents an open file. Various shortcuts are\n available to create file objects: the "open()" built-in function,\n and also "os.popen()", "os.fdopen()", and the "makefile()" method\n of socket objects (and perhaps by other functions or methods\n provided by extension modules).\n\n The objects "sys.stdin", "sys.stdout" and "sys.stderr" are\n initialized to file objects corresponding to the interpreter\'s\n standard input, output and error streams; they are all open in text\n mode and therefore follow the interface defined by the\n "io.TextIOBase" abstract class.\n\nInternal types\n A few types used internally by the interpreter are exposed to the\n user. Their definitions may change with future versions of the\n interpreter, but they are mentioned here for completeness.\n\n Code objects\n Code objects represent *byte-compiled* executable Python code,\n or *bytecode*. The difference between a code object and a\n function object is that the function object contains an explicit\n reference to the function\'s globals (the module in which it was\n defined), while a code object contains no context; also the\n default argument values are stored in the function object, not\n in the code object (because they represent values calculated at\n run-time). Unlike function objects, code objects are immutable\n and contain no references (directly or indirectly) to mutable\n objects.\n\n Special read-only attributes: "co_name" gives the function name;\n "co_argcount" is the number of positional arguments (including\n arguments with default values); "co_nlocals" is the number of\n local variables used by the function (including arguments);\n "co_varnames" is a tuple containing the names of the local\n variables (starting with the argument names); "co_cellvars" is a\n tuple containing the names of local variables that are\n referenced by nested functions; "co_freevars" is a tuple\n containing the names of free variables; "co_code" is a string\n representing the sequence of bytecode instructions; "co_consts"\n is a tuple containing the literals used by the bytecode;\n "co_names" is a tuple containing the names used by the bytecode;\n "co_filename" is the filename from which the code was compiled;\n "co_firstlineno" is the first line number of the function;\n "co_lnotab" is a string encoding the mapping from bytecode\n offsets to line numbers (for details see the source code of the\n interpreter); "co_stacksize" is the required stack size\n (including local variables); "co_flags" is an integer encoding a\n number of flags for the interpreter.\n\n The following flag bits are defined for "co_flags": bit "0x04"\n is set if the function uses the "*arguments" syntax to accept an\n arbitrary number of positional arguments; bit "0x08" is set if\n the function uses the "**keywords" syntax to accept arbitrary\n keyword arguments; bit "0x20" is set if the function is a\n generator.\n\n Future feature declarations ("from __future__ import division")\n also use bits in "co_flags" to indicate whether a code object\n was compiled with a particular feature enabled: bit "0x2000" is\n set if the function was compiled with future division enabled;\n bits "0x10" and "0x1000" were used in earlier versions of\n Python.\n\n Other bits in "co_flags" are reserved for internal use.\n\n If a code object represents a function, the first item in\n "co_consts" is the documentation string of the function, or\n "None" if undefined.\n\n Frame objects\n Frame objects represent execution frames. They may occur in\n traceback objects (see below).\n\n Special read-only attributes: "f_back" is to the previous stack\n frame (towards the caller), or "None" if this is the bottom\n stack frame; "f_code" is the code object being executed in this\n frame; "f_locals" is the dictionary used to look up local\n variables; "f_globals" is used for global variables;\n "f_builtins" is used for built-in (intrinsic) names; "f_lasti"\n gives the precise instruction (this is an index into the\n bytecode string of the code object).\n\n Special writable attributes: "f_trace", if not "None", is a\n function called at the start of each source code line (this is\n used by the debugger); "f_lineno" is the current line number of\n the frame --- writing to this from within a trace function jumps\n to the given line (only for the bottom-most frame). A debugger\n can implement a Jump command (aka Set Next Statement) by writing\n to f_lineno.\n\n Frame objects support one method:\n\n frame.clear()\n\n This method clears all references to local variables held by\n the frame. Also, if the frame belonged to a generator, the\n generator is finalized. This helps break reference cycles\n involving frame objects (for example when catching an\n exception and storing its traceback for later use).\n\n "RuntimeError" is raised if the frame is currently executing.\n\n New in version 3.4.\n\n Traceback objects\n Traceback objects represent a stack trace of an exception. A\n traceback object is created when an exception occurs. When the\n search for an exception handler unwinds the execution stack, at\n each unwound level a traceback object is inserted in front of\n the current traceback. When an exception handler is entered,\n the stack trace is made available to the program. (See section\n *The try statement*.) It is accessible as the third item of the\n tuple returned by "sys.exc_info()". When the program contains no\n suitable handler, the stack trace is written (nicely formatted)\n to the standard error stream; if the interpreter is interactive,\n it is also made available to the user as "sys.last_traceback".\n\n Special read-only attributes: "tb_next" is the next level in the\n stack trace (towards the frame where the exception occurred), or\n "None" if there is no next level; "tb_frame" points to the\n execution frame of the current level; "tb_lineno" gives the line\n number where the exception occurred; "tb_lasti" indicates the\n precise instruction. The line number and last instruction in\n the traceback may differ from the line number of its frame\n object if the exception occurred in a "try" statement with no\n matching except clause or with a finally clause.\n\n Slice objects\n Slice objects are used to represent slices for "__getitem__()"\n methods. They are also created by the built-in "slice()"\n function.\n\n Special read-only attributes: "start" is the lower bound; "stop"\n is the upper bound; "step" is the step value; each is "None" if\n omitted. These attributes can have any type.\n\n Slice objects support one method:\n\n slice.indices(self, length)\n\n This method takes a single integer argument *length* and\n computes information about the slice that the slice object\n would describe if applied to a sequence of *length* items.\n It returns a tuple of three integers; respectively these are\n the *start* and *stop* indices and the *step* or stride\n length of the slice. Missing or out-of-bounds indices are\n handled in a manner consistent with regular slices.\n\n Static method objects\n Static method objects provide a way of defeating the\n transformation of function objects to method objects described\n above. A static method object is a wrapper around any other\n object, usually a user-defined method object. When a static\n method object is retrieved from a class or a class instance, the\n object actually returned is the wrapped object, which is not\n subject to any further transformation. Static method objects are\n not themselves callable, although the objects they wrap usually\n are. Static method objects are created by the built-in\n "staticmethod()" constructor.\n\n Class method objects\n A class method object, like a static method object, is a wrapper\n around another object that alters the way in which that object\n is retrieved from classes and class instances. The behaviour of\n class method objects upon such retrieval is described above,\n under "User-defined methods". Class method objects are created\n by the built-in "classmethod()" constructor.\n',
- 'typesfunctions': u'\nFunctions\n*********\n\nFunction objects are created by function definitions. The only\noperation on a function object is to call it: "func(argument-list)".\n\nThere are really two flavors of function objects: built-in functions\nand user-defined functions. Both support the same operation (to call\nthe function), but the implementation is different, hence the\ndifferent object types.\n\nSee *Function definitions* for more information.\n',
- 'typesmapping': u'\nMapping Types --- "dict"\n************************\n\nA *mapping* object maps *hashable* values to arbitrary objects.\nMappings are mutable objects. There is currently only one standard\nmapping type, the *dictionary*. (For other containers see the built-\nin "list", "set", and "tuple" classes, and the "collections" module.)\n\nA dictionary\'s keys are *almost* arbitrary values. Values that are\nnot *hashable*, that is, values containing lists, dictionaries or\nother mutable types (that are compared by value rather than by object\nidentity) may not be used as keys. Numeric types used for keys obey\nthe normal rules for numeric comparison: if two numbers compare equal\n(such as "1" and "1.0") then they can be used interchangeably to index\nthe same dictionary entry. (Note however, that since computers store\nfloating-point numbers as approximations it is usually unwise to use\nthem as dictionary keys.)\n\nDictionaries can be created by placing a comma-separated list of "key:\nvalue" pairs within braces, for example: "{\'jack\': 4098, \'sjoerd\':\n4127}" or "{4098: \'jack\', 4127: \'sjoerd\'}", or by the "dict"\nconstructor.\n\nclass class dict(**kwarg)\nclass class dict(mapping, **kwarg)\nclass class dict(iterable, **kwarg)\n\n Return a new dictionary initialized from an optional positional\n argument and a possibly empty set of keyword arguments.\n\n If no positional argument is given, an empty dictionary is created.\n If a positional argument is given and it is a mapping object, a\n dictionary is created with the same key-value pairs as the mapping\n object. Otherwise, the positional argument must be an *iterable*\n object. Each item in the iterable must itself be an iterable with\n exactly two objects. The first object of each item becomes a key\n in the new dictionary, and the second object the corresponding\n value. If a key occurs more than once, the last value for that key\n becomes the corresponding value in the new dictionary.\n\n If keyword arguments are given, the keyword arguments and their\n values are added to the dictionary created from the positional\n argument. If a key being added is already present, the value from\n the keyword argument replaces the value from the positional\n argument.\n\n To illustrate, the following examples all return a dictionary equal\n to "{"one": 1, "two": 2, "three": 3}":\n\n >>> a = dict(one=1, two=2, three=3)\n >>> b = {\'one\': 1, \'two\': 2, \'three\': 3}\n >>> c = dict(zip([\'one\', \'two\', \'three\'], [1, 2, 3]))\n >>> d = dict([(\'two\', 2), (\'one\', 1), (\'three\', 3)])\n >>> e = dict({\'three\': 3, \'one\': 1, \'two\': 2})\n >>> a == b == c == d == e\n True\n\n Providing keyword arguments as in the first example only works for\n keys that are valid Python identifiers. Otherwise, any valid keys\n can be used.\n\n These are the operations that dictionaries support (and therefore,\n custom mapping types should support too):\n\n len(d)\n\n Return the number of items in the dictionary *d*.\n\n d[key]\n\n Return the item of *d* with key *key*. Raises a "KeyError" if\n *key* is not in the map.\n\n If a subclass of dict defines a method "__missing__()" and *key*\n is not present, the "d[key]" operation calls that method with\n the key *key* as argument. The "d[key]" operation then returns\n or raises whatever is returned or raised by the\n "__missing__(key)" call. No other operations or methods invoke\n "__missing__()". If "__missing__()" is not defined, "KeyError"\n is raised. "__missing__()" must be a method; it cannot be an\n instance variable:\n\n >>> class Counter(dict):\n ... def __missing__(self, key):\n ... return 0\n >>> c = Counter()\n >>> c[\'red\']\n 0\n >>> c[\'red\'] += 1\n >>> c[\'red\']\n 1\n\n The example above shows part of the implementation of\n "collections.Counter". A different "__missing__" method is used\n by "collections.defaultdict".\n\n d[key] = value\n\n Set "d[key]" to *value*.\n\n del d[key]\n\n Remove "d[key]" from *d*. Raises a "KeyError" if *key* is not\n in the map.\n\n key in d\n\n Return "True" if *d* has a key *key*, else "False".\n\n key not in d\n\n Equivalent to "not key in d".\n\n iter(d)\n\n Return an iterator over the keys of the dictionary. This is a\n shortcut for "iter(d.keys())".\n\n clear()\n\n Remove all items from the dictionary.\n\n copy()\n\n Return a shallow copy of the dictionary.\n\n classmethod fromkeys(seq[, value])\n\n Create a new dictionary with keys from *seq* and values set to\n *value*.\n\n "fromkeys()" is a class method that returns a new dictionary.\n *value* defaults to "None".\n\n get(key[, default])\n\n Return the value for *key* if *key* is in the dictionary, else\n *default*. If *default* is not given, it defaults to "None", so\n that this method never raises a "KeyError".\n\n items()\n\n Return a new view of the dictionary\'s items ("(key, value)"\n pairs). See the *documentation of view objects*.\n\n keys()\n\n Return a new view of the dictionary\'s keys. See the\n *documentation of view objects*.\n\n pop(key[, default])\n\n If *key* is in the dictionary, remove it and return its value,\n else return *default*. If *default* is not given and *key* is\n not in the dictionary, a "KeyError" is raised.\n\n popitem()\n\n Remove and return an arbitrary "(key, value)" pair from the\n dictionary.\n\n "popitem()" is useful to destructively iterate over a\n dictionary, as often used in set algorithms. If the dictionary\n is empty, calling "popitem()" raises a "KeyError".\n\n setdefault(key[, default])\n\n If *key* is in the dictionary, return its value. If not, insert\n *key* with a value of *default* and return *default*. *default*\n defaults to "None".\n\n update([other])\n\n Update the dictionary with the key/value pairs from *other*,\n overwriting existing keys. Return "None".\n\n "update()" accepts either another dictionary object or an\n iterable of key/value pairs (as tuples or other iterables of\n length two). If keyword arguments are specified, the dictionary\n is then updated with those key/value pairs: "d.update(red=1,\n blue=2)".\n\n values()\n\n Return a new view of the dictionary\'s values. See the\n *documentation of view objects*.\n\n Dictionaries compare equal if and only if they have the same "(key,\n value)" pairs. Order comparisons (\'<\', \'<=\', \'>=\', \'>\') raise\n "TypeError".\n\nSee also: "types.MappingProxyType" can be used to create a read-only\n view of a "dict".\n\n\nDictionary view objects\n=======================\n\nThe objects returned by "dict.keys()", "dict.values()" and\n"dict.items()" are *view objects*. They provide a dynamic view on the\ndictionary\'s entries, which means that when the dictionary changes,\nthe view reflects these changes.\n\nDictionary views can be iterated over to yield their respective data,\nand support membership tests:\n\nlen(dictview)\n\n Return the number of entries in the dictionary.\n\niter(dictview)\n\n Return an iterator over the keys, values or items (represented as\n tuples of "(key, value)") in the dictionary.\n\n Keys and values are iterated over in an arbitrary order which is\n non-random, varies across Python implementations, and depends on\n the dictionary\'s history of insertions and deletions. If keys,\n values and items views are iterated over with no intervening\n modifications to the dictionary, the order of items will directly\n correspond. This allows the creation of "(value, key)" pairs using\n "zip()": "pairs = zip(d.values(), d.keys())". Another way to\n create the same list is "pairs = [(v, k) for (k, v) in d.items()]".\n\n Iterating views while adding or deleting entries in the dictionary\n may raise a "RuntimeError" or fail to iterate over all entries.\n\nx in dictview\n\n Return "True" if *x* is in the underlying dictionary\'s keys, values\n or items (in the latter case, *x* should be a "(key, value)"\n tuple).\n\nKeys views are set-like since their entries are unique and hashable.\nIf all values are hashable, so that "(key, value)" pairs are unique\nand hashable, then the items view is also set-like. (Values views are\nnot treated as set-like since the entries are generally not unique.)\nFor set-like views, all of the operations defined for the abstract\nbase class "collections.abc.Set" are available (for example, "==",\n"<", or "^").\n\nAn example of dictionary view usage:\n\n >>> dishes = {\'eggs\': 2, \'sausage\': 1, \'bacon\': 1, \'spam\': 500}\n >>> keys = dishes.keys()\n >>> values = dishes.values()\n\n >>> # iteration\n >>> n = 0\n >>> for val in values:\n ... n += val\n >>> print(n)\n 504\n\n >>> # keys and values are iterated over in the same order\n >>> list(keys)\n [\'eggs\', \'bacon\', \'sausage\', \'spam\']\n >>> list(values)\n [2, 1, 1, 500]\n\n >>> # view objects are dynamic and reflect dict changes\n >>> del dishes[\'eggs\']\n >>> del dishes[\'sausage\']\n >>> list(keys)\n [\'spam\', \'bacon\']\n\n >>> # set operations\n >>> keys & {\'eggs\', \'bacon\', \'salad\'}\n {\'bacon\'}\n >>> keys ^ {\'sausage\', \'juice\'}\n {\'juice\', \'sausage\', \'bacon\', \'spam\'}\n',
- 'typesmethods': u'\nMethods\n*******\n\nMethods are functions that are called using the attribute notation.\nThere are two flavors: built-in methods (such as "append()" on lists)\nand class instance methods. Built-in methods are described with the\ntypes that support them.\n\nIf you access a method (a function defined in a class namespace)\nthrough an instance, you get a special object: a *bound method* (also\ncalled *instance method*) object. When called, it will add the "self"\nargument to the argument list. Bound methods have two special read-\nonly attributes: "m.__self__" is the object on which the method\noperates, and "m.__func__" is the function implementing the method.\nCalling "m(arg-1, arg-2, ..., arg-n)" is completely equivalent to\ncalling "m.__func__(m.__self__, arg-1, arg-2, ..., arg-n)".\n\nLike function objects, bound method objects support getting arbitrary\nattributes. However, since method attributes are actually stored on\nthe underlying function object ("meth.__func__"), setting method\nattributes on bound methods is disallowed. Attempting to set an\nattribute on a method results in an "AttributeError" being raised. In\norder to set a method attribute, you need to explicitly set it on the\nunderlying function object:\n\n >>> class C:\n ... def method(self):\n ... pass\n ...\n >>> c = C()\n >>> c.method.whoami = \'my name is method\' # can\'t set on the method\n Traceback (most recent call last):\n File "<stdin>", line 1, in <module>\n AttributeError: \'method\' object has no attribute \'whoami\'\n >>> c.method.__func__.whoami = \'my name is method\'\n >>> c.method.whoami\n \'my name is method\'\n\nSee *The standard type hierarchy* for more information.\n',
- 'typesmodules': u'\nModules\n*******\n\nThe only special operation on a module is attribute access: "m.name",\nwhere *m* is a module and *name* accesses a name defined in *m*\'s\nsymbol table. Module attributes can be assigned to. (Note that the\n"import" statement is not, strictly speaking, an operation on a module\nobject; "import foo" does not require a module object named *foo* to\nexist, rather it requires an (external) *definition* for a module\nnamed *foo* somewhere.)\n\nA special attribute of every module is "__dict__". This is the\ndictionary containing the module\'s symbol table. Modifying this\ndictionary will actually change the module\'s symbol table, but direct\nassignment to the "__dict__" attribute is not possible (you can write\n"m.__dict__[\'a\'] = 1", which defines "m.a" to be "1", but you can\'t\nwrite "m.__dict__ = {}"). Modifying "__dict__" directly is not\nrecommended.\n\nModules built into the interpreter are written like this: "<module\n\'sys\' (built-in)>". If loaded from a file, they are written as\n"<module \'os\' from \'/usr/local/lib/pythonX.Y/os.pyc\'>".\n',
- 'typesseq': u'\nSequence Types --- "list", "tuple", "range"\n*******************************************\n\nThere are three basic sequence types: lists, tuples, and range\nobjects. Additional sequence types tailored for processing of *binary\ndata* and *text strings* are described in dedicated sections.\n\n\nCommon Sequence Operations\n==========================\n\nThe operations in the following table are supported by most sequence\ntypes, both mutable and immutable. The "collections.abc.Sequence" ABC\nis provided to make it easier to correctly implement these operations\non custom sequence types.\n\nThis table lists the sequence operations sorted in ascending priority.\nIn the table, *s* and *t* are sequences of the same type, *n*, *i*,\n*j* and *k* are integers and *x* is an arbitrary object that meets any\ntype and value restrictions imposed by *s*.\n\nThe "in" and "not in" operations have the same priorities as the\ncomparison operations. The "+" (concatenation) and "*" (repetition)\noperations have the same priority as the corresponding numeric\noperations.\n\n+----------------------------+----------------------------------+------------+\n| Operation | Result | Notes |\n+============================+==================================+============+\n| "x in s" | "True" if an item of *s* is | (1) |\n| | equal to *x*, else "False" | |\n+----------------------------+----------------------------------+------------+\n| "x not in s" | "False" if an item of *s* is | (1) |\n| | equal to *x*, else "True" | |\n+----------------------------+----------------------------------+------------+\n| "s + t" | the concatenation of *s* and *t* | (6)(7) |\n+----------------------------+----------------------------------+------------+\n| "s * n" or "n * s" | equivalent to adding *s* to | (2)(7) |\n| | itself *n* times | |\n+----------------------------+----------------------------------+------------+\n| "s[i]" | *i*th item of *s*, origin 0 | (3) |\n+----------------------------+----------------------------------+------------+\n| "s[i:j]" | slice of *s* from *i* to *j* | (3)(4) |\n+----------------------------+----------------------------------+------------+\n| "s[i:j:k]" | slice of *s* from *i* to *j* | (3)(5) |\n| | with step *k* | |\n+----------------------------+----------------------------------+------------+\n| "len(s)" | length of *s* | |\n+----------------------------+----------------------------------+------------+\n| "min(s)" | smallest item of *s* | |\n+----------------------------+----------------------------------+------------+\n| "max(s)" | largest item of *s* | |\n+----------------------------+----------------------------------+------------+\n| "s.index(x[, i[, j]])" | index of the first occurrence of | (8) |\n| | *x* in *s* (at or after index | |\n| | *i* and before index *j*) | |\n+----------------------------+----------------------------------+------------+\n| "s.count(x)" | total number of occurrences of | |\n| | *x* in *s* | |\n+----------------------------+----------------------------------+------------+\n\nSequences of the same type also support comparisons. In particular,\ntuples and lists are compared lexicographically by comparing\ncorresponding elements. This means that to compare equal, every\nelement must compare equal and the two sequences must be of the same\ntype and have the same length. (For full details see *Comparisons* in\nthe language reference.)\n\nNotes:\n\n1. While the "in" and "not in" operations are used only for simple\n containment testing in the general case, some specialised sequences\n (such as "str", "bytes" and "bytearray") also use them for\n subsequence testing:\n\n >>> "gg" in "eggs"\n True\n\n2. Values of *n* less than "0" are treated as "0" (which yields an\n empty sequence of the same type as *s*). Note that items in the\n sequence *s* are not copied; they are referenced multiple times.\n This often haunts new Python programmers; consider:\n\n >>> lists = [[]] * 3\n >>> lists\n [[], [], []]\n >>> lists[0].append(3)\n >>> lists\n [[3], [3], [3]]\n\n What has happened is that "[[]]" is a one-element list containing\n an empty list, so all three elements of "[[]] * 3" are references\n to this single empty list. Modifying any of the elements of\n "lists" modifies this single list. You can create a list of\n different lists this way:\n\n >>> lists = [[] for i in range(3)]\n >>> lists[0].append(3)\n >>> lists[1].append(5)\n >>> lists[2].append(7)\n >>> lists\n [[3], [5], [7]]\n\n Further explanation is available in the FAQ entry *How do I create\n a multidimensional list?*.\n\n3. If *i* or *j* is negative, the index is relative to the end of\n the string: "len(s) + i" or "len(s) + j" is substituted. But note\n that "-0" is still "0".\n\n4. The slice of *s* from *i* to *j* is defined as the sequence of\n items with index *k* such that "i <= k < j". If *i* or *j* is\n greater than "len(s)", use "len(s)". If *i* is omitted or "None",\n use "0". If *j* is omitted or "None", use "len(s)". If *i* is\n greater than or equal to *j*, the slice is empty.\n\n5. The slice of *s* from *i* to *j* with step *k* is defined as the\n sequence of items with index "x = i + n*k" such that "0 <= n <\n (j-i)/k". In other words, the indices are "i", "i+k", "i+2*k",\n "i+3*k" and so on, stopping when *j* is reached (but never\n including *j*). If *i* or *j* is greater than "len(s)", use\n "len(s)". If *i* or *j* are omitted or "None", they become "end"\n values (which end depends on the sign of *k*). Note, *k* cannot be\n zero. If *k* is "None", it is treated like "1".\n\n6. Concatenating immutable sequences always results in a new\n object. This means that building up a sequence by repeated\n concatenation will have a quadratic runtime cost in the total\n sequence length. To get a linear runtime cost, you must switch to\n one of the alternatives below:\n\n * if concatenating "str" objects, you can build a list and use\n "str.join()" at the end or else write to an "io.StringIO"\n instance and retrieve its value when complete\n\n * if concatenating "bytes" objects, you can similarly use\n "bytes.join()" or "io.BytesIO", or you can do in-place\n concatenation with a "bytearray" object. "bytearray" objects are\n mutable and have an efficient overallocation mechanism\n\n * if concatenating "tuple" objects, extend a "list" instead\n\n * for other types, investigate the relevant class documentation\n\n7. Some sequence types (such as "range") only support item\n sequences that follow specific patterns, and hence don\'t support\n sequence concatenation or repetition.\n\n8. "index" raises "ValueError" when *x* is not found in *s*. When\n supported, the additional arguments to the index method allow\n efficient searching of subsections of the sequence. Passing the\n extra arguments is roughly equivalent to using "s[i:j].index(x)",\n only without copying any data and with the returned index being\n relative to the start of the sequence rather than the start of the\n slice.\n\n\nImmutable Sequence Types\n========================\n\nThe only operation that immutable sequence types generally implement\nthat is not also implemented by mutable sequence types is support for\nthe "hash()" built-in.\n\nThis support allows immutable sequences, such as "tuple" instances, to\nbe used as "dict" keys and stored in "set" and "frozenset" instances.\n\nAttempting to hash an immutable sequence that contains unhashable\nvalues will result in "TypeError".\n\n\nMutable Sequence Types\n======================\n\nThe operations in the following table are defined on mutable sequence\ntypes. The "collections.abc.MutableSequence" ABC is provided to make\nit easier to correctly implement these operations on custom sequence\ntypes.\n\nIn the table *s* is an instance of a mutable sequence type, *t* is any\niterable object and *x* is an arbitrary object that meets any type and\nvalue restrictions imposed by *s* (for example, "bytearray" only\naccepts integers that meet the value restriction "0 <= x <= 255").\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation | Result | Notes |\n+================================+==================================+=======================+\n| "s[i] = x" | item *i* of *s* is replaced by | |\n| | *x* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s[i:j] = t" | slice of *s* from *i* to *j* is | |\n| | replaced by the contents of the | |\n| | iterable *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "del s[i:j]" | same as "s[i:j] = []" | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s[i:j:k] = t" | the elements of "s[i:j:k]" are | (1) |\n| | replaced by those of *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "del s[i:j:k]" | removes the elements of | |\n| | "s[i:j:k]" from the list | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.append(x)" | appends *x* to the end of the | |\n| | sequence (same as | |\n| | "s[len(s):len(s)] = [x]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.clear()" | removes all items from "s" (same | (5) |\n| | as "del s[:]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.copy()" | creates a shallow copy of "s" | (5) |\n| | (same as "s[:]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.extend(t)" or "s += t" | extends *s* with the contents of | |\n| | *t* (for the most part the same | |\n| | as "s[len(s):len(s)] = t") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s *= n" | updates *s* with its contents | (6) |\n| | repeated *n* times | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.insert(i, x)" | inserts *x* into *s* at the | |\n| | index given by *i* (same as | |\n| | "s[i:i] = [x]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.pop([i])" | retrieves the item at *i* and | (2) |\n| | also removes it from *s* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.remove(x)" | remove the first item from *s* | (3) |\n| | where "s[i] == x" | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.reverse()" | reverses the items of *s* in | (4) |\n| | place | |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. The optional argument *i* defaults to "-1", so that by default\n the last item is removed and returned.\n\n3. "remove" raises "ValueError" when *x* is not found in *s*.\n\n4. The "reverse()" method modifies the sequence in place for\n economy of space when reversing a large sequence. To remind users\n that it operates by side effect, it does not return the reversed\n sequence.\n\n5. "clear()" and "copy()" are included for consistency with the\n interfaces of mutable containers that don\'t support slicing\n operations (such as "dict" and "set")\n\n New in version 3.3: "clear()" and "copy()" methods.\n\n6. The value *n* is an integer, or an object implementing\n "__index__()". Zero and negative values of *n* clear the sequence.\n Items in the sequence are not copied; they are referenced multiple\n times, as explained for "s * n" under *Common Sequence Operations*.\n\n\nLists\n=====\n\nLists are mutable sequences, typically used to store collections of\nhomogeneous items (where the precise degree of similarity will vary by\napplication).\n\nclass class list([iterable])\n\n Lists may be constructed in several ways:\n\n * Using a pair of square brackets to denote the empty list: "[]"\n\n * Using square brackets, separating items with commas: "[a]",\n "[a, b, c]"\n\n * Using a list comprehension: "[x for x in iterable]"\n\n * Using the type constructor: "list()" or "list(iterable)"\n\n The constructor builds a list whose items are the same and in the\n same order as *iterable*\'s items. *iterable* may be either a\n sequence, a container that supports iteration, or an iterator\n object. If *iterable* is already a list, a copy is made and\n returned, similar to "iterable[:]". For example, "list(\'abc\')"\n returns "[\'a\', \'b\', \'c\']" and "list( (1, 2, 3) )" returns "[1, 2,\n 3]". If no argument is given, the constructor creates a new empty\n list, "[]".\n\n Many other operations also produce lists, including the "sorted()"\n built-in.\n\n Lists implement all of the *common* and *mutable* sequence\n operations. Lists also provide the following additional method:\n\n sort(*, key=None, reverse=None)\n\n This method sorts the list in place, using only "<" comparisons\n between items. Exceptions are not suppressed - if any comparison\n operations fail, the entire sort operation will fail (and the\n list will likely be left in a partially modified state).\n\n "sort()" accepts two arguments that can only be passed by\n keyword (*keyword-only arguments*):\n\n *key* specifies a function of one argument that is used to\n extract a comparison key from each list element (for example,\n "key=str.lower"). The key corresponding to each item in the list\n is calculated once and then used for the entire sorting process.\n The default value of "None" means that list items are sorted\n directly without calculating a separate key value.\n\n The "functools.cmp_to_key()" utility is available to convert a\n 2.x style *cmp* function to a *key* function.\n\n *reverse* is a boolean value. If set to "True", then the list\n elements are sorted as if each comparison were reversed.\n\n This method modifies the sequence in place for economy of space\n when sorting a large sequence. To remind users that it operates\n by side effect, it does not return the sorted sequence (use\n "sorted()" to explicitly request a new sorted list instance).\n\n The "sort()" method is guaranteed to be stable. A sort is\n stable if it guarantees not to change the relative order of\n elements that compare equal --- this is helpful for sorting in\n multiple passes (for example, sort by department, then by salary\n grade).\n\n **CPython implementation detail:** While a list is being sorted,\n the effect of attempting to mutate, or even inspect, the list is\n undefined. The C implementation of Python makes the list appear\n empty for the duration, and raises "ValueError" if it can detect\n that the list has been mutated during a sort.\n\n\nTuples\n======\n\nTuples are immutable sequences, typically used to store collections of\nheterogeneous data (such as the 2-tuples produced by the "enumerate()"\nbuilt-in). Tuples are also used for cases where an immutable sequence\nof homogeneous data is needed (such as allowing storage in a "set" or\n"dict" instance).\n\nclass class tuple([iterable])\n\n Tuples may be constructed in a number of ways:\n\n * Using a pair of parentheses to denote the empty tuple: "()"\n\n * Using a trailing comma for a singleton tuple: "a," or "(a,)"\n\n * Separating items with commas: "a, b, c" or "(a, b, c)"\n\n * Using the "tuple()" built-in: "tuple()" or "tuple(iterable)"\n\n The constructor builds a tuple whose items are the same and in the\n same order as *iterable*\'s items. *iterable* may be either a\n sequence, a container that supports iteration, or an iterator\n object. If *iterable* is already a tuple, it is returned\n unchanged. For example, "tuple(\'abc\')" returns "(\'a\', \'b\', \'c\')"\n and "tuple( [1, 2, 3] )" returns "(1, 2, 3)". If no argument is\n given, the constructor creates a new empty tuple, "()".\n\n Note that it is actually the comma which makes a tuple, not the\n parentheses. The parentheses are optional, except in the empty\n tuple case, or when they are needed to avoid syntactic ambiguity.\n For example, "f(a, b, c)" is a function call with three arguments,\n while "f((a, b, c))" is a function call with a 3-tuple as the sole\n argument.\n\n Tuples implement all of the *common* sequence operations.\n\nFor heterogeneous collections of data where access by name is clearer\nthan access by index, "collections.namedtuple()" may be a more\nappropriate choice than a simple tuple object.\n\n\nRanges\n======\n\nThe "range" type represents an immutable sequence of numbers and is\ncommonly used for looping a specific number of times in "for" loops.\n\nclass class range(stop)\nclass class range(start, stop[, step])\n\n The arguments to the range constructor must be integers (either\n built-in "int" or any object that implements the "__index__"\n special method). If the *step* argument is omitted, it defaults to\n "1". If the *start* argument is omitted, it defaults to "0". If\n *step* is zero, "ValueError" is raised.\n\n For a positive *step*, the contents of a range "r" are determined\n by the formula "r[i] = start + step*i" where "i >= 0" and "r[i] <\n stop".\n\n For a negative *step*, the contents of the range are still\n determined by the formula "r[i] = start + step*i", but the\n constraints are "i >= 0" and "r[i] > stop".\n\n A range object will be empty if "r[0]" does not meet the value\n constraint. Ranges do support negative indices, but these are\n interpreted as indexing from the end of the sequence determined by\n the positive indices.\n\n Ranges containing absolute values larger than "sys.maxsize" are\n permitted but some features (such as "len()") may raise\n "OverflowError".\n\n Range examples:\n\n >>> list(range(10))\n [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n >>> list(range(1, 11))\n [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n >>> list(range(0, 30, 5))\n [0, 5, 10, 15, 20, 25]\n >>> list(range(0, 10, 3))\n [0, 3, 6, 9]\n >>> list(range(0, -10, -1))\n [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]\n >>> list(range(0))\n []\n >>> list(range(1, 0))\n []\n\n Ranges implement all of the *common* sequence operations except\n concatenation and repetition (due to the fact that range objects\n can only represent sequences that follow a strict pattern and\n repetition and concatenation will usually violate that pattern).\n\n start\n\n The value of the *start* parameter (or "0" if the parameter was\n not supplied)\n\n stop\n\n The value of the *stop* parameter\n\n step\n\n The value of the *step* parameter (or "1" if the parameter was\n not supplied)\n\nThe advantage of the "range" type over a regular "list" or "tuple" is\nthat a "range" object will always take the same (small) amount of\nmemory, no matter the size of the range it represents (as it only\nstores the "start", "stop" and "step" values, calculating individual\nitems and subranges as needed).\n\nRange objects implement the "collections.abc.Sequence" ABC, and\nprovide features such as containment tests, element index lookup,\nslicing and support for negative indices (see *Sequence Types ---\nlist, tuple, range*):\n\n>>> r = range(0, 20, 2)\n>>> r\nrange(0, 20, 2)\n>>> 11 in r\nFalse\n>>> 10 in r\nTrue\n>>> r.index(10)\n5\n>>> r[5]\n10\n>>> r[:5]\nrange(0, 10, 2)\n>>> r[-1]\n18\n\nTesting range objects for equality with "==" and "!=" compares them as\nsequences. That is, two range objects are considered equal if they\nrepresent the same sequence of values. (Note that two range objects\nthat compare equal might have different "start", "stop" and "step"\nattributes, for example "range(0) == range(2, 1, 3)" or "range(0, 3,\n2) == range(0, 4, 2)".)\n\nChanged in version 3.2: Implement the Sequence ABC. Support slicing\nand negative indices. Test "int" objects for membership in constant\ntime instead of iterating through all items.\n\nChanged in version 3.3: Define \'==\' and \'!=\' to compare range objects\nbased on the sequence of values they define (instead of comparing\nbased on object identity).\n\nNew in version 3.3: The "start", "stop" and "step" attributes.\n',
- 'typesseq-mutable': u'\nMutable Sequence Types\n**********************\n\nThe operations in the following table are defined on mutable sequence\ntypes. The "collections.abc.MutableSequence" ABC is provided to make\nit easier to correctly implement these operations on custom sequence\ntypes.\n\nIn the table *s* is an instance of a mutable sequence type, *t* is any\niterable object and *x* is an arbitrary object that meets any type and\nvalue restrictions imposed by *s* (for example, "bytearray" only\naccepts integers that meet the value restriction "0 <= x <= 255").\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation | Result | Notes |\n+================================+==================================+=======================+\n| "s[i] = x" | item *i* of *s* is replaced by | |\n| | *x* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s[i:j] = t" | slice of *s* from *i* to *j* is | |\n| | replaced by the contents of the | |\n| | iterable *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "del s[i:j]" | same as "s[i:j] = []" | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s[i:j:k] = t" | the elements of "s[i:j:k]" are | (1) |\n| | replaced by those of *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "del s[i:j:k]" | removes the elements of | |\n| | "s[i:j:k]" from the list | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.append(x)" | appends *x* to the end of the | |\n| | sequence (same as | |\n| | "s[len(s):len(s)] = [x]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.clear()" | removes all items from "s" (same | (5) |\n| | as "del s[:]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.copy()" | creates a shallow copy of "s" | (5) |\n| | (same as "s[:]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.extend(t)" or "s += t" | extends *s* with the contents of | |\n| | *t* (for the most part the same | |\n| | as "s[len(s):len(s)] = t") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s *= n" | updates *s* with its contents | (6) |\n| | repeated *n* times | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.insert(i, x)" | inserts *x* into *s* at the | |\n| | index given by *i* (same as | |\n| | "s[i:i] = [x]") | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.pop([i])" | retrieves the item at *i* and | (2) |\n| | also removes it from *s* | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.remove(x)" | remove the first item from *s* | (3) |\n| | where "s[i] == x" | |\n+--------------------------------+----------------------------------+-----------------------+\n| "s.reverse()" | reverses the items of *s* in | (4) |\n| | place | |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. The optional argument *i* defaults to "-1", so that by default\n the last item is removed and returned.\n\n3. "remove" raises "ValueError" when *x* is not found in *s*.\n\n4. The "reverse()" method modifies the sequence in place for\n economy of space when reversing a large sequence. To remind users\n that it operates by side effect, it does not return the reversed\n sequence.\n\n5. "clear()" and "copy()" are included for consistency with the\n interfaces of mutable containers that don\'t support slicing\n operations (such as "dict" and "set")\n\n New in version 3.3: "clear()" and "copy()" methods.\n\n6. The value *n* is an integer, or an object implementing\n "__index__()". Zero and negative values of *n* clear the sequence.\n Items in the sequence are not copied; they are referenced multiple\n times, as explained for "s * n" under *Common Sequence Operations*.\n',
- 'unary': u'\nUnary arithmetic and bitwise operations\n***************************************\n\nAll unary arithmetic and bitwise operations have the same priority:\n\n u_expr ::= power | "-" u_expr | "+" u_expr | "~" u_expr\n\nThe unary "-" (minus) operator yields the negation of its numeric\nargument.\n\nThe unary "+" (plus) operator yields its numeric argument unchanged.\n\nThe unary "~" (invert) operator yields the bitwise inversion of its\ninteger argument. The bitwise inversion of "x" is defined as\n"-(x+1)". It only applies to integral numbers.\n\nIn all three cases, if the argument does not have the proper type, a\n"TypeError" exception is raised.\n',
- 'while': u'\nThe "while" statement\n*********************\n\nThe "while" statement is used for repeated execution as long as an\nexpression is true:\n\n while_stmt ::= "while" expression ":" suite\n ["else" ":" suite]\n\nThis repeatedly tests the expression and, if it is true, executes the\nfirst suite; if the expression is false (which may be the first time\nit is tested) the suite of the "else" clause, if present, is executed\nand the loop terminates.\n\nA "break" statement executed in the first suite terminates the loop\nwithout executing the "else" clause\'s suite. A "continue" statement\nexecuted in the first suite skips the rest of the suite and goes back\nto testing the expression.\n',
- 'with': u'\nThe "with" statement\n********************\n\nThe "with" statement is used to wrap the execution of a block with\nmethods defined by a context manager (see section *With Statement\nContext Managers*). This allows common "try"..."except"..."finally"\nusage patterns to be encapsulated for convenient reuse.\n\n with_stmt ::= "with" with_item ("," with_item)* ":" suite\n with_item ::= expression ["as" target]\n\nThe execution of the "with" statement with one "item" proceeds as\nfollows:\n\n1. The context expression (the expression given in the "with_item")\n is evaluated to obtain a context manager.\n\n2. The context manager\'s "__exit__()" is loaded for later use.\n\n3. The context manager\'s "__enter__()" method is invoked.\n\n4. If a target was included in the "with" statement, the return\n value from "__enter__()" is assigned to it.\n\n Note: The "with" statement guarantees that if the "__enter__()"\n method returns without an error, then "__exit__()" will always be\n called. Thus, if an error occurs during the assignment to the\n target list, it will be treated the same as an error occurring\n within the suite would be. See step 6 below.\n\n5. The suite is executed.\n\n6. The context manager\'s "__exit__()" method is invoked. If an\n exception caused the suite to be exited, its type, value, and\n traceback are passed as arguments to "__exit__()". Otherwise, three\n "None" arguments are supplied.\n\n If the suite was exited due to an exception, and the return value\n from the "__exit__()" method was false, the exception is reraised.\n If the return value was true, the exception is suppressed, and\n execution continues with the statement following the "with"\n statement.\n\n If the suite was exited for any reason other than an exception, the\n return value from "__exit__()" is ignored, and execution proceeds\n at the normal location for the kind of exit that was taken.\n\nWith more than one item, the context managers are processed as if\nmultiple "with" statements were nested:\n\n with A() as a, B() as b:\n suite\n\nis equivalent to\n\n with A() as a:\n with B() as b:\n suite\n\nChanged in version 3.1: Support for multiple context expressions.\n\nSee also: **PEP 343** - The "with" statement\n\n The specification, background, and examples for the Python "with"\n statement.\n',
- 'yield': u'\nThe "yield" statement\n*********************\n\n yield_stmt ::= yield_expression\n\nA "yield" statement is semantically equivalent to a *yield\nexpression*. The yield statement can be used to omit the parentheses\nthat would otherwise be required in the equivalent yield expression\nstatement. For example, the yield statements\n\n yield <expr>\n yield from <expr>\n\nare equivalent to the yield expression statements\n\n (yield <expr>)\n (yield from <expr>)\n\nYield expressions and statements are only used when defining a\n*generator* function, and are only used in the body of the generator\nfunction. Using yield in a function definition is sufficient to cause\nthat definition to create a generator function instead of a normal\nfunction.\n\nFor full details of "yield" semantics, refer to the *Yield\nexpressions* section.\n'}
+# Autogenerated by Sphinx on Mon Jun 13 16:49:58 2016
+topics = {'assert': '\n'
+ 'The "assert" statement\n'
+ '**********************\n'
+ '\n'
+ 'Assert statements are a convenient way to insert debugging '
+ 'assertions\n'
+ 'into a program:\n'
+ '\n'
+ ' assert_stmt ::= "assert" expression ["," expression]\n'
+ '\n'
+ 'The simple form, "assert expression", is equivalent to\n'
+ '\n'
+ ' if __debug__:\n'
+ ' if not expression: raise AssertionError\n'
+ '\n'
+ 'The extended form, "assert expression1, expression2", is '
+ 'equivalent to\n'
+ '\n'
+ ' if __debug__:\n'
+ ' if not expression1: raise AssertionError(expression2)\n'
+ '\n'
+ 'These equivalences assume that "__debug__" and "AssertionError" '
+ 'refer\n'
+ 'to the built-in variables with those names. In the current\n'
+ 'implementation, the built-in variable "__debug__" is "True" under\n'
+ 'normal circumstances, "False" when optimization is requested '
+ '(command\n'
+ 'line option -O). The current code generator emits no code for an\n'
+ 'assert statement when optimization is requested at compile time. '
+ 'Note\n'
+ 'that it is unnecessary to include the source code for the '
+ 'expression\n'
+ 'that failed in the error message; it will be displayed as part of '
+ 'the\n'
+ 'stack trace.\n'
+ '\n'
+ 'Assignments to "__debug__" are illegal. The value for the '
+ 'built-in\n'
+ 'variable is determined when the interpreter starts.\n',
+ 'assignment': '\n'
+ 'Assignment statements\n'
+ '*********************\n'
+ '\n'
+ 'Assignment statements are used to (re)bind names to values and '
+ 'to\n'
+ 'modify attributes or items of mutable objects:\n'
+ '\n'
+ ' assignment_stmt ::= (target_list "=")+ (starred_expression '
+ '| yield_expression)\n'
+ ' target_list ::= target ("," target)* [","]\n'
+ ' target ::= identifier\n'
+ ' | "(" [target_list] ")"\n'
+ ' | "[" [target_list] "]"\n'
+ ' | attributeref\n'
+ ' | subscription\n'
+ ' | slicing\n'
+ ' | "*" target\n'
+ '\n'
+ '(See section Primaries for the syntax definitions for '
+ '*attributeref*,\n'
+ '*subscription*, and *slicing*.)\n'
+ '\n'
+ 'An assignment statement evaluates the expression list '
+ '(remember that\n'
+ 'this can be a single expression or a comma-separated list, the '
+ 'latter\n'
+ 'yielding a tuple) and assigns the single resulting object to '
+ 'each of\n'
+ 'the target lists, from left to right.\n'
+ '\n'
+ 'Assignment is defined recursively depending on the form of the '
+ 'target\n'
+ '(list). When a target is part of a mutable object (an '
+ 'attribute\n'
+ 'reference, subscription or slicing), the mutable object must\n'
+ 'ultimately perform the assignment and decide about its '
+ 'validity, and\n'
+ 'may raise an exception if the assignment is unacceptable. The '
+ 'rules\n'
+ 'observed by various types and the exceptions raised are given '
+ 'with the\n'
+ 'definition of the object types (see section The standard type\n'
+ 'hierarchy).\n'
+ '\n'
+ 'Assignment of an object to a target list, optionally enclosed '
+ 'in\n'
+ 'parentheses or square brackets, is recursively defined as '
+ 'follows.\n'
+ '\n'
+ '* If the target list is empty: The object must also be an '
+ 'empty\n'
+ ' iterable.\n'
+ '\n'
+ '* If the target list is a single target in parentheses: The '
+ 'object\n'
+ ' is assigned to that target.\n'
+ '\n'
+ '* If the target list is a comma-separated list of targets, or '
+ 'a\n'
+ ' single target in square brackets: The object must be an '
+ 'iterable\n'
+ ' with the same number of items as there are targets in the '
+ 'target\n'
+ ' list, and the items are assigned, from left to right, to '
+ 'the\n'
+ ' corresponding targets.\n'
+ '\n'
+ ' * If the target list contains one target prefixed with an\n'
+ ' asterisk, called a "starred" target: The object must be '
+ 'an\n'
+ ' iterable with at least as many items as there are targets '
+ 'in the\n'
+ ' target list, minus one. The first items of the iterable '
+ 'are\n'
+ ' assigned, from left to right, to the targets before the '
+ 'starred\n'
+ ' target. The final items of the iterable are assigned to '
+ 'the\n'
+ ' targets after the starred target. A list of the remaining '
+ 'items\n'
+ ' in the iterable is then assigned to the starred target '
+ '(the list\n'
+ ' can be empty).\n'
+ '\n'
+ ' * Else: The object must be an iterable with the same number '
+ 'of\n'
+ ' items as there are targets in the target list, and the '
+ 'items are\n'
+ ' assigned, from left to right, to the corresponding '
+ 'targets.\n'
+ '\n'
+ 'Assignment of an object to a single target is recursively '
+ 'defined as\n'
+ 'follows.\n'
+ '\n'
+ '* If the target is an identifier (name):\n'
+ '\n'
+ ' * If the name does not occur in a "global" or "nonlocal" '
+ 'statement\n'
+ ' in the current code block: the name is bound to the object '
+ 'in the\n'
+ ' current local namespace.\n'
+ '\n'
+ ' * Otherwise: the name is bound to the object in the global\n'
+ ' namespace or the outer namespace determined by '
+ '"nonlocal",\n'
+ ' respectively.\n'
+ '\n'
+ ' The name is rebound if it was already bound. This may cause '
+ 'the\n'
+ ' reference count for the object previously bound to the name '
+ 'to reach\n'
+ ' zero, causing the object to be deallocated and its '
+ 'destructor (if it\n'
+ ' has one) to be called.\n'
+ '\n'
+ '* If the target is an attribute reference: The primary '
+ 'expression in\n'
+ ' the reference is evaluated. It should yield an object with\n'
+ ' assignable attributes; if this is not the case, "TypeError" '
+ 'is\n'
+ ' raised. That object is then asked to assign the assigned '
+ 'object to\n'
+ ' the given attribute; if it cannot perform the assignment, it '
+ 'raises\n'
+ ' an exception (usually but not necessarily '
+ '"AttributeError").\n'
+ '\n'
+ ' Note: If the object is a class instance and the attribute '
+ 'reference\n'
+ ' occurs on both sides of the assignment operator, the RHS '
+ 'expression,\n'
+ ' "a.x" can access either an instance attribute or (if no '
+ 'instance\n'
+ ' attribute exists) a class attribute. The LHS target "a.x" '
+ 'is always\n'
+ ' set as an instance attribute, creating it if necessary. '
+ 'Thus, the\n'
+ ' two occurrences of "a.x" do not necessarily refer to the '
+ 'same\n'
+ ' attribute: if the RHS expression refers to a class '
+ 'attribute, the\n'
+ ' LHS creates a new instance attribute as the target of the\n'
+ ' assignment:\n'
+ '\n'
+ ' class Cls:\n'
+ ' x = 3 # class variable\n'
+ ' inst = Cls()\n'
+ ' inst.x = inst.x + 1 # writes inst.x as 4 leaving Cls.x '
+ 'as 3\n'
+ '\n'
+ ' This description does not necessarily apply to descriptor\n'
+ ' attributes, such as properties created with "property()".\n'
+ '\n'
+ '* If the target is a subscription: The primary expression in '
+ 'the\n'
+ ' reference is evaluated. It should yield either a mutable '
+ 'sequence\n'
+ ' object (such as a list) or a mapping object (such as a '
+ 'dictionary).\n'
+ ' Next, the subscript expression is evaluated.\n'
+ '\n'
+ ' If the primary is a mutable sequence object (such as a '
+ 'list), the\n'
+ ' subscript must yield an integer. If it is negative, the '
+ "sequence's\n"
+ ' length is added to it. The resulting value must be a '
+ 'nonnegative\n'
+ " integer less than the sequence's length, and the sequence is "
+ 'asked\n'
+ ' to assign the assigned object to its item with that index. '
+ 'If the\n'
+ ' index is out of range, "IndexError" is raised (assignment to '
+ 'a\n'
+ ' subscripted sequence cannot add new items to a list).\n'
+ '\n'
+ ' If the primary is a mapping object (such as a dictionary), '
+ 'the\n'
+ " subscript must have a type compatible with the mapping's key "
+ 'type,\n'
+ ' and the mapping is then asked to create a key/datum pair '
+ 'which maps\n'
+ ' the subscript to the assigned object. This can either '
+ 'replace an\n'
+ ' existing key/value pair with the same key value, or insert a '
+ 'new\n'
+ ' key/value pair (if no key with the same value existed).\n'
+ '\n'
+ ' For user-defined objects, the "__setitem__()" method is '
+ 'called with\n'
+ ' appropriate arguments.\n'
+ '\n'
+ '* If the target is a slicing: The primary expression in the\n'
+ ' reference is evaluated. It should yield a mutable sequence '
+ 'object\n'
+ ' (such as a list). The assigned object should be a sequence '
+ 'object\n'
+ ' of the same type. Next, the lower and upper bound '
+ 'expressions are\n'
+ ' evaluated, insofar they are present; defaults are zero and '
+ 'the\n'
+ " sequence's length. The bounds should evaluate to integers. "
+ 'If\n'
+ " either bound is negative, the sequence's length is added to "
+ 'it. The\n'
+ ' resulting bounds are clipped to lie between zero and the '
+ "sequence's\n"
+ ' length, inclusive. Finally, the sequence object is asked to '
+ 'replace\n'
+ ' the slice with the items of the assigned sequence. The '
+ 'length of\n'
+ ' the slice may be different from the length of the assigned '
+ 'sequence,\n'
+ ' thus changing the length of the target sequence, if the '
+ 'target\n'
+ ' sequence allows it.\n'
+ '\n'
+ '**CPython implementation detail:** In the current '
+ 'implementation, the\n'
+ 'syntax for targets is taken to be the same as for expressions, '
+ 'and\n'
+ 'invalid syntax is rejected during the code generation phase, '
+ 'causing\n'
+ 'less detailed error messages.\n'
+ '\n'
+ 'Although the definition of assignment implies that overlaps '
+ 'between\n'
+ "the left-hand side and the right-hand side are 'simultaneous' "
+ '(for\n'
+ 'example "a, b = b, a" swaps two variables), overlaps *within* '
+ 'the\n'
+ 'collection of assigned-to variables occur left-to-right, '
+ 'sometimes\n'
+ 'resulting in confusion. For instance, the following program '
+ 'prints\n'
+ '"[0, 2]":\n'
+ '\n'
+ ' x = [0, 1]\n'
+ ' i = 0\n'
+ ' i, x[i] = 1, 2 # i is updated, then x[i] is '
+ 'updated\n'
+ ' print(x)\n'
+ '\n'
+ 'See also:\n'
+ '\n'
+ ' **PEP 3132** - Extended Iterable Unpacking\n'
+ ' The specification for the "*target" feature.\n'
+ '\n'
+ '\n'
+ 'Augmented assignment statements\n'
+ '===============================\n'
+ '\n'
+ 'Augmented assignment is the combination, in a single '
+ 'statement, of a\n'
+ 'binary operation and an assignment statement:\n'
+ '\n'
+ ' augmented_assignment_stmt ::= augtarget augop '
+ '(expression_list | yield_expression)\n'
+ ' augtarget ::= identifier | attributeref | '
+ 'subscription | slicing\n'
+ ' augop ::= "+=" | "-=" | "*=" | "@=" | '
+ '"/=" | "//=" | "%=" | "**="\n'
+ ' | ">>=" | "<<=" | "&=" | "^=" | "|="\n'
+ '\n'
+ '(See section Primaries for the syntax definitions of the last '
+ 'three\n'
+ 'symbols.)\n'
+ '\n'
+ 'An augmented assignment evaluates the target (which, unlike '
+ 'normal\n'
+ 'assignment statements, cannot be an unpacking) and the '
+ 'expression\n'
+ 'list, performs the binary operation specific to the type of '
+ 'assignment\n'
+ 'on the two operands, and assigns the result to the original '
+ 'target.\n'
+ 'The target is only evaluated once.\n'
+ '\n'
+ 'An augmented assignment expression like "x += 1" can be '
+ 'rewritten as\n'
+ '"x = x + 1" to achieve a similar, but not exactly equal '
+ 'effect. In the\n'
+ 'augmented version, "x" is only evaluated once. Also, when '
+ 'possible,\n'
+ 'the actual operation is performed *in-place*, meaning that '
+ 'rather than\n'
+ 'creating a new object and assigning that to the target, the '
+ 'old object\n'
+ 'is modified instead.\n'
+ '\n'
+ 'Unlike normal assignments, augmented assignments evaluate the '
+ 'left-\n'
+ 'hand side *before* evaluating the right-hand side. For '
+ 'example, "a[i]\n'
+ '+= f(x)" first looks-up "a[i]", then it evaluates "f(x)" and '
+ 'performs\n'
+ 'the addition, and lastly, it writes the result back to '
+ '"a[i]".\n'
+ '\n'
+ 'With the exception of assigning to tuples and multiple targets '
+ 'in a\n'
+ 'single statement, the assignment done by augmented assignment\n'
+ 'statements is handled the same way as normal assignments. '
+ 'Similarly,\n'
+ 'with the exception of the possible *in-place* behavior, the '
+ 'binary\n'
+ 'operation performed by augmented assignment is the same as the '
+ 'normal\n'
+ 'binary operations.\n'
+ '\n'
+ 'For targets which are attribute references, the same caveat '
+ 'about\n'
+ 'class and instance attributes applies as for regular '
+ 'assignments.\n',
+ 'atom-identifiers': '\n'
+ 'Identifiers (Names)\n'
+ '*******************\n'
+ '\n'
+ 'An identifier occurring as an atom is a name. See '
+ 'section Identifiers\n'
+ 'and keywords for lexical definition and section Naming '
+ 'and binding for\n'
+ 'documentation of naming and binding.\n'
+ '\n'
+ 'When the name is bound to an object, evaluation of the '
+ 'atom yields\n'
+ 'that object. When a name is not bound, an attempt to '
+ 'evaluate it\n'
+ 'raises a "NameError" exception.\n'
+ '\n'
+ '**Private name mangling:** When an identifier that '
+ 'textually occurs in\n'
+ 'a class definition begins with two or more underscore '
+ 'characters and\n'
+ 'does not end in two or more underscores, it is '
+ 'considered a *private\n'
+ 'name* of that class. Private names are transformed to a '
+ 'longer form\n'
+ 'before code is generated for them. The transformation '
+ 'inserts the\n'
+ 'class name, with leading underscores removed and a '
+ 'single underscore\n'
+ 'inserted, in front of the name. For example, the '
+ 'identifier "__spam"\n'
+ 'occurring in a class named "Ham" will be transformed to '
+ '"_Ham__spam".\n'
+ 'This transformation is independent of the syntactical '
+ 'context in which\n'
+ 'the identifier is used. If the transformed name is '
+ 'extremely long\n'
+ '(longer than 255 characters), implementation defined '
+ 'truncation may\n'
+ 'happen. If the class name consists only of underscores, '
+ 'no\n'
+ 'transformation is done.\n',
+ 'atom-literals': '\n'
+ 'Literals\n'
+ '********\n'
+ '\n'
+ 'Python supports string and bytes literals and various '
+ 'numeric\n'
+ 'literals:\n'
+ '\n'
+ ' literal ::= stringliteral | bytesliteral\n'
+ ' | integer | floatnumber | imagnumber\n'
+ '\n'
+ 'Evaluation of a literal yields an object of the given type '
+ '(string,\n'
+ 'bytes, integer, floating point number, complex number) with '
+ 'the given\n'
+ 'value. The value may be approximated in the case of '
+ 'floating point\n'
+ 'and imaginary (complex) literals. See section Literals for '
+ 'details.\n'
+ '\n'
+ 'All literals correspond to immutable data types, and hence '
+ 'the\n'
+ "object's identity is less important than its value. "
+ 'Multiple\n'
+ 'evaluations of literals with the same value (either the '
+ 'same\n'
+ 'occurrence in the program text or a different occurrence) '
+ 'may obtain\n'
+ 'the same object or a different object with the same '
+ 'value.\n',
+ 'attribute-access': '\n'
+ 'Customizing attribute access\n'
+ '****************************\n'
+ '\n'
+ 'The following methods can be defined to customize the '
+ 'meaning of\n'
+ 'attribute access (use of, assignment to, or deletion of '
+ '"x.name") for\n'
+ 'class instances.\n'
+ '\n'
+ 'object.__getattr__(self, name)\n'
+ '\n'
+ ' Called when an attribute lookup has not found the '
+ 'attribute in the\n'
+ ' usual places (i.e. it is not an instance attribute '
+ 'nor is it found\n'
+ ' in the class tree for "self"). "name" is the '
+ 'attribute name. This\n'
+ ' method should return the (computed) attribute value '
+ 'or raise an\n'
+ ' "AttributeError" exception.\n'
+ '\n'
+ ' Note that if the attribute is found through the '
+ 'normal mechanism,\n'
+ ' "__getattr__()" is not called. (This is an '
+ 'intentional asymmetry\n'
+ ' between "__getattr__()" and "__setattr__()".) This is '
+ 'done both for\n'
+ ' efficiency reasons and because otherwise '
+ '"__getattr__()" would have\n'
+ ' no way to access other attributes of the instance. '
+ 'Note that at\n'
+ ' least for instance variables, you can fake total '
+ 'control by not\n'
+ ' inserting any values in the instance attribute '
+ 'dictionary (but\n'
+ ' instead inserting them in another object). See the\n'
+ ' "__getattribute__()" method below for a way to '
+ 'actually get total\n'
+ ' control over attribute access.\n'
+ '\n'
+ 'object.__getattribute__(self, name)\n'
+ '\n'
+ ' Called unconditionally to implement attribute '
+ 'accesses for\n'
+ ' instances of the class. If the class also defines '
+ '"__getattr__()",\n'
+ ' the latter will not be called unless '
+ '"__getattribute__()" either\n'
+ ' calls it explicitly or raises an "AttributeError". '
+ 'This method\n'
+ ' should return the (computed) attribute value or raise '
+ 'an\n'
+ ' "AttributeError" exception. In order to avoid '
+ 'infinite recursion in\n'
+ ' this method, its implementation should always call '
+ 'the base class\n'
+ ' method with the same name to access any attributes it '
+ 'needs, for\n'
+ ' example, "object.__getattribute__(self, name)".\n'
+ '\n'
+ ' Note: This method may still be bypassed when looking '
+ 'up special\n'
+ ' methods as the result of implicit invocation via '
+ 'language syntax\n'
+ ' or built-in functions. See Special method lookup.\n'
+ '\n'
+ 'object.__setattr__(self, name, value)\n'
+ '\n'
+ ' Called when an attribute assignment is attempted. '
+ 'This is called\n'
+ ' instead of the normal mechanism (i.e. store the value '
+ 'in the\n'
+ ' instance dictionary). *name* is the attribute name, '
+ '*value* is the\n'
+ ' value to be assigned to it.\n'
+ '\n'
+ ' If "__setattr__()" wants to assign to an instance '
+ 'attribute, it\n'
+ ' should call the base class method with the same name, '
+ 'for example,\n'
+ ' "object.__setattr__(self, name, value)".\n'
+ '\n'
+ 'object.__delattr__(self, name)\n'
+ '\n'
+ ' Like "__setattr__()" but for attribute deletion '
+ 'instead of\n'
+ ' assignment. This should only be implemented if "del '
+ 'obj.name" is\n'
+ ' meaningful for the object.\n'
+ '\n'
+ 'object.__dir__(self)\n'
+ '\n'
+ ' Called when "dir()" is called on the object. A '
+ 'sequence must be\n'
+ ' returned. "dir()" converts the returned sequence to a '
+ 'list and\n'
+ ' sorts it.\n'
+ '\n'
+ '\n'
+ 'Implementing Descriptors\n'
+ '========================\n'
+ '\n'
+ 'The following methods only apply when an instance of the '
+ 'class\n'
+ 'containing the method (a so-called *descriptor* class) '
+ 'appears in an\n'
+ '*owner* class (the descriptor must be in either the '
+ "owner's class\n"
+ 'dictionary or in the class dictionary for one of its '
+ 'parents). In the\n'
+ 'examples below, "the attribute" refers to the attribute '
+ 'whose name is\n'
+ "the key of the property in the owner class' "
+ '"__dict__".\n'
+ '\n'
+ 'object.__get__(self, instance, owner)\n'
+ '\n'
+ ' Called to get the attribute of the owner class (class '
+ 'attribute\n'
+ ' access) or of an instance of that class (instance '
+ 'attribute\n'
+ ' access). *owner* is always the owner class, while '
+ '*instance* is the\n'
+ ' instance that the attribute was accessed through, or '
+ '"None" when\n'
+ ' the attribute is accessed through the *owner*. This '
+ 'method should\n'
+ ' return the (computed) attribute value or raise an '
+ '"AttributeError"\n'
+ ' exception.\n'
+ '\n'
+ 'object.__set__(self, instance, value)\n'
+ '\n'
+ ' Called to set the attribute on an instance *instance* '
+ 'of the owner\n'
+ ' class to a new value, *value*.\n'
+ '\n'
+ 'object.__delete__(self, instance)\n'
+ '\n'
+ ' Called to delete the attribute on an instance '
+ '*instance* of the\n'
+ ' owner class.\n'
+ '\n'
+ 'The attribute "__objclass__" is interpreted by the '
+ '"inspect" module as\n'
+ 'specifying the class where this object was defined '
+ '(setting this\n'
+ 'appropriately can assist in runtime introspection of '
+ 'dynamic class\n'
+ 'attributes). For callables, it may indicate that an '
+ 'instance of the\n'
+ 'given type (or a subclass) is expected or required as '
+ 'the first\n'
+ 'positional argument (for example, CPython sets this '
+ 'attribute for\n'
+ 'unbound methods that are implemented in C).\n'
+ '\n'
+ '\n'
+ 'Invoking Descriptors\n'
+ '====================\n'
+ '\n'
+ 'In general, a descriptor is an object attribute with '
+ '"binding\n'
+ 'behavior", one whose attribute access has been '
+ 'overridden by methods\n'
+ 'in the descriptor protocol: "__get__()", "__set__()", '
+ 'and\n'
+ '"__delete__()". If any of those methods are defined for '
+ 'an object, it\n'
+ 'is said to be a descriptor.\n'
+ '\n'
+ 'The default behavior for attribute access is to get, '
+ 'set, or delete\n'
+ "the attribute from an object's dictionary. For instance, "
+ '"a.x" has a\n'
+ 'lookup chain starting with "a.__dict__[\'x\']", then\n'
+ '"type(a).__dict__[\'x\']", and continuing through the '
+ 'base classes of\n'
+ '"type(a)" excluding metaclasses.\n'
+ '\n'
+ 'However, if the looked-up value is an object defining '
+ 'one of the\n'
+ 'descriptor methods, then Python may override the default '
+ 'behavior and\n'
+ 'invoke the descriptor method instead. Where this occurs '
+ 'in the\n'
+ 'precedence chain depends on which descriptor methods '
+ 'were defined and\n'
+ 'how they were called.\n'
+ '\n'
+ 'The starting point for descriptor invocation is a '
+ 'binding, "a.x". How\n'
+ 'the arguments are assembled depends on "a":\n'
+ '\n'
+ 'Direct Call\n'
+ ' The simplest and least common call is when user code '
+ 'directly\n'
+ ' invokes a descriptor method: "x.__get__(a)".\n'
+ '\n'
+ 'Instance Binding\n'
+ ' If binding to an object instance, "a.x" is '
+ 'transformed into the\n'
+ ' call: "type(a).__dict__[\'x\'].__get__(a, type(a))".\n'
+ '\n'
+ 'Class Binding\n'
+ ' If binding to a class, "A.x" is transformed into the '
+ 'call:\n'
+ ' "A.__dict__[\'x\'].__get__(None, A)".\n'
+ '\n'
+ 'Super Binding\n'
+ ' If "a" is an instance of "super", then the binding '
+ '"super(B,\n'
+ ' obj).m()" searches "obj.__class__.__mro__" for the '
+ 'base class "A"\n'
+ ' immediately preceding "B" and then invokes the '
+ 'descriptor with the\n'
+ ' call: "A.__dict__[\'m\'].__get__(obj, '
+ 'obj.__class__)".\n'
+ '\n'
+ 'For instance bindings, the precedence of descriptor '
+ 'invocation depends\n'
+ 'on the which descriptor methods are defined. A '
+ 'descriptor can define\n'
+ 'any combination of "__get__()", "__set__()" and '
+ '"__delete__()". If it\n'
+ 'does not define "__get__()", then accessing the '
+ 'attribute will return\n'
+ 'the descriptor object itself unless there is a value in '
+ "the object's\n"
+ 'instance dictionary. If the descriptor defines '
+ '"__set__()" and/or\n'
+ '"__delete__()", it is a data descriptor; if it defines '
+ 'neither, it is\n'
+ 'a non-data descriptor. Normally, data descriptors '
+ 'define both\n'
+ '"__get__()" and "__set__()", while non-data descriptors '
+ 'have just the\n'
+ '"__get__()" method. Data descriptors with "__set__()" '
+ 'and "__get__()"\n'
+ 'defined always override a redefinition in an instance '
+ 'dictionary. In\n'
+ 'contrast, non-data descriptors can be overridden by '
+ 'instances.\n'
+ '\n'
+ 'Python methods (including "staticmethod()" and '
+ '"classmethod()") are\n'
+ 'implemented as non-data descriptors. Accordingly, '
+ 'instances can\n'
+ 'redefine and override methods. This allows individual '
+ 'instances to\n'
+ 'acquire behaviors that differ from other instances of '
+ 'the same class.\n'
+ '\n'
+ 'The "property()" function is implemented as a data '
+ 'descriptor.\n'
+ 'Accordingly, instances cannot override the behavior of a '
+ 'property.\n'
+ '\n'
+ '\n'
+ '__slots__\n'
+ '=========\n'
+ '\n'
+ 'By default, instances of classes have a dictionary for '
+ 'attribute\n'
+ 'storage. This wastes space for objects having very few '
+ 'instance\n'
+ 'variables. The space consumption can become acute when '
+ 'creating large\n'
+ 'numbers of instances.\n'
+ '\n'
+ 'The default can be overridden by defining *__slots__* in '
+ 'a class\n'
+ 'definition. The *__slots__* declaration takes a sequence '
+ 'of instance\n'
+ 'variables and reserves just enough space in each '
+ 'instance to hold a\n'
+ 'value for each variable. Space is saved because '
+ '*__dict__* is not\n'
+ 'created for each instance.\n'
+ '\n'
+ 'object.__slots__\n'
+ '\n'
+ ' This class variable can be assigned a string, '
+ 'iterable, or sequence\n'
+ ' of strings with variable names used by instances. '
+ '*__slots__*\n'
+ ' reserves space for the declared variables and '
+ 'prevents the\n'
+ ' automatic creation of *__dict__* and *__weakref__* '
+ 'for each\n'
+ ' instance.\n'
+ '\n'
+ '\n'
+ 'Notes on using *__slots__*\n'
+ '--------------------------\n'
+ '\n'
+ '* When inheriting from a class without *__slots__*, the '
+ '*__dict__*\n'
+ ' attribute of that class will always be accessible, so '
+ 'a *__slots__*\n'
+ ' definition in the subclass is meaningless.\n'
+ '\n'
+ '* Without a *__dict__* variable, instances cannot be '
+ 'assigned new\n'
+ ' variables not listed in the *__slots__* definition. '
+ 'Attempts to\n'
+ ' assign to an unlisted variable name raises '
+ '"AttributeError". If\n'
+ ' dynamic assignment of new variables is desired, then '
+ 'add\n'
+ ' "\'__dict__\'" to the sequence of strings in the '
+ '*__slots__*\n'
+ ' declaration.\n'
+ '\n'
+ '* Without a *__weakref__* variable for each instance, '
+ 'classes\n'
+ ' defining *__slots__* do not support weak references to '
+ 'its\n'
+ ' instances. If weak reference support is needed, then '
+ 'add\n'
+ ' "\'__weakref__\'" to the sequence of strings in the '
+ '*__slots__*\n'
+ ' declaration.\n'
+ '\n'
+ '* *__slots__* are implemented at the class level by '
+ 'creating\n'
+ ' descriptors (Implementing Descriptors) for each '
+ 'variable name. As a\n'
+ ' result, class attributes cannot be used to set default '
+ 'values for\n'
+ ' instance variables defined by *__slots__*; otherwise, '
+ 'the class\n'
+ ' attribute would overwrite the descriptor assignment.\n'
+ '\n'
+ '* The action of a *__slots__* declaration is limited to '
+ 'the class\n'
+ ' where it is defined. As a result, subclasses will '
+ 'have a *__dict__*\n'
+ ' unless they also define *__slots__* (which must only '
+ 'contain names\n'
+ ' of any *additional* slots).\n'
+ '\n'
+ '* If a class defines a slot also defined in a base '
+ 'class, the\n'
+ ' instance variable defined by the base class slot is '
+ 'inaccessible\n'
+ ' (except by retrieving its descriptor directly from the '
+ 'base class).\n'
+ ' This renders the meaning of the program undefined. In '
+ 'the future, a\n'
+ ' check may be added to prevent this.\n'
+ '\n'
+ '* Nonempty *__slots__* does not work for classes derived '
+ 'from\n'
+ ' "variable-length" built-in types such as "int", '
+ '"bytes" and "tuple".\n'
+ '\n'
+ '* Any non-string iterable may be assigned to '
+ '*__slots__*. Mappings\n'
+ ' may also be used; however, in the future, special '
+ 'meaning may be\n'
+ ' assigned to the values corresponding to each key.\n'
+ '\n'
+ '* *__class__* assignment works only if both classes have '
+ 'the same\n'
+ ' *__slots__*.\n',
+ 'attribute-references': '\n'
+ 'Attribute references\n'
+ '********************\n'
+ '\n'
+ 'An attribute reference is a primary followed by a '
+ 'period and a name:\n'
+ '\n'
+ ' attributeref ::= primary "." identifier\n'
+ '\n'
+ 'The primary must evaluate to an object of a type '
+ 'that supports\n'
+ 'attribute references, which most objects do. This '
+ 'object is then\n'
+ 'asked to produce the attribute whose name is the '
+ 'identifier. This\n'
+ 'production can be customized by overriding the '
+ '"__getattr__()" method.\n'
+ 'If this attribute is not available, the exception '
+ '"AttributeError" is\n'
+ 'raised. Otherwise, the type and value of the object '
+ 'produced is\n'
+ 'determined by the object. Multiple evaluations of '
+ 'the same attribute\n'
+ 'reference may yield different objects.\n',
+ 'augassign': '\n'
+ 'Augmented assignment statements\n'
+ '*******************************\n'
+ '\n'
+ 'Augmented assignment is the combination, in a single statement, '
+ 'of a\n'
+ 'binary operation and an assignment statement:\n'
+ '\n'
+ ' augmented_assignment_stmt ::= augtarget augop '
+ '(expression_list | yield_expression)\n'
+ ' augtarget ::= identifier | attributeref | '
+ 'subscription | slicing\n'
+ ' augop ::= "+=" | "-=" | "*=" | "@=" | '
+ '"/=" | "//=" | "%=" | "**="\n'
+ ' | ">>=" | "<<=" | "&=" | "^=" | "|="\n'
+ '\n'
+ '(See section Primaries for the syntax definitions of the last '
+ 'three\n'
+ 'symbols.)\n'
+ '\n'
+ 'An augmented assignment evaluates the target (which, unlike '
+ 'normal\n'
+ 'assignment statements, cannot be an unpacking) and the '
+ 'expression\n'
+ 'list, performs the binary operation specific to the type of '
+ 'assignment\n'
+ 'on the two operands, and assigns the result to the original '
+ 'target.\n'
+ 'The target is only evaluated once.\n'
+ '\n'
+ 'An augmented assignment expression like "x += 1" can be '
+ 'rewritten as\n'
+ '"x = x + 1" to achieve a similar, but not exactly equal effect. '
+ 'In the\n'
+ 'augmented version, "x" is only evaluated once. Also, when '
+ 'possible,\n'
+ 'the actual operation is performed *in-place*, meaning that '
+ 'rather than\n'
+ 'creating a new object and assigning that to the target, the old '
+ 'object\n'
+ 'is modified instead.\n'
+ '\n'
+ 'Unlike normal assignments, augmented assignments evaluate the '
+ 'left-\n'
+ 'hand side *before* evaluating the right-hand side. For '
+ 'example, "a[i]\n'
+ '+= f(x)" first looks-up "a[i]", then it evaluates "f(x)" and '
+ 'performs\n'
+ 'the addition, and lastly, it writes the result back to "a[i]".\n'
+ '\n'
+ 'With the exception of assigning to tuples and multiple targets '
+ 'in a\n'
+ 'single statement, the assignment done by augmented assignment\n'
+ 'statements is handled the same way as normal assignments. '
+ 'Similarly,\n'
+ 'with the exception of the possible *in-place* behavior, the '
+ 'binary\n'
+ 'operation performed by augmented assignment is the same as the '
+ 'normal\n'
+ 'binary operations.\n'
+ '\n'
+ 'For targets which are attribute references, the same caveat '
+ 'about\n'
+ 'class and instance attributes applies as for regular '
+ 'assignments.\n',
+ 'binary': '\n'
+ 'Binary arithmetic operations\n'
+ '****************************\n'
+ '\n'
+ 'The binary arithmetic operations have the conventional priority\n'
+ 'levels. Note that some of these operations also apply to certain '
+ 'non-\n'
+ 'numeric types. Apart from the power operator, there are only two\n'
+ 'levels, one for multiplicative operators and one for additive\n'
+ 'operators:\n'
+ '\n'
+ ' m_expr ::= u_expr | m_expr "*" u_expr | m_expr "@" m_expr |\n'
+ ' m_expr "//" u_expr| m_expr "/" u_expr |\n'
+ ' m_expr "%" u_expr\n'
+ ' a_expr ::= m_expr | a_expr "+" m_expr | a_expr "-" m_expr\n'
+ '\n'
+ 'The "*" (multiplication) operator yields the product of its '
+ 'arguments.\n'
+ 'The arguments must either both be numbers, or one argument must be '
+ 'an\n'
+ 'integer and the other must be a sequence. In the former case, the\n'
+ 'numbers are converted to a common type and then multiplied '
+ 'together.\n'
+ 'In the latter case, sequence repetition is performed; a negative\n'
+ 'repetition factor yields an empty sequence.\n'
+ '\n'
+ 'The "@" (at) operator is intended to be used for matrix\n'
+ 'multiplication. No builtin Python types implement this operator.\n'
+ '\n'
+ 'New in version 3.5.\n'
+ '\n'
+ 'The "/" (division) and "//" (floor division) operators yield the\n'
+ 'quotient of their arguments. The numeric arguments are first\n'
+ 'converted to a common type. Division of integers yields a float, '
+ 'while\n'
+ 'floor division of integers results in an integer; the result is '
+ 'that\n'
+ "of mathematical division with the 'floor' function applied to the\n"
+ 'result. Division by zero raises the "ZeroDivisionError" '
+ 'exception.\n'
+ '\n'
+ 'The "%" (modulo) operator yields the remainder from the division '
+ 'of\n'
+ 'the first argument by the second. The numeric arguments are '
+ 'first\n'
+ 'converted to a common type. A zero right argument raises the\n'
+ '"ZeroDivisionError" exception. The arguments may be floating '
+ 'point\n'
+ 'numbers, e.g., "3.14%0.7" equals "0.34" (since "3.14" equals '
+ '"4*0.7 +\n'
+ '0.34".) The modulo operator always yields a result with the same '
+ 'sign\n'
+ 'as its second operand (or zero); the absolute value of the result '
+ 'is\n'
+ 'strictly smaller than the absolute value of the second operand '
+ '[1].\n'
+ '\n'
+ 'The floor division and modulo operators are connected by the '
+ 'following\n'
+ 'identity: "x == (x//y)*y + (x%y)". Floor division and modulo are '
+ 'also\n'
+ 'connected with the built-in function "divmod()": "divmod(x, y) ==\n'
+ '(x//y, x%y)". [2].\n'
+ '\n'
+ 'In addition to performing the modulo operation on numbers, the '
+ '"%"\n'
+ 'operator is also overloaded by string objects to perform '
+ 'old-style\n'
+ 'string formatting (also known as interpolation). The syntax for\n'
+ 'string formatting is described in the Python Library Reference,\n'
+ 'section printf-style String Formatting.\n'
+ '\n'
+ 'The floor division operator, the modulo operator, and the '
+ '"divmod()"\n'
+ 'function are not defined for complex numbers. Instead, convert to '
+ 'a\n'
+ 'floating point number using the "abs()" function if appropriate.\n'
+ '\n'
+ 'The "+" (addition) operator yields the sum of its arguments. The\n'
+ 'arguments must either both be numbers or both be sequences of the '
+ 'same\n'
+ 'type. In the former case, the numbers are converted to a common '
+ 'type\n'
+ 'and then added together. In the latter case, the sequences are\n'
+ 'concatenated.\n'
+ '\n'
+ 'The "-" (subtraction) operator yields the difference of its '
+ 'arguments.\n'
+ 'The numeric arguments are first converted to a common type.\n',
+ 'bitwise': '\n'
+ 'Binary bitwise operations\n'
+ '*************************\n'
+ '\n'
+ 'Each of the three bitwise operations has a different priority '
+ 'level:\n'
+ '\n'
+ ' and_expr ::= shift_expr | and_expr "&" shift_expr\n'
+ ' xor_expr ::= and_expr | xor_expr "^" and_expr\n'
+ ' or_expr ::= xor_expr | or_expr "|" xor_expr\n'
+ '\n'
+ 'The "&" operator yields the bitwise AND of its arguments, which '
+ 'must\n'
+ 'be integers.\n'
+ '\n'
+ 'The "^" operator yields the bitwise XOR (exclusive OR) of its\n'
+ 'arguments, which must be integers.\n'
+ '\n'
+ 'The "|" operator yields the bitwise (inclusive) OR of its '
+ 'arguments,\n'
+ 'which must be integers.\n',
+ 'bltin-code-objects': '\n'
+ 'Code Objects\n'
+ '************\n'
+ '\n'
+ 'Code objects are used by the implementation to '
+ 'represent "pseudo-\n'
+ 'compiled" executable Python code such as a function '
+ 'body. They differ\n'
+ "from function objects because they don't contain a "
+ 'reference to their\n'
+ 'global execution environment. Code objects are '
+ 'returned by the built-\n'
+ 'in "compile()" function and can be extracted from '
+ 'function objects\n'
+ 'through their "__code__" attribute. See also the '
+ '"code" module.\n'
+ '\n'
+ 'A code object can be executed or evaluated by passing '
+ 'it (instead of a\n'
+ 'source string) to the "exec()" or "eval()" built-in '
+ 'functions.\n'
+ '\n'
+ 'See The standard type hierarchy for more '
+ 'information.\n',
+ 'bltin-ellipsis-object': '\n'
+ 'The Ellipsis Object\n'
+ '*******************\n'
+ '\n'
+ 'This object is commonly used by slicing (see '
+ 'Slicings). It supports\n'
+ 'no special operations. There is exactly one '
+ 'ellipsis object, named\n'
+ '"Ellipsis" (a built-in name). "type(Ellipsis)()" '
+ 'produces the\n'
+ '"Ellipsis" singleton.\n'
+ '\n'
+ 'It is written as "Ellipsis" or "...".\n',
+ 'bltin-null-object': '\n'
+ 'The Null Object\n'
+ '***************\n'
+ '\n'
+ "This object is returned by functions that don't "
+ 'explicitly return a\n'
+ 'value. It supports no special operations. There is '
+ 'exactly one null\n'
+ 'object, named "None" (a built-in name). "type(None)()" '
+ 'produces the\n'
+ 'same singleton.\n'
+ '\n'
+ 'It is written as "None".\n',
+ 'bltin-type-objects': '\n'
+ 'Type Objects\n'
+ '************\n'
+ '\n'
+ 'Type objects represent the various object types. An '
+ "object's type is\n"
+ 'accessed by the built-in function "type()". There are '
+ 'no special\n'
+ 'operations on types. The standard module "types" '
+ 'defines names for\n'
+ 'all standard built-in types.\n'
+ '\n'
+ 'Types are written like this: "<class \'int\'>".\n',
+ 'booleans': '\n'
+ 'Boolean operations\n'
+ '******************\n'
+ '\n'
+ ' or_test ::= and_test | or_test "or" and_test\n'
+ ' and_test ::= not_test | and_test "and" not_test\n'
+ ' not_test ::= comparison | "not" not_test\n'
+ '\n'
+ 'In the context of Boolean operations, and also when expressions '
+ 'are\n'
+ 'used by control flow statements, the following values are '
+ 'interpreted\n'
+ 'as false: "False", "None", numeric zero of all types, and empty\n'
+ 'strings and containers (including strings, tuples, lists,\n'
+ 'dictionaries, sets and frozensets). All other values are '
+ 'interpreted\n'
+ 'as true. User-defined objects can customize their truth value '
+ 'by\n'
+ 'providing a "__bool__()" method.\n'
+ '\n'
+ 'The operator "not" yields "True" if its argument is false, '
+ '"False"\n'
+ 'otherwise.\n'
+ '\n'
+ 'The expression "x and y" first evaluates *x*; if *x* is false, '
+ 'its\n'
+ 'value is returned; otherwise, *y* is evaluated and the resulting '
+ 'value\n'
+ 'is returned.\n'
+ '\n'
+ 'The expression "x or y" first evaluates *x*; if *x* is true, its '
+ 'value\n'
+ 'is returned; otherwise, *y* is evaluated and the resulting value '
+ 'is\n'
+ 'returned.\n'
+ '\n'
+ '(Note that neither "and" nor "or" restrict the value and type '
+ 'they\n'
+ 'return to "False" and "True", but rather return the last '
+ 'evaluated\n'
+ 'argument. This is sometimes useful, e.g., if "s" is a string '
+ 'that\n'
+ 'should be replaced by a default value if it is empty, the '
+ 'expression\n'
+ '"s or \'foo\'" yields the desired value. Because "not" has to '
+ 'create a\n'
+ 'new value, it returns a boolean value regardless of the type of '
+ 'its\n'
+ 'argument (for example, "not \'foo\'" produces "False" rather '
+ 'than "\'\'".)\n',
+ 'break': '\n'
+ 'The "break" statement\n'
+ '*********************\n'
+ '\n'
+ ' break_stmt ::= "break"\n'
+ '\n'
+ '"break" may only occur syntactically nested in a "for" or "while"\n'
+ 'loop, but not nested in a function or class definition within that\n'
+ 'loop.\n'
+ '\n'
+ 'It terminates the nearest enclosing loop, skipping the optional '
+ '"else"\n'
+ 'clause if the loop has one.\n'
+ '\n'
+ 'If a "for" loop is terminated by "break", the loop control target\n'
+ 'keeps its current value.\n'
+ '\n'
+ 'When "break" passes control out of a "try" statement with a '
+ '"finally"\n'
+ 'clause, that "finally" clause is executed before really leaving '
+ 'the\n'
+ 'loop.\n',
+ 'callable-types': '\n'
+ 'Emulating callable objects\n'
+ '**************************\n'
+ '\n'
+ 'object.__call__(self[, args...])\n'
+ '\n'
+ ' Called when the instance is "called" as a function; if '
+ 'this method\n'
+ ' is defined, "x(arg1, arg2, ...)" is a shorthand for\n'
+ ' "x.__call__(arg1, arg2, ...)".\n',
+ 'calls': '\n'
+ 'Calls\n'
+ '*****\n'
+ '\n'
+ 'A call calls a callable object (e.g., a *function*) with a '
+ 'possibly\n'
+ 'empty series of *arguments*:\n'
+ '\n'
+ ' call ::= primary "(" [argument_list [","] | '
+ 'comprehension] ")"\n'
+ ' argument_list ::= positional_arguments ["," '
+ 'starred_and_keywords]\n'
+ ' ["," keywords_arguments]\n'
+ ' | starred_and_keywords ["," '
+ 'keywords_arguments]\n'
+ ' | keywords_arguments\n'
+ ' positional_arguments ::= ["*"] expression ("," ["*"] '
+ 'expression)*\n'
+ ' starred_and_keywords ::= ("*" expression | keyword_item)\n'
+ ' ("," "*" expression | "," '
+ 'keyword_item)*\n'
+ ' keywords_arguments ::= (keyword_item | "**" expression)\n'
+ ' ("," keyword_item | "**" expression)*\n'
+ ' keyword_item ::= identifier "=" expression\n'
+ '\n'
+ 'An optional trailing comma may be present after the positional and\n'
+ 'keyword arguments but does not affect the semantics.\n'
+ '\n'
+ 'The primary must evaluate to a callable object (user-defined\n'
+ 'functions, built-in functions, methods of built-in objects, class\n'
+ 'objects, methods of class instances, and all objects having a\n'
+ '"__call__()" method are callable). All argument expressions are\n'
+ 'evaluated before the call is attempted. Please refer to section\n'
+ 'Function definitions for the syntax of formal *parameter* lists.\n'
+ '\n'
+ 'If keyword arguments are present, they are first converted to\n'
+ 'positional arguments, as follows. First, a list of unfilled slots '
+ 'is\n'
+ 'created for the formal parameters. If there are N positional\n'
+ 'arguments, they are placed in the first N slots. Next, for each\n'
+ 'keyword argument, the identifier is used to determine the\n'
+ 'corresponding slot (if the identifier is the same as the first '
+ 'formal\n'
+ 'parameter name, the first slot is used, and so on). If the slot '
+ 'is\n'
+ 'already filled, a "TypeError" exception is raised. Otherwise, the\n'
+ 'value of the argument is placed in the slot, filling it (even if '
+ 'the\n'
+ 'expression is "None", it fills the slot). When all arguments have\n'
+ 'been processed, the slots that are still unfilled are filled with '
+ 'the\n'
+ 'corresponding default value from the function definition. '
+ '(Default\n'
+ 'values are calculated, once, when the function is defined; thus, a\n'
+ 'mutable object such as a list or dictionary used as default value '
+ 'will\n'
+ "be shared by all calls that don't specify an argument value for "
+ 'the\n'
+ 'corresponding slot; this should usually be avoided.) If there are '
+ 'any\n'
+ 'unfilled slots for which no default value is specified, a '
+ '"TypeError"\n'
+ 'exception is raised. Otherwise, the list of filled slots is used '
+ 'as\n'
+ 'the argument list for the call.\n'
+ '\n'
+ '**CPython implementation detail:** An implementation may provide\n'
+ 'built-in functions whose positional parameters do not have names, '
+ 'even\n'
+ "if they are 'named' for the purpose of documentation, and which\n"
+ 'therefore cannot be supplied by keyword. In CPython, this is the '
+ 'case\n'
+ 'for functions implemented in C that use "PyArg_ParseTuple()" to '
+ 'parse\n'
+ 'their arguments.\n'
+ '\n'
+ 'If there are more positional arguments than there are formal '
+ 'parameter\n'
+ 'slots, a "TypeError" exception is raised, unless a formal '
+ 'parameter\n'
+ 'using the syntax "*identifier" is present; in this case, that '
+ 'formal\n'
+ 'parameter receives a tuple containing the excess positional '
+ 'arguments\n'
+ '(or an empty tuple if there were no excess positional arguments).\n'
+ '\n'
+ 'If any keyword argument does not correspond to a formal parameter\n'
+ 'name, a "TypeError" exception is raised, unless a formal parameter\n'
+ 'using the syntax "**identifier" is present; in this case, that '
+ 'formal\n'
+ 'parameter receives a dictionary containing the excess keyword\n'
+ 'arguments (using the keywords as keys and the argument values as\n'
+ 'corresponding values), or a (new) empty dictionary if there were '
+ 'no\n'
+ 'excess keyword arguments.\n'
+ '\n'
+ 'If the syntax "*expression" appears in the function call, '
+ '"expression"\n'
+ 'must evaluate to an *iterable*. Elements from these iterables are\n'
+ 'treated as if they were additional positional arguments. For the '
+ 'call\n'
+ '"f(x1, x2, *y, x3, x4)", if *y* evaluates to a sequence *y1*, ...,\n'
+ '*yM*, this is equivalent to a call with M+4 positional arguments '
+ '*x1*,\n'
+ '*x2*, *y1*, ..., *yM*, *x3*, *x4*.\n'
+ '\n'
+ 'A consequence of this is that although the "*expression" syntax '
+ 'may\n'
+ 'appear *after* explicit keyword arguments, it is processed '
+ '*before*\n'
+ 'the keyword arguments (and any "**expression" arguments -- see '
+ 'below).\n'
+ 'So:\n'
+ '\n'
+ ' >>> def f(a, b):\n'
+ ' ... print(a, b)\n'
+ ' ...\n'
+ ' >>> f(b=1, *(2,))\n'
+ ' 2 1\n'
+ ' >>> f(a=1, *(2,))\n'
+ ' Traceback (most recent call last):\n'
+ ' File "<stdin>", line 1, in ?\n'
+ " TypeError: f() got multiple values for keyword argument 'a'\n"
+ ' >>> f(1, *(2,))\n'
+ ' 1 2\n'
+ '\n'
+ 'It is unusual for both keyword arguments and the "*expression" '
+ 'syntax\n'
+ 'to be used in the same call, so in practice this confusion does '
+ 'not\n'
+ 'arise.\n'
+ '\n'
+ 'If the syntax "**expression" appears in the function call,\n'
+ '"expression" must evaluate to a *mapping*, the contents of which '
+ 'are\n'
+ 'treated as additional keyword arguments. If a keyword is already\n'
+ 'present (as an explicit keyword argument, or from another '
+ 'unpacking),\n'
+ 'a "TypeError" exception is raised.\n'
+ '\n'
+ 'Formal parameters using the syntax "*identifier" or "**identifier"\n'
+ 'cannot be used as positional argument slots or as keyword argument\n'
+ 'names.\n'
+ '\n'
+ 'Changed in version 3.5: Function calls accept any number of "*" '
+ 'and\n'
+ '"**" unpackings, positional arguments may follow iterable '
+ 'unpackings\n'
+ '("*"), and keyword arguments may follow dictionary unpackings '
+ '("**").\n'
+ 'Originally proposed by **PEP 448**.\n'
+ '\n'
+ 'A call always returns some value, possibly "None", unless it raises '
+ 'an\n'
+ 'exception. How this value is computed depends on the type of the\n'
+ 'callable object.\n'
+ '\n'
+ 'If it is---\n'
+ '\n'
+ 'a user-defined function:\n'
+ ' The code block for the function is executed, passing it the\n'
+ ' argument list. The first thing the code block will do is bind '
+ 'the\n'
+ ' formal parameters to the arguments; this is described in '
+ 'section\n'
+ ' Function definitions. When the code block executes a "return"\n'
+ ' statement, this specifies the return value of the function '
+ 'call.\n'
+ '\n'
+ 'a built-in function or method:\n'
+ ' The result is up to the interpreter; see Built-in Functions for '
+ 'the\n'
+ ' descriptions of built-in functions and methods.\n'
+ '\n'
+ 'a class object:\n'
+ ' A new instance of that class is returned.\n'
+ '\n'
+ 'a class instance method:\n'
+ ' The corresponding user-defined function is called, with an '
+ 'argument\n'
+ ' list that is one longer than the argument list of the call: the\n'
+ ' instance becomes the first argument.\n'
+ '\n'
+ 'a class instance:\n'
+ ' The class must define a "__call__()" method; the effect is then '
+ 'the\n'
+ ' same as if that method was called.\n',
+ 'class': '\n'
+ 'Class definitions\n'
+ '*****************\n'
+ '\n'
+ 'A class definition defines a class object (see section The '
+ 'standard\n'
+ 'type hierarchy):\n'
+ '\n'
+ ' classdef ::= [decorators] "class" classname [inheritance] ":" '
+ 'suite\n'
+ ' inheritance ::= "(" [argument_list] ")"\n'
+ ' classname ::= identifier\n'
+ '\n'
+ 'A class definition is an executable statement. The inheritance '
+ 'list\n'
+ 'usually gives a list of base classes (see Customizing class '
+ 'creation\n'
+ 'for more advanced uses), so each item in the list should evaluate '
+ 'to a\n'
+ 'class object which allows subclassing. Classes without an '
+ 'inheritance\n'
+ 'list inherit, by default, from the base class "object"; hence,\n'
+ '\n'
+ ' class Foo:\n'
+ ' pass\n'
+ '\n'
+ 'is equivalent to\n'
+ '\n'
+ ' class Foo(object):\n'
+ ' pass\n'
+ '\n'
+ "The class's suite is then executed in a new execution frame (see\n"
+ 'Naming and binding), using a newly created local namespace and the\n'
+ 'original global namespace. (Usually, the suite contains mostly\n'
+ "function definitions.) When the class's suite finishes execution, "
+ 'its\n'
+ 'execution frame is discarded but its local namespace is saved. [4] '
+ 'A\n'
+ 'class object is then created using the inheritance list for the '
+ 'base\n'
+ 'classes and the saved local namespace for the attribute '
+ 'dictionary.\n'
+ 'The class name is bound to this class object in the original local\n'
+ 'namespace.\n'
+ '\n'
+ 'Class creation can be customized heavily using metaclasses.\n'
+ '\n'
+ 'Classes can also be decorated: just like when decorating '
+ 'functions,\n'
+ '\n'
+ ' @f1(arg)\n'
+ ' @f2\n'
+ ' class Foo: pass\n'
+ '\n'
+ 'is equivalent to\n'
+ '\n'
+ ' class Foo: pass\n'
+ ' Foo = f1(arg)(f2(Foo))\n'
+ '\n'
+ 'The evaluation rules for the decorator expressions are the same as '
+ 'for\n'
+ 'function decorators. The result must be a class object, which is '
+ 'then\n'
+ 'bound to the class name.\n'
+ '\n'
+ "**Programmer's note:** Variables defined in the class definition "
+ 'are\n'
+ 'class attributes; they are shared by instances. Instance '
+ 'attributes\n'
+ 'can be set in a method with "self.name = value". Both class and\n'
+ 'instance attributes are accessible through the notation '
+ '""self.name"",\n'
+ 'and an instance attribute hides a class attribute with the same '
+ 'name\n'
+ 'when accessed in this way. Class attributes can be used as '
+ 'defaults\n'
+ 'for instance attributes, but using mutable values there can lead '
+ 'to\n'
+ 'unexpected results. Descriptors can be used to create instance\n'
+ 'variables with different implementation details.\n'
+ '\n'
+ 'See also: **PEP 3115** - Metaclasses in Python 3 **PEP 3129** -\n'
+ ' Class Decorators\n',
+ 'comparisons': '\n'
+ 'Comparisons\n'
+ '***********\n'
+ '\n'
+ 'Unlike C, all comparison operations in Python have the same '
+ 'priority,\n'
+ 'which is lower than that of any arithmetic, shifting or '
+ 'bitwise\n'
+ 'operation. Also unlike C, expressions like "a < b < c" have '
+ 'the\n'
+ 'interpretation that is conventional in mathematics:\n'
+ '\n'
+ ' comparison ::= or_expr ( comp_operator or_expr )*\n'
+ ' comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="\n'
+ ' | "is" ["not"] | ["not"] "in"\n'
+ '\n'
+ 'Comparisons yield boolean values: "True" or "False".\n'
+ '\n'
+ 'Comparisons can be chained arbitrarily, e.g., "x < y <= z" '
+ 'is\n'
+ 'equivalent to "x < y and y <= z", except that "y" is '
+ 'evaluated only\n'
+ 'once (but in both cases "z" is not evaluated at all when "x < '
+ 'y" is\n'
+ 'found to be false).\n'
+ '\n'
+ 'Formally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and '
+ '*op1*,\n'
+ '*op2*, ..., *opN* are comparison operators, then "a op1 b op2 '
+ 'c ... y\n'
+ 'opN z" is equivalent to "a op1 b and b op2 c and ... y opN '
+ 'z", except\n'
+ 'that each expression is evaluated at most once.\n'
+ '\n'
+ 'Note that "a op1 b op2 c" doesn\'t imply any kind of '
+ 'comparison between\n'
+ '*a* and *c*, so that, e.g., "x < y > z" is perfectly legal '
+ '(though\n'
+ 'perhaps not pretty).\n'
+ '\n'
+ '\n'
+ 'Value comparisons\n'
+ '=================\n'
+ '\n'
+ 'The operators "<", ">", "==", ">=", "<=", and "!=" compare '
+ 'the values\n'
+ 'of two objects. The objects do not need to have the same '
+ 'type.\n'
+ '\n'
+ 'Chapter Objects, values and types states that objects have a '
+ 'value (in\n'
+ 'addition to type and identity). The value of an object is a '
+ 'rather\n'
+ 'abstract notion in Python: For example, there is no canonical '
+ 'access\n'
+ "method for an object's value. Also, there is no requirement "
+ 'that the\n'
+ 'value of an object should be constructed in a particular way, '
+ 'e.g.\n'
+ 'comprised of all its data attributes. Comparison operators '
+ 'implement a\n'
+ 'particular notion of what the value of an object is. One can '
+ 'think of\n'
+ 'them as defining the value of an object indirectly, by means '
+ 'of their\n'
+ 'comparison implementation.\n'
+ '\n'
+ 'Because all types are (direct or indirect) subtypes of '
+ '"object", they\n'
+ 'inherit the default comparison behavior from "object". Types '
+ 'can\n'
+ 'customize their comparison behavior by implementing *rich '
+ 'comparison\n'
+ 'methods* like "__lt__()", described in Basic customization.\n'
+ '\n'
+ 'The default behavior for equality comparison ("==" and "!=") '
+ 'is based\n'
+ 'on the identity of the objects. Hence, equality comparison '
+ 'of\n'
+ 'instances with the same identity results in equality, and '
+ 'equality\n'
+ 'comparison of instances with different identities results in\n'
+ 'inequality. A motivation for this default behavior is the '
+ 'desire that\n'
+ 'all objects should be reflexive (i.e. "x is y" implies "x == '
+ 'y").\n'
+ '\n'
+ 'A default order comparison ("<", ">", "<=", and ">=") is not '
+ 'provided;\n'
+ 'an attempt raises "TypeError". A motivation for this default '
+ 'behavior\n'
+ 'is the lack of a similar invariant as for equality.\n'
+ '\n'
+ 'The behavior of the default equality comparison, that '
+ 'instances with\n'
+ 'different identities are always unequal, may be in contrast '
+ 'to what\n'
+ 'types will need that have a sensible definition of object '
+ 'value and\n'
+ 'value-based equality. Such types will need to customize '
+ 'their\n'
+ 'comparison behavior, and in fact, a number of built-in types '
+ 'have done\n'
+ 'that.\n'
+ '\n'
+ 'The following list describes the comparison behavior of the '
+ 'most\n'
+ 'important built-in types.\n'
+ '\n'
+ '* Numbers of built-in numeric types (Numeric Types --- int, '
+ 'float,\n'
+ ' complex) and of the standard library types '
+ '"fractions.Fraction" and\n'
+ ' "decimal.Decimal" can be compared within and across their '
+ 'types,\n'
+ ' with the restriction that complex numbers do not support '
+ 'order\n'
+ ' comparison. Within the limits of the types involved, they '
+ 'compare\n'
+ ' mathematically (algorithmically) correct without loss of '
+ 'precision.\n'
+ '\n'
+ ' The not-a-number values "float(\'NaN\')" and '
+ '"Decimal(\'NaN\')" are\n'
+ ' special. They are identical to themselves ("x is x" is '
+ 'true) but\n'
+ ' are not equal to themselves ("x == x" is false). '
+ 'Additionally,\n'
+ ' comparing any number to a not-a-number value will return '
+ '"False".\n'
+ ' For example, both "3 < float(\'NaN\')" and "float(\'NaN\') '
+ '< 3" will\n'
+ ' return "False".\n'
+ '\n'
+ '* Binary sequences (instances of "bytes" or "bytearray") can '
+ 'be\n'
+ ' compared within and across their types. They compare\n'
+ ' lexicographically using the numeric values of their '
+ 'elements.\n'
+ '\n'
+ '* Strings (instances of "str") compare lexicographically '
+ 'using the\n'
+ ' numerical Unicode code points (the result of the built-in '
+ 'function\n'
+ ' "ord()") of their characters. [3]\n'
+ '\n'
+ ' Strings and binary sequences cannot be directly compared.\n'
+ '\n'
+ '* Sequences (instances of "tuple", "list", or "range") can '
+ 'be\n'
+ ' compared only within each of their types, with the '
+ 'restriction that\n'
+ ' ranges do not support order comparison. Equality '
+ 'comparison across\n'
+ ' these types results in unequality, and ordering comparison '
+ 'across\n'
+ ' these types raises "TypeError".\n'
+ '\n'
+ ' Sequences compare lexicographically using comparison of\n'
+ ' corresponding elements, whereby reflexivity of the elements '
+ 'is\n'
+ ' enforced.\n'
+ '\n'
+ ' In enforcing reflexivity of elements, the comparison of '
+ 'collections\n'
+ ' assumes that for a collection element "x", "x == x" is '
+ 'always true.\n'
+ ' Based on that assumption, element identity is compared '
+ 'first, and\n'
+ ' element comparison is performed only for distinct '
+ 'elements. This\n'
+ ' approach yields the same result as a strict element '
+ 'comparison\n'
+ ' would, if the compared elements are reflexive. For '
+ 'non-reflexive\n'
+ ' elements, the result is different than for strict element\n'
+ ' comparison, and may be surprising: The non-reflexive '
+ 'not-a-number\n'
+ ' values for example result in the following comparison '
+ 'behavior when\n'
+ ' used in a list:\n'
+ '\n'
+ " >>> nan = float('NaN')\n"
+ ' >>> nan is nan\n'
+ ' True\n'
+ ' >>> nan == nan\n'
+ ' False <-- the defined non-reflexive '
+ 'behavior of NaN\n'
+ ' >>> [nan] == [nan]\n'
+ ' True <-- list enforces reflexivity and '
+ 'tests identity first\n'
+ '\n'
+ ' Lexicographical comparison between built-in collections '
+ 'works as\n'
+ ' follows:\n'
+ '\n'
+ ' * For two collections to compare equal, they must be of the '
+ 'same\n'
+ ' type, have the same length, and each pair of '
+ 'corresponding\n'
+ ' elements must compare equal (for example, "[1,2] == '
+ '(1,2)" is\n'
+ ' false because the type is not the same).\n'
+ '\n'
+ ' * Collections that support order comparison are ordered the '
+ 'same\n'
+ ' as their first unequal elements (for example, "[1,2,x] <= '
+ '[1,2,y]"\n'
+ ' has the same value as "x <= y"). If a corresponding '
+ 'element does\n'
+ ' not exist, the shorter collection is ordered first (for '
+ 'example,\n'
+ ' "[1,2] < [1,2,3]" is true).\n'
+ '\n'
+ '* Mappings (instances of "dict") compare equal if and only if '
+ 'they\n'
+ ' have equal *(key, value)* pairs. Equality comparison of the '
+ 'keys and\n'
+ ' elements enforces reflexivity.\n'
+ '\n'
+ ' Order comparisons ("<", ">", "<=", and ">=") raise '
+ '"TypeError".\n'
+ '\n'
+ '* Sets (instances of "set" or "frozenset") can be compared '
+ 'within\n'
+ ' and across their types.\n'
+ '\n'
+ ' They define order comparison operators to mean subset and '
+ 'superset\n'
+ ' tests. Those relations do not define total orderings (for '
+ 'example,\n'
+ ' the two sets "{1,2}" and "{2,3}" are not equal, nor subsets '
+ 'of one\n'
+ ' another, nor supersets of one another). Accordingly, sets '
+ 'are not\n'
+ ' appropriate arguments for functions which depend on total '
+ 'ordering\n'
+ ' (for example, "min()", "max()", and "sorted()" produce '
+ 'undefined\n'
+ ' results given a list of sets as inputs).\n'
+ '\n'
+ ' Comparison of sets enforces reflexivity of its elements.\n'
+ '\n'
+ '* Most other built-in types have no comparison methods '
+ 'implemented,\n'
+ ' so they inherit the default comparison behavior.\n'
+ '\n'
+ 'User-defined classes that customize their comparison behavior '
+ 'should\n'
+ 'follow some consistency rules, if possible:\n'
+ '\n'
+ '* Equality comparison should be reflexive. In other words, '
+ 'identical\n'
+ ' objects should compare equal:\n'
+ '\n'
+ ' "x is y" implies "x == y"\n'
+ '\n'
+ '* Comparison should be symmetric. In other words, the '
+ 'following\n'
+ ' expressions should have the same result:\n'
+ '\n'
+ ' "x == y" and "y == x"\n'
+ '\n'
+ ' "x != y" and "y != x"\n'
+ '\n'
+ ' "x < y" and "y > x"\n'
+ '\n'
+ ' "x <= y" and "y >= x"\n'
+ '\n'
+ '* Comparison should be transitive. The following '
+ '(non-exhaustive)\n'
+ ' examples illustrate that:\n'
+ '\n'
+ ' "x > y and y > z" implies "x > z"\n'
+ '\n'
+ ' "x < y and y <= z" implies "x < z"\n'
+ '\n'
+ '* Inverse comparison should result in the boolean negation. '
+ 'In other\n'
+ ' words, the following expressions should have the same '
+ 'result:\n'
+ '\n'
+ ' "x == y" and "not x != y"\n'
+ '\n'
+ ' "x < y" and "not x >= y" (for total ordering)\n'
+ '\n'
+ ' "x > y" and "not x <= y" (for total ordering)\n'
+ '\n'
+ ' The last two expressions apply to totally ordered '
+ 'collections (e.g.\n'
+ ' to sequences, but not to sets or mappings). See also the\n'
+ ' "total_ordering()" decorator.\n'
+ '\n'
+ 'Python does not enforce these consistency rules. In fact, '
+ 'the\n'
+ 'not-a-number values are an example for not following these '
+ 'rules.\n'
+ '\n'
+ '\n'
+ 'Membership test operations\n'
+ '==========================\n'
+ '\n'
+ 'The operators "in" and "not in" test for membership. "x in '
+ 's"\n'
+ 'evaluates to true if *x* is a member of *s*, and false '
+ 'otherwise. "x\n'
+ 'not in s" returns the negation of "x in s". All built-in '
+ 'sequences\n'
+ 'and set types support this as well as dictionary, for which '
+ '"in" tests\n'
+ 'whether the dictionary has a given key. For container types '
+ 'such as\n'
+ 'list, tuple, set, frozenset, dict, or collections.deque, the\n'
+ 'expression "x in y" is equivalent to "any(x is e or x == e '
+ 'for e in\n'
+ 'y)".\n'
+ '\n'
+ 'For the string and bytes types, "x in y" is true if and only '
+ 'if *x* is\n'
+ 'a substring of *y*. An equivalent test is "y.find(x) != '
+ '-1". Empty\n'
+ 'strings are always considered to be a substring of any other '
+ 'string,\n'
+ 'so """ in "abc"" will return "True".\n'
+ '\n'
+ 'For user-defined classes which define the "__contains__()" '
+ 'method, "x\n'
+ 'in y" is true if and only if "y.__contains__(x)" is true.\n'
+ '\n'
+ 'For user-defined classes which do not define "__contains__()" '
+ 'but do\n'
+ 'define "__iter__()", "x in y" is true if some value "z" with '
+ '"x == z"\n'
+ 'is produced while iterating over "y". If an exception is '
+ 'raised\n'
+ 'during the iteration, it is as if "in" raised that '
+ 'exception.\n'
+ '\n'
+ 'Lastly, the old-style iteration protocol is tried: if a class '
+ 'defines\n'
+ '"__getitem__()", "x in y" is true if and only if there is a '
+ 'non-\n'
+ 'negative integer index *i* such that "x == y[i]", and all '
+ 'lower\n'
+ 'integer indices do not raise "IndexError" exception. (If any '
+ 'other\n'
+ 'exception is raised, it is as if "in" raised that '
+ 'exception).\n'
+ '\n'
+ 'The operator "not in" is defined to have the inverse true '
+ 'value of\n'
+ '"in".\n'
+ '\n'
+ '\n'
+ 'Identity comparisons\n'
+ '====================\n'
+ '\n'
+ 'The operators "is" and "is not" test for object identity: "x '
+ 'is y" is\n'
+ 'true if and only if *x* and *y* are the same object. "x is '
+ 'not y"\n'
+ 'yields the inverse truth value. [4]\n',
+ 'compound': '\n'
+ 'Compound statements\n'
+ '*******************\n'
+ '\n'
+ 'Compound statements contain (groups of) other statements; they '
+ 'affect\n'
+ 'or control the execution of those other statements in some way. '
+ 'In\n'
+ 'general, compound statements span multiple lines, although in '
+ 'simple\n'
+ 'incarnations a whole compound statement may be contained in one '
+ 'line.\n'
+ '\n'
+ 'The "if", "while" and "for" statements implement traditional '
+ 'control\n'
+ 'flow constructs. "try" specifies exception handlers and/or '
+ 'cleanup\n'
+ 'code for a group of statements, while the "with" statement '
+ 'allows the\n'
+ 'execution of initialization and finalization code around a block '
+ 'of\n'
+ 'code. Function and class definitions are also syntactically '
+ 'compound\n'
+ 'statements.\n'
+ '\n'
+ "A compound statement consists of one or more 'clauses.' A "
+ 'clause\n'
+ "consists of a header and a 'suite.' The clause headers of a\n"
+ 'particular compound statement are all at the same indentation '
+ 'level.\n'
+ 'Each clause header begins with a uniquely identifying keyword '
+ 'and ends\n'
+ 'with a colon. A suite is a group of statements controlled by a\n'
+ 'clause. A suite can be one or more semicolon-separated simple\n'
+ 'statements on the same line as the header, following the '
+ "header's\n"
+ 'colon, or it can be one or more indented statements on '
+ 'subsequent\n'
+ 'lines. Only the latter form of a suite can contain nested '
+ 'compound\n'
+ "statements; the following is illegal, mostly because it wouldn't "
+ 'be\n'
+ 'clear to which "if" clause a following "else" clause would '
+ 'belong:\n'
+ '\n'
+ ' if test1: if test2: print(x)\n'
+ '\n'
+ 'Also note that the semicolon binds tighter than the colon in '
+ 'this\n'
+ 'context, so that in the following example, either all or none of '
+ 'the\n'
+ '"print()" calls are executed:\n'
+ '\n'
+ ' if x < y < z: print(x); print(y); print(z)\n'
+ '\n'
+ 'Summarizing:\n'
+ '\n'
+ ' compound_stmt ::= if_stmt\n'
+ ' | while_stmt\n'
+ ' | for_stmt\n'
+ ' | try_stmt\n'
+ ' | with_stmt\n'
+ ' | funcdef\n'
+ ' | classdef\n'
+ ' | async_with_stmt\n'
+ ' | async_for_stmt\n'
+ ' | async_funcdef\n'
+ ' suite ::= stmt_list NEWLINE | NEWLINE INDENT '
+ 'statement+ DEDENT\n'
+ ' statement ::= stmt_list NEWLINE | compound_stmt\n'
+ ' stmt_list ::= simple_stmt (";" simple_stmt)* [";"]\n'
+ '\n'
+ 'Note that statements always end in a "NEWLINE" possibly followed '
+ 'by a\n'
+ '"DEDENT". Also note that optional continuation clauses always '
+ 'begin\n'
+ 'with a keyword that cannot start a statement, thus there are no\n'
+ 'ambiguities (the \'dangling "else"\' problem is solved in Python '
+ 'by\n'
+ 'requiring nested "if" statements to be indented).\n'
+ '\n'
+ 'The formatting of the grammar rules in the following sections '
+ 'places\n'
+ 'each clause on a separate line for clarity.\n'
+ '\n'
+ '\n'
+ 'The "if" statement\n'
+ '==================\n'
+ '\n'
+ 'The "if" statement is used for conditional execution:\n'
+ '\n'
+ ' if_stmt ::= "if" expression ":" suite\n'
+ ' ( "elif" expression ":" suite )*\n'
+ ' ["else" ":" suite]\n'
+ '\n'
+ 'It selects exactly one of the suites by evaluating the '
+ 'expressions one\n'
+ 'by one until one is found to be true (see section Boolean '
+ 'operations\n'
+ 'for the definition of true and false); then that suite is '
+ 'executed\n'
+ '(and no other part of the "if" statement is executed or '
+ 'evaluated).\n'
+ 'If all expressions are false, the suite of the "else" clause, '
+ 'if\n'
+ 'present, is executed.\n'
+ '\n'
+ '\n'
+ 'The "while" statement\n'
+ '=====================\n'
+ '\n'
+ 'The "while" statement is used for repeated execution as long as '
+ 'an\n'
+ 'expression is true:\n'
+ '\n'
+ ' while_stmt ::= "while" expression ":" suite\n'
+ ' ["else" ":" suite]\n'
+ '\n'
+ 'This repeatedly tests the expression and, if it is true, '
+ 'executes the\n'
+ 'first suite; if the expression is false (which may be the first '
+ 'time\n'
+ 'it is tested) the suite of the "else" clause, if present, is '
+ 'executed\n'
+ 'and the loop terminates.\n'
+ '\n'
+ 'A "break" statement executed in the first suite terminates the '
+ 'loop\n'
+ 'without executing the "else" clause\'s suite. A "continue" '
+ 'statement\n'
+ 'executed in the first suite skips the rest of the suite and goes '
+ 'back\n'
+ 'to testing the expression.\n'
+ '\n'
+ '\n'
+ 'The "for" statement\n'
+ '===================\n'
+ '\n'
+ 'The "for" statement is used to iterate over the elements of a '
+ 'sequence\n'
+ '(such as a string, tuple or list) or other iterable object:\n'
+ '\n'
+ ' for_stmt ::= "for" target_list "in" expression_list ":" '
+ 'suite\n'
+ ' ["else" ":" suite]\n'
+ '\n'
+ 'The expression list is evaluated once; it should yield an '
+ 'iterable\n'
+ 'object. An iterator is created for the result of the\n'
+ '"expression_list". The suite is then executed once for each '
+ 'item\n'
+ 'provided by the iterator, in the order returned by the '
+ 'iterator. Each\n'
+ 'item in turn is assigned to the target list using the standard '
+ 'rules\n'
+ 'for assignments (see Assignment statements), and then the suite '
+ 'is\n'
+ 'executed. When the items are exhausted (which is immediately '
+ 'when the\n'
+ 'sequence is empty or an iterator raises a "StopIteration" '
+ 'exception),\n'
+ 'the suite in the "else" clause, if present, is executed, and the '
+ 'loop\n'
+ 'terminates.\n'
+ '\n'
+ 'A "break" statement executed in the first suite terminates the '
+ 'loop\n'
+ 'without executing the "else" clause\'s suite. A "continue" '
+ 'statement\n'
+ 'executed in the first suite skips the rest of the suite and '
+ 'continues\n'
+ 'with the next item, or with the "else" clause if there is no '
+ 'next\n'
+ 'item.\n'
+ '\n'
+ 'The for-loop makes assignments to the variables(s) in the target '
+ 'list.\n'
+ 'This overwrites all previous assignments to those variables '
+ 'including\n'
+ 'those made in the suite of the for-loop:\n'
+ '\n'
+ ' for i in range(10):\n'
+ ' print(i)\n'
+ ' i = 5 # this will not affect the for-loop\n'
+ ' # because i will be overwritten with '
+ 'the next\n'
+ ' # index in the range\n'
+ '\n'
+ 'Names in the target list are not deleted when the loop is '
+ 'finished,\n'
+ 'but if the sequence is empty, they will not have been assigned '
+ 'to at\n'
+ 'all by the loop. Hint: the built-in function "range()" returns '
+ 'an\n'
+ "iterator of integers suitable to emulate the effect of Pascal's "
+ '"for i\n'
+ ':= a to b do"; e.g., "list(range(3))" returns the list "[0, 1, '
+ '2]".\n'
+ '\n'
+ 'Note: There is a subtlety when the sequence is being modified by '
+ 'the\n'
+ ' loop (this can only occur for mutable sequences, i.e. lists). '
+ 'An\n'
+ ' internal counter is used to keep track of which item is used '
+ 'next,\n'
+ ' and this is incremented on each iteration. When this counter '
+ 'has\n'
+ ' reached the length of the sequence the loop terminates. This '
+ 'means\n'
+ ' that if the suite deletes the current (or a previous) item '
+ 'from the\n'
+ ' sequence, the next item will be skipped (since it gets the '
+ 'index of\n'
+ ' the current item which has already been treated). Likewise, '
+ 'if the\n'
+ ' suite inserts an item in the sequence before the current item, '
+ 'the\n'
+ ' current item will be treated again the next time through the '
+ 'loop.\n'
+ ' This can lead to nasty bugs that can be avoided by making a\n'
+ ' temporary copy using a slice of the whole sequence, e.g.,\n'
+ '\n'
+ ' for x in a[:]:\n'
+ ' if x < 0: a.remove(x)\n'
+ '\n'
+ '\n'
+ 'The "try" statement\n'
+ '===================\n'
+ '\n'
+ 'The "try" statement specifies exception handlers and/or cleanup '
+ 'code\n'
+ 'for a group of statements:\n'
+ '\n'
+ ' try_stmt ::= try1_stmt | try2_stmt\n'
+ ' try1_stmt ::= "try" ":" suite\n'
+ ' ("except" [expression ["as" identifier]] ":" '
+ 'suite)+\n'
+ ' ["else" ":" suite]\n'
+ ' ["finally" ":" suite]\n'
+ ' try2_stmt ::= "try" ":" suite\n'
+ ' "finally" ":" suite\n'
+ '\n'
+ 'The "except" clause(s) specify one or more exception handlers. '
+ 'When no\n'
+ 'exception occurs in the "try" clause, no exception handler is\n'
+ 'executed. When an exception occurs in the "try" suite, a search '
+ 'for an\n'
+ 'exception handler is started. This search inspects the except '
+ 'clauses\n'
+ 'in turn until one is found that matches the exception. An '
+ 'expression-\n'
+ 'less except clause, if present, must be last; it matches any\n'
+ 'exception. For an except clause with an expression, that '
+ 'expression\n'
+ 'is evaluated, and the clause matches the exception if the '
+ 'resulting\n'
+ 'object is "compatible" with the exception. An object is '
+ 'compatible\n'
+ 'with an exception if it is the class or a base class of the '
+ 'exception\n'
+ 'object or a tuple containing an item compatible with the '
+ 'exception.\n'
+ '\n'
+ 'If no except clause matches the exception, the search for an '
+ 'exception\n'
+ 'handler continues in the surrounding code and on the invocation '
+ 'stack.\n'
+ '[1]\n'
+ '\n'
+ 'If the evaluation of an expression in the header of an except '
+ 'clause\n'
+ 'raises an exception, the original search for a handler is '
+ 'canceled and\n'
+ 'a search starts for the new exception in the surrounding code '
+ 'and on\n'
+ 'the call stack (it is treated as if the entire "try" statement '
+ 'raised\n'
+ 'the exception).\n'
+ '\n'
+ 'When a matching except clause is found, the exception is '
+ 'assigned to\n'
+ 'the target specified after the "as" keyword in that except '
+ 'clause, if\n'
+ "present, and the except clause's suite is executed. All except\n"
+ 'clauses must have an executable block. When the end of this '
+ 'block is\n'
+ 'reached, execution continues normally after the entire try '
+ 'statement.\n'
+ '(This means that if two nested handlers exist for the same '
+ 'exception,\n'
+ 'and the exception occurs in the try clause of the inner handler, '
+ 'the\n'
+ 'outer handler will not handle the exception.)\n'
+ '\n'
+ 'When an exception has been assigned using "as target", it is '
+ 'cleared\n'
+ 'at the end of the except clause. This is as if\n'
+ '\n'
+ ' except E as N:\n'
+ ' foo\n'
+ '\n'
+ 'was translated to\n'
+ '\n'
+ ' except E as N:\n'
+ ' try:\n'
+ ' foo\n'
+ ' finally:\n'
+ ' del N\n'
+ '\n'
+ 'This means the exception must be assigned to a different name to '
+ 'be\n'
+ 'able to refer to it after the except clause. Exceptions are '
+ 'cleared\n'
+ 'because with the traceback attached to them, they form a '
+ 'reference\n'
+ 'cycle with the stack frame, keeping all locals in that frame '
+ 'alive\n'
+ 'until the next garbage collection occurs.\n'
+ '\n'
+ "Before an except clause's suite is executed, details about the\n"
+ 'exception are stored in the "sys" module and can be accessed '
+ 'via\n'
+ '"sys.exc_info()". "sys.exc_info()" returns a 3-tuple consisting '
+ 'of the\n'
+ 'exception class, the exception instance and a traceback object '
+ '(see\n'
+ 'section The standard type hierarchy) identifying the point in '
+ 'the\n'
+ 'program where the exception occurred. "sys.exc_info()" values '
+ 'are\n'
+ 'restored to their previous values (before the call) when '
+ 'returning\n'
+ 'from a function that handled an exception.\n'
+ '\n'
+ 'The optional "else" clause is executed if and when control flows '
+ 'off\n'
+ 'the end of the "try" clause. [2] Exceptions in the "else" clause '
+ 'are\n'
+ 'not handled by the preceding "except" clauses.\n'
+ '\n'
+ 'If "finally" is present, it specifies a \'cleanup\' handler. '
+ 'The "try"\n'
+ 'clause is executed, including any "except" and "else" clauses. '
+ 'If an\n'
+ 'exception occurs in any of the clauses and is not handled, the\n'
+ 'exception is temporarily saved. The "finally" clause is '
+ 'executed. If\n'
+ 'there is a saved exception it is re-raised at the end of the '
+ '"finally"\n'
+ 'clause. If the "finally" clause raises another exception, the '
+ 'saved\n'
+ 'exception is set as the context of the new exception. If the '
+ '"finally"\n'
+ 'clause executes a "return" or "break" statement, the saved '
+ 'exception\n'
+ 'is discarded:\n'
+ '\n'
+ ' >>> def f():\n'
+ ' ... try:\n'
+ ' ... 1/0\n'
+ ' ... finally:\n'
+ ' ... return 42\n'
+ ' ...\n'
+ ' >>> f()\n'
+ ' 42\n'
+ '\n'
+ 'The exception information is not available to the program '
+ 'during\n'
+ 'execution of the "finally" clause.\n'
+ '\n'
+ 'When a "return", "break" or "continue" statement is executed in '
+ 'the\n'
+ '"try" suite of a "try"..."finally" statement, the "finally" '
+ 'clause is\n'
+ 'also executed \'on the way out.\' A "continue" statement is '
+ 'illegal in\n'
+ 'the "finally" clause. (The reason is a problem with the current\n'
+ 'implementation --- this restriction may be lifted in the '
+ 'future).\n'
+ '\n'
+ 'The return value of a function is determined by the last '
+ '"return"\n'
+ 'statement executed. Since the "finally" clause always executes, '
+ 'a\n'
+ '"return" statement executed in the "finally" clause will always '
+ 'be the\n'
+ 'last one executed:\n'
+ '\n'
+ ' >>> def foo():\n'
+ ' ... try:\n'
+ " ... return 'try'\n"
+ ' ... finally:\n'
+ " ... return 'finally'\n"
+ ' ...\n'
+ ' >>> foo()\n'
+ " 'finally'\n"
+ '\n'
+ 'Additional information on exceptions can be found in section\n'
+ 'Exceptions, and information on using the "raise" statement to '
+ 'generate\n'
+ 'exceptions may be found in section The raise statement.\n'
+ '\n'
+ '\n'
+ 'The "with" statement\n'
+ '====================\n'
+ '\n'
+ 'The "with" statement is used to wrap the execution of a block '
+ 'with\n'
+ 'methods defined by a context manager (see section With '
+ 'Statement\n'
+ 'Context Managers). This allows common '
+ '"try"..."except"..."finally"\n'
+ 'usage patterns to be encapsulated for convenient reuse.\n'
+ '\n'
+ ' with_stmt ::= "with" with_item ("," with_item)* ":" suite\n'
+ ' with_item ::= expression ["as" target]\n'
+ '\n'
+ 'The execution of the "with" statement with one "item" proceeds '
+ 'as\n'
+ 'follows:\n'
+ '\n'
+ '1. The context expression (the expression given in the '
+ '"with_item")\n'
+ ' is evaluated to obtain a context manager.\n'
+ '\n'
+ '2. The context manager\'s "__exit__()" is loaded for later use.\n'
+ '\n'
+ '3. The context manager\'s "__enter__()" method is invoked.\n'
+ '\n'
+ '4. If a target was included in the "with" statement, the return\n'
+ ' value from "__enter__()" is assigned to it.\n'
+ '\n'
+ ' Note: The "with" statement guarantees that if the '
+ '"__enter__()"\n'
+ ' method returns without an error, then "__exit__()" will '
+ 'always be\n'
+ ' called. Thus, if an error occurs during the assignment to '
+ 'the\n'
+ ' target list, it will be treated the same as an error '
+ 'occurring\n'
+ ' within the suite would be. See step 6 below.\n'
+ '\n'
+ '5. The suite is executed.\n'
+ '\n'
+ '6. The context manager\'s "__exit__()" method is invoked. If '
+ 'an\n'
+ ' exception caused the suite to be exited, its type, value, '
+ 'and\n'
+ ' traceback are passed as arguments to "__exit__()". Otherwise, '
+ 'three\n'
+ ' "None" arguments are supplied.\n'
+ '\n'
+ ' If the suite was exited due to an exception, and the return '
+ 'value\n'
+ ' from the "__exit__()" method was false, the exception is '
+ 'reraised.\n'
+ ' If the return value was true, the exception is suppressed, '
+ 'and\n'
+ ' execution continues with the statement following the "with"\n'
+ ' statement.\n'
+ '\n'
+ ' If the suite was exited for any reason other than an '
+ 'exception, the\n'
+ ' return value from "__exit__()" is ignored, and execution '
+ 'proceeds\n'
+ ' at the normal location for the kind of exit that was taken.\n'
+ '\n'
+ 'With more than one item, the context managers are processed as '
+ 'if\n'
+ 'multiple "with" statements were nested:\n'
+ '\n'
+ ' with A() as a, B() as b:\n'
+ ' suite\n'
+ '\n'
+ 'is equivalent to\n'
+ '\n'
+ ' with A() as a:\n'
+ ' with B() as b:\n'
+ ' suite\n'
+ '\n'
+ 'Changed in version 3.1: Support for multiple context '
+ 'expressions.\n'
+ '\n'
+ 'See also:\n'
+ '\n'
+ ' **PEP 343** - The "with" statement\n'
+ ' The specification, background, and examples for the Python '
+ '"with"\n'
+ ' statement.\n'
+ '\n'
+ '\n'
+ 'Function definitions\n'
+ '====================\n'
+ '\n'
+ 'A function definition defines a user-defined function object '
+ '(see\n'
+ 'section The standard type hierarchy):\n'
+ '\n'
+ ' funcdef ::= [decorators] "def" funcname "(" '
+ '[parameter_list] ")" ["->" expression] ":" suite\n'
+ ' decorators ::= decorator+\n'
+ ' decorator ::= "@" dotted_name ["(" '
+ '[argument_list [","]] ")"] NEWLINE\n'
+ ' dotted_name ::= identifier ("." identifier)*\n'
+ ' parameter_list ::= defparameter ("," defparameter)* '
+ '["," [parameter_list_starargs]]\n'
+ ' | parameter_list_starargs\n'
+ ' parameter_list_starargs ::= "*" [parameter] ("," '
+ 'defparameter)* ["," ["**" parameter [","]]]\n'
+ ' | "**" parameter [","]\n'
+ ' parameter ::= identifier [":" expression]\n'
+ ' defparameter ::= parameter ["=" expression]\n'
+ ' funcname ::= identifier\n'
+ '\n'
+ 'A function definition is an executable statement. Its execution '
+ 'binds\n'
+ 'the function name in the current local namespace to a function '
+ 'object\n'
+ '(a wrapper around the executable code for the function). This\n'
+ 'function object contains a reference to the current global '
+ 'namespace\n'
+ 'as the global namespace to be used when the function is called.\n'
+ '\n'
+ 'The function definition does not execute the function body; this '
+ 'gets\n'
+ 'executed only when the function is called. [3]\n'
+ '\n'
+ 'A function definition may be wrapped by one or more *decorator*\n'
+ 'expressions. Decorator expressions are evaluated when the '
+ 'function is\n'
+ 'defined, in the scope that contains the function definition. '
+ 'The\n'
+ 'result must be a callable, which is invoked with the function '
+ 'object\n'
+ 'as the only argument. The returned value is bound to the '
+ 'function name\n'
+ 'instead of the function object. Multiple decorators are applied '
+ 'in\n'
+ 'nested fashion. For example, the following code\n'
+ '\n'
+ ' @f1(arg)\n'
+ ' @f2\n'
+ ' def func(): pass\n'
+ '\n'
+ 'is equivalent to\n'
+ '\n'
+ ' def func(): pass\n'
+ ' func = f1(arg)(f2(func))\n'
+ '\n'
+ 'When one or more *parameters* have the form *parameter* "="\n'
+ '*expression*, the function is said to have "default parameter '
+ 'values."\n'
+ 'For a parameter with a default value, the corresponding '
+ '*argument* may\n'
+ "be omitted from a call, in which case the parameter's default "
+ 'value is\n'
+ 'substituted. If a parameter has a default value, all following\n'
+ 'parameters up until the ""*"" must also have a default value --- '
+ 'this\n'
+ 'is a syntactic restriction that is not expressed by the '
+ 'grammar.\n'
+ '\n'
+ '**Default parameter values are evaluated from left to right when '
+ 'the\n'
+ 'function definition is executed.** This means that the '
+ 'expression is\n'
+ 'evaluated once, when the function is defined, and that the same '
+ '"pre-\n'
+ 'computed" value is used for each call. This is especially '
+ 'important\n'
+ 'to understand when a default parameter is a mutable object, such '
+ 'as a\n'
+ 'list or a dictionary: if the function modifies the object (e.g. '
+ 'by\n'
+ 'appending an item to a list), the default value is in effect '
+ 'modified.\n'
+ 'This is generally not what was intended. A way around this is '
+ 'to use\n'
+ '"None" as the default, and explicitly test for it in the body of '
+ 'the\n'
+ 'function, e.g.:\n'
+ '\n'
+ ' def whats_on_the_telly(penguin=None):\n'
+ ' if penguin is None:\n'
+ ' penguin = []\n'
+ ' penguin.append("property of the zoo")\n'
+ ' return penguin\n'
+ '\n'
+ 'Function call semantics are described in more detail in section '
+ 'Calls.\n'
+ 'A function call always assigns values to all parameters '
+ 'mentioned in\n'
+ 'the parameter list, either from position arguments, from '
+ 'keyword\n'
+ 'arguments, or from default values. If the form ""*identifier"" '
+ 'is\n'
+ 'present, it is initialized to a tuple receiving any excess '
+ 'positional\n'
+ 'parameters, defaulting to the empty tuple. If the form\n'
+ '""**identifier"" is present, it is initialized to a new '
+ 'dictionary\n'
+ 'receiving any excess keyword arguments, defaulting to a new '
+ 'empty\n'
+ 'dictionary. Parameters after ""*"" or ""*identifier"" are '
+ 'keyword-only\n'
+ 'parameters and may only be passed used keyword arguments.\n'
+ '\n'
+ 'Parameters may have annotations of the form "": expression"" '
+ 'following\n'
+ 'the parameter name. Any parameter may have an annotation even '
+ 'those\n'
+ 'of the form "*identifier" or "**identifier". Functions may '
+ 'have\n'
+ '"return" annotation of the form ""-> expression"" after the '
+ 'parameter\n'
+ 'list. These annotations can be any valid Python expression and '
+ 'are\n'
+ 'evaluated when the function definition is executed. Annotations '
+ 'may\n'
+ 'be evaluated in a different order than they appear in the source '
+ 'code.\n'
+ 'The presence of annotations does not change the semantics of a\n'
+ 'function. The annotation values are available as values of a\n'
+ "dictionary keyed by the parameters' names in the "
+ '"__annotations__"\n'
+ 'attribute of the function object.\n'
+ '\n'
+ 'It is also possible to create anonymous functions (functions not '
+ 'bound\n'
+ 'to a name), for immediate use in expressions. This uses lambda\n'
+ 'expressions, described in section Lambdas. Note that the '
+ 'lambda\n'
+ 'expression is merely a shorthand for a simplified function '
+ 'definition;\n'
+ 'a function defined in a ""def"" statement can be passed around '
+ 'or\n'
+ 'assigned to another name just like a function defined by a '
+ 'lambda\n'
+ 'expression. The ""def"" form is actually more powerful since '
+ 'it\n'
+ 'allows the execution of multiple statements and annotations.\n'
+ '\n'
+ "**Programmer's note:** Functions are first-class objects. A "
+ '""def""\n'
+ 'statement executed inside a function definition defines a local\n'
+ 'function that can be returned or passed around. Free variables '
+ 'used\n'
+ 'in the nested function can access the local variables of the '
+ 'function\n'
+ 'containing the def. See section Naming and binding for '
+ 'details.\n'
+ '\n'
+ 'See also:\n'
+ '\n'
+ ' **PEP 3107** - Function Annotations\n'
+ ' The original specification for function annotations.\n'
+ '\n'
+ '\n'
+ 'Class definitions\n'
+ '=================\n'
+ '\n'
+ 'A class definition defines a class object (see section The '
+ 'standard\n'
+ 'type hierarchy):\n'
+ '\n'
+ ' classdef ::= [decorators] "class" classname [inheritance] '
+ '":" suite\n'
+ ' inheritance ::= "(" [argument_list] ")"\n'
+ ' classname ::= identifier\n'
+ '\n'
+ 'A class definition is an executable statement. The inheritance '
+ 'list\n'
+ 'usually gives a list of base classes (see Customizing class '
+ 'creation\n'
+ 'for more advanced uses), so each item in the list should '
+ 'evaluate to a\n'
+ 'class object which allows subclassing. Classes without an '
+ 'inheritance\n'
+ 'list inherit, by default, from the base class "object"; hence,\n'
+ '\n'
+ ' class Foo:\n'
+ ' pass\n'
+ '\n'
+ 'is equivalent to\n'
+ '\n'
+ ' class Foo(object):\n'
+ ' pass\n'
+ '\n'
+ "The class's suite is then executed in a new execution frame "
+ '(see\n'
+ 'Naming and binding), using a newly created local namespace and '
+ 'the\n'
+ 'original global namespace. (Usually, the suite contains mostly\n'
+ "function definitions.) When the class's suite finishes "
+ 'execution, its\n'
+ 'execution frame is discarded but its local namespace is saved. '
+ '[4] A\n'
+ 'class object is then created using the inheritance list for the '
+ 'base\n'
+ 'classes and the saved local namespace for the attribute '
+ 'dictionary.\n'
+ 'The class name is bound to this class object in the original '
+ 'local\n'
+ 'namespace.\n'
+ '\n'
+ 'Class creation can be customized heavily using metaclasses.\n'
+ '\n'
+ 'Classes can also be decorated: just like when decorating '
+ 'functions,\n'
+ '\n'
+ ' @f1(arg)\n'
+ ' @f2\n'
+ ' class Foo: pass\n'
+ '\n'
+ 'is equivalent to\n'
+ '\n'
+ ' class Foo: pass\n'
+ ' Foo = f1(arg)(f2(Foo))\n'
+ '\n'
+ 'The evaluation rules for the decorator expressions are the same '
+ 'as for\n'
+ 'function decorators. The result must be a class object, which '
+ 'is then\n'
+ 'bound to the class name.\n'
+ '\n'
+ "**Programmer's note:** Variables defined in the class definition "
+ 'are\n'
+ 'class attributes; they are shared by instances. Instance '
+ 'attributes\n'
+ 'can be set in a method with "self.name = value". Both class '
+ 'and\n'
+ 'instance attributes are accessible through the notation '
+ '""self.name"",\n'
+ 'and an instance attribute hides a class attribute with the same '
+ 'name\n'
+ 'when accessed in this way. Class attributes can be used as '
+ 'defaults\n'
+ 'for instance attributes, but using mutable values there can lead '
+ 'to\n'
+ 'unexpected results. Descriptors can be used to create instance\n'
+ 'variables with different implementation details.\n'
+ '\n'
+ 'See also: **PEP 3115** - Metaclasses in Python 3 **PEP 3129** -\n'
+ ' Class Decorators\n'
+ '\n'
+ '\n'
+ 'Coroutines\n'
+ '==========\n'
+ '\n'
+ 'New in version 3.5.\n'
+ '\n'
+ '\n'
+ 'Coroutine function definition\n'
+ '-----------------------------\n'
+ '\n'
+ ' async_funcdef ::= [decorators] "async" "def" funcname "(" '
+ '[parameter_list] ")" ["->" expression] ":" suite\n'
+ '\n'
+ 'Execution of Python coroutines can be suspended and resumed at '
+ 'many\n'
+ 'points (see *coroutine*). In the body of a coroutine, any '
+ '"await" and\n'
+ '"async" identifiers become reserved keywords; "await" '
+ 'expressions,\n'
+ '"async for" and "async with" can only be used in coroutine '
+ 'bodies.\n'
+ '\n'
+ 'Functions defined with "async def" syntax are always coroutine\n'
+ 'functions, even if they do not contain "await" or "async" '
+ 'keywords.\n'
+ '\n'
+ 'It is a "SyntaxError" to use "yield" expressions in "async def"\n'
+ 'coroutines.\n'
+ '\n'
+ 'An example of a coroutine function:\n'
+ '\n'
+ ' async def func(param1, param2):\n'
+ ' do_stuff()\n'
+ ' await some_coroutine()\n'
+ '\n'
+ '\n'
+ 'The "async for" statement\n'
+ '-------------------------\n'
+ '\n'
+ ' async_for_stmt ::= "async" for_stmt\n'
+ '\n'
+ 'An *asynchronous iterable* is able to call asynchronous code in '
+ 'its\n'
+ '*iter* implementation, and *asynchronous iterator* can call\n'
+ 'asynchronous code in its *next* method.\n'
+ '\n'
+ 'The "async for" statement allows convenient iteration over\n'
+ 'asynchronous iterators.\n'
+ '\n'
+ 'The following code:\n'
+ '\n'
+ ' async for TARGET in ITER:\n'
+ ' BLOCK\n'
+ ' else:\n'
+ ' BLOCK2\n'
+ '\n'
+ 'Is semantically equivalent to:\n'
+ '\n'
+ ' iter = (ITER)\n'
+ ' iter = type(iter).__aiter__(iter)\n'
+ ' running = True\n'
+ ' while running:\n'
+ ' try:\n'
+ ' TARGET = await type(iter).__anext__(iter)\n'
+ ' except StopAsyncIteration:\n'
+ ' running = False\n'
+ ' else:\n'
+ ' BLOCK\n'
+ ' else:\n'
+ ' BLOCK2\n'
+ '\n'
+ 'See also "__aiter__()" and "__anext__()" for details.\n'
+ '\n'
+ 'It is a "SyntaxError" to use "async for" statement outside of '
+ 'an\n'
+ '"async def" function.\n'
+ '\n'
+ '\n'
+ 'The "async with" statement\n'
+ '--------------------------\n'
+ '\n'
+ ' async_with_stmt ::= "async" with_stmt\n'
+ '\n'
+ 'An *asynchronous context manager* is a *context manager* that is '
+ 'able\n'
+ 'to suspend execution in its *enter* and *exit* methods.\n'
+ '\n'
+ 'The following code:\n'
+ '\n'
+ ' async with EXPR as VAR:\n'
+ ' BLOCK\n'
+ '\n'
+ 'Is semantically equivalent to:\n'
+ '\n'
+ ' mgr = (EXPR)\n'
+ ' aexit = type(mgr).__aexit__\n'
+ ' aenter = type(mgr).__aenter__(mgr)\n'
+ ' exc = True\n'
+ '\n'
+ ' VAR = await aenter\n'
+ ' try:\n'
+ ' BLOCK\n'
+ ' except:\n'
+ ' if not await aexit(mgr, *sys.exc_info()):\n'
+ ' raise\n'
+ ' else:\n'
+ ' await aexit(mgr, None, None, None)\n'
+ '\n'
+ 'See also "__aenter__()" and "__aexit__()" for details.\n'
+ '\n'
+ 'It is a "SyntaxError" to use "async with" statement outside of '
+ 'an\n'
+ '"async def" function.\n'
+ '\n'
+ 'See also: **PEP 492** - Coroutines with async and await syntax\n'
+ '\n'
+ '-[ Footnotes ]-\n'
+ '\n'
+ '[1] The exception is propagated to the invocation stack unless\n'
+ ' there is a "finally" clause which happens to raise another\n'
+ ' exception. That new exception causes the old one to be '
+ 'lost.\n'
+ '\n'
+ '[2] Currently, control "flows off the end" except in the case '
+ 'of\n'
+ ' an exception or the execution of a "return", "continue", or\n'
+ ' "break" statement.\n'
+ '\n'
+ '[3] A string literal appearing as the first statement in the\n'
+ ' function body is transformed into the function\'s "__doc__"\n'
+ " attribute and therefore the function's *docstring*.\n"
+ '\n'
+ '[4] A string literal appearing as the first statement in the '
+ 'class\n'
+ ' body is transformed into the namespace\'s "__doc__" item '
+ 'and\n'
+ " therefore the class's *docstring*.\n",
+ 'context-managers': '\n'
+ 'With Statement Context Managers\n'
+ '*******************************\n'
+ '\n'
+ 'A *context manager* is an object that defines the '
+ 'runtime context to\n'
+ 'be established when executing a "with" statement. The '
+ 'context manager\n'
+ 'handles the entry into, and the exit from, the desired '
+ 'runtime context\n'
+ 'for the execution of the block of code. Context '
+ 'managers are normally\n'
+ 'invoked using the "with" statement (described in section '
+ 'The with\n'
+ 'statement), but can also be used by directly invoking '
+ 'their methods.\n'
+ '\n'
+ 'Typical uses of context managers include saving and '
+ 'restoring various\n'
+ 'kinds of global state, locking and unlocking resources, '
+ 'closing opened\n'
+ 'files, etc.\n'
+ '\n'
+ 'For more information on context managers, see Context '
+ 'Manager Types.\n'
+ '\n'
+ 'object.__enter__(self)\n'
+ '\n'
+ ' Enter the runtime context related to this object. The '
+ '"with"\n'
+ " statement will bind this method's return value to the "
+ 'target(s)\n'
+ ' specified in the "as" clause of the statement, if '
+ 'any.\n'
+ '\n'
+ 'object.__exit__(self, exc_type, exc_value, traceback)\n'
+ '\n'
+ ' Exit the runtime context related to this object. The '
+ 'parameters\n'
+ ' describe the exception that caused the context to be '
+ 'exited. If the\n'
+ ' context was exited without an exception, all three '
+ 'arguments will\n'
+ ' be "None".\n'
+ '\n'
+ ' If an exception is supplied, and the method wishes to '
+ 'suppress the\n'
+ ' exception (i.e., prevent it from being propagated), '
+ 'it should\n'
+ ' return a true value. Otherwise, the exception will be '
+ 'processed\n'
+ ' normally upon exit from this method.\n'
+ '\n'
+ ' Note that "__exit__()" methods should not reraise the '
+ 'passed-in\n'
+ " exception; this is the caller's responsibility.\n"
+ '\n'
+ 'See also:\n'
+ '\n'
+ ' **PEP 343** - The "with" statement\n'
+ ' The specification, background, and examples for the '
+ 'Python "with"\n'
+ ' statement.\n',
+ 'continue': '\n'
+ 'The "continue" statement\n'
+ '************************\n'
+ '\n'
+ ' continue_stmt ::= "continue"\n'
+ '\n'
+ '"continue" may only occur syntactically nested in a "for" or '
+ '"while"\n'
+ 'loop, but not nested in a function or class definition or '
+ '"finally"\n'
+ 'clause within that loop. It continues with the next cycle of '
+ 'the\n'
+ 'nearest enclosing loop.\n'
+ '\n'
+ 'When "continue" passes control out of a "try" statement with a\n'
+ '"finally" clause, that "finally" clause is executed before '
+ 'really\n'
+ 'starting the next loop cycle.\n',
+ 'conversions': '\n'
+ 'Arithmetic conversions\n'
+ '**********************\n'
+ '\n'
+ 'When a description of an arithmetic operator below uses the '
+ 'phrase\n'
+ '"the numeric arguments are converted to a common type," this '
+ 'means\n'
+ 'that the operator implementation for built-in types works as '
+ 'follows:\n'
+ '\n'
+ '* If either argument is a complex number, the other is '
+ 'converted to\n'
+ ' complex;\n'
+ '\n'
+ '* otherwise, if either argument is a floating point number, '
+ 'the\n'
+ ' other is converted to floating point;\n'
+ '\n'
+ '* otherwise, both must be integers and no conversion is '
+ 'necessary.\n'
+ '\n'
+ 'Some additional rules apply for certain operators (e.g., a '
+ 'string as a\n'
+ "left argument to the '%' operator). Extensions must define "
+ 'their own\n'
+ 'conversion behavior.\n',
+ 'customization': '\n'
+ 'Basic customization\n'
+ '*******************\n'
+ '\n'
+ 'object.__new__(cls[, ...])\n'
+ '\n'
+ ' Called to create a new instance of class *cls*. '
+ '"__new__()" is a\n'
+ ' static method (special-cased so you need not declare it '
+ 'as such)\n'
+ ' that takes the class of which an instance was requested '
+ 'as its\n'
+ ' first argument. The remaining arguments are those '
+ 'passed to the\n'
+ ' object constructor expression (the call to the class). '
+ 'The return\n'
+ ' value of "__new__()" should be the new object instance '
+ '(usually an\n'
+ ' instance of *cls*).\n'
+ '\n'
+ ' Typical implementations create a new instance of the '
+ 'class by\n'
+ ' invoking the superclass\'s "__new__()" method using\n'
+ ' "super(currentclass, cls).__new__(cls[, ...])" with '
+ 'appropriate\n'
+ ' arguments and then modifying the newly-created instance '
+ 'as\n'
+ ' necessary before returning it.\n'
+ '\n'
+ ' If "__new__()" returns an instance of *cls*, then the '
+ 'new\n'
+ ' instance\'s "__init__()" method will be invoked like\n'
+ ' "__init__(self[, ...])", where *self* is the new '
+ 'instance and the\n'
+ ' remaining arguments are the same as were passed to '
+ '"__new__()".\n'
+ '\n'
+ ' If "__new__()" does not return an instance of *cls*, '
+ 'then the new\n'
+ ' instance\'s "__init__()" method will not be invoked.\n'
+ '\n'
+ ' "__new__()" is intended mainly to allow subclasses of '
+ 'immutable\n'
+ ' types (like int, str, or tuple) to customize instance '
+ 'creation. It\n'
+ ' is also commonly overridden in custom metaclasses in '
+ 'order to\n'
+ ' customize class creation.\n'
+ '\n'
+ 'object.__init__(self[, ...])\n'
+ '\n'
+ ' Called after the instance has been created (by '
+ '"__new__()"), but\n'
+ ' before it is returned to the caller. The arguments are '
+ 'those\n'
+ ' passed to the class constructor expression. If a base '
+ 'class has an\n'
+ ' "__init__()" method, the derived class\'s "__init__()" '
+ 'method, if\n'
+ ' any, must explicitly call it to ensure proper '
+ 'initialization of the\n'
+ ' base class part of the instance; for example:\n'
+ ' "BaseClass.__init__(self, [args...])".\n'
+ '\n'
+ ' Because "__new__()" and "__init__()" work together in '
+ 'constructing\n'
+ ' objects ("__new__()" to create it, and "__init__()" to '
+ 'customise\n'
+ ' it), no non-"None" value may be returned by '
+ '"__init__()"; doing so\n'
+ ' will cause a "TypeError" to be raised at runtime.\n'
+ '\n'
+ 'object.__del__(self)\n'
+ '\n'
+ ' Called when the instance is about to be destroyed. This '
+ 'is also\n'
+ ' called a destructor. If a base class has a "__del__()" '
+ 'method, the\n'
+ ' derived class\'s "__del__()" method, if any, must '
+ 'explicitly call it\n'
+ ' to ensure proper deletion of the base class part of the '
+ 'instance.\n'
+ ' Note that it is possible (though not recommended!) for '
+ 'the\n'
+ ' "__del__()" method to postpone destruction of the '
+ 'instance by\n'
+ ' creating a new reference to it. It may then be called '
+ 'at a later\n'
+ ' time when this new reference is deleted. It is not '
+ 'guaranteed that\n'
+ ' "__del__()" methods are called for objects that still '
+ 'exist when\n'
+ ' the interpreter exits.\n'
+ '\n'
+ ' Note: "del x" doesn\'t directly call "x.__del__()" --- '
+ 'the former\n'
+ ' decrements the reference count for "x" by one, and the '
+ 'latter is\n'
+ ' only called when "x"\'s reference count reaches zero. '
+ 'Some common\n'
+ ' situations that may prevent the reference count of an '
+ 'object from\n'
+ ' going to zero include: circular references between '
+ 'objects (e.g.,\n'
+ ' a doubly-linked list or a tree data structure with '
+ 'parent and\n'
+ ' child pointers); a reference to the object on the '
+ 'stack frame of\n'
+ ' a function that caught an exception (the traceback '
+ 'stored in\n'
+ ' "sys.exc_info()[2]" keeps the stack frame alive); or a '
+ 'reference\n'
+ ' to the object on the stack frame that raised an '
+ 'unhandled\n'
+ ' exception in interactive mode (the traceback stored '
+ 'in\n'
+ ' "sys.last_traceback" keeps the stack frame alive). '
+ 'The first\n'
+ ' situation can only be remedied by explicitly breaking '
+ 'the cycles;\n'
+ ' the second can be resolved by freeing the reference to '
+ 'the\n'
+ ' traceback object when it is no longer useful, and the '
+ 'third can\n'
+ ' be resolved by storing "None" in "sys.last_traceback". '
+ 'Circular\n'
+ ' references which are garbage are detected and cleaned '
+ 'up when the\n'
+ " cyclic garbage collector is enabled (it's on by "
+ 'default). Refer\n'
+ ' to the documentation for the "gc" module for more '
+ 'information\n'
+ ' about this topic.\n'
+ '\n'
+ ' Warning: Due to the precarious circumstances under '
+ 'which\n'
+ ' "__del__()" methods are invoked, exceptions that occur '
+ 'during\n'
+ ' their execution are ignored, and a warning is printed '
+ 'to\n'
+ ' "sys.stderr" instead. Also, when "__del__()" is '
+ 'invoked in\n'
+ ' response to a module being deleted (e.g., when '
+ 'execution of the\n'
+ ' program is done), other globals referenced by the '
+ '"__del__()"\n'
+ ' method may already have been deleted or in the process '
+ 'of being\n'
+ ' torn down (e.g. the import machinery shutting down). '
+ 'For this\n'
+ ' reason, "__del__()" methods should do the absolute '
+ 'minimum needed\n'
+ ' to maintain external invariants. Starting with '
+ 'version 1.5,\n'
+ ' Python guarantees that globals whose name begins with '
+ 'a single\n'
+ ' underscore are deleted from their module before other '
+ 'globals are\n'
+ ' deleted; if no other references to such globals exist, '
+ 'this may\n'
+ ' help in assuring that imported modules are still '
+ 'available at the\n'
+ ' time when the "__del__()" method is called.\n'
+ '\n'
+ 'object.__repr__(self)\n'
+ '\n'
+ ' Called by the "repr()" built-in function to compute the '
+ '"official"\n'
+ ' string representation of an object. If at all possible, '
+ 'this\n'
+ ' should look like a valid Python expression that could be '
+ 'used to\n'
+ ' recreate an object with the same value (given an '
+ 'appropriate\n'
+ ' environment). If this is not possible, a string of the '
+ 'form\n'
+ ' "<...some useful description...>" should be returned. '
+ 'The return\n'
+ ' value must be a string object. If a class defines '
+ '"__repr__()" but\n'
+ ' not "__str__()", then "__repr__()" is also used when an '
+ '"informal"\n'
+ ' string representation of instances of that class is '
+ 'required.\n'
+ '\n'
+ ' This is typically used for debugging, so it is important '
+ 'that the\n'
+ ' representation is information-rich and unambiguous.\n'
+ '\n'
+ 'object.__str__(self)\n'
+ '\n'
+ ' Called by "str(object)" and the built-in functions '
+ '"format()" and\n'
+ ' "print()" to compute the "informal" or nicely printable '
+ 'string\n'
+ ' representation of an object. The return value must be a '
+ 'string\n'
+ ' object.\n'
+ '\n'
+ ' This method differs from "object.__repr__()" in that '
+ 'there is no\n'
+ ' expectation that "__str__()" return a valid Python '
+ 'expression: a\n'
+ ' more convenient or concise representation can be used.\n'
+ '\n'
+ ' The default implementation defined by the built-in type '
+ '"object"\n'
+ ' calls "object.__repr__()".\n'
+ '\n'
+ 'object.__bytes__(self)\n'
+ '\n'
+ ' Called by "bytes()" to compute a byte-string '
+ 'representation of an\n'
+ ' object. This should return a "bytes" object.\n'
+ '\n'
+ 'object.__format__(self, format_spec)\n'
+ '\n'
+ ' Called by the "format()" built-in function, and by '
+ 'extension,\n'
+ ' evaluation of formatted string literals and the '
+ '"str.format()"\n'
+ ' method, to produce a "formatted" string representation '
+ 'of an\n'
+ ' object. The "format_spec" argument is a string that '
+ 'contains a\n'
+ ' description of the formatting options desired. The '
+ 'interpretation\n'
+ ' of the "format_spec" argument is up to the type '
+ 'implementing\n'
+ ' "__format__()", however most classes will either '
+ 'delegate\n'
+ ' formatting to one of the built-in types, or use a '
+ 'similar\n'
+ ' formatting option syntax.\n'
+ '\n'
+ ' See Format Specification Mini-Language for a description '
+ 'of the\n'
+ ' standard formatting syntax.\n'
+ '\n'
+ ' The return value must be a string object.\n'
+ '\n'
+ ' Changed in version 3.4: The __format__ method of '
+ '"object" itself\n'
+ ' raises a "TypeError" if passed any non-empty string.\n'
+ '\n'
+ 'object.__lt__(self, other)\n'
+ 'object.__le__(self, other)\n'
+ 'object.__eq__(self, other)\n'
+ 'object.__ne__(self, other)\n'
+ 'object.__gt__(self, other)\n'
+ 'object.__ge__(self, other)\n'
+ '\n'
+ ' These are the so-called "rich comparison" methods. The\n'
+ ' correspondence between operator symbols and method names '
+ 'is as\n'
+ ' follows: "x<y" calls "x.__lt__(y)", "x<=y" calls '
+ '"x.__le__(y)",\n'
+ ' "x==y" calls "x.__eq__(y)", "x!=y" calls "x.__ne__(y)", '
+ '"x>y" calls\n'
+ ' "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".\n'
+ '\n'
+ ' A rich comparison method may return the singleton '
+ '"NotImplemented"\n'
+ ' if it does not implement the operation for a given pair '
+ 'of\n'
+ ' arguments. By convention, "False" and "True" are '
+ 'returned for a\n'
+ ' successful comparison. However, these methods can return '
+ 'any value,\n'
+ ' so if the comparison operator is used in a Boolean '
+ 'context (e.g.,\n'
+ ' in the condition of an "if" statement), Python will call '
+ '"bool()"\n'
+ ' on the value to determine if the result is true or '
+ 'false.\n'
+ '\n'
+ ' By default, "__ne__()" delegates to "__eq__()" and '
+ 'inverts the\n'
+ ' result unless it is "NotImplemented". There are no '
+ 'other implied\n'
+ ' relationships among the comparison operators, for '
+ 'example, the\n'
+ ' truth of "(x<y or x==y)" does not imply "x<=y". To '
+ 'automatically\n'
+ ' generate ordering operations from a single root '
+ 'operation, see\n'
+ ' "functools.total_ordering()".\n'
+ '\n'
+ ' See the paragraph on "__hash__()" for some important '
+ 'notes on\n'
+ ' creating *hashable* objects which support custom '
+ 'comparison\n'
+ ' operations and are usable as dictionary keys.\n'
+ '\n'
+ ' There are no swapped-argument versions of these methods '
+ '(to be used\n'
+ ' when the left argument does not support the operation '
+ 'but the right\n'
+ ' argument does); rather, "__lt__()" and "__gt__()" are '
+ "each other's\n"
+ ' reflection, "__le__()" and "__ge__()" are each other\'s '
+ 'reflection,\n'
+ ' and "__eq__()" and "__ne__()" are their own reflection. '
+ 'If the\n'
+ " operands are of different types, and right operand's "
+ 'type is a\n'
+ " direct or indirect subclass of the left operand's type, "
+ 'the\n'
+ ' reflected method of the right operand has priority, '
+ 'otherwise the\n'
+ " left operand's method has priority. Virtual subclassing "
+ 'is not\n'
+ ' considered.\n'
+ '\n'
+ 'object.__hash__(self)\n'
+ '\n'
+ ' Called by built-in function "hash()" and for operations '
+ 'on members\n'
+ ' of hashed collections including "set", "frozenset", and '
+ '"dict".\n'
+ ' "__hash__()" should return an integer. The only '
+ 'required property\n'
+ ' is that objects which compare equal have the same hash '
+ 'value; it is\n'
+ ' advised to somehow mix together (e.g. using exclusive '
+ 'or) the hash\n'
+ ' values for the components of the object that also play a '
+ 'part in\n'
+ ' comparison of objects.\n'
+ '\n'
+ ' Note: "hash()" truncates the value returned from an '
+ "object's\n"
+ ' custom "__hash__()" method to the size of a '
+ '"Py_ssize_t". This\n'
+ ' is typically 8 bytes on 64-bit builds and 4 bytes on '
+ '32-bit\n'
+ ' builds. If an object\'s "__hash__()" must '
+ 'interoperate on builds\n'
+ ' of different bit sizes, be sure to check the width on '
+ 'all\n'
+ ' supported builds. An easy way to do this is with '
+ '"python -c\n'
+ ' "import sys; print(sys.hash_info.width)"".\n'
+ '\n'
+ ' If a class does not define an "__eq__()" method it '
+ 'should not\n'
+ ' define a "__hash__()" operation either; if it defines '
+ '"__eq__()"\n'
+ ' but not "__hash__()", its instances will not be usable '
+ 'as items in\n'
+ ' hashable collections. If a class defines mutable '
+ 'objects and\n'
+ ' implements an "__eq__()" method, it should not '
+ 'implement\n'
+ ' "__hash__()", since the implementation of hashable '
+ 'collections\n'
+ " requires that a key's hash value is immutable (if the "
+ "object's hash\n"
+ ' value changes, it will be in the wrong hash bucket).\n'
+ '\n'
+ ' User-defined classes have "__eq__()" and "__hash__()" '
+ 'methods by\n'
+ ' default; with them, all objects compare unequal (except '
+ 'with\n'
+ ' themselves) and "x.__hash__()" returns an appropriate '
+ 'value such\n'
+ ' that "x == y" implies both that "x is y" and "hash(x) == '
+ 'hash(y)".\n'
+ '\n'
+ ' A class that overrides "__eq__()" and does not define '
+ '"__hash__()"\n'
+ ' will have its "__hash__()" implicitly set to "None". '
+ 'When the\n'
+ ' "__hash__()" method of a class is "None", instances of '
+ 'the class\n'
+ ' will raise an appropriate "TypeError" when a program '
+ 'attempts to\n'
+ ' retrieve their hash value, and will also be correctly '
+ 'identified as\n'
+ ' unhashable when checking "isinstance(obj, '
+ 'collections.Hashable)".\n'
+ '\n'
+ ' If a class that overrides "__eq__()" needs to retain '
+ 'the\n'
+ ' implementation of "__hash__()" from a parent class, the '
+ 'interpreter\n'
+ ' must be told this explicitly by setting "__hash__ =\n'
+ ' <ParentClass>.__hash__".\n'
+ '\n'
+ ' If a class that does not override "__eq__()" wishes to '
+ 'suppress\n'
+ ' hash support, it should include "__hash__ = None" in the '
+ 'class\n'
+ ' definition. A class which defines its own "__hash__()" '
+ 'that\n'
+ ' explicitly raises a "TypeError" would be incorrectly '
+ 'identified as\n'
+ ' hashable by an "isinstance(obj, collections.Hashable)" '
+ 'call.\n'
+ '\n'
+ ' Note: By default, the "__hash__()" values of str, bytes '
+ 'and\n'
+ ' datetime objects are "salted" with an unpredictable '
+ 'random value.\n'
+ ' Although they remain constant within an individual '
+ 'Python\n'
+ ' process, they are not predictable between repeated '
+ 'invocations of\n'
+ ' Python.This is intended to provide protection against '
+ 'a denial-\n'
+ ' of-service caused by carefully-chosen inputs that '
+ 'exploit the\n'
+ ' worst case performance of a dict insertion, O(n^2) '
+ 'complexity.\n'
+ ' See '
+ 'http://www.ocert.org/advisories/ocert-2011-003.html for\n'
+ ' details.Changing hash values affects the iteration '
+ 'order of\n'
+ ' dicts, sets and other mappings. Python has never made '
+ 'guarantees\n'
+ ' about this ordering (and it typically varies between '
+ '32-bit and\n'
+ ' 64-bit builds).See also "PYTHONHASHSEED".\n'
+ '\n'
+ ' Changed in version 3.3: Hash randomization is enabled by '
+ 'default.\n'
+ '\n'
+ 'object.__bool__(self)\n'
+ '\n'
+ ' Called to implement truth value testing and the built-in '
+ 'operation\n'
+ ' "bool()"; should return "False" or "True". When this '
+ 'method is not\n'
+ ' defined, "__len__()" is called, if it is defined, and '
+ 'the object is\n'
+ ' considered true if its result is nonzero. If a class '
+ 'defines\n'
+ ' neither "__len__()" nor "__bool__()", all its instances '
+ 'are\n'
+ ' considered true.\n',
+ 'debugger': '\n'
+ '"pdb" --- The Python Debugger\n'
+ '*****************************\n'
+ '\n'
+ '**Source code:** Lib/pdb.py\n'
+ '\n'
+ '======================================================================\n'
+ '\n'
+ 'The module "pdb" defines an interactive source code debugger '
+ 'for\n'
+ 'Python programs. It supports setting (conditional) breakpoints '
+ 'and\n'
+ 'single stepping at the source line level, inspection of stack '
+ 'frames,\n'
+ 'source code listing, and evaluation of arbitrary Python code in '
+ 'the\n'
+ 'context of any stack frame. It also supports post-mortem '
+ 'debugging\n'
+ 'and can be called under program control.\n'
+ '\n'
+ 'The debugger is extensible -- it is actually defined as the '
+ 'class\n'
+ '"Pdb". This is currently undocumented but easily understood by '
+ 'reading\n'
+ 'the source. The extension interface uses the modules "bdb" and '
+ '"cmd".\n'
+ '\n'
+ 'The debugger\'s prompt is "(Pdb)". Typical usage to run a '
+ 'program under\n'
+ 'control of the debugger is:\n'
+ '\n'
+ ' >>> import pdb\n'
+ ' >>> import mymodule\n'
+ " >>> pdb.run('mymodule.test()')\n"
+ ' > <string>(0)?()\n'
+ ' (Pdb) continue\n'
+ ' > <string>(1)?()\n'
+ ' (Pdb) continue\n'
+ " NameError: 'spam'\n"
+ ' > <string>(1)?()\n'
+ ' (Pdb)\n'
+ '\n'
+ 'Changed in version 3.3: Tab-completion via the "readline" module '
+ 'is\n'
+ 'available for commands and command arguments, e.g. the current '
+ 'global\n'
+ 'and local names are offered as arguments of the "p" command.\n'
+ '\n'
+ '"pdb.py" can also be invoked as a script to debug other '
+ 'scripts. For\n'
+ 'example:\n'
+ '\n'
+ ' python3 -m pdb myscript.py\n'
+ '\n'
+ 'When invoked as a script, pdb will automatically enter '
+ 'post-mortem\n'
+ 'debugging if the program being debugged exits abnormally. After '
+ 'post-\n'
+ 'mortem debugging (or after normal exit of the program), pdb '
+ 'will\n'
+ "restart the program. Automatic restarting preserves pdb's state "
+ '(such\n'
+ 'as breakpoints) and in most cases is more useful than quitting '
+ 'the\n'
+ "debugger upon program's exit.\n"
+ '\n'
+ 'New in version 3.2: "pdb.py" now accepts a "-c" option that '
+ 'executes\n'
+ 'commands as if given in a ".pdbrc" file, see Debugger Commands.\n'
+ '\n'
+ 'The typical usage to break into the debugger from a running '
+ 'program is\n'
+ 'to insert\n'
+ '\n'
+ ' import pdb; pdb.set_trace()\n'
+ '\n'
+ 'at the location you want to break into the debugger. You can '
+ 'then\n'
+ 'step through the code following this statement, and continue '
+ 'running\n'
+ 'without the debugger using the "continue" command.\n'
+ '\n'
+ 'The typical usage to inspect a crashed program is:\n'
+ '\n'
+ ' >>> import pdb\n'
+ ' >>> import mymodule\n'
+ ' >>> mymodule.test()\n'
+ ' Traceback (most recent call last):\n'
+ ' File "<stdin>", line 1, in ?\n'
+ ' File "./mymodule.py", line 4, in test\n'
+ ' test2()\n'
+ ' File "./mymodule.py", line 3, in test2\n'
+ ' print(spam)\n'
+ ' NameError: spam\n'
+ ' >>> pdb.pm()\n'
+ ' > ./mymodule.py(3)test2()\n'
+ ' -> print(spam)\n'
+ ' (Pdb)\n'
+ '\n'
+ 'The module defines the following functions; each enters the '
+ 'debugger\n'
+ 'in a slightly different way:\n'
+ '\n'
+ 'pdb.run(statement, globals=None, locals=None)\n'
+ '\n'
+ ' Execute the *statement* (given as a string or a code object) '
+ 'under\n'
+ ' debugger control. The debugger prompt appears before any '
+ 'code is\n'
+ ' executed; you can set breakpoints and type "continue", or you '
+ 'can\n'
+ ' step through the statement using "step" or "next" (all these\n'
+ ' commands are explained below). The optional *globals* and '
+ '*locals*\n'
+ ' arguments specify the environment in which the code is '
+ 'executed; by\n'
+ ' default the dictionary of the module "__main__" is used. '
+ '(See the\n'
+ ' explanation of the built-in "exec()" or "eval()" functions.)\n'
+ '\n'
+ 'pdb.runeval(expression, globals=None, locals=None)\n'
+ '\n'
+ ' Evaluate the *expression* (given as a string or a code '
+ 'object)\n'
+ ' under debugger control. When "runeval()" returns, it returns '
+ 'the\n'
+ ' value of the expression. Otherwise this function is similar '
+ 'to\n'
+ ' "run()".\n'
+ '\n'
+ 'pdb.runcall(function, *args, **kwds)\n'
+ '\n'
+ ' Call the *function* (a function or method object, not a '
+ 'string)\n'
+ ' with the given arguments. When "runcall()" returns, it '
+ 'returns\n'
+ ' whatever the function call returned. The debugger prompt '
+ 'appears\n'
+ ' as soon as the function is entered.\n'
+ '\n'
+ 'pdb.set_trace()\n'
+ '\n'
+ ' Enter the debugger at the calling stack frame. This is '
+ 'useful to\n'
+ ' hard-code a breakpoint at a given point in a program, even if '
+ 'the\n'
+ ' code is not otherwise being debugged (e.g. when an assertion\n'
+ ' fails).\n'
+ '\n'
+ 'pdb.post_mortem(traceback=None)\n'
+ '\n'
+ ' Enter post-mortem debugging of the given *traceback* object. '
+ 'If no\n'
+ ' *traceback* is given, it uses the one of the exception that '
+ 'is\n'
+ ' currently being handled (an exception must be being handled '
+ 'if the\n'
+ ' default is to be used).\n'
+ '\n'
+ 'pdb.pm()\n'
+ '\n'
+ ' Enter post-mortem debugging of the traceback found in\n'
+ ' "sys.last_traceback".\n'
+ '\n'
+ 'The "run*" functions and "set_trace()" are aliases for '
+ 'instantiating\n'
+ 'the "Pdb" class and calling the method of the same name. If you '
+ 'want\n'
+ 'to access further features, you have to do this yourself:\n'
+ '\n'
+ "class pdb.Pdb(completekey='tab', stdin=None, stdout=None, "
+ 'skip=None, nosigint=False)\n'
+ '\n'
+ ' "Pdb" is the debugger class.\n'
+ '\n'
+ ' The *completekey*, *stdin* and *stdout* arguments are passed '
+ 'to the\n'
+ ' underlying "cmd.Cmd" class; see the description there.\n'
+ '\n'
+ ' The *skip* argument, if given, must be an iterable of '
+ 'glob-style\n'
+ ' module name patterns. The debugger will not step into frames '
+ 'that\n'
+ ' originate in a module that matches one of these patterns. '
+ '[1]\n'
+ '\n'
+ ' By default, Pdb sets a handler for the SIGINT signal (which '
+ 'is sent\n'
+ ' when the user presses "Ctrl-C" on the console) when you give '
+ 'a\n'
+ ' "continue" command. This allows you to break into the '
+ 'debugger\n'
+ ' again by pressing "Ctrl-C". If you want Pdb not to touch '
+ 'the\n'
+ ' SIGINT handler, set *nosigint* tot true.\n'
+ '\n'
+ ' Example call to enable tracing with *skip*:\n'
+ '\n'
+ " import pdb; pdb.Pdb(skip=['django.*']).set_trace()\n"
+ '\n'
+ ' New in version 3.1: The *skip* argument.\n'
+ '\n'
+ ' New in version 3.2: The *nosigint* argument. Previously, a '
+ 'SIGINT\n'
+ ' handler was never set by Pdb.\n'
+ '\n'
+ ' run(statement, globals=None, locals=None)\n'
+ ' runeval(expression, globals=None, locals=None)\n'
+ ' runcall(function, *args, **kwds)\n'
+ ' set_trace()\n'
+ '\n'
+ ' See the documentation for the functions explained above.\n'
+ '\n'
+ '\n'
+ 'Debugger Commands\n'
+ '=================\n'
+ '\n'
+ 'The commands recognized by the debugger are listed below. Most\n'
+ 'commands can be abbreviated to one or two letters as indicated; '
+ 'e.g.\n'
+ '"h(elp)" means that either "h" or "help" can be used to enter '
+ 'the help\n'
+ 'command (but not "he" or "hel", nor "H" or "Help" or "HELP").\n'
+ 'Arguments to commands must be separated by whitespace (spaces '
+ 'or\n'
+ 'tabs). Optional arguments are enclosed in square brackets '
+ '("[]") in\n'
+ 'the command syntax; the square brackets must not be typed.\n'
+ 'Alternatives in the command syntax are separated by a vertical '
+ 'bar\n'
+ '("|").\n'
+ '\n'
+ 'Entering a blank line repeats the last command entered. '
+ 'Exception: if\n'
+ 'the last command was a "list" command, the next 11 lines are '
+ 'listed.\n'
+ '\n'
+ "Commands that the debugger doesn't recognize are assumed to be "
+ 'Python\n'
+ 'statements and are executed in the context of the program being\n'
+ 'debugged. Python statements can also be prefixed with an '
+ 'exclamation\n'
+ 'point ("!"). This is a powerful way to inspect the program '
+ 'being\n'
+ 'debugged; it is even possible to change a variable or call a '
+ 'function.\n'
+ 'When an exception occurs in such a statement, the exception name '
+ 'is\n'
+ "printed but the debugger's state is not changed.\n"
+ '\n'
+ 'The debugger supports aliases. Aliases can have parameters '
+ 'which\n'
+ 'allows one a certain level of adaptability to the context under\n'
+ 'examination.\n'
+ '\n'
+ 'Multiple commands may be entered on a single line, separated by '
+ '";;".\n'
+ '(A single ";" is not used as it is the separator for multiple '
+ 'commands\n'
+ 'in a line that is passed to the Python parser.) No intelligence '
+ 'is\n'
+ 'applied to separating the commands; the input is split at the '
+ 'first\n'
+ '";;" pair, even if it is in the middle of a quoted string.\n'
+ '\n'
+ 'If a file ".pdbrc" exists in the user\'s home directory or in '
+ 'the\n'
+ 'current directory, it is read in and executed as if it had been '
+ 'typed\n'
+ 'at the debugger prompt. This is particularly useful for '
+ 'aliases. If\n'
+ 'both files exist, the one in the home directory is read first '
+ 'and\n'
+ 'aliases defined there can be overridden by the local file.\n'
+ '\n'
+ 'Changed in version 3.2: ".pdbrc" can now contain commands that\n'
+ 'continue debugging, such as "continue" or "next". Previously, '
+ 'these\n'
+ 'commands had no effect.\n'
+ '\n'
+ 'h(elp) [command]\n'
+ '\n'
+ ' Without argument, print the list of available commands. With '
+ 'a\n'
+ ' *command* as argument, print help about that command. "help '
+ 'pdb"\n'
+ ' displays the full documentation (the docstring of the "pdb"\n'
+ ' module). Since the *command* argument must be an identifier, '
+ '"help\n'
+ ' exec" must be entered to get help on the "!" command.\n'
+ '\n'
+ 'w(here)\n'
+ '\n'
+ ' Print a stack trace, with the most recent frame at the '
+ 'bottom. An\n'
+ ' arrow indicates the current frame, which determines the '
+ 'context of\n'
+ ' most commands.\n'
+ '\n'
+ 'd(own) [count]\n'
+ '\n'
+ ' Move the current frame *count* (default one) levels down in '
+ 'the\n'
+ ' stack trace (to a newer frame).\n'
+ '\n'
+ 'u(p) [count]\n'
+ '\n'
+ ' Move the current frame *count* (default one) levels up in the '
+ 'stack\n'
+ ' trace (to an older frame).\n'
+ '\n'
+ 'b(reak) [([filename:]lineno | function) [, condition]]\n'
+ '\n'
+ ' With a *lineno* argument, set a break there in the current '
+ 'file.\n'
+ ' With a *function* argument, set a break at the first '
+ 'executable\n'
+ ' statement within that function. The line number may be '
+ 'prefixed\n'
+ ' with a filename and a colon, to specify a breakpoint in '
+ 'another\n'
+ " file (probably one that hasn't been loaded yet). The file "
+ 'is\n'
+ ' searched on "sys.path". Note that each breakpoint is '
+ 'assigned a\n'
+ ' number to which all the other breakpoint commands refer.\n'
+ '\n'
+ ' If a second argument is present, it is an expression which '
+ 'must\n'
+ ' evaluate to true before the breakpoint is honored.\n'
+ '\n'
+ ' Without argument, list all breaks, including for each '
+ 'breakpoint,\n'
+ ' the number of times that breakpoint has been hit, the '
+ 'current\n'
+ ' ignore count, and the associated condition if any.\n'
+ '\n'
+ 'tbreak [([filename:]lineno | function) [, condition]]\n'
+ '\n'
+ ' Temporary breakpoint, which is removed automatically when it '
+ 'is\n'
+ ' first hit. The arguments are the same as for "break".\n'
+ '\n'
+ 'cl(ear) [filename:lineno | bpnumber [bpnumber ...]]\n'
+ '\n'
+ ' With a *filename:lineno* argument, clear all the breakpoints '
+ 'at\n'
+ ' this line. With a space separated list of breakpoint numbers, '
+ 'clear\n'
+ ' those breakpoints. Without argument, clear all breaks (but '
+ 'first\n'
+ ' ask confirmation).\n'
+ '\n'
+ 'disable [bpnumber [bpnumber ...]]\n'
+ '\n'
+ ' Disable the breakpoints given as a space separated list of\n'
+ ' breakpoint numbers. Disabling a breakpoint means it cannot '
+ 'cause\n'
+ ' the program to stop execution, but unlike clearing a '
+ 'breakpoint, it\n'
+ ' remains in the list of breakpoints and can be (re-)enabled.\n'
+ '\n'
+ 'enable [bpnumber [bpnumber ...]]\n'
+ '\n'
+ ' Enable the breakpoints specified.\n'
+ '\n'
+ 'ignore bpnumber [count]\n'
+ '\n'
+ ' Set the ignore count for the given breakpoint number. If '
+ 'count is\n'
+ ' omitted, the ignore count is set to 0. A breakpoint becomes '
+ 'active\n'
+ ' when the ignore count is zero. When non-zero, the count is\n'
+ ' decremented each time the breakpoint is reached and the '
+ 'breakpoint\n'
+ ' is not disabled and any associated condition evaluates to '
+ 'true.\n'
+ '\n'
+ 'condition bpnumber [condition]\n'
+ '\n'
+ ' Set a new *condition* for the breakpoint, an expression which '
+ 'must\n'
+ ' evaluate to true before the breakpoint is honored. If '
+ '*condition*\n'
+ ' is absent, any existing condition is removed; i.e., the '
+ 'breakpoint\n'
+ ' is made unconditional.\n'
+ '\n'
+ 'commands [bpnumber]\n'
+ '\n'
+ ' Specify a list of commands for breakpoint number *bpnumber*. '
+ 'The\n'
+ ' commands themselves appear on the following lines. Type a '
+ 'line\n'
+ ' containing just "end" to terminate the commands. An example:\n'
+ '\n'
+ ' (Pdb) commands 1\n'
+ ' (com) p some_variable\n'
+ ' (com) end\n'
+ ' (Pdb)\n'
+ '\n'
+ ' To remove all commands from a breakpoint, type commands and '
+ 'follow\n'
+ ' it immediately with "end"; that is, give no commands.\n'
+ '\n'
+ ' With no *bpnumber* argument, commands refers to the last '
+ 'breakpoint\n'
+ ' set.\n'
+ '\n'
+ ' You can use breakpoint commands to start your program up '
+ 'again.\n'
+ ' Simply use the continue command, or step, or any other '
+ 'command that\n'
+ ' resumes execution.\n'
+ '\n'
+ ' Specifying any command resuming execution (currently '
+ 'continue,\n'
+ ' step, next, return, jump, quit and their abbreviations) '
+ 'terminates\n'
+ ' the command list (as if that command was immediately followed '
+ 'by\n'
+ ' end). This is because any time you resume execution (even '
+ 'with a\n'
+ ' simple next or step), you may encounter another '
+ 'breakpoint--which\n'
+ ' could have its own command list, leading to ambiguities about '
+ 'which\n'
+ ' list to execute.\n'
+ '\n'
+ " If you use the 'silent' command in the command list, the "
+ 'usual\n'
+ ' message about stopping at a breakpoint is not printed. This '
+ 'may be\n'
+ ' desirable for breakpoints that are to print a specific '
+ 'message and\n'
+ ' then continue. If none of the other commands print anything, '
+ 'you\n'
+ ' see no sign that the breakpoint was reached.\n'
+ '\n'
+ 's(tep)\n'
+ '\n'
+ ' Execute the current line, stop at the first possible '
+ 'occasion\n'
+ ' (either in a function that is called or on the next line in '
+ 'the\n'
+ ' current function).\n'
+ '\n'
+ 'n(ext)\n'
+ '\n'
+ ' Continue execution until the next line in the current '
+ 'function is\n'
+ ' reached or it returns. (The difference between "next" and '
+ '"step"\n'
+ ' is that "step" stops inside a called function, while "next"\n'
+ ' executes called functions at (nearly) full speed, only '
+ 'stopping at\n'
+ ' the next line in the current function.)\n'
+ '\n'
+ 'unt(il) [lineno]\n'
+ '\n'
+ ' Without argument, continue execution until the line with a '
+ 'number\n'
+ ' greater than the current one is reached.\n'
+ '\n'
+ ' With a line number, continue execution until a line with a '
+ 'number\n'
+ ' greater or equal to that is reached. In both cases, also '
+ 'stop when\n'
+ ' the current frame returns.\n'
+ '\n'
+ ' Changed in version 3.2: Allow giving an explicit line '
+ 'number.\n'
+ '\n'
+ 'r(eturn)\n'
+ '\n'
+ ' Continue execution until the current function returns.\n'
+ '\n'
+ 'c(ont(inue))\n'
+ '\n'
+ ' Continue execution, only stop when a breakpoint is '
+ 'encountered.\n'
+ '\n'
+ 'j(ump) lineno\n'
+ '\n'
+ ' Set the next line that will be executed. Only available in '
+ 'the\n'
+ ' bottom-most frame. This lets you jump back and execute code '
+ 'again,\n'
+ " or jump forward to skip code that you don't want to run.\n"
+ '\n'
+ ' It should be noted that not all jumps are allowed -- for '
+ 'instance\n'
+ ' it is not possible to jump into the middle of a "for" loop or '
+ 'out\n'
+ ' of a "finally" clause.\n'
+ '\n'
+ 'l(ist) [first[, last]]\n'
+ '\n'
+ ' List source code for the current file. Without arguments, '
+ 'list 11\n'
+ ' lines around the current line or continue the previous '
+ 'listing.\n'
+ ' With "." as argument, list 11 lines around the current line. '
+ 'With\n'
+ ' one argument, list 11 lines around at that line. With two\n'
+ ' arguments, list the given range; if the second argument is '
+ 'less\n'
+ ' than the first, it is interpreted as a count.\n'
+ '\n'
+ ' The current line in the current frame is indicated by "->". '
+ 'If an\n'
+ ' exception is being debugged, the line where the exception '
+ 'was\n'
+ ' originally raised or propagated is indicated by ">>", if it '
+ 'differs\n'
+ ' from the current line.\n'
+ '\n'
+ ' New in version 3.2: The ">>" marker.\n'
+ '\n'
+ 'll | longlist\n'
+ '\n'
+ ' List all source code for the current function or frame.\n'
+ ' Interesting lines are marked as for "list".\n'
+ '\n'
+ ' New in version 3.2.\n'
+ '\n'
+ 'a(rgs)\n'
+ '\n'
+ ' Print the argument list of the current function.\n'
+ '\n'
+ 'p expression\n'
+ '\n'
+ ' Evaluate the *expression* in the current context and print '
+ 'its\n'
+ ' value.\n'
+ '\n'
+ ' Note: "print()" can also be used, but is not a debugger '
+ 'command\n'
+ ' --- this executes the Python "print()" function.\n'
+ '\n'
+ 'pp expression\n'
+ '\n'
+ ' Like the "p" command, except the value of the expression is '
+ 'pretty-\n'
+ ' printed using the "pprint" module.\n'
+ '\n'
+ 'whatis expression\n'
+ '\n'
+ ' Print the type of the *expression*.\n'
+ '\n'
+ 'source expression\n'
+ '\n'
+ ' Try to get source code for the given object and display it.\n'
+ '\n'
+ ' New in version 3.2.\n'
+ '\n'
+ 'display [expression]\n'
+ '\n'
+ ' Display the value of the expression if it changed, each time\n'
+ ' execution stops in the current frame.\n'
+ '\n'
+ ' Without expression, list all display expressions for the '
+ 'current\n'
+ ' frame.\n'
+ '\n'
+ ' New in version 3.2.\n'
+ '\n'
+ 'undisplay [expression]\n'
+ '\n'
+ ' Do not display the expression any more in the current frame.\n'
+ ' Without expression, clear all display expressions for the '
+ 'current\n'
+ ' frame.\n'
+ '\n'
+ ' New in version 3.2.\n'
+ '\n'
+ 'interact\n'
+ '\n'
+ ' Start an interative interpreter (using the "code" module) '
+ 'whose\n'
+ ' global namespace contains all the (global and local) names '
+ 'found in\n'
+ ' the current scope.\n'
+ '\n'
+ ' New in version 3.2.\n'
+ '\n'
+ 'alias [name [command]]\n'
+ '\n'
+ ' Create an alias called *name* that executes *command*. The '
+ 'command\n'
+ ' must *not* be enclosed in quotes. Replaceable parameters can '
+ 'be\n'
+ ' indicated by "%1", "%2", and so on, while "%*" is replaced by '
+ 'all\n'
+ ' the parameters. If no command is given, the current alias '
+ 'for\n'
+ ' *name* is shown. If no arguments are given, all aliases are '
+ 'listed.\n'
+ '\n'
+ ' Aliases may be nested and can contain anything that can be '
+ 'legally\n'
+ ' typed at the pdb prompt. Note that internal pdb commands '
+ '*can* be\n'
+ ' overridden by aliases. Such a command is then hidden until '
+ 'the\n'
+ ' alias is removed. Aliasing is recursively applied to the '
+ 'first\n'
+ ' word of the command line; all other words in the line are '
+ 'left\n'
+ ' alone.\n'
+ '\n'
+ ' As an example, here are two useful aliases (especially when '
+ 'placed\n'
+ ' in the ".pdbrc" file):\n'
+ '\n'
+ ' # Print instance variables (usage "pi classInst")\n'
+ ' alias pi for k in %1.__dict__.keys(): '
+ 'print("%1.",k,"=",%1.__dict__[k])\n'
+ ' # Print instance variables in self\n'
+ ' alias ps pi self\n'
+ '\n'
+ 'unalias name\n'
+ '\n'
+ ' Delete the specified alias.\n'
+ '\n'
+ '! statement\n'
+ '\n'
+ ' Execute the (one-line) *statement* in the context of the '
+ 'current\n'
+ ' stack frame. The exclamation point can be omitted unless the '
+ 'first\n'
+ ' word of the statement resembles a debugger command. To set '
+ 'a\n'
+ ' global variable, you can prefix the assignment command with '
+ 'a\n'
+ ' "global" statement on the same line, e.g.:\n'
+ '\n'
+ " (Pdb) global list_options; list_options = ['-l']\n"
+ ' (Pdb)\n'
+ '\n'
+ 'run [args ...]\n'
+ 'restart [args ...]\n'
+ '\n'
+ ' Restart the debugged Python program. If an argument is '
+ 'supplied,\n'
+ ' it is split with "shlex" and the result is used as the new\n'
+ ' "sys.argv". History, breakpoints, actions and debugger '
+ 'options are\n'
+ ' preserved. "restart" is an alias for "run".\n'
+ '\n'
+ 'q(uit)\n'
+ '\n'
+ ' Quit from the debugger. The program being executed is '
+ 'aborted.\n'
+ '\n'
+ '-[ Footnotes ]-\n'
+ '\n'
+ '[1] Whether a frame is considered to originate in a certain '
+ 'module\n'
+ ' is determined by the "__name__" in the frame globals.\n',
+ 'del': '\n'
+ 'The "del" statement\n'
+ '*******************\n'
+ '\n'
+ ' del_stmt ::= "del" target_list\n'
+ '\n'
+ 'Deletion is recursively defined very similar to the way assignment '
+ 'is\n'
+ 'defined. Rather than spelling it out in full details, here are some\n'
+ 'hints.\n'
+ '\n'
+ 'Deletion of a target list recursively deletes each target, from left\n'
+ 'to right.\n'
+ '\n'
+ 'Deletion of a name removes the binding of that name from the local '
+ 'or\n'
+ 'global namespace, depending on whether the name occurs in a "global"\n'
+ 'statement in the same code block. If the name is unbound, a\n'
+ '"NameError" exception will be raised.\n'
+ '\n'
+ 'Deletion of attribute references, subscriptions and slicings is '
+ 'passed\n'
+ 'to the primary object involved; deletion of a slicing is in general\n'
+ 'equivalent to assignment of an empty slice of the right type (but '
+ 'even\n'
+ 'this is determined by the sliced object).\n'
+ '\n'
+ 'Changed in version 3.2: Previously it was illegal to delete a name\n'
+ 'from the local namespace if it occurs as a free variable in a nested\n'
+ 'block.\n',
+ 'dict': '\n'
+ 'Dictionary displays\n'
+ '*******************\n'
+ '\n'
+ 'A dictionary display is a possibly empty series of key/datum pairs\n'
+ 'enclosed in curly braces:\n'
+ '\n'
+ ' dict_display ::= "{" [key_datum_list | dict_comprehension] '
+ '"}"\n'
+ ' key_datum_list ::= key_datum ("," key_datum)* [","]\n'
+ ' key_datum ::= expression ":" expression | "**" or_expr\n'
+ ' dict_comprehension ::= expression ":" expression comp_for\n'
+ '\n'
+ 'A dictionary display yields a new dictionary object.\n'
+ '\n'
+ 'If a comma-separated sequence of key/datum pairs is given, they are\n'
+ 'evaluated from left to right to define the entries of the '
+ 'dictionary:\n'
+ 'each key object is used as a key into the dictionary to store the\n'
+ 'corresponding datum. This means that you can specify the same key\n'
+ "multiple times in the key/datum list, and the final dictionary's "
+ 'value\n'
+ 'for that key will be the last one given.\n'
+ '\n'
+ 'A double asterisk "**" denotes *dictionary unpacking*. Its operand\n'
+ 'must be a *mapping*. Each mapping item is added to the new\n'
+ 'dictionary. Later values replace values already set by earlier\n'
+ 'key/datum pairs and earlier dictionary unpackings.\n'
+ '\n'
+ 'New in version 3.5: Unpacking into dictionary displays, originally\n'
+ 'proposed by **PEP 448**.\n'
+ '\n'
+ 'A dict comprehension, in contrast to list and set comprehensions,\n'
+ 'needs two expressions separated with a colon followed by the usual\n'
+ '"for" and "if" clauses. When the comprehension is run, the '
+ 'resulting\n'
+ 'key and value elements are inserted in the new dictionary in the '
+ 'order\n'
+ 'they are produced.\n'
+ '\n'
+ 'Restrictions on the types of the key values are listed earlier in\n'
+ 'section The standard type hierarchy. (To summarize, the key type\n'
+ 'should be *hashable*, which excludes all mutable objects.) Clashes\n'
+ 'between duplicate keys are not detected; the last datum (textually\n'
+ 'rightmost in the display) stored for a given key value prevails.\n',
+ 'dynamic-features': '\n'
+ 'Interaction with dynamic features\n'
+ '*********************************\n'
+ '\n'
+ 'Name resolution of free variables occurs at runtime, not '
+ 'at compile\n'
+ 'time. This means that the following code will print 42:\n'
+ '\n'
+ ' i = 10\n'
+ ' def f():\n'
+ ' print(i)\n'
+ ' i = 42\n'
+ ' f()\n'
+ '\n'
+ 'There are several cases where Python statements are '
+ 'illegal when used\n'
+ 'in conjunction with nested scopes that contain free '
+ 'variables.\n'
+ '\n'
+ 'If a variable is referenced in an enclosing scope, it is '
+ 'illegal to\n'
+ 'delete the name. An error will be reported at compile '
+ 'time.\n'
+ '\n'
+ 'The "eval()" and "exec()" functions do not have access '
+ 'to the full\n'
+ 'environment for resolving names. Names may be resolved '
+ 'in the local\n'
+ 'and global namespaces of the caller. Free variables are '
+ 'not resolved\n'
+ 'in the nearest enclosing namespace, but in the global '
+ 'namespace. [1]\n'
+ 'The "exec()" and "eval()" functions have optional '
+ 'arguments to\n'
+ 'override the global and local namespace. If only one '
+ 'namespace is\n'
+ 'specified, it is used for both.\n',
+ 'else': '\n'
+ 'The "if" statement\n'
+ '******************\n'
+ '\n'
+ 'The "if" statement is used for conditional execution:\n'
+ '\n'
+ ' if_stmt ::= "if" expression ":" suite\n'
+ ' ( "elif" expression ":" suite )*\n'
+ ' ["else" ":" suite]\n'
+ '\n'
+ 'It selects exactly one of the suites by evaluating the expressions '
+ 'one\n'
+ 'by one until one is found to be true (see section Boolean '
+ 'operations\n'
+ 'for the definition of true and false); then that suite is executed\n'
+ '(and no other part of the "if" statement is executed or evaluated).\n'
+ 'If all expressions are false, the suite of the "else" clause, if\n'
+ 'present, is executed.\n',
+ 'exceptions': '\n'
+ 'Exceptions\n'
+ '**********\n'
+ '\n'
+ 'Exceptions are a means of breaking out of the normal flow of '
+ 'control\n'
+ 'of a code block in order to handle errors or other '
+ 'exceptional\n'
+ 'conditions. An exception is *raised* at the point where the '
+ 'error is\n'
+ 'detected; it may be *handled* by the surrounding code block or '
+ 'by any\n'
+ 'code block that directly or indirectly invoked the code block '
+ 'where\n'
+ 'the error occurred.\n'
+ '\n'
+ 'The Python interpreter raises an exception when it detects a '
+ 'run-time\n'
+ 'error (such as division by zero). A Python program can also\n'
+ 'explicitly raise an exception with the "raise" statement. '
+ 'Exception\n'
+ 'handlers are specified with the "try" ... "except" statement. '
+ 'The\n'
+ '"finally" clause of such a statement can be used to specify '
+ 'cleanup\n'
+ 'code which does not handle the exception, but is executed '
+ 'whether an\n'
+ 'exception occurred or not in the preceding code.\n'
+ '\n'
+ 'Python uses the "termination" model of error handling: an '
+ 'exception\n'
+ 'handler can find out what happened and continue execution at '
+ 'an outer\n'
+ 'level, but it cannot repair the cause of the error and retry '
+ 'the\n'
+ 'failing operation (except by re-entering the offending piece '
+ 'of code\n'
+ 'from the top).\n'
+ '\n'
+ 'When an exception is not handled at all, the interpreter '
+ 'terminates\n'
+ 'execution of the program, or returns to its interactive main '
+ 'loop. In\n'
+ 'either case, it prints a stack backtrace, except when the '
+ 'exception is\n'
+ '"SystemExit".\n'
+ '\n'
+ 'Exceptions are identified by class instances. The "except" '
+ 'clause is\n'
+ 'selected depending on the class of the instance: it must '
+ 'reference the\n'
+ 'class of the instance or a base class thereof. The instance '
+ 'can be\n'
+ 'received by the handler and can carry additional information '
+ 'about the\n'
+ 'exceptional condition.\n'
+ '\n'
+ 'Note: Exception messages are not part of the Python API. '
+ 'Their\n'
+ ' contents may change from one version of Python to the next '
+ 'without\n'
+ ' warning and should not be relied on by code which will run '
+ 'under\n'
+ ' multiple versions of the interpreter.\n'
+ '\n'
+ 'See also the description of the "try" statement in section The '
+ 'try\n'
+ 'statement and "raise" statement in section The raise '
+ 'statement.\n'
+ '\n'
+ '-[ Footnotes ]-\n'
+ '\n'
+ '[1] This limitation occurs because the code that is executed '
+ 'by\n'
+ ' these operations is not available at the time the module '
+ 'is\n'
+ ' compiled.\n',
+ 'execmodel': '\n'
+ 'Execution model\n'
+ '***************\n'
+ '\n'
+ '\n'
+ 'Structure of a program\n'
+ '======================\n'
+ '\n'
+ 'A Python program is constructed from code blocks. A *block* is '
+ 'a piece\n'
+ 'of Python program text that is executed as a unit. The '
+ 'following are\n'
+ 'blocks: a module, a function body, and a class definition. '
+ 'Each\n'
+ 'command typed interactively is a block. A script file (a file '
+ 'given\n'
+ 'as standard input to the interpreter or specified as a command '
+ 'line\n'
+ 'argument to the interpreter) is a code block. A script command '
+ '(a\n'
+ 'command specified on the interpreter command line with the '
+ "'**-c**'\n"
+ 'option) is a code block. The string argument passed to the '
+ 'built-in\n'
+ 'functions "eval()" and "exec()" is a code block.\n'
+ '\n'
+ 'A code block is executed in an *execution frame*. A frame '
+ 'contains\n'
+ 'some administrative information (used for debugging) and '
+ 'determines\n'
+ "where and how execution continues after the code block's "
+ 'execution has\n'
+ 'completed.\n'
+ '\n'
+ '\n'
+ 'Naming and binding\n'
+ '==================\n'
+ '\n'
+ '\n'
+ 'Binding of names\n'
+ '----------------\n'
+ '\n'
+ '*Names* refer to objects. Names are introduced by name '
+ 'binding\n'
+ 'operations.\n'
+ '\n'
+ 'The following constructs bind names: formal parameters to '
+ 'functions,\n'
+ '"import" statements, class and function definitions (these bind '
+ 'the\n'
+ 'class or function name in the defining block), and targets that '
+ 'are\n'
+ 'identifiers if occurring in an assignment, "for" loop header, '
+ 'or after\n'
+ '"as" in a "with" statement or "except" clause. The "import" '
+ 'statement\n'
+ 'of the form "from ... import *" binds all names defined in the\n'
+ 'imported module, except those beginning with an underscore. '
+ 'This form\n'
+ 'may only be used at the module level.\n'
+ '\n'
+ 'A target occurring in a "del" statement is also considered '
+ 'bound for\n'
+ 'this purpose (though the actual semantics are to unbind the '
+ 'name).\n'
+ '\n'
+ 'Each assignment or import statement occurs within a block '
+ 'defined by a\n'
+ 'class or function definition or at the module level (the '
+ 'top-level\n'
+ 'code block).\n'
+ '\n'
+ 'If a name is bound in a block, it is a local variable of that '
+ 'block,\n'
+ 'unless declared as "nonlocal" or "global". If a name is bound '
+ 'at the\n'
+ 'module level, it is a global variable. (The variables of the '
+ 'module\n'
+ 'code block are local and global.) If a variable is used in a '
+ 'code\n'
+ 'block but not defined there, it is a *free variable*.\n'
+ '\n'
+ 'Each occurrence of a name in the program text refers to the '
+ '*binding*\n'
+ 'of that name established by the following name resolution '
+ 'rules.\n'
+ '\n'
+ '\n'
+ 'Resolution of names\n'
+ '-------------------\n'
+ '\n'
+ 'A *scope* defines the visibility of a name within a block. If '
+ 'a local\n'
+ 'variable is defined in a block, its scope includes that block. '
+ 'If the\n'
+ 'definition occurs in a function block, the scope extends to any '
+ 'blocks\n'
+ 'contained within the defining one, unless a contained block '
+ 'introduces\n'
+ 'a different binding for the name.\n'
+ '\n'
+ 'When a name is used in a code block, it is resolved using the '
+ 'nearest\n'
+ 'enclosing scope. The set of all such scopes visible to a code '
+ 'block\n'
+ "is called the block's *environment*.\n"
+ '\n'
+ 'When a name is not found at all, a "NameError" exception is '
+ 'raised. If\n'
+ 'the current scope is a function scope, and the name refers to a '
+ 'local\n'
+ 'variable that has not yet been bound to a value at the point '
+ 'where the\n'
+ 'name is used, an "UnboundLocalError" exception is raised.\n'
+ '"UnboundLocalError" is a subclass of "NameError".\n'
+ '\n'
+ 'If a name binding operation occurs anywhere within a code '
+ 'block, all\n'
+ 'uses of the name within the block are treated as references to '
+ 'the\n'
+ 'current block. This can lead to errors when a name is used '
+ 'within a\n'
+ 'block before it is bound. This rule is subtle. Python lacks\n'
+ 'declarations and allows name binding operations to occur '
+ 'anywhere\n'
+ 'within a code block. The local variables of a code block can '
+ 'be\n'
+ 'determined by scanning the entire text of the block for name '
+ 'binding\n'
+ 'operations.\n'
+ '\n'
+ 'If the "global" statement occurs within a block, all uses of '
+ 'the name\n'
+ 'specified in the statement refer to the binding of that name in '
+ 'the\n'
+ 'top-level namespace. Names are resolved in the top-level '
+ 'namespace by\n'
+ 'searching the global namespace, i.e. the namespace of the '
+ 'module\n'
+ 'containing the code block, and the builtins namespace, the '
+ 'namespace\n'
+ 'of the module "builtins". The global namespace is searched '
+ 'first. If\n'
+ 'the name is not found there, the builtins namespace is '
+ 'searched. The\n'
+ '"global" statement must precede all uses of the name.\n'
+ '\n'
+ 'The "global" statement has the same scope as a name binding '
+ 'operation\n'
+ 'in the same block. If the nearest enclosing scope for a free '
+ 'variable\n'
+ 'contains a global statement, the free variable is treated as a '
+ 'global.\n'
+ '\n'
+ 'The "nonlocal" statement causes corresponding names to refer '
+ 'to\n'
+ 'previously bound variables in the nearest enclosing function '
+ 'scope.\n'
+ '"SyntaxError" is raised at compile time if the given name does '
+ 'not\n'
+ 'exist in any enclosing function scope.\n'
+ '\n'
+ 'The namespace for a module is automatically created the first '
+ 'time a\n'
+ 'module is imported. The main module for a script is always '
+ 'called\n'
+ '"__main__".\n'
+ '\n'
+ 'Class definition blocks and arguments to "exec()" and "eval()" '
+ 'are\n'
+ 'special in the context of name resolution. A class definition '
+ 'is an\n'
+ 'executable statement that may use and define names. These '
+ 'references\n'
+ 'follow the normal rules for name resolution with an exception '
+ 'that\n'
+ 'unbound local variables are looked up in the global namespace. '
+ 'The\n'
+ 'namespace of the class definition becomes the attribute '
+ 'dictionary of\n'
+ 'the class. The scope of names defined in a class block is '
+ 'limited to\n'
+ 'the class block; it does not extend to the code blocks of '
+ 'methods --\n'
+ 'this includes comprehensions and generator expressions since '
+ 'they are\n'
+ 'implemented using a function scope. This means that the '
+ 'following\n'
+ 'will fail:\n'
+ '\n'
+ ' class A:\n'
+ ' a = 42\n'
+ ' b = list(a + i for i in range(10))\n'
+ '\n'
+ '\n'
+ 'Builtins and restricted execution\n'
+ '---------------------------------\n'
+ '\n'
+ 'The builtins namespace associated with the execution of a code '
+ 'block\n'
+ 'is actually found by looking up the name "__builtins__" in its '
+ 'global\n'
+ 'namespace; this should be a dictionary or a module (in the '
+ 'latter case\n'
+ "the module's dictionary is used). By default, when in the "
+ '"__main__"\n'
+ 'module, "__builtins__" is the built-in module "builtins"; when '
+ 'in any\n'
+ 'other module, "__builtins__" is an alias for the dictionary of '
+ 'the\n'
+ '"builtins" module itself. "__builtins__" can be set to a '
+ 'user-created\n'
+ 'dictionary to create a weak form of restricted execution.\n'
+ '\n'
+ '**CPython implementation detail:** Users should not touch\n'
+ '"__builtins__"; it is strictly an implementation detail. '
+ 'Users\n'
+ 'wanting to override values in the builtins namespace should '
+ '"import"\n'
+ 'the "builtins" module and modify its attributes appropriately.\n'
+ '\n'
+ '\n'
+ 'Interaction with dynamic features\n'
+ '---------------------------------\n'
+ '\n'
+ 'Name resolution of free variables occurs at runtime, not at '
+ 'compile\n'
+ 'time. This means that the following code will print 42:\n'
+ '\n'
+ ' i = 10\n'
+ ' def f():\n'
+ ' print(i)\n'
+ ' i = 42\n'
+ ' f()\n'
+ '\n'
+ 'There are several cases where Python statements are illegal '
+ 'when used\n'
+ 'in conjunction with nested scopes that contain free variables.\n'
+ '\n'
+ 'If a variable is referenced in an enclosing scope, it is '
+ 'illegal to\n'
+ 'delete the name. An error will be reported at compile time.\n'
+ '\n'
+ 'The "eval()" and "exec()" functions do not have access to the '
+ 'full\n'
+ 'environment for resolving names. Names may be resolved in the '
+ 'local\n'
+ 'and global namespaces of the caller. Free variables are not '
+ 'resolved\n'
+ 'in the nearest enclosing namespace, but in the global '
+ 'namespace. [1]\n'
+ 'The "exec()" and "eval()" functions have optional arguments to\n'
+ 'override the global and local namespace. If only one namespace '
+ 'is\n'
+ 'specified, it is used for both.\n'
+ '\n'
+ '\n'
+ 'Exceptions\n'
+ '==========\n'
+ '\n'
+ 'Exceptions are a means of breaking out of the normal flow of '
+ 'control\n'
+ 'of a code block in order to handle errors or other exceptional\n'
+ 'conditions. An exception is *raised* at the point where the '
+ 'error is\n'
+ 'detected; it may be *handled* by the surrounding code block or '
+ 'by any\n'
+ 'code block that directly or indirectly invoked the code block '
+ 'where\n'
+ 'the error occurred.\n'
+ '\n'
+ 'The Python interpreter raises an exception when it detects a '
+ 'run-time\n'
+ 'error (such as division by zero). A Python program can also\n'
+ 'explicitly raise an exception with the "raise" statement. '
+ 'Exception\n'
+ 'handlers are specified with the "try" ... "except" statement. '
+ 'The\n'
+ '"finally" clause of such a statement can be used to specify '
+ 'cleanup\n'
+ 'code which does not handle the exception, but is executed '
+ 'whether an\n'
+ 'exception occurred or not in the preceding code.\n'
+ '\n'
+ 'Python uses the "termination" model of error handling: an '
+ 'exception\n'
+ 'handler can find out what happened and continue execution at an '
+ 'outer\n'
+ 'level, but it cannot repair the cause of the error and retry '
+ 'the\n'
+ 'failing operation (except by re-entering the offending piece of '
+ 'code\n'
+ 'from the top).\n'
+ '\n'
+ 'When an exception is not handled at all, the interpreter '
+ 'terminates\n'
+ 'execution of the program, or returns to its interactive main '
+ 'loop. In\n'
+ 'either case, it prints a stack backtrace, except when the '
+ 'exception is\n'
+ '"SystemExit".\n'
+ '\n'
+ 'Exceptions are identified by class instances. The "except" '
+ 'clause is\n'
+ 'selected depending on the class of the instance: it must '
+ 'reference the\n'
+ 'class of the instance or a base class thereof. The instance '
+ 'can be\n'
+ 'received by the handler and can carry additional information '
+ 'about the\n'
+ 'exceptional condition.\n'
+ '\n'
+ 'Note: Exception messages are not part of the Python API. '
+ 'Their\n'
+ ' contents may change from one version of Python to the next '
+ 'without\n'
+ ' warning and should not be relied on by code which will run '
+ 'under\n'
+ ' multiple versions of the interpreter.\n'
+ '\n'
+ 'See also the description of the "try" statement in section The '
+ 'try\n'
+ 'statement and "raise" statement in section The raise '
+ 'statement.\n'
+ '\n'
+ '-[ Footnotes ]-\n'
+ '\n'
+ '[1] This limitation occurs because the code that is executed '
+ 'by\n'
+ ' these operations is not available at the time the module '
+ 'is\n'
+ ' compiled.\n',
+ 'exprlists': '\n'
+ 'Expression lists\n'
+ '****************\n'
+ '\n'
+ ' expression_list ::= expression ( "," expression )* [","]\n'
+ ' starred_list ::= starred_item ( "," starred_item )* '
+ '[","]\n'
+ ' starred_expression ::= expression | ( starred_item "," )* '
+ '[starred_item]\n'
+ ' starred_item ::= expression | "*" or_expr\n'
+ '\n'
+ 'Except when part of a list or set display, an expression list\n'
+ 'containing at least one comma yields a tuple. The length of '
+ 'the tuple\n'
+ 'is the number of expressions in the list. The expressions are\n'
+ 'evaluated from left to right.\n'
+ '\n'
+ 'An asterisk "*" denotes *iterable unpacking*. Its operand must '
+ 'be an\n'
+ '*iterable*. The iterable is expanded into a sequence of items, '
+ 'which\n'
+ 'are included in the new tuple, list, or set, at the site of '
+ 'the\n'
+ 'unpacking.\n'
+ '\n'
+ 'New in version 3.5: Iterable unpacking in expression lists, '
+ 'originally\n'
+ 'proposed by **PEP 448**.\n'
+ '\n'
+ 'The trailing comma is required only to create a single tuple '
+ '(a.k.a. a\n'
+ '*singleton*); it is optional in all other cases. A single '
+ 'expression\n'
+ "without a trailing comma doesn't create a tuple, but rather "
+ 'yields the\n'
+ 'value of that expression. (To create an empty tuple, use an '
+ 'empty pair\n'
+ 'of parentheses: "()".)\n',
+ 'floating': '\n'
+ 'Floating point literals\n'
+ '***********************\n'
+ '\n'
+ 'Floating point literals are described by the following lexical\n'
+ 'definitions:\n'
+ '\n'
+ ' floatnumber ::= pointfloat | exponentfloat\n'
+ ' pointfloat ::= [intpart] fraction | intpart "."\n'
+ ' exponentfloat ::= (intpart | pointfloat) exponent\n'
+ ' intpart ::= digit+\n'
+ ' fraction ::= "." digit+\n'
+ ' exponent ::= ("e" | "E") ["+" | "-"] digit+\n'
+ '\n'
+ 'Note that the integer and exponent parts are always interpreted '
+ 'using\n'
+ 'radix 10. For example, "077e010" is legal, and denotes the same '
+ 'number\n'
+ 'as "77e10". The allowed range of floating point literals is\n'
+ 'implementation-dependent. Some examples of floating point '
+ 'literals:\n'
+ '\n'
+ ' 3.14 10. .001 1e100 3.14e-10 0e0\n'
+ '\n'
+ 'Note that numeric literals do not include a sign; a phrase like '
+ '"-1"\n'
+ 'is actually an expression composed of the unary operator "-" and '
+ 'the\n'
+ 'literal "1".\n',
+ 'for': '\n'
+ 'The "for" statement\n'
+ '*******************\n'
+ '\n'
+ 'The "for" statement is used to iterate over the elements of a '
+ 'sequence\n'
+ '(such as a string, tuple or list) or other iterable object:\n'
+ '\n'
+ ' for_stmt ::= "for" target_list "in" expression_list ":" suite\n'
+ ' ["else" ":" suite]\n'
+ '\n'
+ 'The expression list is evaluated once; it should yield an iterable\n'
+ 'object. An iterator is created for the result of the\n'
+ '"expression_list". The suite is then executed once for each item\n'
+ 'provided by the iterator, in the order returned by the iterator. '
+ 'Each\n'
+ 'item in turn is assigned to the target list using the standard rules\n'
+ 'for assignments (see Assignment statements), and then the suite is\n'
+ 'executed. When the items are exhausted (which is immediately when '
+ 'the\n'
+ 'sequence is empty or an iterator raises a "StopIteration" '
+ 'exception),\n'
+ 'the suite in the "else" clause, if present, is executed, and the '
+ 'loop\n'
+ 'terminates.\n'
+ '\n'
+ 'A "break" statement executed in the first suite terminates the loop\n'
+ 'without executing the "else" clause\'s suite. A "continue" '
+ 'statement\n'
+ 'executed in the first suite skips the rest of the suite and '
+ 'continues\n'
+ 'with the next item, or with the "else" clause if there is no next\n'
+ 'item.\n'
+ '\n'
+ 'The for-loop makes assignments to the variables(s) in the target '
+ 'list.\n'
+ 'This overwrites all previous assignments to those variables '
+ 'including\n'
+ 'those made in the suite of the for-loop:\n'
+ '\n'
+ ' for i in range(10):\n'
+ ' print(i)\n'
+ ' i = 5 # this will not affect the for-loop\n'
+ ' # because i will be overwritten with the '
+ 'next\n'
+ ' # index in the range\n'
+ '\n'
+ 'Names in the target list are not deleted when the loop is finished,\n'
+ 'but if the sequence is empty, they will not have been assigned to at\n'
+ 'all by the loop. Hint: the built-in function "range()" returns an\n'
+ 'iterator of integers suitable to emulate the effect of Pascal\'s "for '
+ 'i\n'
+ ':= a to b do"; e.g., "list(range(3))" returns the list "[0, 1, 2]".\n'
+ '\n'
+ 'Note: There is a subtlety when the sequence is being modified by the\n'
+ ' loop (this can only occur for mutable sequences, i.e. lists). An\n'
+ ' internal counter is used to keep track of which item is used next,\n'
+ ' and this is incremented on each iteration. When this counter has\n'
+ ' reached the length of the sequence the loop terminates. This '
+ 'means\n'
+ ' that if the suite deletes the current (or a previous) item from '
+ 'the\n'
+ ' sequence, the next item will be skipped (since it gets the index '
+ 'of\n'
+ ' the current item which has already been treated). Likewise, if '
+ 'the\n'
+ ' suite inserts an item in the sequence before the current item, the\n'
+ ' current item will be treated again the next time through the loop.\n'
+ ' This can lead to nasty bugs that can be avoided by making a\n'
+ ' temporary copy using a slice of the whole sequence, e.g.,\n'
+ '\n'
+ ' for x in a[:]:\n'
+ ' if x < 0: a.remove(x)\n',
+ 'formatstrings': '\n'
+ 'Format String Syntax\n'
+ '********************\n'
+ '\n'
+ 'The "str.format()" method and the "Formatter" class share '
+ 'the same\n'
+ 'syntax for format strings (although in the case of '
+ '"Formatter",\n'
+ 'subclasses can define their own format string syntax). The '
+ 'syntax is\n'
+ 'related to that of formatted string literals, but there '
+ 'are\n'
+ 'differences.\n'
+ '\n'
+ 'Format strings contain "replacement fields" surrounded by '
+ 'curly braces\n'
+ '"{}". Anything that is not contained in braces is '
+ 'considered literal\n'
+ 'text, which is copied unchanged to the output. If you need '
+ 'to include\n'
+ 'a brace character in the literal text, it can be escaped by '
+ 'doubling:\n'
+ '"{{" and "}}".\n'
+ '\n'
+ 'The grammar for a replacement field is as follows:\n'
+ '\n'
+ ' replacement_field ::= "{" [field_name] ["!" '
+ 'conversion] [":" format_spec] "}"\n'
+ ' field_name ::= arg_name ("." attribute_name | '
+ '"[" element_index "]")*\n'
+ ' arg_name ::= [identifier | integer]\n'
+ ' attribute_name ::= identifier\n'
+ ' element_index ::= integer | index_string\n'
+ ' index_string ::= <any source character except '
+ '"]"> +\n'
+ ' conversion ::= "r" | "s" | "a"\n'
+ ' format_spec ::= <described in the next '
+ 'section>\n'
+ '\n'
+ 'In less formal terms, the replacement field can start with '
+ 'a\n'
+ '*field_name* that specifies the object whose value is to be '
+ 'formatted\n'
+ 'and inserted into the output instead of the replacement '
+ 'field. The\n'
+ '*field_name* is optionally followed by a *conversion* '
+ 'field, which is\n'
+ 'preceded by an exclamation point "\'!\'", and a '
+ '*format_spec*, which is\n'
+ 'preceded by a colon "\':\'". These specify a non-default '
+ 'format for the\n'
+ 'replacement value.\n'
+ '\n'
+ 'See also the Format Specification Mini-Language section.\n'
+ '\n'
+ 'The *field_name* itself begins with an *arg_name* that is '
+ 'either a\n'
+ "number or a keyword. If it's a number, it refers to a "
+ 'positional\n'
+ "argument, and if it's a keyword, it refers to a named "
+ 'keyword\n'
+ 'argument. If the numerical arg_names in a format string '
+ 'are 0, 1, 2,\n'
+ '... in sequence, they can all be omitted (not just some) '
+ 'and the\n'
+ 'numbers 0, 1, 2, ... will be automatically inserted in that '
+ 'order.\n'
+ 'Because *arg_name* is not quote-delimited, it is not '
+ 'possible to\n'
+ 'specify arbitrary dictionary keys (e.g., the strings '
+ '"\'10\'" or\n'
+ '"\':-]\'") within a format string. The *arg_name* can be '
+ 'followed by any\n'
+ 'number of index or attribute expressions. An expression of '
+ 'the form\n'
+ '"\'.name\'" selects the named attribute using "getattr()", '
+ 'while an\n'
+ 'expression of the form "\'[index]\'" does an index lookup '
+ 'using\n'
+ '"__getitem__()".\n'
+ '\n'
+ 'Changed in version 3.1: The positional argument specifiers '
+ 'can be\n'
+ 'omitted, so "\'{} {}\'" is equivalent to "\'{0} {1}\'".\n'
+ '\n'
+ 'Some simple format string examples:\n'
+ '\n'
+ ' "First, thou shalt count to {0}" # References first '
+ 'positional argument\n'
+ ' "Bring me a {}" # Implicitly '
+ 'references the first positional argument\n'
+ ' "From {} to {}" # Same as "From {0} to '
+ '{1}"\n'
+ ' "My quest is {name}" # References keyword '
+ "argument 'name'\n"
+ ' "Weight in tons {0.weight}" # \'weight\' attribute '
+ 'of first positional arg\n'
+ ' "Units destroyed: {players[0]}" # First element of '
+ "keyword argument 'players'.\n"
+ '\n'
+ 'The *conversion* field causes a type coercion before '
+ 'formatting.\n'
+ 'Normally, the job of formatting a value is done by the '
+ '"__format__()"\n'
+ 'method of the value itself. However, in some cases it is '
+ 'desirable to\n'
+ 'force a type to be formatted as a string, overriding its '
+ 'own\n'
+ 'definition of formatting. By converting the value to a '
+ 'string before\n'
+ 'calling "__format__()", the normal formatting logic is '
+ 'bypassed.\n'
+ '\n'
+ 'Three conversion flags are currently supported: "\'!s\'" '
+ 'which calls\n'
+ '"str()" on the value, "\'!r\'" which calls "repr()" and '
+ '"\'!a\'" which\n'
+ 'calls "ascii()".\n'
+ '\n'
+ 'Some examples:\n'
+ '\n'
+ ' "Harold\'s a clever {0!s}" # Calls str() on the '
+ 'argument first\n'
+ ' "Bring out the holy {name!r}" # Calls repr() on the '
+ 'argument first\n'
+ ' "More {!a}" # Calls ascii() on the '
+ 'argument first\n'
+ '\n'
+ 'The *format_spec* field contains a specification of how the '
+ 'value\n'
+ 'should be presented, including such details as field width, '
+ 'alignment,\n'
+ 'padding, decimal precision and so on. Each value type can '
+ 'define its\n'
+ 'own "formatting mini-language" or interpretation of the '
+ '*format_spec*.\n'
+ '\n'
+ 'Most built-in types support a common formatting '
+ 'mini-language, which\n'
+ 'is described in the next section.\n'
+ '\n'
+ 'A *format_spec* field can also include nested replacement '
+ 'fields\n'
+ 'within it. These nested replacement fields may contain a '
+ 'field name,\n'
+ 'conversion flag and format specification, but deeper '
+ 'nesting is not\n'
+ 'allowed. The replacement fields within the format_spec '
+ 'are\n'
+ 'substituted before the *format_spec* string is interpreted. '
+ 'This\n'
+ 'allows the formatting of a value to be dynamically '
+ 'specified.\n'
+ '\n'
+ 'See the Format examples section for some examples.\n'
+ '\n'
+ '\n'
+ 'Format Specification Mini-Language\n'
+ '==================================\n'
+ '\n'
+ '"Format specifications" are used within replacement fields '
+ 'contained\n'
+ 'within a format string to define how individual values are '
+ 'presented\n'
+ '(see Format String Syntax and Formatted string literals). '
+ 'They can\n'
+ 'also be passed directly to the built-in "format()" '
+ 'function. Each\n'
+ 'formattable type may define how the format specification is '
+ 'to be\n'
+ 'interpreted.\n'
+ '\n'
+ 'Most built-in types implement the following options for '
+ 'format\n'
+ 'specifications, although some of the formatting options are '
+ 'only\n'
+ 'supported by the numeric types.\n'
+ '\n'
+ 'A general convention is that an empty format string ("""") '
+ 'produces\n'
+ 'the same result as if you had called "str()" on the value. '
+ 'A non-empty\n'
+ 'format string typically modifies the result.\n'
+ '\n'
+ 'The general form of a *standard format specifier* is:\n'
+ '\n'
+ ' format_spec ::= '
+ '[[fill]align][sign][#][0][width][,][.precision][type]\n'
+ ' fill ::= <any character>\n'
+ ' align ::= "<" | ">" | "=" | "^"\n'
+ ' sign ::= "+" | "-" | " "\n'
+ ' width ::= integer\n'
+ ' precision ::= integer\n'
+ ' type ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" '
+ '| "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"\n'
+ '\n'
+ 'If a valid *align* value is specified, it can be preceded '
+ 'by a *fill*\n'
+ 'character that can be any character and defaults to a space '
+ 'if\n'
+ 'omitted. It is not possible to use a literal curly brace '
+ '(""{"" or\n'
+ '""}"") as the *fill* character in a formatted string '
+ 'literal or when\n'
+ 'using the "str.format()" method. However, it is possible '
+ 'to insert a\n'
+ 'curly brace with a nested replacement field. This '
+ "limitation doesn't\n"
+ 'affect the "format()" function.\n'
+ '\n'
+ 'The meaning of the various alignment options is as '
+ 'follows:\n'
+ '\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | Option | '
+ 'Meaning '
+ '|\n'
+ ' '
+ '+===========+============================================================+\n'
+ ' | "\'<\'" | Forces the field to be left-aligned '
+ 'within the available |\n'
+ ' | | space (this is the default for most '
+ 'objects). |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | "\'>\'" | Forces the field to be right-aligned '
+ 'within the available |\n'
+ ' | | space (this is the default for '
+ 'numbers). |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | "\'=\'" | Forces the padding to be placed after '
+ 'the sign (if any) |\n'
+ ' | | but before the digits. This is used for '
+ 'printing fields |\n'
+ " | | in the form '+000000120'. This alignment "
+ 'option is only |\n'
+ ' | | valid for numeric types. It becomes the '
+ "default when '0' |\n"
+ ' | | immediately precedes the field '
+ 'width. |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | "\'^\'" | Forces the field to be centered within '
+ 'the available |\n'
+ ' | | '
+ 'space. '
+ '|\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ '\n'
+ 'Note that unless a minimum field width is defined, the '
+ 'field width\n'
+ 'will always be the same size as the data to fill it, so '
+ 'that the\n'
+ 'alignment option has no meaning in this case.\n'
+ '\n'
+ 'The *sign* option is only valid for number types, and can '
+ 'be one of\n'
+ 'the following:\n'
+ '\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | Option | '
+ 'Meaning '
+ '|\n'
+ ' '
+ '+===========+============================================================+\n'
+ ' | "\'+\'" | indicates that a sign should be used for '
+ 'both positive as |\n'
+ ' | | well as negative '
+ 'numbers. |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | "\'-\'" | indicates that a sign should be used '
+ 'only for negative |\n'
+ ' | | numbers (this is the default '
+ 'behavior). |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | space | indicates that a leading space should be '
+ 'used on positive |\n'
+ ' | | numbers, and a minus sign on negative '
+ 'numbers. |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ '\n'
+ 'The "\'#\'" option causes the "alternate form" to be used '
+ 'for the\n'
+ 'conversion. The alternate form is defined differently for '
+ 'different\n'
+ 'types. This option is only valid for integer, float, '
+ 'complex and\n'
+ 'Decimal types. For integers, when binary, octal, or '
+ 'hexadecimal output\n'
+ 'is used, this option adds the prefix respective "\'0b\'", '
+ '"\'0o\'", or\n'
+ '"\'0x\'" to the output value. For floats, complex and '
+ 'Decimal the\n'
+ 'alternate form causes the result of the conversion to '
+ 'always contain a\n'
+ 'decimal-point character, even if no digits follow it. '
+ 'Normally, a\n'
+ 'decimal-point character appears in the result of these '
+ 'conversions\n'
+ 'only if a digit follows it. In addition, for "\'g\'" and '
+ '"\'G\'"\n'
+ 'conversions, trailing zeros are not removed from the '
+ 'result.\n'
+ '\n'
+ 'The "\',\'" option signals the use of a comma for a '
+ 'thousands separator.\n'
+ 'For a locale aware separator, use the "\'n\'" integer '
+ 'presentation type\n'
+ 'instead.\n'
+ '\n'
+ 'Changed in version 3.1: Added the "\',\'" option (see also '
+ '**PEP 378**).\n'
+ '\n'
+ '*width* is a decimal integer defining the minimum field '
+ 'width. If not\n'
+ 'specified, then the field width will be determined by the '
+ 'content.\n'
+ '\n'
+ 'When no explicit alignment is given, preceding the *width* '
+ 'field by a\n'
+ 'zero ("\'0\'") character enables sign-aware zero-padding '
+ 'for numeric\n'
+ 'types. This is equivalent to a *fill* character of "\'0\'" '
+ 'with an\n'
+ '*alignment* type of "\'=\'".\n'
+ '\n'
+ 'The *precision* is a decimal number indicating how many '
+ 'digits should\n'
+ 'be displayed after the decimal point for a floating point '
+ 'value\n'
+ 'formatted with "\'f\'" and "\'F\'", or before and after the '
+ 'decimal point\n'
+ 'for a floating point value formatted with "\'g\'" or '
+ '"\'G\'". For non-\n'
+ 'number types the field indicates the maximum field size - '
+ 'in other\n'
+ 'words, how many characters will be used from the field '
+ 'content. The\n'
+ '*precision* is not allowed for integer values.\n'
+ '\n'
+ 'Finally, the *type* determines how the data should be '
+ 'presented.\n'
+ '\n'
+ 'The available string presentation types are:\n'
+ '\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | Type | '
+ 'Meaning '
+ '|\n'
+ ' '
+ '+===========+============================================================+\n'
+ ' | "\'s\'" | String format. This is the default type '
+ 'for strings and |\n'
+ ' | | may be '
+ 'omitted. |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | None | The same as '
+ '"\'s\'". |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ '\n'
+ 'The available integer presentation types are:\n'
+ '\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | Type | '
+ 'Meaning '
+ '|\n'
+ ' '
+ '+===========+============================================================+\n'
+ ' | "\'b\'" | Binary format. Outputs the number in '
+ 'base 2. |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | "\'c\'" | Character. Converts the integer to the '
+ 'corresponding |\n'
+ ' | | unicode character before '
+ 'printing. |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | "\'d\'" | Decimal Integer. Outputs the number in '
+ 'base 10. |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | "\'o\'" | Octal format. Outputs the number in base '
+ '8. |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | "\'x\'" | Hex format. Outputs the number in base '
+ '16, using lower- |\n'
+ ' | | case letters for the digits above '
+ '9. |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | "\'X\'" | Hex format. Outputs the number in base '
+ '16, using upper- |\n'
+ ' | | case letters for the digits above '
+ '9. |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | "\'n\'" | Number. This is the same as "\'d\'", '
+ 'except that it uses the |\n'
+ ' | | current locale setting to insert the '
+ 'appropriate number |\n'
+ ' | | separator '
+ 'characters. |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | None | The same as '
+ '"\'d\'". |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ '\n'
+ 'In addition to the above presentation types, integers can '
+ 'be formatted\n'
+ 'with the floating point presentation types listed below '
+ '(except "\'n\'"\n'
+ 'and None). When doing so, "float()" is used to convert the '
+ 'integer to\n'
+ 'a floating point number before formatting.\n'
+ '\n'
+ 'The available presentation types for floating point and '
+ 'decimal values\n'
+ 'are:\n'
+ '\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | Type | '
+ 'Meaning '
+ '|\n'
+ ' '
+ '+===========+============================================================+\n'
+ ' | "\'e\'" | Exponent notation. Prints the number in '
+ 'scientific |\n'
+ " | | notation using the letter 'e' to indicate "
+ 'the exponent. |\n'
+ ' | | The default precision is '
+ '"6". |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | "\'E\'" | Exponent notation. Same as "\'e\'" '
+ 'except it uses an upper |\n'
+ " | | case 'E' as the separator "
+ 'character. |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | "\'f\'" | Fixed point. Displays the number as a '
+ 'fixed-point number. |\n'
+ ' | | The default precision is '
+ '"6". |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | "\'F\'" | Fixed point. Same as "\'f\'", but '
+ 'converts "nan" to "NAN" |\n'
+ ' | | and "inf" to '
+ '"INF". |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | "\'g\'" | General format. For a given precision '
+ '"p >= 1", this |\n'
+ ' | | rounds the number to "p" significant '
+ 'digits and then |\n'
+ ' | | formats the result in either fixed-point '
+ 'format or in |\n'
+ ' | | scientific notation, depending on its '
+ 'magnitude. The |\n'
+ ' | | precise rules are as follows: suppose that '
+ 'the result |\n'
+ ' | | formatted with presentation type "\'e\'" '
+ 'and precision "p-1" |\n'
+ ' | | would have exponent "exp". Then if "-4 <= '
+ 'exp < p", the |\n'
+ ' | | number is formatted with presentation type '
+ '"\'f\'" and |\n'
+ ' | | precision "p-1-exp". Otherwise, the '
+ 'number is formatted |\n'
+ ' | | with presentation type "\'e\'" and '
+ 'precision "p-1". In both |\n'
+ ' | | cases insignificant trailing zeros are '
+ 'removed from the |\n'
+ ' | | significand, and the decimal point is also '
+ 'removed if |\n'
+ ' | | there are no remaining digits following '
+ 'it. Positive and |\n'
+ ' | | negative infinity, positive and negative '
+ 'zero, and nans, |\n'
+ ' | | are formatted as "inf", "-inf", "0", "-0" '
+ 'and "nan" |\n'
+ ' | | respectively, regardless of the '
+ 'precision. A precision of |\n'
+ ' | | "0" is treated as equivalent to a '
+ 'precision of "1". The |\n'
+ ' | | default precision is '
+ '"6". |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | "\'G\'" | General format. Same as "\'g\'" except '
+ 'switches to "\'E\'" if |\n'
+ ' | | the number gets too large. The '
+ 'representations of infinity |\n'
+ ' | | and NaN are uppercased, '
+ 'too. |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | "\'n\'" | Number. This is the same as "\'g\'", '
+ 'except that it uses the |\n'
+ ' | | current locale setting to insert the '
+ 'appropriate number |\n'
+ ' | | separator '
+ 'characters. |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | "\'%\'" | Percentage. Multiplies the number by 100 '
+ 'and displays in |\n'
+ ' | | fixed ("\'f\'") format, followed by a '
+ 'percent sign. |\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ ' | None | Similar to "\'g\'", except that '
+ 'fixed-point notation, when |\n'
+ ' | | used, has at least one digit past the '
+ 'decimal point. The |\n'
+ ' | | default precision is as high as needed to '
+ 'represent the |\n'
+ ' | | particular value. The overall effect is to '
+ 'match the |\n'
+ ' | | output of "str()" as altered by the other '
+ 'format |\n'
+ ' | | '
+ 'modifiers. '
+ '|\n'
+ ' '
+ '+-----------+------------------------------------------------------------+\n'
+ '\n'
+ '\n'
+ 'Format examples\n'
+ '===============\n'
+ '\n'
+ 'This section contains examples of the "str.format()" syntax '
+ 'and\n'
+ 'comparison with the old "%"-formatting.\n'
+ '\n'
+ 'In most of the cases the syntax is similar to the old '
+ '"%"-formatting,\n'
+ 'with the addition of the "{}" and with ":" used instead of '
+ '"%". For\n'
+ 'example, "\'%03.2f\'" can be translated to "\'{:03.2f}\'".\n'
+ '\n'
+ 'The new format syntax also supports new and different '
+ 'options, shown\n'
+ 'in the follow examples.\n'
+ '\n'
+ 'Accessing arguments by position:\n'
+ '\n'
+ " >>> '{0}, {1}, {2}'.format('a', 'b', 'c')\n"
+ " 'a, b, c'\n"
+ " >>> '{}, {}, {}'.format('a', 'b', 'c') # 3.1+ only\n"
+ " 'a, b, c'\n"
+ " >>> '{2}, {1}, {0}'.format('a', 'b', 'c')\n"
+ " 'c, b, a'\n"
+ " >>> '{2}, {1}, {0}'.format(*'abc') # unpacking "
+ 'argument sequence\n'
+ " 'c, b, a'\n"
+ " >>> '{0}{1}{0}'.format('abra', 'cad') # arguments' "
+ 'indices can be repeated\n'
+ " 'abracadabra'\n"
+ '\n'
+ 'Accessing arguments by name:\n'
+ '\n'
+ " >>> 'Coordinates: {latitude}, "
+ "{longitude}'.format(latitude='37.24N', "
+ "longitude='-115.81W')\n"
+ " 'Coordinates: 37.24N, -115.81W'\n"
+ " >>> coord = {'latitude': '37.24N', 'longitude': "
+ "'-115.81W'}\n"
+ " >>> 'Coordinates: {latitude}, "
+ "{longitude}'.format(**coord)\n"
+ " 'Coordinates: 37.24N, -115.81W'\n"
+ '\n'
+ "Accessing arguments' attributes:\n"
+ '\n'
+ ' >>> c = 3-5j\n'
+ " >>> ('The complex number {0} is formed from the real "
+ "part {0.real} '\n"
+ " ... 'and the imaginary part {0.imag}.').format(c)\n"
+ " 'The complex number (3-5j) is formed from the real part "
+ "3.0 and the imaginary part -5.0.'\n"
+ ' >>> class Point:\n'
+ ' ... def __init__(self, x, y):\n'
+ ' ... self.x, self.y = x, y\n'
+ ' ... def __str__(self):\n'
+ " ... return 'Point({self.x}, "
+ "{self.y})'.format(self=self)\n"
+ ' ...\n'
+ ' >>> str(Point(4, 2))\n'
+ " 'Point(4, 2)'\n"
+ '\n'
+ "Accessing arguments' items:\n"
+ '\n'
+ ' >>> coord = (3, 5)\n'
+ " >>> 'X: {0[0]}; Y: {0[1]}'.format(coord)\n"
+ " 'X: 3; Y: 5'\n"
+ '\n'
+ 'Replacing "%s" and "%r":\n'
+ '\n'
+ ' >>> "repr() shows quotes: {!r}; str() doesn\'t: '
+ '{!s}".format(\'test1\', \'test2\')\n'
+ ' "repr() shows quotes: \'test1\'; str() doesn\'t: test2"\n'
+ '\n'
+ 'Aligning the text and specifying a width:\n'
+ '\n'
+ " >>> '{:<30}'.format('left aligned')\n"
+ " 'left aligned '\n"
+ " >>> '{:>30}'.format('right aligned')\n"
+ " ' right aligned'\n"
+ " >>> '{:^30}'.format('centered')\n"
+ " ' centered '\n"
+ " >>> '{:*^30}'.format('centered') # use '*' as a fill "
+ 'char\n'
+ " '***********centered***********'\n"
+ '\n'
+ 'Replacing "%+f", "%-f", and "% f" and specifying a sign:\n'
+ '\n'
+ " >>> '{:+f}; {:+f}'.format(3.14, -3.14) # show it "
+ 'always\n'
+ " '+3.140000; -3.140000'\n"
+ " >>> '{: f}; {: f}'.format(3.14, -3.14) # show a space "
+ 'for positive numbers\n'
+ " ' 3.140000; -3.140000'\n"
+ " >>> '{:-f}; {:-f}'.format(3.14, -3.14) # show only the "
+ "minus -- same as '{:f}; {:f}'\n"
+ " '3.140000; -3.140000'\n"
+ '\n'
+ 'Replacing "%x" and "%o" and converting the value to '
+ 'different bases:\n'
+ '\n'
+ ' >>> # format also supports binary numbers\n'
+ ' >>> "int: {0:d}; hex: {0:x}; oct: {0:o}; bin: '
+ '{0:b}".format(42)\n'
+ " 'int: 42; hex: 2a; oct: 52; bin: 101010'\n"
+ ' >>> # with 0x, 0o, or 0b as prefix:\n'
+ ' >>> "int: {0:d}; hex: {0:#x}; oct: {0:#o}; bin: '
+ '{0:#b}".format(42)\n'
+ " 'int: 42; hex: 0x2a; oct: 0o52; bin: 0b101010'\n"
+ '\n'
+ 'Using the comma as a thousands separator:\n'
+ '\n'
+ " >>> '{:,}'.format(1234567890)\n"
+ " '1,234,567,890'\n"
+ '\n'
+ 'Expressing a percentage:\n'
+ '\n'
+ ' >>> points = 19\n'
+ ' >>> total = 22\n'
+ " >>> 'Correct answers: {:.2%}'.format(points/total)\n"
+ " 'Correct answers: 86.36%'\n"
+ '\n'
+ 'Using type-specific formatting:\n'
+ '\n'
+ ' >>> import datetime\n'
+ ' >>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)\n'
+ " >>> '{:%Y-%m-%d %H:%M:%S}'.format(d)\n"
+ " '2010-07-04 12:15:58'\n"
+ '\n'
+ 'Nesting arguments and more complex examples:\n'
+ '\n'
+ " >>> for align, text in zip('<^>', ['left', 'center', "
+ "'right']):\n"
+ " ... '{0:{fill}{align}16}'.format(text, fill=align, "
+ 'align=align)\n'
+ ' ...\n'
+ " 'left<<<<<<<<<<<<'\n"
+ " '^^^^^center^^^^^'\n"
+ " '>>>>>>>>>>>right'\n"
+ ' >>>\n'
+ ' >>> octets = [192, 168, 0, 1]\n'
+ " >>> '{:02X}{:02X}{:02X}{:02X}'.format(*octets)\n"
+ " 'C0A80001'\n"
+ ' >>> int(_, 16)\n'
+ ' 3232235521\n'
+ ' >>>\n'
+ ' >>> width = 5\n'
+ ' >>> for num in range(5,12): #doctest: '
+ '+NORMALIZE_WHITESPACE\n'
+ " ... for base in 'dXob':\n"
+ " ... print('{0:{width}{base}}'.format(num, "
+ "base=base, width=width), end=' ')\n"
+ ' ... print()\n'
+ ' ...\n'
+ ' 5 5 5 101\n'
+ ' 6 6 6 110\n'
+ ' 7 7 7 111\n'
+ ' 8 8 10 1000\n'
+ ' 9 9 11 1001\n'
+ ' 10 A 12 1010\n'
+ ' 11 B 13 1011\n',
+ 'function': '\n'
+ 'Function definitions\n'
+ '********************\n'
+ '\n'
+ 'A function definition defines a user-defined function object '
+ '(see\n'
+ 'section The standard type hierarchy):\n'
+ '\n'
+ ' funcdef ::= [decorators] "def" funcname "(" '
+ '[parameter_list] ")" ["->" expression] ":" suite\n'
+ ' decorators ::= decorator+\n'
+ ' decorator ::= "@" dotted_name ["(" '
+ '[argument_list [","]] ")"] NEWLINE\n'
+ ' dotted_name ::= identifier ("." identifier)*\n'
+ ' parameter_list ::= defparameter ("," defparameter)* '
+ '["," [parameter_list_starargs]]\n'
+ ' | parameter_list_starargs\n'
+ ' parameter_list_starargs ::= "*" [parameter] ("," '
+ 'defparameter)* ["," ["**" parameter [","]]]\n'
+ ' | "**" parameter [","]\n'
+ ' parameter ::= identifier [":" expression]\n'
+ ' defparameter ::= parameter ["=" expression]\n'
+ ' funcname ::= identifier\n'
+ '\n'
+ 'A function definition is an executable statement. Its execution '
+ 'binds\n'
+ 'the function name in the current local namespace to a function '
+ 'object\n'
+ '(a wrapper around the executable code for the function). This\n'
+ 'function object contains a reference to the current global '
+ 'namespace\n'
+ 'as the global namespace to be used when the function is called.\n'
+ '\n'
+ 'The function definition does not execute the function body; this '
+ 'gets\n'
+ 'executed only when the function is called. [3]\n'
+ '\n'
+ 'A function definition may be wrapped by one or more *decorator*\n'
+ 'expressions. Decorator expressions are evaluated when the '
+ 'function is\n'
+ 'defined, in the scope that contains the function definition. '
+ 'The\n'
+ 'result must be a callable, which is invoked with the function '
+ 'object\n'
+ 'as the only argument. The returned value is bound to the '
+ 'function name\n'
+ 'instead of the function object. Multiple decorators are applied '
+ 'in\n'
+ 'nested fashion. For example, the following code\n'
+ '\n'
+ ' @f1(arg)\n'
+ ' @f2\n'
+ ' def func(): pass\n'
+ '\n'
+ 'is equivalent to\n'
+ '\n'
+ ' def func(): pass\n'
+ ' func = f1(arg)(f2(func))\n'
+ '\n'
+ 'When one or more *parameters* have the form *parameter* "="\n'
+ '*expression*, the function is said to have "default parameter '
+ 'values."\n'
+ 'For a parameter with a default value, the corresponding '
+ '*argument* may\n'
+ "be omitted from a call, in which case the parameter's default "
+ 'value is\n'
+ 'substituted. If a parameter has a default value, all following\n'
+ 'parameters up until the ""*"" must also have a default value --- '
+ 'this\n'
+ 'is a syntactic restriction that is not expressed by the '
+ 'grammar.\n'
+ '\n'
+ '**Default parameter values are evaluated from left to right when '
+ 'the\n'
+ 'function definition is executed.** This means that the '
+ 'expression is\n'
+ 'evaluated once, when the function is defined, and that the same '
+ '"pre-\n'
+ 'computed" value is used for each call. This is especially '
+ 'important\n'
+ 'to understand when a default parameter is a mutable object, such '
+ 'as a\n'
+ 'list or a dictionary: if the function modifies the object (e.g. '
+ 'by\n'
+ 'appending an item to a list), the default value is in effect '
+ 'modified.\n'
+ 'This is generally not what was intended. A way around this is '
+ 'to use\n'
+ '"None" as the default, and explicitly test for it in the body of '
+ 'the\n'
+ 'function, e.g.:\n'
+ '\n'
+ ' def whats_on_the_telly(penguin=None):\n'
+ ' if penguin is None:\n'
+ ' penguin = []\n'
+ ' penguin.append("property of the zoo")\n'
+ ' return penguin\n'
+ '\n'
+ 'Function call semantics are described in more detail in section '
+ 'Calls.\n'
+ 'A function call always assigns values to all parameters '
+ 'mentioned in\n'
+ 'the parameter list, either from position arguments, from '
+ 'keyword\n'
+ 'arguments, or from default values. If the form ""*identifier"" '
+ 'is\n'
+ 'present, it is initialized to a tuple receiving any excess '
+ 'positional\n'
+ 'parameters, defaulting to the empty tuple. If the form\n'
+ '""**identifier"" is present, it is initialized to a new '
+ 'dictionary\n'
+ 'receiving any excess keyword arguments, defaulting to a new '
+ 'empty\n'
+ 'dictionary. Parameters after ""*"" or ""*identifier"" are '
+ 'keyword-only\n'
+ 'parameters and may only be passed used keyword arguments.\n'
+ '\n'
+ 'Parameters may have annotations of the form "": expression"" '
+ 'following\n'
+ 'the parameter name. Any parameter may have an annotation even '
+ 'those\n'
+ 'of the form "*identifier" or "**identifier". Functions may '
+ 'have\n'
+ '"return" annotation of the form ""-> expression"" after the '
+ 'parameter\n'
+ 'list. These annotations can be any valid Python expression and '
+ 'are\n'
+ 'evaluated when the function definition is executed. Annotations '
+ 'may\n'
+ 'be evaluated in a different order than they appear in the source '
+ 'code.\n'
+ 'The presence of annotations does not change the semantics of a\n'
+ 'function. The annotation values are available as values of a\n'
+ "dictionary keyed by the parameters' names in the "
+ '"__annotations__"\n'
+ 'attribute of the function object.\n'
+ '\n'
+ 'It is also possible to create anonymous functions (functions not '
+ 'bound\n'
+ 'to a name), for immediate use in expressions. This uses lambda\n'
+ 'expressions, described in section Lambdas. Note that the '
+ 'lambda\n'
+ 'expression is merely a shorthand for a simplified function '
+ 'definition;\n'
+ 'a function defined in a ""def"" statement can be passed around '
+ 'or\n'
+ 'assigned to another name just like a function defined by a '
+ 'lambda\n'
+ 'expression. The ""def"" form is actually more powerful since '
+ 'it\n'
+ 'allows the execution of multiple statements and annotations.\n'
+ '\n'
+ "**Programmer's note:** Functions are first-class objects. A "
+ '""def""\n'
+ 'statement executed inside a function definition defines a local\n'
+ 'function that can be returned or passed around. Free variables '
+ 'used\n'
+ 'in the nested function can access the local variables of the '
+ 'function\n'
+ 'containing the def. See section Naming and binding for '
+ 'details.\n'
+ '\n'
+ 'See also:\n'
+ '\n'
+ ' **PEP 3107** - Function Annotations\n'
+ ' The original specification for function annotations.\n',
+ 'global': '\n'
+ 'The "global" statement\n'
+ '**********************\n'
+ '\n'
+ ' global_stmt ::= "global" identifier ("," identifier)*\n'
+ '\n'
+ 'The "global" statement is a declaration which holds for the '
+ 'entire\n'
+ 'current code block. It means that the listed identifiers are to '
+ 'be\n'
+ 'interpreted as globals. It would be impossible to assign to a '
+ 'global\n'
+ 'variable without "global", although free variables may refer to\n'
+ 'globals without being declared global.\n'
+ '\n'
+ 'Names listed in a "global" statement must not be used in the same '
+ 'code\n'
+ 'block textually preceding that "global" statement.\n'
+ '\n'
+ 'Names listed in a "global" statement must not be defined as '
+ 'formal\n'
+ 'parameters or in a "for" loop control target, "class" definition,\n'
+ 'function definition, or "import" statement.\n'
+ '\n'
+ '**CPython implementation detail:** The current implementation does '
+ 'not\n'
+ 'enforce the two restrictions, but programs should not abuse this\n'
+ 'freedom, as future implementations may enforce them or silently '
+ 'change\n'
+ 'the meaning of the program.\n'
+ '\n'
+ '**Programmer\'s note:** the "global" is a directive to the '
+ 'parser. It\n'
+ 'applies only to code parsed at the same time as the "global"\n'
+ 'statement. In particular, a "global" statement contained in a '
+ 'string\n'
+ 'or code object supplied to the built-in "exec()" function does '
+ 'not\n'
+ 'affect the code block *containing* the function call, and code\n'
+ 'contained in such a string is unaffected by "global" statements in '
+ 'the\n'
+ 'code containing the function call. The same applies to the '
+ '"eval()"\n'
+ 'and "compile()" functions.\n',
+ 'id-classes': '\n'
+ 'Reserved classes of identifiers\n'
+ '*******************************\n'
+ '\n'
+ 'Certain classes of identifiers (besides keywords) have '
+ 'special\n'
+ 'meanings. These classes are identified by the patterns of '
+ 'leading and\n'
+ 'trailing underscore characters:\n'
+ '\n'
+ '"_*"\n'
+ ' Not imported by "from module import *". The special '
+ 'identifier "_"\n'
+ ' is used in the interactive interpreter to store the result '
+ 'of the\n'
+ ' last evaluation; it is stored in the "builtins" module. '
+ 'When not\n'
+ ' in interactive mode, "_" has no special meaning and is not '
+ 'defined.\n'
+ ' See section The import statement.\n'
+ '\n'
+ ' Note: The name "_" is often used in conjunction with\n'
+ ' internationalization; refer to the documentation for the\n'
+ ' "gettext" module for more information on this '
+ 'convention.\n'
+ '\n'
+ '"__*__"\n'
+ ' System-defined names. These names are defined by the '
+ 'interpreter\n'
+ ' and its implementation (including the standard library). '
+ 'Current\n'
+ ' system names are discussed in the Special method names '
+ 'section and\n'
+ ' elsewhere. More will likely be defined in future versions '
+ 'of\n'
+ ' Python. *Any* use of "__*__" names, in any context, that '
+ 'does not\n'
+ ' follow explicitly documented use, is subject to breakage '
+ 'without\n'
+ ' warning.\n'
+ '\n'
+ '"__*"\n'
+ ' Class-private names. Names in this category, when used '
+ 'within the\n'
+ ' context of a class definition, are re-written to use a '
+ 'mangled form\n'
+ ' to help avoid name clashes between "private" attributes of '
+ 'base and\n'
+ ' derived classes. See section Identifiers (Names).\n',
+ 'identifiers': '\n'
+ 'Identifiers and keywords\n'
+ '************************\n'
+ '\n'
+ 'Identifiers (also referred to as *names*) are described by '
+ 'the\n'
+ 'following lexical definitions.\n'
+ '\n'
+ 'The syntax of identifiers in Python is based on the Unicode '
+ 'standard\n'
+ 'annex UAX-31, with elaboration and changes as defined below; '
+ 'see also\n'
+ '**PEP 3131** for further details.\n'
+ '\n'
+ 'Within the ASCII range (U+0001..U+007F), the valid characters '
+ 'for\n'
+ 'identifiers are the same as in Python 2.x: the uppercase and '
+ 'lowercase\n'
+ 'letters "A" through "Z", the underscore "_" and, except for '
+ 'the first\n'
+ 'character, the digits "0" through "9".\n'
+ '\n'
+ 'Python 3.0 introduces additional characters from outside the '
+ 'ASCII\n'
+ 'range (see **PEP 3131**). For these characters, the '
+ 'classification\n'
+ 'uses the version of the Unicode Character Database as '
+ 'included in the\n'
+ '"unicodedata" module.\n'
+ '\n'
+ 'Identifiers are unlimited in length. Case is significant.\n'
+ '\n'
+ ' identifier ::= xid_start xid_continue*\n'
+ ' id_start ::= <all characters in general categories Lu, '
+ 'Ll, Lt, Lm, Lo, Nl, the underscore, and characters with the '
+ 'Other_ID_Start property>\n'
+ ' id_continue ::= <all characters in id_start, plus '
+ 'characters in the categories Mn, Mc, Nd, Pc and others with '
+ 'the Other_ID_Continue property>\n'
+ ' xid_start ::= <all characters in id_start whose NFKC '
+ 'normalization is in "id_start xid_continue*">\n'
+ ' xid_continue ::= <all characters in id_continue whose NFKC '
+ 'normalization is in "id_continue*">\n'
+ '\n'
+ 'The Unicode category codes mentioned above stand for:\n'
+ '\n'
+ '* *Lu* - uppercase letters\n'
+ '\n'
+ '* *Ll* - lowercase letters\n'
+ '\n'
+ '* *Lt* - titlecase letters\n'
+ '\n'
+ '* *Lm* - modifier letters\n'
+ '\n'
+ '* *Lo* - other letters\n'
+ '\n'
+ '* *Nl* - letter numbers\n'
+ '\n'
+ '* *Mn* - nonspacing marks\n'
+ '\n'
+ '* *Mc* - spacing combining marks\n'
+ '\n'
+ '* *Nd* - decimal numbers\n'
+ '\n'
+ '* *Pc* - connector punctuations\n'
+ '\n'
+ '* *Other_ID_Start* - explicit list of characters in '
+ 'PropList.txt to\n'
+ ' support backwards compatibility\n'
+ '\n'
+ '* *Other_ID_Continue* - likewise\n'
+ '\n'
+ 'All identifiers are converted into the normal form NFKC while '
+ 'parsing;\n'
+ 'comparison of identifiers is based on NFKC.\n'
+ '\n'
+ 'A non-normative HTML file listing all valid identifier '
+ 'characters for\n'
+ 'Unicode 4.1 can be found at https://www.dcl.hpi.uni-\n'
+ 'potsdam.de/home/loewis/table-3131.html.\n'
+ '\n'
+ '\n'
+ 'Keywords\n'
+ '========\n'
+ '\n'
+ 'The following identifiers are used as reserved words, or '
+ '*keywords* of\n'
+ 'the language, and cannot be used as ordinary identifiers. '
+ 'They must\n'
+ 'be spelled exactly as written here:\n'
+ '\n'
+ ' False class finally is return\n'
+ ' None continue for lambda try\n'
+ ' True def from nonlocal while\n'
+ ' and del global not with\n'
+ ' as elif if or yield\n'
+ ' assert else import pass\n'
+ ' break except in raise\n'
+ '\n'
+ '\n'
+ 'Reserved classes of identifiers\n'
+ '===============================\n'
+ '\n'
+ 'Certain classes of identifiers (besides keywords) have '
+ 'special\n'
+ 'meanings. These classes are identified by the patterns of '
+ 'leading and\n'
+ 'trailing underscore characters:\n'
+ '\n'
+ '"_*"\n'
+ ' Not imported by "from module import *". The special '
+ 'identifier "_"\n'
+ ' is used in the interactive interpreter to store the result '
+ 'of the\n'
+ ' last evaluation; it is stored in the "builtins" module. '
+ 'When not\n'
+ ' in interactive mode, "_" has no special meaning and is not '
+ 'defined.\n'
+ ' See section The import statement.\n'
+ '\n'
+ ' Note: The name "_" is often used in conjunction with\n'
+ ' internationalization; refer to the documentation for '
+ 'the\n'
+ ' "gettext" module for more information on this '
+ 'convention.\n'
+ '\n'
+ '"__*__"\n'
+ ' System-defined names. These names are defined by the '
+ 'interpreter\n'
+ ' and its implementation (including the standard library). '
+ 'Current\n'
+ ' system names are discussed in the Special method names '
+ 'section and\n'
+ ' elsewhere. More will likely be defined in future versions '
+ 'of\n'
+ ' Python. *Any* use of "__*__" names, in any context, that '
+ 'does not\n'
+ ' follow explicitly documented use, is subject to breakage '
+ 'without\n'
+ ' warning.\n'
+ '\n'
+ '"__*"\n'
+ ' Class-private names. Names in this category, when used '
+ 'within the\n'
+ ' context of a class definition, are re-written to use a '
+ 'mangled form\n'
+ ' to help avoid name clashes between "private" attributes of '
+ 'base and\n'
+ ' derived classes. See section Identifiers (Names).\n',
+ 'if': '\n'
+ 'The "if" statement\n'
+ '******************\n'
+ '\n'
+ 'The "if" statement is used for conditional execution:\n'
+ '\n'
+ ' if_stmt ::= "if" expression ":" suite\n'
+ ' ( "elif" expression ":" suite )*\n'
+ ' ["else" ":" suite]\n'
+ '\n'
+ 'It selects exactly one of the suites by evaluating the expressions '
+ 'one\n'
+ 'by one until one is found to be true (see section Boolean operations\n'
+ 'for the definition of true and false); then that suite is executed\n'
+ '(and no other part of the "if" statement is executed or evaluated).\n'
+ 'If all expressions are false, the suite of the "else" clause, if\n'
+ 'present, is executed.\n',
+ 'imaginary': '\n'
+ 'Imaginary literals\n'
+ '******************\n'
+ '\n'
+ 'Imaginary literals are described by the following lexical '
+ 'definitions:\n'
+ '\n'
+ ' imagnumber ::= (floatnumber | intpart) ("j" | "J")\n'
+ '\n'
+ 'An imaginary literal yields a complex number with a real part '
+ 'of 0.0.\n'
+ 'Complex numbers are represented as a pair of floating point '
+ 'numbers\n'
+ 'and have the same restrictions on their range. To create a '
+ 'complex\n'
+ 'number with a nonzero real part, add a floating point number to '
+ 'it,\n'
+ 'e.g., "(3+4j)". Some examples of imaginary literals:\n'
+ '\n'
+ ' 3.14j 10.j 10j .001j 1e100j 3.14e-10j\n',
+ 'import': '\n'
+ 'The "import" statement\n'
+ '**********************\n'
+ '\n'
+ ' import_stmt ::= "import" module ["as" name] ( "," module '
+ '["as" name] )*\n'
+ ' | "from" relative_module "import" identifier '
+ '["as" name]\n'
+ ' ( "," identifier ["as" name] )*\n'
+ ' | "from" relative_module "import" "(" '
+ 'identifier ["as" name]\n'
+ ' ( "," identifier ["as" name] )* [","] ")"\n'
+ ' | "from" module "import" "*"\n'
+ ' module ::= (identifier ".")* identifier\n'
+ ' relative_module ::= "."* module | "."+\n'
+ ' name ::= identifier\n'
+ '\n'
+ 'The basic import statement (no "from" clause) is executed in two\n'
+ 'steps:\n'
+ '\n'
+ '1. find a module, loading and initializing it if necessary\n'
+ '\n'
+ '2. define a name or names in the local namespace for the scope\n'
+ ' where the "import" statement occurs.\n'
+ '\n'
+ 'When the statement contains multiple clauses (separated by commas) '
+ 'the\n'
+ 'two steps are carried out separately for each clause, just as '
+ 'though\n'
+ 'the clauses had been separated out into individual import '
+ 'statements.\n'
+ '\n'
+ 'The details of the first step, finding and loading modules are\n'
+ 'described in greater detail in the section on the import system, '
+ 'which\n'
+ 'also describes the various types of packages and modules that can '
+ 'be\n'
+ 'imported, as well as all the hooks that can be used to customize '
+ 'the\n'
+ 'import system. Note that failures in this step may indicate '
+ 'either\n'
+ 'that the module could not be located, *or* that an error occurred\n'
+ 'while initializing the module, which includes execution of the\n'
+ "module's code.\n"
+ '\n'
+ 'If the requested module is retrieved successfully, it will be '
+ 'made\n'
+ 'available in the local namespace in one of three ways:\n'
+ '\n'
+ '* If the module name is followed by "as", then the name following\n'
+ ' "as" is bound directly to the imported module.\n'
+ '\n'
+ '* If no other name is specified, and the module being imported is '
+ 'a\n'
+ " top level module, the module's name is bound in the local "
+ 'namespace\n'
+ ' as a reference to the imported module\n'
+ '\n'
+ '* If the module being imported is *not* a top level module, then '
+ 'the\n'
+ ' name of the top level package that contains the module is bound '
+ 'in\n'
+ ' the local namespace as a reference to the top level package. '
+ 'The\n'
+ ' imported module must be accessed using its full qualified name\n'
+ ' rather than directly\n'
+ '\n'
+ 'The "from" form uses a slightly more complex process:\n'
+ '\n'
+ '1. find the module specified in the "from" clause, loading and\n'
+ ' initializing it if necessary;\n'
+ '\n'
+ '2. for each of the identifiers specified in the "import" clauses:\n'
+ '\n'
+ ' 1. check if the imported module has an attribute by that name\n'
+ '\n'
+ ' 2. if not, attempt to import a submodule with that name and '
+ 'then\n'
+ ' check the imported module again for that attribute\n'
+ '\n'
+ ' 3. if the attribute is not found, "ImportError" is raised.\n'
+ '\n'
+ ' 4. otherwise, a reference to that value is stored in the local\n'
+ ' namespace, using the name in the "as" clause if it is '
+ 'present,\n'
+ ' otherwise using the attribute name\n'
+ '\n'
+ 'Examples:\n'
+ '\n'
+ ' import foo # foo imported and bound locally\n'
+ ' import foo.bar.baz # foo.bar.baz imported, foo bound '
+ 'locally\n'
+ ' import foo.bar.baz as fbb # foo.bar.baz imported and bound as '
+ 'fbb\n'
+ ' from foo.bar import baz # foo.bar.baz imported and bound as '
+ 'baz\n'
+ ' from foo import attr # foo imported and foo.attr bound as '
+ 'attr\n'
+ '\n'
+ 'If the list of identifiers is replaced by a star ("\'*\'"), all '
+ 'public\n'
+ 'names defined in the module are bound in the local namespace for '
+ 'the\n'
+ 'scope where the "import" statement occurs.\n'
+ '\n'
+ 'The *public names* defined by a module are determined by checking '
+ 'the\n'
+ 'module\'s namespace for a variable named "__all__"; if defined, it '
+ 'must\n'
+ 'be a sequence of strings which are names defined or imported by '
+ 'that\n'
+ 'module. The names given in "__all__" are all considered public '
+ 'and\n'
+ 'are required to exist. If "__all__" is not defined, the set of '
+ 'public\n'
+ "names includes all names found in the module's namespace which do "
+ 'not\n'
+ 'begin with an underscore character ("\'_\'"). "__all__" should '
+ 'contain\n'
+ 'the entire public API. It is intended to avoid accidentally '
+ 'exporting\n'
+ 'items that are not part of the API (such as library modules which '
+ 'were\n'
+ 'imported and used within the module).\n'
+ '\n'
+ 'The wild card form of import --- "from module import *" --- is '
+ 'only\n'
+ 'allowed at the module level. Attempting to use it in class or\n'
+ 'function definitions will raise a "SyntaxError".\n'
+ '\n'
+ 'When specifying what module to import you do not have to specify '
+ 'the\n'
+ 'absolute name of the module. When a module or package is '
+ 'contained\n'
+ 'within another package it is possible to make a relative import '
+ 'within\n'
+ 'the same top package without having to mention the package name. '
+ 'By\n'
+ 'using leading dots in the specified module or package after "from" '
+ 'you\n'
+ 'can specify how high to traverse up the current package hierarchy\n'
+ 'without specifying exact names. One leading dot means the current\n'
+ 'package where the module making the import exists. Two dots means '
+ 'up\n'
+ 'one package level. Three dots is up two levels, etc. So if you '
+ 'execute\n'
+ '"from . import mod" from a module in the "pkg" package then you '
+ 'will\n'
+ 'end up importing "pkg.mod". If you execute "from ..subpkg2 import '
+ 'mod"\n'
+ 'from within "pkg.subpkg1" you will import "pkg.subpkg2.mod". The\n'
+ 'specification for relative imports is contained within **PEP '
+ '328**.\n'
+ '\n'
+ '"importlib.import_module()" is provided to support applications '
+ 'that\n'
+ 'determine dynamically the modules to be loaded.\n'
+ '\n'
+ '\n'
+ 'Future statements\n'
+ '=================\n'
+ '\n'
+ 'A *future statement* is a directive to the compiler that a '
+ 'particular\n'
+ 'module should be compiled using syntax or semantics that will be\n'
+ 'available in a specified future release of Python where the '
+ 'feature\n'
+ 'becomes standard.\n'
+ '\n'
+ 'The future statement is intended to ease migration to future '
+ 'versions\n'
+ 'of Python that introduce incompatible changes to the language. '
+ 'It\n'
+ 'allows use of the new features on a per-module basis before the\n'
+ 'release in which the feature becomes standard.\n'
+ '\n'
+ ' future_statement ::= "from" "__future__" "import" feature ["as" '
+ 'name]\n'
+ ' ("," feature ["as" name])*\n'
+ ' | "from" "__future__" "import" "(" feature '
+ '["as" name]\n'
+ ' ("," feature ["as" name])* [","] ")"\n'
+ ' feature ::= identifier\n'
+ ' name ::= identifier\n'
+ '\n'
+ 'A future statement must appear near the top of the module. The '
+ 'only\n'
+ 'lines that can appear before a future statement are:\n'
+ '\n'
+ '* the module docstring (if any),\n'
+ '\n'
+ '* comments,\n'
+ '\n'
+ '* blank lines, and\n'
+ '\n'
+ '* other future statements.\n'
+ '\n'
+ 'The features recognized by Python 3.0 are "absolute_import",\n'
+ '"division", "generators", "unicode_literals", "print_function",\n'
+ '"nested_scopes" and "with_statement". They are all redundant '
+ 'because\n'
+ 'they are always enabled, and only kept for backwards '
+ 'compatibility.\n'
+ '\n'
+ 'A future statement is recognized and treated specially at compile\n'
+ 'time: Changes to the semantics of core constructs are often\n'
+ 'implemented by generating different code. It may even be the '
+ 'case\n'
+ 'that a new feature introduces new incompatible syntax (such as a '
+ 'new\n'
+ 'reserved word), in which case the compiler may need to parse the\n'
+ 'module differently. Such decisions cannot be pushed off until\n'
+ 'runtime.\n'
+ '\n'
+ 'For any given release, the compiler knows which feature names '
+ 'have\n'
+ 'been defined, and raises a compile-time error if a future '
+ 'statement\n'
+ 'contains a feature not known to it.\n'
+ '\n'
+ 'The direct runtime semantics are the same as for any import '
+ 'statement:\n'
+ 'there is a standard module "__future__", described later, and it '
+ 'will\n'
+ 'be imported in the usual way at the time the future statement is\n'
+ 'executed.\n'
+ '\n'
+ 'The interesting runtime semantics depend on the specific feature\n'
+ 'enabled by the future statement.\n'
+ '\n'
+ 'Note that there is nothing special about the statement:\n'
+ '\n'
+ ' import __future__ [as name]\n'
+ '\n'
+ "That is not a future statement; it's an ordinary import statement "
+ 'with\n'
+ 'no special semantics or syntax restrictions.\n'
+ '\n'
+ 'Code compiled by calls to the built-in functions "exec()" and\n'
+ '"compile()" that occur in a module "M" containing a future '
+ 'statement\n'
+ 'will, by default, use the new syntax or semantics associated with '
+ 'the\n'
+ 'future statement. This can be controlled by optional arguments '
+ 'to\n'
+ '"compile()" --- see the documentation of that function for '
+ 'details.\n'
+ '\n'
+ 'A future statement typed at an interactive interpreter prompt '
+ 'will\n'
+ 'take effect for the rest of the interpreter session. If an\n'
+ 'interpreter is started with the "-i" option, is passed a script '
+ 'name\n'
+ 'to execute, and the script includes a future statement, it will be '
+ 'in\n'
+ 'effect in the interactive session started after the script is\n'
+ 'executed.\n'
+ '\n'
+ 'See also:\n'
+ '\n'
+ ' **PEP 236** - Back to the __future__\n'
+ ' The original proposal for the __future__ mechanism.\n',
+ 'in': '\n'
+ 'Membership test operations\n'
+ '**************************\n'
+ '\n'
+ 'The operators "in" and "not in" test for membership. "x in s"\n'
+ 'evaluates to true if *x* is a member of *s*, and false otherwise. "x\n'
+ 'not in s" returns the negation of "x in s". All built-in sequences\n'
+ 'and set types support this as well as dictionary, for which "in" '
+ 'tests\n'
+ 'whether the dictionary has a given key. For container types such as\n'
+ 'list, tuple, set, frozenset, dict, or collections.deque, the\n'
+ 'expression "x in y" is equivalent to "any(x is e or x == e for e in\n'
+ 'y)".\n'
+ '\n'
+ 'For the string and bytes types, "x in y" is true if and only if *x* '
+ 'is\n'
+ 'a substring of *y*. An equivalent test is "y.find(x) != -1". Empty\n'
+ 'strings are always considered to be a substring of any other string,\n'
+ 'so """ in "abc"" will return "True".\n'
+ '\n'
+ 'For user-defined classes which define the "__contains__()" method, "x\n'
+ 'in y" is true if and only if "y.__contains__(x)" is true.\n'
+ '\n'
+ 'For user-defined classes which do not define "__contains__()" but do\n'
+ 'define "__iter__()", "x in y" is true if some value "z" with "x == z"\n'
+ 'is produced while iterating over "y". If an exception is raised\n'
+ 'during the iteration, it is as if "in" raised that exception.\n'
+ '\n'
+ 'Lastly, the old-style iteration protocol is tried: if a class defines\n'
+ '"__getitem__()", "x in y" is true if and only if there is a non-\n'
+ 'negative integer index *i* such that "x == y[i]", and all lower\n'
+ 'integer indices do not raise "IndexError" exception. (If any other\n'
+ 'exception is raised, it is as if "in" raised that exception).\n'
+ '\n'
+ 'The operator "not in" is defined to have the inverse true value of\n'
+ '"in".\n',
+ 'integers': '\n'
+ 'Integer literals\n'
+ '****************\n'
+ '\n'
+ 'Integer literals are described by the following lexical '
+ 'definitions:\n'
+ '\n'
+ ' integer ::= decimalinteger | octinteger | hexinteger | '
+ 'bininteger\n'
+ ' decimalinteger ::= nonzerodigit digit* | "0"+\n'
+ ' nonzerodigit ::= "1"..."9"\n'
+ ' digit ::= "0"..."9"\n'
+ ' octinteger ::= "0" ("o" | "O") octdigit+\n'
+ ' hexinteger ::= "0" ("x" | "X") hexdigit+\n'
+ ' bininteger ::= "0" ("b" | "B") bindigit+\n'
+ ' octdigit ::= "0"..."7"\n'
+ ' hexdigit ::= digit | "a"..."f" | "A"..."F"\n'
+ ' bindigit ::= "0" | "1"\n'
+ '\n'
+ 'There is no limit for the length of integer literals apart from '
+ 'what\n'
+ 'can be stored in available memory.\n'
+ '\n'
+ 'Note that leading zeros in a non-zero decimal number are not '
+ 'allowed.\n'
+ 'This is for disambiguation with C-style octal literals, which '
+ 'Python\n'
+ 'used before version 3.0.\n'
+ '\n'
+ 'Some examples of integer literals:\n'
+ '\n'
+ ' 7 2147483647 0o177 0b100110111\n'
+ ' 3 79228162514264337593543950336 0o377 0xdeadbeef\n',
+ 'lambda': '\n'
+ 'Lambdas\n'
+ '*******\n'
+ '\n'
+ ' lambda_expr ::= "lambda" [parameter_list]: expression\n'
+ ' lambda_expr_nocond ::= "lambda" [parameter_list]: '
+ 'expression_nocond\n'
+ '\n'
+ 'Lambda expressions (sometimes called lambda forms) are used to '
+ 'create\n'
+ 'anonymous functions. The expression "lambda arguments: '
+ 'expression"\n'
+ 'yields a function object. The unnamed object behaves like a '
+ 'function\n'
+ 'object defined with\n'
+ '\n'
+ ' def <lambda>(arguments):\n'
+ ' return expression\n'
+ '\n'
+ 'See section Function definitions for the syntax of parameter '
+ 'lists.\n'
+ 'Note that functions created with lambda expressions cannot '
+ 'contain\n'
+ 'statements or annotations.\n',
+ 'lists': '\n'
+ 'List displays\n'
+ '*************\n'
+ '\n'
+ 'A list display is a possibly empty series of expressions enclosed '
+ 'in\n'
+ 'square brackets:\n'
+ '\n'
+ ' list_display ::= "[" [starred_list | comprehension] "]"\n'
+ '\n'
+ 'A list display yields a new list object, the contents being '
+ 'specified\n'
+ 'by either a list of expressions or a comprehension. When a comma-\n'
+ 'separated list of expressions is supplied, its elements are '
+ 'evaluated\n'
+ 'from left to right and placed into the list object in that order.\n'
+ 'When a comprehension is supplied, the list is constructed from the\n'
+ 'elements resulting from the comprehension.\n',
+ 'naming': '\n'
+ 'Naming and binding\n'
+ '******************\n'
+ '\n'
+ '\n'
+ 'Binding of names\n'
+ '================\n'
+ '\n'
+ '*Names* refer to objects. Names are introduced by name binding\n'
+ 'operations.\n'
+ '\n'
+ 'The following constructs bind names: formal parameters to '
+ 'functions,\n'
+ '"import" statements, class and function definitions (these bind '
+ 'the\n'
+ 'class or function name in the defining block), and targets that '
+ 'are\n'
+ 'identifiers if occurring in an assignment, "for" loop header, or '
+ 'after\n'
+ '"as" in a "with" statement or "except" clause. The "import" '
+ 'statement\n'
+ 'of the form "from ... import *" binds all names defined in the\n'
+ 'imported module, except those beginning with an underscore. This '
+ 'form\n'
+ 'may only be used at the module level.\n'
+ '\n'
+ 'A target occurring in a "del" statement is also considered bound '
+ 'for\n'
+ 'this purpose (though the actual semantics are to unbind the '
+ 'name).\n'
+ '\n'
+ 'Each assignment or import statement occurs within a block defined '
+ 'by a\n'
+ 'class or function definition or at the module level (the '
+ 'top-level\n'
+ 'code block).\n'
+ '\n'
+ 'If a name is bound in a block, it is a local variable of that '
+ 'block,\n'
+ 'unless declared as "nonlocal" or "global". If a name is bound at '
+ 'the\n'
+ 'module level, it is a global variable. (The variables of the '
+ 'module\n'
+ 'code block are local and global.) If a variable is used in a '
+ 'code\n'
+ 'block but not defined there, it is a *free variable*.\n'
+ '\n'
+ 'Each occurrence of a name in the program text refers to the '
+ '*binding*\n'
+ 'of that name established by the following name resolution rules.\n'
+ '\n'
+ '\n'
+ 'Resolution of names\n'
+ '===================\n'
+ '\n'
+ 'A *scope* defines the visibility of a name within a block. If a '
+ 'local\n'
+ 'variable is defined in a block, its scope includes that block. If '
+ 'the\n'
+ 'definition occurs in a function block, the scope extends to any '
+ 'blocks\n'
+ 'contained within the defining one, unless a contained block '
+ 'introduces\n'
+ 'a different binding for the name.\n'
+ '\n'
+ 'When a name is used in a code block, it is resolved using the '
+ 'nearest\n'
+ 'enclosing scope. The set of all such scopes visible to a code '
+ 'block\n'
+ "is called the block's *environment*.\n"
+ '\n'
+ 'When a name is not found at all, a "NameError" exception is '
+ 'raised. If\n'
+ 'the current scope is a function scope, and the name refers to a '
+ 'local\n'
+ 'variable that has not yet been bound to a value at the point where '
+ 'the\n'
+ 'name is used, an "UnboundLocalError" exception is raised.\n'
+ '"UnboundLocalError" is a subclass of "NameError".\n'
+ '\n'
+ 'If a name binding operation occurs anywhere within a code block, '
+ 'all\n'
+ 'uses of the name within the block are treated as references to '
+ 'the\n'
+ 'current block. This can lead to errors when a name is used within '
+ 'a\n'
+ 'block before it is bound. This rule is subtle. Python lacks\n'
+ 'declarations and allows name binding operations to occur anywhere\n'
+ 'within a code block. The local variables of a code block can be\n'
+ 'determined by scanning the entire text of the block for name '
+ 'binding\n'
+ 'operations.\n'
+ '\n'
+ 'If the "global" statement occurs within a block, all uses of the '
+ 'name\n'
+ 'specified in the statement refer to the binding of that name in '
+ 'the\n'
+ 'top-level namespace. Names are resolved in the top-level '
+ 'namespace by\n'
+ 'searching the global namespace, i.e. the namespace of the module\n'
+ 'containing the code block, and the builtins namespace, the '
+ 'namespace\n'
+ 'of the module "builtins". The global namespace is searched '
+ 'first. If\n'
+ 'the name is not found there, the builtins namespace is searched. '
+ 'The\n'
+ '"global" statement must precede all uses of the name.\n'
+ '\n'
+ 'The "global" statement has the same scope as a name binding '
+ 'operation\n'
+ 'in the same block. If the nearest enclosing scope for a free '
+ 'variable\n'
+ 'contains a global statement, the free variable is treated as a '
+ 'global.\n'
+ '\n'
+ 'The "nonlocal" statement causes corresponding names to refer to\n'
+ 'previously bound variables in the nearest enclosing function '
+ 'scope.\n'
+ '"SyntaxError" is raised at compile time if the given name does '
+ 'not\n'
+ 'exist in any enclosing function scope.\n'
+ '\n'
+ 'The namespace for a module is automatically created the first time '
+ 'a\n'
+ 'module is imported. The main module for a script is always '
+ 'called\n'
+ '"__main__".\n'
+ '\n'
+ 'Class definition blocks and arguments to "exec()" and "eval()" '
+ 'are\n'
+ 'special in the context of name resolution. A class definition is '
+ 'an\n'
+ 'executable statement that may use and define names. These '
+ 'references\n'
+ 'follow the normal rules for name resolution with an exception '
+ 'that\n'
+ 'unbound local variables are looked up in the global namespace. '
+ 'The\n'
+ 'namespace of the class definition becomes the attribute dictionary '
+ 'of\n'
+ 'the class. The scope of names defined in a class block is limited '
+ 'to\n'
+ 'the class block; it does not extend to the code blocks of methods '
+ '--\n'
+ 'this includes comprehensions and generator expressions since they '
+ 'are\n'
+ 'implemented using a function scope. This means that the '
+ 'following\n'
+ 'will fail:\n'
+ '\n'
+ ' class A:\n'
+ ' a = 42\n'
+ ' b = list(a + i for i in range(10))\n'
+ '\n'
+ '\n'
+ 'Builtins and restricted execution\n'
+ '=================================\n'
+ '\n'
+ 'The builtins namespace associated with the execution of a code '
+ 'block\n'
+ 'is actually found by looking up the name "__builtins__" in its '
+ 'global\n'
+ 'namespace; this should be a dictionary or a module (in the latter '
+ 'case\n'
+ "the module's dictionary is used). By default, when in the "
+ '"__main__"\n'
+ 'module, "__builtins__" is the built-in module "builtins"; when in '
+ 'any\n'
+ 'other module, "__builtins__" is an alias for the dictionary of '
+ 'the\n'
+ '"builtins" module itself. "__builtins__" can be set to a '
+ 'user-created\n'
+ 'dictionary to create a weak form of restricted execution.\n'
+ '\n'
+ '**CPython implementation detail:** Users should not touch\n'
+ '"__builtins__"; it is strictly an implementation detail. Users\n'
+ 'wanting to override values in the builtins namespace should '
+ '"import"\n'
+ 'the "builtins" module and modify its attributes appropriately.\n'
+ '\n'
+ '\n'
+ 'Interaction with dynamic features\n'
+ '=================================\n'
+ '\n'
+ 'Name resolution of free variables occurs at runtime, not at '
+ 'compile\n'
+ 'time. This means that the following code will print 42:\n'
+ '\n'
+ ' i = 10\n'
+ ' def f():\n'
+ ' print(i)\n'
+ ' i = 42\n'
+ ' f()\n'
+ '\n'
+ 'There are several cases where Python statements are illegal when '
+ 'used\n'
+ 'in conjunction with nested scopes that contain free variables.\n'
+ '\n'
+ 'If a variable is referenced in an enclosing scope, it is illegal '
+ 'to\n'
+ 'delete the name. An error will be reported at compile time.\n'
+ '\n'
+ 'The "eval()" and "exec()" functions do not have access to the '
+ 'full\n'
+ 'environment for resolving names. Names may be resolved in the '
+ 'local\n'
+ 'and global namespaces of the caller. Free variables are not '
+ 'resolved\n'
+ 'in the nearest enclosing namespace, but in the global namespace. '
+ '[1]\n'
+ 'The "exec()" and "eval()" functions have optional arguments to\n'
+ 'override the global and local namespace. If only one namespace '
+ 'is\n'
+ 'specified, it is used for both.\n',
+ 'nonlocal': '\n'
+ 'The "nonlocal" statement\n'
+ '************************\n'
+ '\n'
+ ' nonlocal_stmt ::= "nonlocal" identifier ("," identifier)*\n'
+ '\n'
+ 'The "nonlocal" statement causes the listed identifiers to refer '
+ 'to\n'
+ 'previously bound variables in the nearest enclosing scope '
+ 'excluding\n'
+ 'globals. This is important because the default behavior for '
+ 'binding is\n'
+ 'to search the local namespace first. The statement allows\n'
+ 'encapsulated code to rebind variables outside of the local '
+ 'scope\n'
+ 'besides the global (module) scope.\n'
+ '\n'
+ 'Names listed in a "nonlocal" statement, unlike those listed in '
+ 'a\n'
+ '"global" statement, must refer to pre-existing bindings in an\n'
+ 'enclosing scope (the scope in which a new binding should be '
+ 'created\n'
+ 'cannot be determined unambiguously).\n'
+ '\n'
+ 'Names listed in a "nonlocal" statement must not collide with '
+ 'pre-\n'
+ 'existing bindings in the local scope.\n'
+ '\n'
+ 'See also:\n'
+ '\n'
+ ' **PEP 3104** - Access to Names in Outer Scopes\n'
+ ' The specification for the "nonlocal" statement.\n',
+ 'numbers': '\n'
+ 'Numeric literals\n'
+ '****************\n'
+ '\n'
+ 'There are three types of numeric literals: integers, floating '
+ 'point\n'
+ 'numbers, and imaginary numbers. There are no complex literals\n'
+ '(complex numbers can be formed by adding a real number and an\n'
+ 'imaginary number).\n'
+ '\n'
+ 'Note that numeric literals do not include a sign; a phrase like '
+ '"-1"\n'
+ 'is actually an expression composed of the unary operator \'"-"\' '
+ 'and the\n'
+ 'literal "1".\n',
+ 'numeric-types': '\n'
+ 'Emulating numeric types\n'
+ '***********************\n'
+ '\n'
+ 'The following methods can be defined to emulate numeric '
+ 'objects.\n'
+ 'Methods corresponding to operations that are not supported '
+ 'by the\n'
+ 'particular kind of number implemented (e.g., bitwise '
+ 'operations for\n'
+ 'non-integral numbers) should be left undefined.\n'
+ '\n'
+ 'object.__add__(self, other)\n'
+ 'object.__sub__(self, other)\n'
+ 'object.__mul__(self, other)\n'
+ 'object.__matmul__(self, other)\n'
+ 'object.__truediv__(self, other)\n'
+ 'object.__floordiv__(self, other)\n'
+ 'object.__mod__(self, other)\n'
+ 'object.__divmod__(self, other)\n'
+ 'object.__pow__(self, other[, modulo])\n'
+ 'object.__lshift__(self, other)\n'
+ 'object.__rshift__(self, other)\n'
+ 'object.__and__(self, other)\n'
+ 'object.__xor__(self, other)\n'
+ 'object.__or__(self, other)\n'
+ '\n'
+ ' These methods are called to implement the binary '
+ 'arithmetic\n'
+ ' operations ("+", "-", "*", "@", "/", "//", "%", '
+ '"divmod()",\n'
+ ' "pow()", "**", "<<", ">>", "&", "^", "|"). For '
+ 'instance, to\n'
+ ' evaluate the expression "x + y", where *x* is an '
+ 'instance of a\n'
+ ' class that has an "__add__()" method, "x.__add__(y)" is '
+ 'called.\n'
+ ' The "__divmod__()" method should be the equivalent to '
+ 'using\n'
+ ' "__floordiv__()" and "__mod__()"; it should not be '
+ 'related to\n'
+ ' "__truediv__()". Note that "__pow__()" should be '
+ 'defined to accept\n'
+ ' an optional third argument if the ternary version of the '
+ 'built-in\n'
+ ' "pow()" function is to be supported.\n'
+ '\n'
+ ' If one of those methods does not support the operation '
+ 'with the\n'
+ ' supplied arguments, it should return "NotImplemented".\n'
+ '\n'
+ 'object.__radd__(self, other)\n'
+ 'object.__rsub__(self, other)\n'
+ 'object.__rmul__(self, other)\n'
+ 'object.__rmatmul__(self, other)\n'
+ 'object.__rtruediv__(self, other)\n'
+ 'object.__rfloordiv__(self, other)\n'
+ 'object.__rmod__(self, other)\n'
+ 'object.__rdivmod__(self, other)\n'
+ 'object.__rpow__(self, other)\n'
+ 'object.__rlshift__(self, other)\n'
+ 'object.__rrshift__(self, other)\n'
+ 'object.__rand__(self, other)\n'
+ 'object.__rxor__(self, other)\n'
+ 'object.__ror__(self, other)\n'
+ '\n'
+ ' These methods are called to implement the binary '
+ 'arithmetic\n'
+ ' operations ("+", "-", "*", "@", "/", "//", "%", '
+ '"divmod()",\n'
+ ' "pow()", "**", "<<", ">>", "&", "^", "|") with reflected '
+ '(swapped)\n'
+ ' operands. These functions are only called if the left '
+ 'operand does\n'
+ ' not support the corresponding operation and the operands '
+ 'are of\n'
+ ' different types. [2] For instance, to evaluate the '
+ 'expression "x -\n'
+ ' y", where *y* is an instance of a class that has an '
+ '"__rsub__()"\n'
+ ' method, "y.__rsub__(x)" is called if "x.__sub__(y)" '
+ 'returns\n'
+ ' *NotImplemented*.\n'
+ '\n'
+ ' Note that ternary "pow()" will not try calling '
+ '"__rpow__()" (the\n'
+ ' coercion rules would become too complicated).\n'
+ '\n'
+ " Note: If the right operand's type is a subclass of the "
+ 'left\n'
+ " operand's type and that subclass provides the "
+ 'reflected method\n'
+ ' for the operation, this method will be called before '
+ 'the left\n'
+ " operand's non-reflected method. This behavior allows "
+ 'subclasses\n'
+ " to override their ancestors' operations.\n"
+ '\n'
+ 'object.__iadd__(self, other)\n'
+ 'object.__isub__(self, other)\n'
+ 'object.__imul__(self, other)\n'
+ 'object.__imatmul__(self, other)\n'
+ 'object.__itruediv__(self, other)\n'
+ 'object.__ifloordiv__(self, other)\n'
+ 'object.__imod__(self, other)\n'
+ 'object.__ipow__(self, other[, modulo])\n'
+ 'object.__ilshift__(self, other)\n'
+ 'object.__irshift__(self, other)\n'
+ 'object.__iand__(self, other)\n'
+ 'object.__ixor__(self, other)\n'
+ 'object.__ior__(self, other)\n'
+ '\n'
+ ' These methods are called to implement the augmented '
+ 'arithmetic\n'
+ ' assignments ("+=", "-=", "*=", "@=", "/=", "//=", "%=", '
+ '"**=",\n'
+ ' "<<=", ">>=", "&=", "^=", "|="). These methods should '
+ 'attempt to\n'
+ ' do the operation in-place (modifying *self*) and return '
+ 'the result\n'
+ ' (which could be, but does not have to be, *self*). If a '
+ 'specific\n'
+ ' method is not defined, the augmented assignment falls '
+ 'back to the\n'
+ ' normal methods. For instance, if *x* is an instance of '
+ 'a class\n'
+ ' with an "__iadd__()" method, "x += y" is equivalent to '
+ '"x =\n'
+ ' x.__iadd__(y)" . Otherwise, "x.__add__(y)" and '
+ '"y.__radd__(x)" are\n'
+ ' considered, as with the evaluation of "x + y". In '
+ 'certain\n'
+ ' situations, augmented assignment can result in '
+ 'unexpected errors\n'
+ " (see Why does a_tuple[i] += ['item'] raise an exception "
+ 'when the\n'
+ ' addition works?), but this behavior is in fact part of '
+ 'the data\n'
+ ' model.\n'
+ '\n'
+ 'object.__neg__(self)\n'
+ 'object.__pos__(self)\n'
+ 'object.__abs__(self)\n'
+ 'object.__invert__(self)\n'
+ '\n'
+ ' Called to implement the unary arithmetic operations '
+ '("-", "+",\n'
+ ' "abs()" and "~").\n'
+ '\n'
+ 'object.__complex__(self)\n'
+ 'object.__int__(self)\n'
+ 'object.__float__(self)\n'
+ 'object.__round__(self[, n])\n'
+ '\n'
+ ' Called to implement the built-in functions "complex()", '
+ '"int()",\n'
+ ' "float()" and "round()". Should return a value of the '
+ 'appropriate\n'
+ ' type.\n'
+ '\n'
+ 'object.__index__(self)\n'
+ '\n'
+ ' Called to implement "operator.index()", and whenever '
+ 'Python needs\n'
+ ' to losslessly convert the numeric object to an integer '
+ 'object (such\n'
+ ' as in slicing, or in the built-in "bin()", "hex()" and '
+ '"oct()"\n'
+ ' functions). Presence of this method indicates that the '
+ 'numeric\n'
+ ' object is an integer type. Must return an integer.\n'
+ '\n'
+ ' Note: In order to have a coherent integer type class, '
+ 'when\n'
+ ' "__index__()" is defined "__int__()" should also be '
+ 'defined, and\n'
+ ' both should return the same value.\n',
+ 'objects': '\n'
+ 'Objects, values and types\n'
+ '*************************\n'
+ '\n'
+ "*Objects* are Python's abstraction for data. All data in a "
+ 'Python\n'
+ 'program is represented by objects or by relations between '
+ 'objects. (In\n'
+ 'a sense, and in conformance to Von Neumann\'s model of a "stored\n'
+ 'program computer," code is also represented by objects.)\n'
+ '\n'
+ "Every object has an identity, a type and a value. An object's\n"
+ '*identity* never changes once it has been created; you may think '
+ 'of it\n'
+ 'as the object\'s address in memory. The \'"is"\' operator '
+ 'compares the\n'
+ 'identity of two objects; the "id()" function returns an integer\n'
+ 'representing its identity.\n'
+ '\n'
+ '**CPython implementation detail:** For CPython, "id(x)" is the '
+ 'memory\n'
+ 'address where "x" is stored.\n'
+ '\n'
+ "An object's type determines the operations that the object "
+ 'supports\n'
+ '(e.g., "does it have a length?") and also defines the possible '
+ 'values\n'
+ 'for objects of that type. The "type()" function returns an '
+ "object's\n"
+ 'type (which is an object itself). Like its identity, an '
+ "object's\n"
+ '*type* is also unchangeable. [1]\n'
+ '\n'
+ 'The *value* of some objects can change. Objects whose value can\n'
+ 'change are said to be *mutable*; objects whose value is '
+ 'unchangeable\n'
+ 'once they are created are called *immutable*. (The value of an\n'
+ 'immutable container object that contains a reference to a '
+ 'mutable\n'
+ "object can change when the latter's value is changed; however "
+ 'the\n'
+ 'container is still considered immutable, because the collection '
+ 'of\n'
+ 'objects it contains cannot be changed. So, immutability is not\n'
+ 'strictly the same as having an unchangeable value, it is more '
+ 'subtle.)\n'
+ "An object's mutability is determined by its type; for instance,\n"
+ 'numbers, strings and tuples are immutable, while dictionaries '
+ 'and\n'
+ 'lists are mutable.\n'
+ '\n'
+ 'Objects are never explicitly destroyed; however, when they '
+ 'become\n'
+ 'unreachable they may be garbage-collected. An implementation is\n'
+ 'allowed to postpone garbage collection or omit it altogether --- '
+ 'it is\n'
+ 'a matter of implementation quality how garbage collection is\n'
+ 'implemented, as long as no objects are collected that are still\n'
+ 'reachable.\n'
+ '\n'
+ '**CPython implementation detail:** CPython currently uses a '
+ 'reference-\n'
+ 'counting scheme with (optional) delayed detection of cyclically '
+ 'linked\n'
+ 'garbage, which collects most objects as soon as they become\n'
+ 'unreachable, but is not guaranteed to collect garbage containing\n'
+ 'circular references. See the documentation of the "gc" module '
+ 'for\n'
+ 'information on controlling the collection of cyclic garbage. '
+ 'Other\n'
+ 'implementations act differently and CPython may change. Do not '
+ 'depend\n'
+ 'on immediate finalization of objects when they become unreachable '
+ '(so\n'
+ 'you should always close files explicitly).\n'
+ '\n'
+ "Note that the use of the implementation's tracing or debugging\n"
+ 'facilities may keep objects alive that would normally be '
+ 'collectable.\n'
+ 'Also note that catching an exception with a \'"try"..."except"\'\n'
+ 'statement may keep objects alive.\n'
+ '\n'
+ 'Some objects contain references to "external" resources such as '
+ 'open\n'
+ 'files or windows. It is understood that these resources are '
+ 'freed\n'
+ 'when the object is garbage-collected, but since garbage '
+ 'collection is\n'
+ 'not guaranteed to happen, such objects also provide an explicit '
+ 'way to\n'
+ 'release the external resource, usually a "close()" method. '
+ 'Programs\n'
+ 'are strongly recommended to explicitly close such objects. The\n'
+ '\'"try"..."finally"\' statement and the \'"with"\' statement '
+ 'provide\n'
+ 'convenient ways to do this.\n'
+ '\n'
+ 'Some objects contain references to other objects; these are '
+ 'called\n'
+ '*containers*. Examples of containers are tuples, lists and\n'
+ "dictionaries. The references are part of a container's value. "
+ 'In\n'
+ 'most cases, when we talk about the value of a container, we imply '
+ 'the\n'
+ 'values, not the identities of the contained objects; however, '
+ 'when we\n'
+ 'talk about the mutability of a container, only the identities of '
+ 'the\n'
+ 'immediately contained objects are implied. So, if an immutable\n'
+ 'container (like a tuple) contains a reference to a mutable '
+ 'object, its\n'
+ 'value changes if that mutable object is changed.\n'
+ '\n'
+ 'Types affect almost all aspects of object behavior. Even the\n'
+ 'importance of object identity is affected in some sense: for '
+ 'immutable\n'
+ 'types, operations that compute new values may actually return a\n'
+ 'reference to any existing object with the same type and value, '
+ 'while\n'
+ 'for mutable objects this is not allowed. E.g., after "a = 1; b = '
+ '1",\n'
+ '"a" and "b" may or may not refer to the same object with the '
+ 'value\n'
+ 'one, depending on the implementation, but after "c = []; d = []", '
+ '"c"\n'
+ 'and "d" are guaranteed to refer to two different, unique, newly\n'
+ 'created empty lists. (Note that "c = d = []" assigns the same '
+ 'object\n'
+ 'to both "c" and "d".)\n',
+ 'operator-summary': '\n'
+ 'Operator precedence\n'
+ '*******************\n'
+ '\n'
+ 'The following table summarizes the operator precedence '
+ 'in Python, from\n'
+ 'lowest precedence (least binding) to highest precedence '
+ '(most\n'
+ 'binding). Operators in the same box have the same '
+ 'precedence. Unless\n'
+ 'the syntax is explicitly given, operators are binary. '
+ 'Operators in\n'
+ 'the same box group left to right (except for '
+ 'exponentiation, which\n'
+ 'groups from right to left).\n'
+ '\n'
+ 'Note that comparisons, membership tests, and identity '
+ 'tests, all have\n'
+ 'the same precedence and have a left-to-right chaining '
+ 'feature as\n'
+ 'described in the Comparisons section.\n'
+ '\n'
+ '+-------------------------------------------------+---------------------------------------+\n'
+ '| Operator | '
+ 'Description |\n'
+ '+=================================================+=======================================+\n'
+ '| "lambda" | '
+ 'Lambda expression |\n'
+ '+-------------------------------------------------+---------------------------------------+\n'
+ '| "if" -- "else" | '
+ 'Conditional expression |\n'
+ '+-------------------------------------------------+---------------------------------------+\n'
+ '| "or" | '
+ 'Boolean OR |\n'
+ '+-------------------------------------------------+---------------------------------------+\n'
+ '| "and" | '
+ 'Boolean AND |\n'
+ '+-------------------------------------------------+---------------------------------------+\n'
+ '| "not" "x" | '
+ 'Boolean NOT |\n'
+ '+-------------------------------------------------+---------------------------------------+\n'
+ '| "in", "not in", "is", "is not", "<", "<=", ">", | '
+ 'Comparisons, including membership |\n'
+ '| ">=", "!=", "==" | '
+ 'tests and identity tests |\n'
+ '+-------------------------------------------------+---------------------------------------+\n'
+ '| "|" | '
+ 'Bitwise OR |\n'
+ '+-------------------------------------------------+---------------------------------------+\n'
+ '| "^" | '
+ 'Bitwise XOR |\n'
+ '+-------------------------------------------------+---------------------------------------+\n'
+ '| "&" | '
+ 'Bitwise AND |\n'
+ '+-------------------------------------------------+---------------------------------------+\n'
+ '| "<<", ">>" | '
+ 'Shifts |\n'
+ '+-------------------------------------------------+---------------------------------------+\n'
+ '| "+", "-" | '
+ 'Addition and subtraction |\n'
+ '+-------------------------------------------------+---------------------------------------+\n'
+ '| "*", "@", "/", "//", "%" | '
+ 'Multiplication, matrix multiplication |\n'
+ '| | '
+ 'division, remainder [5] |\n'
+ '+-------------------------------------------------+---------------------------------------+\n'
+ '| "+x", "-x", "~x" | '
+ 'Positive, negative, bitwise NOT |\n'
+ '+-------------------------------------------------+---------------------------------------+\n'
+ '| "**" | '
+ 'Exponentiation [6] |\n'
+ '+-------------------------------------------------+---------------------------------------+\n'
+ '| "await" "x" | '
+ 'Await expression |\n'
+ '+-------------------------------------------------+---------------------------------------+\n'
+ '| "x[index]", "x[index:index]", | '
+ 'Subscription, slicing, call, |\n'
+ '| "x(arguments...)", "x.attribute" | '
+ 'attribute reference |\n'
+ '+-------------------------------------------------+---------------------------------------+\n'
+ '| "(expressions...)", "[expressions...]", "{key: | '
+ 'Binding or tuple display, list |\n'
+ '| value...}", "{expressions...}" | '
+ 'display, dictionary display, set |\n'
+ '| | '
+ 'display |\n'
+ '+-------------------------------------------------+---------------------------------------+\n'
+ '\n'
+ '-[ Footnotes ]-\n'
+ '\n'
+ '[1] While "abs(x%y) < abs(y)" is true mathematically, '
+ 'for floats\n'
+ ' it may not be true numerically due to roundoff. For '
+ 'example, and\n'
+ ' assuming a platform on which a Python float is an '
+ 'IEEE 754 double-\n'
+ ' precision number, in order that "-1e-100 % 1e100" '
+ 'have the same\n'
+ ' sign as "1e100", the computed result is "-1e-100 + '
+ '1e100", which\n'
+ ' is numerically exactly equal to "1e100". The '
+ 'function\n'
+ ' "math.fmod()" returns a result whose sign matches '
+ 'the sign of the\n'
+ ' first argument instead, and so returns "-1e-100" in '
+ 'this case.\n'
+ ' Which approach is more appropriate depends on the '
+ 'application.\n'
+ '\n'
+ '[2] If x is very close to an exact integer multiple of '
+ "y, it's\n"
+ ' possible for "x//y" to be one larger than '
+ '"(x-x%y)//y" due to\n'
+ ' rounding. In such cases, Python returns the latter '
+ 'result, in\n'
+ ' order to preserve that "divmod(x,y)[0] * y + x % y" '
+ 'be very close\n'
+ ' to "x".\n'
+ '\n'
+ '[3] The Unicode standard distinguishes between *code '
+ 'points* (e.g.\n'
+ ' U+0041) and *abstract characters* (e.g. "LATIN '
+ 'CAPITAL LETTER A").\n'
+ ' While most abstract characters in Unicode are only '
+ 'represented\n'
+ ' using one code point, there is a number of abstract '
+ 'characters\n'
+ ' that can in addition be represented using a sequence '
+ 'of more than\n'
+ ' one code point. For example, the abstract character '
+ '"LATIN\n'
+ ' CAPITAL LETTER C WITH CEDILLA" can be represented as '
+ 'a single\n'
+ ' *precomposed character* at code position U+00C7, or '
+ 'as a sequence\n'
+ ' of a *base character* at code position U+0043 (LATIN '
+ 'CAPITAL\n'
+ ' LETTER C), followed by a *combining character* at '
+ 'code position\n'
+ ' U+0327 (COMBINING CEDILLA).\n'
+ '\n'
+ ' The comparison operators on strings compare at the '
+ 'level of\n'
+ ' Unicode code points. This may be counter-intuitive '
+ 'to humans. For\n'
+ ' example, ""\\u00C7" == "\\u0043\\u0327"" is "False", '
+ 'even though both\n'
+ ' strings represent the same abstract character "LATIN '
+ 'CAPITAL\n'
+ ' LETTER C WITH CEDILLA".\n'
+ '\n'
+ ' To compare strings at the level of abstract '
+ 'characters (that is,\n'
+ ' in a way intuitive to humans), use '
+ '"unicodedata.normalize()".\n'
+ '\n'
+ '[4] Due to automatic garbage-collection, free lists, and '
+ 'the\n'
+ ' dynamic nature of descriptors, you may notice '
+ 'seemingly unusual\n'
+ ' behaviour in certain uses of the "is" operator, like '
+ 'those\n'
+ ' involving comparisons between instance methods, or '
+ 'constants.\n'
+ ' Check their documentation for more info.\n'
+ '\n'
+ '[5] The "%" operator is also used for string formatting; '
+ 'the same\n'
+ ' precedence applies.\n'
+ '\n'
+ '[6] The power operator "**" binds less tightly than an '
+ 'arithmetic\n'
+ ' or bitwise unary operator on its right, that is, '
+ '"2**-1" is "0.5".\n',
+ 'pass': '\n'
+ 'The "pass" statement\n'
+ '********************\n'
+ '\n'
+ ' pass_stmt ::= "pass"\n'
+ '\n'
+ '"pass" is a null operation --- when it is executed, nothing '
+ 'happens.\n'
+ 'It is useful as a placeholder when a statement is required\n'
+ 'syntactically, but no code needs to be executed, for example:\n'
+ '\n'
+ ' def f(arg): pass # a function that does nothing (yet)\n'
+ '\n'
+ ' class C: pass # a class with no methods (yet)\n',
+ 'power': '\n'
+ 'The power operator\n'
+ '******************\n'
+ '\n'
+ 'The power operator binds more tightly than unary operators on its\n'
+ 'left; it binds less tightly than unary operators on its right. '
+ 'The\n'
+ 'syntax is:\n'
+ '\n'
+ ' power ::= ( await_expr | primary ) ["**" u_expr]\n'
+ '\n'
+ 'Thus, in an unparenthesized sequence of power and unary operators, '
+ 'the\n'
+ 'operators are evaluated from right to left (this does not '
+ 'constrain\n'
+ 'the evaluation order for the operands): "-1**2" results in "-1".\n'
+ '\n'
+ 'The power operator has the same semantics as the built-in "pow()"\n'
+ 'function, when called with two arguments: it yields its left '
+ 'argument\n'
+ 'raised to the power of its right argument. The numeric arguments '
+ 'are\n'
+ 'first converted to a common type, and the result is of that type.\n'
+ '\n'
+ 'For int operands, the result has the same type as the operands '
+ 'unless\n'
+ 'the second argument is negative; in that case, all arguments are\n'
+ 'converted to float and a float result is delivered. For example,\n'
+ '"10**2" returns "100", but "10**-2" returns "0.01".\n'
+ '\n'
+ 'Raising "0.0" to a negative power results in a '
+ '"ZeroDivisionError".\n'
+ 'Raising a negative number to a fractional power results in a '
+ '"complex"\n'
+ 'number. (In earlier versions it raised a "ValueError".)\n',
+ 'raise': '\n'
+ 'The "raise" statement\n'
+ '*********************\n'
+ '\n'
+ ' raise_stmt ::= "raise" [expression ["from" expression]]\n'
+ '\n'
+ 'If no expressions are present, "raise" re-raises the last '
+ 'exception\n'
+ 'that was active in the current scope. If no exception is active '
+ 'in\n'
+ 'the current scope, a "RuntimeError" exception is raised indicating\n'
+ 'that this is an error.\n'
+ '\n'
+ 'Otherwise, "raise" evaluates the first expression as the exception\n'
+ 'object. It must be either a subclass or an instance of\n'
+ '"BaseException". If it is a class, the exception instance will be\n'
+ 'obtained when needed by instantiating the class with no arguments.\n'
+ '\n'
+ "The *type* of the exception is the exception instance's class, the\n"
+ '*value* is the instance itself.\n'
+ '\n'
+ 'A traceback object is normally created automatically when an '
+ 'exception\n'
+ 'is raised and attached to it as the "__traceback__" attribute, '
+ 'which\n'
+ 'is writable. You can create an exception and set your own traceback '
+ 'in\n'
+ 'one step using the "with_traceback()" exception method (which '
+ 'returns\n'
+ 'the same exception instance, with its traceback set to its '
+ 'argument),\n'
+ 'like so:\n'
+ '\n'
+ ' raise Exception("foo occurred").with_traceback(tracebackobj)\n'
+ '\n'
+ 'The "from" clause is used for exception chaining: if given, the '
+ 'second\n'
+ '*expression* must be another exception class or instance, which '
+ 'will\n'
+ 'then be attached to the raised exception as the "__cause__" '
+ 'attribute\n'
+ '(which is writable). If the raised exception is not handled, both\n'
+ 'exceptions will be printed:\n'
+ '\n'
+ ' >>> try:\n'
+ ' ... print(1 / 0)\n'
+ ' ... except Exception as exc:\n'
+ ' ... raise RuntimeError("Something bad happened") from exc\n'
+ ' ...\n'
+ ' Traceback (most recent call last):\n'
+ ' File "<stdin>", line 2, in <module>\n'
+ ' ZeroDivisionError: int division or modulo by zero\n'
+ '\n'
+ ' The above exception was the direct cause of the following '
+ 'exception:\n'
+ '\n'
+ ' Traceback (most recent call last):\n'
+ ' File "<stdin>", line 4, in <module>\n'
+ ' RuntimeError: Something bad happened\n'
+ '\n'
+ 'A similar mechanism works implicitly if an exception is raised '
+ 'inside\n'
+ 'an exception handler or a "finally" clause: the previous exception '
+ 'is\n'
+ 'then attached as the new exception\'s "__context__" attribute:\n'
+ '\n'
+ ' >>> try:\n'
+ ' ... print(1 / 0)\n'
+ ' ... except:\n'
+ ' ... raise RuntimeError("Something bad happened")\n'
+ ' ...\n'
+ ' Traceback (most recent call last):\n'
+ ' File "<stdin>", line 2, in <module>\n'
+ ' ZeroDivisionError: int division or modulo by zero\n'
+ '\n'
+ ' During handling of the above exception, another exception '
+ 'occurred:\n'
+ '\n'
+ ' Traceback (most recent call last):\n'
+ ' File "<stdin>", line 4, in <module>\n'
+ ' RuntimeError: Something bad happened\n'
+ '\n'
+ 'Additional information on exceptions can be found in section\n'
+ 'Exceptions, and information about handling exceptions is in '
+ 'section\n'
+ 'The try statement.\n',
+ 'return': '\n'
+ 'The "return" statement\n'
+ '**********************\n'
+ '\n'
+ ' return_stmt ::= "return" [expression_list]\n'
+ '\n'
+ '"return" may only occur syntactically nested in a function '
+ 'definition,\n'
+ 'not within a nested class definition.\n'
+ '\n'
+ 'If an expression list is present, it is evaluated, else "None" is\n'
+ 'substituted.\n'
+ '\n'
+ '"return" leaves the current function call with the expression list '
+ '(or\n'
+ '"None") as return value.\n'
+ '\n'
+ 'When "return" passes control out of a "try" statement with a '
+ '"finally"\n'
+ 'clause, that "finally" clause is executed before really leaving '
+ 'the\n'
+ 'function.\n'
+ '\n'
+ 'In a generator function, the "return" statement indicates that '
+ 'the\n'
+ 'generator is done and will cause "StopIteration" to be raised. '
+ 'The\n'
+ 'returned value (if any) is used as an argument to construct\n'
+ '"StopIteration" and becomes the "StopIteration.value" attribute.\n',
+ 'sequence-types': '\n'
+ 'Emulating container types\n'
+ '*************************\n'
+ '\n'
+ 'The following methods can be defined to implement '
+ 'container objects.\n'
+ 'Containers usually are sequences (such as lists or tuples) '
+ 'or mappings\n'
+ '(like dictionaries), but can represent other containers as '
+ 'well. The\n'
+ 'first set of methods is used either to emulate a sequence '
+ 'or to\n'
+ 'emulate a mapping; the difference is that for a sequence, '
+ 'the\n'
+ 'allowable keys should be the integers *k* for which "0 <= '
+ 'k < N" where\n'
+ '*N* is the length of the sequence, or slice objects, which '
+ 'define a\n'
+ 'range of items. It is also recommended that mappings '
+ 'provide the\n'
+ 'methods "keys()", "values()", "items()", "get()", '
+ '"clear()",\n'
+ '"setdefault()", "pop()", "popitem()", "copy()", and '
+ '"update()"\n'
+ "behaving similar to those for Python's standard dictionary "
+ 'objects.\n'
+ 'The "collections" module provides a "MutableMapping" '
+ 'abstract base\n'
+ 'class to help create those methods from a base set of '
+ '"__getitem__()",\n'
+ '"__setitem__()", "__delitem__()", and "keys()". Mutable '
+ 'sequences\n'
+ 'should provide methods "append()", "count()", "index()", '
+ '"extend()",\n'
+ '"insert()", "pop()", "remove()", "reverse()" and "sort()", '
+ 'like Python\n'
+ 'standard list objects. Finally, sequence types should '
+ 'implement\n'
+ 'addition (meaning concatenation) and multiplication '
+ '(meaning\n'
+ 'repetition) by defining the methods "__add__()", '
+ '"__radd__()",\n'
+ '"__iadd__()", "__mul__()", "__rmul__()" and "__imul__()" '
+ 'described\n'
+ 'below; they should not define other numerical operators. '
+ 'It is\n'
+ 'recommended that both mappings and sequences implement '
+ 'the\n'
+ '"__contains__()" method to allow efficient use of the "in" '
+ 'operator;\n'
+ 'for mappings, "in" should search the mapping\'s keys; for '
+ 'sequences, it\n'
+ 'should search through the values. It is further '
+ 'recommended that both\n'
+ 'mappings and sequences implement the "__iter__()" method '
+ 'to allow\n'
+ 'efficient iteration through the container; for mappings, '
+ '"__iter__()"\n'
+ 'should be the same as "keys()"; for sequences, it should '
+ 'iterate\n'
+ 'through the values.\n'
+ '\n'
+ 'object.__len__(self)\n'
+ '\n'
+ ' Called to implement the built-in function "len()". '
+ 'Should return\n'
+ ' the length of the object, an integer ">=" 0. Also, an '
+ 'object that\n'
+ ' doesn\'t define a "__bool__()" method and whose '
+ '"__len__()" method\n'
+ ' returns zero is considered to be false in a Boolean '
+ 'context.\n'
+ '\n'
+ 'object.__length_hint__(self)\n'
+ '\n'
+ ' Called to implement "operator.length_hint()". Should '
+ 'return an\n'
+ ' estimated length for the object (which may be greater '
+ 'or less than\n'
+ ' the actual length). The length must be an integer ">=" '
+ '0. This\n'
+ ' method is purely an optimization and is never required '
+ 'for\n'
+ ' correctness.\n'
+ '\n'
+ ' New in version 3.4.\n'
+ '\n'
+ 'Note: Slicing is done exclusively with the following three '
+ 'methods.\n'
+ ' A call like\n'
+ '\n'
+ ' a[1:2] = b\n'
+ '\n'
+ ' is translated to\n'
+ '\n'
+ ' a[slice(1, 2, None)] = b\n'
+ '\n'
+ ' and so forth. Missing slice items are always filled in '
+ 'with "None".\n'
+ '\n'
+ 'object.__getitem__(self, key)\n'
+ '\n'
+ ' Called to implement evaluation of "self[key]". For '
+ 'sequence types,\n'
+ ' the accepted keys should be integers and slice '
+ 'objects. Note that\n'
+ ' the special interpretation of negative indexes (if the '
+ 'class wishes\n'
+ ' to emulate a sequence type) is up to the '
+ '"__getitem__()" method. If\n'
+ ' *key* is of an inappropriate type, "TypeError" may be '
+ 'raised; if of\n'
+ ' a value outside the set of indexes for the sequence '
+ '(after any\n'
+ ' special interpretation of negative values), '
+ '"IndexError" should be\n'
+ ' raised. For mapping types, if *key* is missing (not in '
+ 'the\n'
+ ' container), "KeyError" should be raised.\n'
+ '\n'
+ ' Note: "for" loops expect that an "IndexError" will be '
+ 'raised for\n'
+ ' illegal indexes to allow proper detection of the end '
+ 'of the\n'
+ ' sequence.\n'
+ '\n'
+ 'object.__missing__(self, key)\n'
+ '\n'
+ ' Called by "dict"."__getitem__()" to implement '
+ '"self[key]" for dict\n'
+ ' subclasses when key is not in the dictionary.\n'
+ '\n'
+ 'object.__setitem__(self, key, value)\n'
+ '\n'
+ ' Called to implement assignment to "self[key]". Same '
+ 'note as for\n'
+ ' "__getitem__()". This should only be implemented for '
+ 'mappings if\n'
+ ' the objects support changes to the values for keys, or '
+ 'if new keys\n'
+ ' can be added, or for sequences if elements can be '
+ 'replaced. The\n'
+ ' same exceptions should be raised for improper *key* '
+ 'values as for\n'
+ ' the "__getitem__()" method.\n'
+ '\n'
+ 'object.__delitem__(self, key)\n'
+ '\n'
+ ' Called to implement deletion of "self[key]". Same note '
+ 'as for\n'
+ ' "__getitem__()". This should only be implemented for '
+ 'mappings if\n'
+ ' the objects support removal of keys, or for sequences '
+ 'if elements\n'
+ ' can be removed from the sequence. The same exceptions '
+ 'should be\n'
+ ' raised for improper *key* values as for the '
+ '"__getitem__()" method.\n'
+ '\n'
+ 'object.__iter__(self)\n'
+ '\n'
+ ' This method is called when an iterator is required for '
+ 'a container.\n'
+ ' This method should return a new iterator object that '
+ 'can iterate\n'
+ ' over all the objects in the container. For mappings, '
+ 'it should\n'
+ ' iterate over the keys of the container.\n'
+ '\n'
+ ' Iterator objects also need to implement this method; '
+ 'they are\n'
+ ' required to return themselves. For more information on '
+ 'iterator\n'
+ ' objects, see Iterator Types.\n'
+ '\n'
+ 'object.__reversed__(self)\n'
+ '\n'
+ ' Called (if present) by the "reversed()" built-in to '
+ 'implement\n'
+ ' reverse iteration. It should return a new iterator '
+ 'object that\n'
+ ' iterates over all the objects in the container in '
+ 'reverse order.\n'
+ '\n'
+ ' If the "__reversed__()" method is not provided, the '
+ '"reversed()"\n'
+ ' built-in will fall back to using the sequence protocol '
+ '("__len__()"\n'
+ ' and "__getitem__()"). Objects that support the '
+ 'sequence protocol\n'
+ ' should only provide "__reversed__()" if they can '
+ 'provide an\n'
+ ' implementation that is more efficient than the one '
+ 'provided by\n'
+ ' "reversed()".\n'
+ '\n'
+ 'The membership test operators ("in" and "not in") are '
+ 'normally\n'
+ 'implemented as an iteration through a sequence. However, '
+ 'container\n'
+ 'objects can supply the following special method with a '
+ 'more efficient\n'
+ 'implementation, which also does not require the object be '
+ 'a sequence.\n'
+ '\n'
+ 'object.__contains__(self, item)\n'
+ '\n'
+ ' Called to implement membership test operators. Should '
+ 'return true\n'
+ ' if *item* is in *self*, false otherwise. For mapping '
+ 'objects, this\n'
+ ' should consider the keys of the mapping rather than the '
+ 'values or\n'
+ ' the key-item pairs.\n'
+ '\n'
+ ' For objects that don\'t define "__contains__()", the '
+ 'membership test\n'
+ ' first tries iteration via "__iter__()", then the old '
+ 'sequence\n'
+ ' iteration protocol via "__getitem__()", see this '
+ 'section in the\n'
+ ' language reference.\n',
+ 'shifting': '\n'
+ 'Shifting operations\n'
+ '*******************\n'
+ '\n'
+ 'The shifting operations have lower priority than the arithmetic\n'
+ 'operations:\n'
+ '\n'
+ ' shift_expr ::= a_expr | shift_expr ( "<<" | ">>" ) a_expr\n'
+ '\n'
+ 'These operators accept integers as arguments. They shift the '
+ 'first\n'
+ 'argument to the left or right by the number of bits given by '
+ 'the\n'
+ 'second argument.\n'
+ '\n'
+ 'A right shift by *n* bits is defined as floor division by '
+ '"pow(2,n)".\n'
+ 'A left shift by *n* bits is defined as multiplication with '
+ '"pow(2,n)".\n'
+ '\n'
+ 'Note: In the current implementation, the right-hand operand is\n'
+ ' required to be at most "sys.maxsize". If the right-hand '
+ 'operand is\n'
+ ' larger than "sys.maxsize" an "OverflowError" exception is '
+ 'raised.\n',
+ 'slicings': '\n'
+ 'Slicings\n'
+ '********\n'
+ '\n'
+ 'A slicing selects a range of items in a sequence object (e.g., '
+ 'a\n'
+ 'string, tuple or list). Slicings may be used as expressions or '
+ 'as\n'
+ 'targets in assignment or "del" statements. The syntax for a '
+ 'slicing:\n'
+ '\n'
+ ' slicing ::= primary "[" slice_list "]"\n'
+ ' slice_list ::= slice_item ("," slice_item)* [","]\n'
+ ' slice_item ::= expression | proper_slice\n'
+ ' proper_slice ::= [lower_bound] ":" [upper_bound] [ ":" '
+ '[stride] ]\n'
+ ' lower_bound ::= expression\n'
+ ' upper_bound ::= expression\n'
+ ' stride ::= expression\n'
+ '\n'
+ 'There is ambiguity in the formal syntax here: anything that '
+ 'looks like\n'
+ 'an expression list also looks like a slice list, so any '
+ 'subscription\n'
+ 'can be interpreted as a slicing. Rather than further '
+ 'complicating the\n'
+ 'syntax, this is disambiguated by defining that in this case the\n'
+ 'interpretation as a subscription takes priority over the\n'
+ 'interpretation as a slicing (this is the case if the slice list\n'
+ 'contains no proper slice).\n'
+ '\n'
+ 'The semantics for a slicing are as follows. The primary is '
+ 'indexed\n'
+ '(using the same "__getitem__()" method as normal subscription) '
+ 'with a\n'
+ 'key that is constructed from the slice list, as follows. If the '
+ 'slice\n'
+ 'list contains at least one comma, the key is a tuple containing '
+ 'the\n'
+ 'conversion of the slice items; otherwise, the conversion of the '
+ 'lone\n'
+ 'slice item is the key. The conversion of a slice item that is '
+ 'an\n'
+ 'expression is that expression. The conversion of a proper slice '
+ 'is a\n'
+ 'slice object (see section The standard type hierarchy) whose '
+ '"start",\n'
+ '"stop" and "step" attributes are the values of the expressions '
+ 'given\n'
+ 'as lower bound, upper bound and stride, respectively, '
+ 'substituting\n'
+ '"None" for missing expressions.\n',
+ 'specialattrs': '\n'
+ 'Special Attributes\n'
+ '******************\n'
+ '\n'
+ 'The implementation adds a few special read-only attributes '
+ 'to several\n'
+ 'object types, where they are relevant. Some of these are '
+ 'not reported\n'
+ 'by the "dir()" built-in function.\n'
+ '\n'
+ 'object.__dict__\n'
+ '\n'
+ ' A dictionary or other mapping object used to store an '
+ "object's\n"
+ ' (writable) attributes.\n'
+ '\n'
+ 'instance.__class__\n'
+ '\n'
+ ' The class to which a class instance belongs.\n'
+ '\n'
+ 'class.__bases__\n'
+ '\n'
+ ' The tuple of base classes of a class object.\n'
+ '\n'
+ 'class.__name__\n'
+ '\n'
+ ' The name of the class or type.\n'
+ '\n'
+ 'class.__qualname__\n'
+ '\n'
+ ' The *qualified name* of the class or type.\n'
+ '\n'
+ ' New in version 3.3.\n'
+ '\n'
+ 'class.__mro__\n'
+ '\n'
+ ' This attribute is a tuple of classes that are considered '
+ 'when\n'
+ ' looking for base classes during method resolution.\n'
+ '\n'
+ 'class.mro()\n'
+ '\n'
+ ' This method can be overridden by a metaclass to customize '
+ 'the\n'
+ ' method resolution order for its instances. It is called '
+ 'at class\n'
+ ' instantiation, and its result is stored in "__mro__".\n'
+ '\n'
+ 'class.__subclasses__()\n'
+ '\n'
+ ' Each class keeps a list of weak references to its '
+ 'immediate\n'
+ ' subclasses. This method returns a list of all those '
+ 'references\n'
+ ' still alive. Example:\n'
+ '\n'
+ ' >>> int.__subclasses__()\n'
+ " [<class 'bool'>]\n"
+ '\n'
+ '-[ Footnotes ]-\n'
+ '\n'
+ '[1] Additional information on these special methods may be '
+ 'found\n'
+ ' in the Python Reference Manual (Basic customization).\n'
+ '\n'
+ '[2] As a consequence, the list "[1, 2]" is considered equal '
+ 'to\n'
+ ' "[1.0, 2.0]", and similarly for tuples.\n'
+ '\n'
+ "[3] They must have since the parser can't tell the type of "
+ 'the\n'
+ ' operands.\n'
+ '\n'
+ '[4] Cased characters are those with general category '
+ 'property\n'
+ ' being one of "Lu" (Letter, uppercase), "Ll" (Letter, '
+ 'lowercase),\n'
+ ' or "Lt" (Letter, titlecase).\n'
+ '\n'
+ '[5] To format only a tuple you should therefore provide a\n'
+ ' singleton tuple whose only element is the tuple to be '
+ 'formatted.\n',
+ 'specialnames': '\n'
+ 'Special method names\n'
+ '********************\n'
+ '\n'
+ 'A class can implement certain operations that are invoked by '
+ 'special\n'
+ 'syntax (such as arithmetic operations or subscripting and '
+ 'slicing) by\n'
+ "defining methods with special names. This is Python's "
+ 'approach to\n'
+ '*operator overloading*, allowing classes to define their own '
+ 'behavior\n'
+ 'with respect to language operators. For instance, if a '
+ 'class defines\n'
+ 'a method named "__getitem__()", and "x" is an instance of '
+ 'this class,\n'
+ 'then "x[i]" is roughly equivalent to "type(x).__getitem__(x, '
+ 'i)".\n'
+ 'Except where mentioned, attempts to execute an operation '
+ 'raise an\n'
+ 'exception when no appropriate method is defined (typically\n'
+ '"AttributeError" or "TypeError").\n'
+ '\n'
+ 'When implementing a class that emulates any built-in type, '
+ 'it is\n'
+ 'important that the emulation only be implemented to the '
+ 'degree that it\n'
+ 'makes sense for the object being modelled. For example, '
+ 'some\n'
+ 'sequences may work well with retrieval of individual '
+ 'elements, but\n'
+ 'extracting a slice may not make sense. (One example of this '
+ 'is the\n'
+ '"NodeList" interface in the W3C\'s Document Object Model.)\n'
+ '\n'
+ '\n'
+ 'Basic customization\n'
+ '===================\n'
+ '\n'
+ 'object.__new__(cls[, ...])\n'
+ '\n'
+ ' Called to create a new instance of class *cls*. '
+ '"__new__()" is a\n'
+ ' static method (special-cased so you need not declare it '
+ 'as such)\n'
+ ' that takes the class of which an instance was requested '
+ 'as its\n'
+ ' first argument. The remaining arguments are those passed '
+ 'to the\n'
+ ' object constructor expression (the call to the class). '
+ 'The return\n'
+ ' value of "__new__()" should be the new object instance '
+ '(usually an\n'
+ ' instance of *cls*).\n'
+ '\n'
+ ' Typical implementations create a new instance of the '
+ 'class by\n'
+ ' invoking the superclass\'s "__new__()" method using\n'
+ ' "super(currentclass, cls).__new__(cls[, ...])" with '
+ 'appropriate\n'
+ ' arguments and then modifying the newly-created instance '
+ 'as\n'
+ ' necessary before returning it.\n'
+ '\n'
+ ' If "__new__()" returns an instance of *cls*, then the '
+ 'new\n'
+ ' instance\'s "__init__()" method will be invoked like\n'
+ ' "__init__(self[, ...])", where *self* is the new instance '
+ 'and the\n'
+ ' remaining arguments are the same as were passed to '
+ '"__new__()".\n'
+ '\n'
+ ' If "__new__()" does not return an instance of *cls*, then '
+ 'the new\n'
+ ' instance\'s "__init__()" method will not be invoked.\n'
+ '\n'
+ ' "__new__()" is intended mainly to allow subclasses of '
+ 'immutable\n'
+ ' types (like int, str, or tuple) to customize instance '
+ 'creation. It\n'
+ ' is also commonly overridden in custom metaclasses in '
+ 'order to\n'
+ ' customize class creation.\n'
+ '\n'
+ 'object.__init__(self[, ...])\n'
+ '\n'
+ ' Called after the instance has been created (by '
+ '"__new__()"), but\n'
+ ' before it is returned to the caller. The arguments are '
+ 'those\n'
+ ' passed to the class constructor expression. If a base '
+ 'class has an\n'
+ ' "__init__()" method, the derived class\'s "__init__()" '
+ 'method, if\n'
+ ' any, must explicitly call it to ensure proper '
+ 'initialization of the\n'
+ ' base class part of the instance; for example:\n'
+ ' "BaseClass.__init__(self, [args...])".\n'
+ '\n'
+ ' Because "__new__()" and "__init__()" work together in '
+ 'constructing\n'
+ ' objects ("__new__()" to create it, and "__init__()" to '
+ 'customise\n'
+ ' it), no non-"None" value may be returned by "__init__()"; '
+ 'doing so\n'
+ ' will cause a "TypeError" to be raised at runtime.\n'
+ '\n'
+ 'object.__del__(self)\n'
+ '\n'
+ ' Called when the instance is about to be destroyed. This '
+ 'is also\n'
+ ' called a destructor. If a base class has a "__del__()" '
+ 'method, the\n'
+ ' derived class\'s "__del__()" method, if any, must '
+ 'explicitly call it\n'
+ ' to ensure proper deletion of the base class part of the '
+ 'instance.\n'
+ ' Note that it is possible (though not recommended!) for '
+ 'the\n'
+ ' "__del__()" method to postpone destruction of the '
+ 'instance by\n'
+ ' creating a new reference to it. It may then be called at '
+ 'a later\n'
+ ' time when this new reference is deleted. It is not '
+ 'guaranteed that\n'
+ ' "__del__()" methods are called for objects that still '
+ 'exist when\n'
+ ' the interpreter exits.\n'
+ '\n'
+ ' Note: "del x" doesn\'t directly call "x.__del__()" --- '
+ 'the former\n'
+ ' decrements the reference count for "x" by one, and the '
+ 'latter is\n'
+ ' only called when "x"\'s reference count reaches zero. '
+ 'Some common\n'
+ ' situations that may prevent the reference count of an '
+ 'object from\n'
+ ' going to zero include: circular references between '
+ 'objects (e.g.,\n'
+ ' a doubly-linked list or a tree data structure with '
+ 'parent and\n'
+ ' child pointers); a reference to the object on the stack '
+ 'frame of\n'
+ ' a function that caught an exception (the traceback '
+ 'stored in\n'
+ ' "sys.exc_info()[2]" keeps the stack frame alive); or a '
+ 'reference\n'
+ ' to the object on the stack frame that raised an '
+ 'unhandled\n'
+ ' exception in interactive mode (the traceback stored in\n'
+ ' "sys.last_traceback" keeps the stack frame alive). The '
+ 'first\n'
+ ' situation can only be remedied by explicitly breaking '
+ 'the cycles;\n'
+ ' the second can be resolved by freeing the reference to '
+ 'the\n'
+ ' traceback object when it is no longer useful, and the '
+ 'third can\n'
+ ' be resolved by storing "None" in "sys.last_traceback". '
+ 'Circular\n'
+ ' references which are garbage are detected and cleaned '
+ 'up when the\n'
+ " cyclic garbage collector is enabled (it's on by "
+ 'default). Refer\n'
+ ' to the documentation for the "gc" module for more '
+ 'information\n'
+ ' about this topic.\n'
+ '\n'
+ ' Warning: Due to the precarious circumstances under which\n'
+ ' "__del__()" methods are invoked, exceptions that occur '
+ 'during\n'
+ ' their execution are ignored, and a warning is printed '
+ 'to\n'
+ ' "sys.stderr" instead. Also, when "__del__()" is invoked '
+ 'in\n'
+ ' response to a module being deleted (e.g., when '
+ 'execution of the\n'
+ ' program is done), other globals referenced by the '
+ '"__del__()"\n'
+ ' method may already have been deleted or in the process '
+ 'of being\n'
+ ' torn down (e.g. the import machinery shutting down). '
+ 'For this\n'
+ ' reason, "__del__()" methods should do the absolute '
+ 'minimum needed\n'
+ ' to maintain external invariants. Starting with version '
+ '1.5,\n'
+ ' Python guarantees that globals whose name begins with a '
+ 'single\n'
+ ' underscore are deleted from their module before other '
+ 'globals are\n'
+ ' deleted; if no other references to such globals exist, '
+ 'this may\n'
+ ' help in assuring that imported modules are still '
+ 'available at the\n'
+ ' time when the "__del__()" method is called.\n'
+ '\n'
+ 'object.__repr__(self)\n'
+ '\n'
+ ' Called by the "repr()" built-in function to compute the '
+ '"official"\n'
+ ' string representation of an object. If at all possible, '
+ 'this\n'
+ ' should look like a valid Python expression that could be '
+ 'used to\n'
+ ' recreate an object with the same value (given an '
+ 'appropriate\n'
+ ' environment). If this is not possible, a string of the '
+ 'form\n'
+ ' "<...some useful description...>" should be returned. The '
+ 'return\n'
+ ' value must be a string object. If a class defines '
+ '"__repr__()" but\n'
+ ' not "__str__()", then "__repr__()" is also used when an '
+ '"informal"\n'
+ ' string representation of instances of that class is '
+ 'required.\n'
+ '\n'
+ ' This is typically used for debugging, so it is important '
+ 'that the\n'
+ ' representation is information-rich and unambiguous.\n'
+ '\n'
+ 'object.__str__(self)\n'
+ '\n'
+ ' Called by "str(object)" and the built-in functions '
+ '"format()" and\n'
+ ' "print()" to compute the "informal" or nicely printable '
+ 'string\n'
+ ' representation of an object. The return value must be a '
+ 'string\n'
+ ' object.\n'
+ '\n'
+ ' This method differs from "object.__repr__()" in that '
+ 'there is no\n'
+ ' expectation that "__str__()" return a valid Python '
+ 'expression: a\n'
+ ' more convenient or concise representation can be used.\n'
+ '\n'
+ ' The default implementation defined by the built-in type '
+ '"object"\n'
+ ' calls "object.__repr__()".\n'
+ '\n'
+ 'object.__bytes__(self)\n'
+ '\n'
+ ' Called by "bytes()" to compute a byte-string '
+ 'representation of an\n'
+ ' object. This should return a "bytes" object.\n'
+ '\n'
+ 'object.__format__(self, format_spec)\n'
+ '\n'
+ ' Called by the "format()" built-in function, and by '
+ 'extension,\n'
+ ' evaluation of formatted string literals and the '
+ '"str.format()"\n'
+ ' method, to produce a "formatted" string representation of '
+ 'an\n'
+ ' object. The "format_spec" argument is a string that '
+ 'contains a\n'
+ ' description of the formatting options desired. The '
+ 'interpretation\n'
+ ' of the "format_spec" argument is up to the type '
+ 'implementing\n'
+ ' "__format__()", however most classes will either '
+ 'delegate\n'
+ ' formatting to one of the built-in types, or use a '
+ 'similar\n'
+ ' formatting option syntax.\n'
+ '\n'
+ ' See Format Specification Mini-Language for a description '
+ 'of the\n'
+ ' standard formatting syntax.\n'
+ '\n'
+ ' The return value must be a string object.\n'
+ '\n'
+ ' Changed in version 3.4: The __format__ method of "object" '
+ 'itself\n'
+ ' raises a "TypeError" if passed any non-empty string.\n'
+ '\n'
+ 'object.__lt__(self, other)\n'
+ 'object.__le__(self, other)\n'
+ 'object.__eq__(self, other)\n'
+ 'object.__ne__(self, other)\n'
+ 'object.__gt__(self, other)\n'
+ 'object.__ge__(self, other)\n'
+ '\n'
+ ' These are the so-called "rich comparison" methods. The\n'
+ ' correspondence between operator symbols and method names '
+ 'is as\n'
+ ' follows: "x<y" calls "x.__lt__(y)", "x<=y" calls '
+ '"x.__le__(y)",\n'
+ ' "x==y" calls "x.__eq__(y)", "x!=y" calls "x.__ne__(y)", '
+ '"x>y" calls\n'
+ ' "x.__gt__(y)", and "x>=y" calls "x.__ge__(y)".\n'
+ '\n'
+ ' A rich comparison method may return the singleton '
+ '"NotImplemented"\n'
+ ' if it does not implement the operation for a given pair '
+ 'of\n'
+ ' arguments. By convention, "False" and "True" are returned '
+ 'for a\n'
+ ' successful comparison. However, these methods can return '
+ 'any value,\n'
+ ' so if the comparison operator is used in a Boolean '
+ 'context (e.g.,\n'
+ ' in the condition of an "if" statement), Python will call '
+ '"bool()"\n'
+ ' on the value to determine if the result is true or '
+ 'false.\n'
+ '\n'
+ ' By default, "__ne__()" delegates to "__eq__()" and '
+ 'inverts the\n'
+ ' result unless it is "NotImplemented". There are no other '
+ 'implied\n'
+ ' relationships among the comparison operators, for '
+ 'example, the\n'
+ ' truth of "(x<y or x==y)" does not imply "x<=y". To '
+ 'automatically\n'
+ ' generate ordering operations from a single root '
+ 'operation, see\n'
+ ' "functools.total_ordering()".\n'
+ '\n'
+ ' See the paragraph on "__hash__()" for some important '
+ 'notes on\n'
+ ' creating *hashable* objects which support custom '
+ 'comparison\n'
+ ' operations and are usable as dictionary keys.\n'
+ '\n'
+ ' There are no swapped-argument versions of these methods '
+ '(to be used\n'
+ ' when the left argument does not support the operation but '
+ 'the right\n'
+ ' argument does); rather, "__lt__()" and "__gt__()" are '
+ "each other's\n"
+ ' reflection, "__le__()" and "__ge__()" are each other\'s '
+ 'reflection,\n'
+ ' and "__eq__()" and "__ne__()" are their own reflection. '
+ 'If the\n'
+ " operands are of different types, and right operand's type "
+ 'is a\n'
+ " direct or indirect subclass of the left operand's type, "
+ 'the\n'
+ ' reflected method of the right operand has priority, '
+ 'otherwise the\n'
+ " left operand's method has priority. Virtual subclassing "
+ 'is not\n'
+ ' considered.\n'
+ '\n'
+ 'object.__hash__(self)\n'
+ '\n'
+ ' Called by built-in function "hash()" and for operations '
+ 'on members\n'
+ ' of hashed collections including "set", "frozenset", and '
+ '"dict".\n'
+ ' "__hash__()" should return an integer. The only required '
+ 'property\n'
+ ' is that objects which compare equal have the same hash '
+ 'value; it is\n'
+ ' advised to somehow mix together (e.g. using exclusive or) '
+ 'the hash\n'
+ ' values for the components of the object that also play a '
+ 'part in\n'
+ ' comparison of objects.\n'
+ '\n'
+ ' Note: "hash()" truncates the value returned from an '
+ "object's\n"
+ ' custom "__hash__()" method to the size of a '
+ '"Py_ssize_t". This\n'
+ ' is typically 8 bytes on 64-bit builds and 4 bytes on '
+ '32-bit\n'
+ ' builds. If an object\'s "__hash__()" must '
+ 'interoperate on builds\n'
+ ' of different bit sizes, be sure to check the width on '
+ 'all\n'
+ ' supported builds. An easy way to do this is with '
+ '"python -c\n'
+ ' "import sys; print(sys.hash_info.width)"".\n'
+ '\n'
+ ' If a class does not define an "__eq__()" method it should '
+ 'not\n'
+ ' define a "__hash__()" operation either; if it defines '
+ '"__eq__()"\n'
+ ' but not "__hash__()", its instances will not be usable as '
+ 'items in\n'
+ ' hashable collections. If a class defines mutable objects '
+ 'and\n'
+ ' implements an "__eq__()" method, it should not implement\n'
+ ' "__hash__()", since the implementation of hashable '
+ 'collections\n'
+ " requires that a key's hash value is immutable (if the "
+ "object's hash\n"
+ ' value changes, it will be in the wrong hash bucket).\n'
+ '\n'
+ ' User-defined classes have "__eq__()" and "__hash__()" '
+ 'methods by\n'
+ ' default; with them, all objects compare unequal (except '
+ 'with\n'
+ ' themselves) and "x.__hash__()" returns an appropriate '
+ 'value such\n'
+ ' that "x == y" implies both that "x is y" and "hash(x) == '
+ 'hash(y)".\n'
+ '\n'
+ ' A class that overrides "__eq__()" and does not define '
+ '"__hash__()"\n'
+ ' will have its "__hash__()" implicitly set to "None". '
+ 'When the\n'
+ ' "__hash__()" method of a class is "None", instances of '
+ 'the class\n'
+ ' will raise an appropriate "TypeError" when a program '
+ 'attempts to\n'
+ ' retrieve their hash value, and will also be correctly '
+ 'identified as\n'
+ ' unhashable when checking "isinstance(obj, '
+ 'collections.Hashable)".\n'
+ '\n'
+ ' If a class that overrides "__eq__()" needs to retain the\n'
+ ' implementation of "__hash__()" from a parent class, the '
+ 'interpreter\n'
+ ' must be told this explicitly by setting "__hash__ =\n'
+ ' <ParentClass>.__hash__".\n'
+ '\n'
+ ' If a class that does not override "__eq__()" wishes to '
+ 'suppress\n'
+ ' hash support, it should include "__hash__ = None" in the '
+ 'class\n'
+ ' definition. A class which defines its own "__hash__()" '
+ 'that\n'
+ ' explicitly raises a "TypeError" would be incorrectly '
+ 'identified as\n'
+ ' hashable by an "isinstance(obj, collections.Hashable)" '
+ 'call.\n'
+ '\n'
+ ' Note: By default, the "__hash__()" values of str, bytes '
+ 'and\n'
+ ' datetime objects are "salted" with an unpredictable '
+ 'random value.\n'
+ ' Although they remain constant within an individual '
+ 'Python\n'
+ ' process, they are not predictable between repeated '
+ 'invocations of\n'
+ ' Python.This is intended to provide protection against a '
+ 'denial-\n'
+ ' of-service caused by carefully-chosen inputs that '
+ 'exploit the\n'
+ ' worst case performance of a dict insertion, O(n^2) '
+ 'complexity.\n'
+ ' See http://www.ocert.org/advisories/ocert-2011-003.html '
+ 'for\n'
+ ' details.Changing hash values affects the iteration '
+ 'order of\n'
+ ' dicts, sets and other mappings. Python has never made '
+ 'guarantees\n'
+ ' about this ordering (and it typically varies between '
+ '32-bit and\n'
+ ' 64-bit builds).See also "PYTHONHASHSEED".\n'
+ '\n'
+ ' Changed in version 3.3: Hash randomization is enabled by '
+ 'default.\n'
+ '\n'
+ 'object.__bool__(self)\n'
+ '\n'
+ ' Called to implement truth value testing and the built-in '
+ 'operation\n'
+ ' "bool()"; should return "False" or "True". When this '
+ 'method is not\n'
+ ' defined, "__len__()" is called, if it is defined, and the '
+ 'object is\n'
+ ' considered true if its result is nonzero. If a class '
+ 'defines\n'
+ ' neither "__len__()" nor "__bool__()", all its instances '
+ 'are\n'
+ ' considered true.\n'
+ '\n'
+ '\n'
+ 'Customizing attribute access\n'
+ '============================\n'
+ '\n'
+ 'The following methods can be defined to customize the '
+ 'meaning of\n'
+ 'attribute access (use of, assignment to, or deletion of '
+ '"x.name") for\n'
+ 'class instances.\n'
+ '\n'
+ 'object.__getattr__(self, name)\n'
+ '\n'
+ ' Called when an attribute lookup has not found the '
+ 'attribute in the\n'
+ ' usual places (i.e. it is not an instance attribute nor is '
+ 'it found\n'
+ ' in the class tree for "self"). "name" is the attribute '
+ 'name. This\n'
+ ' method should return the (computed) attribute value or '
+ 'raise an\n'
+ ' "AttributeError" exception.\n'
+ '\n'
+ ' Note that if the attribute is found through the normal '
+ 'mechanism,\n'
+ ' "__getattr__()" is not called. (This is an intentional '
+ 'asymmetry\n'
+ ' between "__getattr__()" and "__setattr__()".) This is '
+ 'done both for\n'
+ ' efficiency reasons and because otherwise "__getattr__()" '
+ 'would have\n'
+ ' no way to access other attributes of the instance. Note '
+ 'that at\n'
+ ' least for instance variables, you can fake total control '
+ 'by not\n'
+ ' inserting any values in the instance attribute dictionary '
+ '(but\n'
+ ' instead inserting them in another object). See the\n'
+ ' "__getattribute__()" method below for a way to actually '
+ 'get total\n'
+ ' control over attribute access.\n'
+ '\n'
+ 'object.__getattribute__(self, name)\n'
+ '\n'
+ ' Called unconditionally to implement attribute accesses '
+ 'for\n'
+ ' instances of the class. If the class also defines '
+ '"__getattr__()",\n'
+ ' the latter will not be called unless "__getattribute__()" '
+ 'either\n'
+ ' calls it explicitly or raises an "AttributeError". This '
+ 'method\n'
+ ' should return the (computed) attribute value or raise an\n'
+ ' "AttributeError" exception. In order to avoid infinite '
+ 'recursion in\n'
+ ' this method, its implementation should always call the '
+ 'base class\n'
+ ' method with the same name to access any attributes it '
+ 'needs, for\n'
+ ' example, "object.__getattribute__(self, name)".\n'
+ '\n'
+ ' Note: This method may still be bypassed when looking up '
+ 'special\n'
+ ' methods as the result of implicit invocation via '
+ 'language syntax\n'
+ ' or built-in functions. See Special method lookup.\n'
+ '\n'
+ 'object.__setattr__(self, name, value)\n'
+ '\n'
+ ' Called when an attribute assignment is attempted. This '
+ 'is called\n'
+ ' instead of the normal mechanism (i.e. store the value in '
+ 'the\n'
+ ' instance dictionary). *name* is the attribute name, '
+ '*value* is the\n'
+ ' value to be assigned to it.\n'
+ '\n'
+ ' If "__setattr__()" wants to assign to an instance '
+ 'attribute, it\n'
+ ' should call the base class method with the same name, for '
+ 'example,\n'
+ ' "object.__setattr__(self, name, value)".\n'
+ '\n'
+ 'object.__delattr__(self, name)\n'
+ '\n'
+ ' Like "__setattr__()" but for attribute deletion instead '
+ 'of\n'
+ ' assignment. This should only be implemented if "del '
+ 'obj.name" is\n'
+ ' meaningful for the object.\n'
+ '\n'
+ 'object.__dir__(self)\n'
+ '\n'
+ ' Called when "dir()" is called on the object. A sequence '
+ 'must be\n'
+ ' returned. "dir()" converts the returned sequence to a '
+ 'list and\n'
+ ' sorts it.\n'
+ '\n'
+ '\n'
+ 'Implementing Descriptors\n'
+ '------------------------\n'
+ '\n'
+ 'The following methods only apply when an instance of the '
+ 'class\n'
+ 'containing the method (a so-called *descriptor* class) '
+ 'appears in an\n'
+ "*owner* class (the descriptor must be in either the owner's "
+ 'class\n'
+ 'dictionary or in the class dictionary for one of its '
+ 'parents). In the\n'
+ 'examples below, "the attribute" refers to the attribute '
+ 'whose name is\n'
+ 'the key of the property in the owner class\' "__dict__".\n'
+ '\n'
+ 'object.__get__(self, instance, owner)\n'
+ '\n'
+ ' Called to get the attribute of the owner class (class '
+ 'attribute\n'
+ ' access) or of an instance of that class (instance '
+ 'attribute\n'
+ ' access). *owner* is always the owner class, while '
+ '*instance* is the\n'
+ ' instance that the attribute was accessed through, or '
+ '"None" when\n'
+ ' the attribute is accessed through the *owner*. This '
+ 'method should\n'
+ ' return the (computed) attribute value or raise an '
+ '"AttributeError"\n'
+ ' exception.\n'
+ '\n'
+ 'object.__set__(self, instance, value)\n'
+ '\n'
+ ' Called to set the attribute on an instance *instance* of '
+ 'the owner\n'
+ ' class to a new value, *value*.\n'
+ '\n'
+ 'object.__delete__(self, instance)\n'
+ '\n'
+ ' Called to delete the attribute on an instance *instance* '
+ 'of the\n'
+ ' owner class.\n'
+ '\n'
+ 'The attribute "__objclass__" is interpreted by the "inspect" '
+ 'module as\n'
+ 'specifying the class where this object was defined (setting '
+ 'this\n'
+ 'appropriately can assist in runtime introspection of dynamic '
+ 'class\n'
+ 'attributes). For callables, it may indicate that an instance '
+ 'of the\n'
+ 'given type (or a subclass) is expected or required as the '
+ 'first\n'
+ 'positional argument (for example, CPython sets this '
+ 'attribute for\n'
+ 'unbound methods that are implemented in C).\n'
+ '\n'
+ '\n'
+ 'Invoking Descriptors\n'
+ '--------------------\n'
+ '\n'
+ 'In general, a descriptor is an object attribute with '
+ '"binding\n'
+ 'behavior", one whose attribute access has been overridden by '
+ 'methods\n'
+ 'in the descriptor protocol: "__get__()", "__set__()", and\n'
+ '"__delete__()". If any of those methods are defined for an '
+ 'object, it\n'
+ 'is said to be a descriptor.\n'
+ '\n'
+ 'The default behavior for attribute access is to get, set, or '
+ 'delete\n'
+ "the attribute from an object's dictionary. For instance, "
+ '"a.x" has a\n'
+ 'lookup chain starting with "a.__dict__[\'x\']", then\n'
+ '"type(a).__dict__[\'x\']", and continuing through the base '
+ 'classes of\n'
+ '"type(a)" excluding metaclasses.\n'
+ '\n'
+ 'However, if the looked-up value is an object defining one of '
+ 'the\n'
+ 'descriptor methods, then Python may override the default '
+ 'behavior and\n'
+ 'invoke the descriptor method instead. Where this occurs in '
+ 'the\n'
+ 'precedence chain depends on which descriptor methods were '
+ 'defined and\n'
+ 'how they were called.\n'
+ '\n'
+ 'The starting point for descriptor invocation is a binding, '
+ '"a.x". How\n'
+ 'the arguments are assembled depends on "a":\n'
+ '\n'
+ 'Direct Call\n'
+ ' The simplest and least common call is when user code '
+ 'directly\n'
+ ' invokes a descriptor method: "x.__get__(a)".\n'
+ '\n'
+ 'Instance Binding\n'
+ ' If binding to an object instance, "a.x" is transformed '
+ 'into the\n'
+ ' call: "type(a).__dict__[\'x\'].__get__(a, type(a))".\n'
+ '\n'
+ 'Class Binding\n'
+ ' If binding to a class, "A.x" is transformed into the '
+ 'call:\n'
+ ' "A.__dict__[\'x\'].__get__(None, A)".\n'
+ '\n'
+ 'Super Binding\n'
+ ' If "a" is an instance of "super", then the binding '
+ '"super(B,\n'
+ ' obj).m()" searches "obj.__class__.__mro__" for the base '
+ 'class "A"\n'
+ ' immediately preceding "B" and then invokes the descriptor '
+ 'with the\n'
+ ' call: "A.__dict__[\'m\'].__get__(obj, obj.__class__)".\n'
+ '\n'
+ 'For instance bindings, the precedence of descriptor '
+ 'invocation depends\n'
+ 'on the which descriptor methods are defined. A descriptor '
+ 'can define\n'
+ 'any combination of "__get__()", "__set__()" and '
+ '"__delete__()". If it\n'
+ 'does not define "__get__()", then accessing the attribute '
+ 'will return\n'
+ 'the descriptor object itself unless there is a value in the '
+ "object's\n"
+ 'instance dictionary. If the descriptor defines "__set__()" '
+ 'and/or\n'
+ '"__delete__()", it is a data descriptor; if it defines '
+ 'neither, it is\n'
+ 'a non-data descriptor. Normally, data descriptors define '
+ 'both\n'
+ '"__get__()" and "__set__()", while non-data descriptors have '
+ 'just the\n'
+ '"__get__()" method. Data descriptors with "__set__()" and '
+ '"__get__()"\n'
+ 'defined always override a redefinition in an instance '
+ 'dictionary. In\n'
+ 'contrast, non-data descriptors can be overridden by '
+ 'instances.\n'
+ '\n'
+ 'Python methods (including "staticmethod()" and '
+ '"classmethod()") are\n'
+ 'implemented as non-data descriptors. Accordingly, instances '
+ 'can\n'
+ 'redefine and override methods. This allows individual '
+ 'instances to\n'
+ 'acquire behaviors that differ from other instances of the '
+ 'same class.\n'
+ '\n'
+ 'The "property()" function is implemented as a data '
+ 'descriptor.\n'
+ 'Accordingly, instances cannot override the behavior of a '
+ 'property.\n'
+ '\n'
+ '\n'
+ '__slots__\n'
+ '---------\n'
+ '\n'
+ 'By default, instances of classes have a dictionary for '
+ 'attribute\n'
+ 'storage. This wastes space for objects having very few '
+ 'instance\n'
+ 'variables. The space consumption can become acute when '
+ 'creating large\n'
+ 'numbers of instances.\n'
+ '\n'
+ 'The default can be overridden by defining *__slots__* in a '
+ 'class\n'
+ 'definition. The *__slots__* declaration takes a sequence of '
+ 'instance\n'
+ 'variables and reserves just enough space in each instance to '
+ 'hold a\n'
+ 'value for each variable. Space is saved because *__dict__* '
+ 'is not\n'
+ 'created for each instance.\n'
+ '\n'
+ 'object.__slots__\n'
+ '\n'
+ ' This class variable can be assigned a string, iterable, '
+ 'or sequence\n'
+ ' of strings with variable names used by instances. '
+ '*__slots__*\n'
+ ' reserves space for the declared variables and prevents '
+ 'the\n'
+ ' automatic creation of *__dict__* and *__weakref__* for '
+ 'each\n'
+ ' instance.\n'
+ '\n'
+ '\n'
+ 'Notes on using *__slots__*\n'
+ '~~~~~~~~~~~~~~~~~~~~~~~~~~\n'
+ '\n'
+ '* When inheriting from a class without *__slots__*, the '
+ '*__dict__*\n'
+ ' attribute of that class will always be accessible, so a '
+ '*__slots__*\n'
+ ' definition in the subclass is meaningless.\n'
+ '\n'
+ '* Without a *__dict__* variable, instances cannot be '
+ 'assigned new\n'
+ ' variables not listed in the *__slots__* definition. '
+ 'Attempts to\n'
+ ' assign to an unlisted variable name raises '
+ '"AttributeError". If\n'
+ ' dynamic assignment of new variables is desired, then add\n'
+ ' "\'__dict__\'" to the sequence of strings in the '
+ '*__slots__*\n'
+ ' declaration.\n'
+ '\n'
+ '* Without a *__weakref__* variable for each instance, '
+ 'classes\n'
+ ' defining *__slots__* do not support weak references to '
+ 'its\n'
+ ' instances. If weak reference support is needed, then add\n'
+ ' "\'__weakref__\'" to the sequence of strings in the '
+ '*__slots__*\n'
+ ' declaration.\n'
+ '\n'
+ '* *__slots__* are implemented at the class level by '
+ 'creating\n'
+ ' descriptors (Implementing Descriptors) for each variable '
+ 'name. As a\n'
+ ' result, class attributes cannot be used to set default '
+ 'values for\n'
+ ' instance variables defined by *__slots__*; otherwise, the '
+ 'class\n'
+ ' attribute would overwrite the descriptor assignment.\n'
+ '\n'
+ '* The action of a *__slots__* declaration is limited to the '
+ 'class\n'
+ ' where it is defined. As a result, subclasses will have a '
+ '*__dict__*\n'
+ ' unless they also define *__slots__* (which must only '
+ 'contain names\n'
+ ' of any *additional* slots).\n'
+ '\n'
+ '* If a class defines a slot also defined in a base class, '
+ 'the\n'
+ ' instance variable defined by the base class slot is '
+ 'inaccessible\n'
+ ' (except by retrieving its descriptor directly from the '
+ 'base class).\n'
+ ' This renders the meaning of the program undefined. In the '
+ 'future, a\n'
+ ' check may be added to prevent this.\n'
+ '\n'
+ '* Nonempty *__slots__* does not work for classes derived '
+ 'from\n'
+ ' "variable-length" built-in types such as "int", "bytes" '
+ 'and "tuple".\n'
+ '\n'
+ '* Any non-string iterable may be assigned to *__slots__*. '
+ 'Mappings\n'
+ ' may also be used; however, in the future, special meaning '
+ 'may be\n'
+ ' assigned to the values corresponding to each key.\n'
+ '\n'
+ '* *__class__* assignment works only if both classes have the '
+ 'same\n'
+ ' *__slots__*.\n'
+ '\n'
+ '\n'
+ 'Customizing class creation\n'
+ '==========================\n'
+ '\n'
+ 'By default, classes are constructed using "type()". The '
+ 'class body is\n'
+ 'executed in a new namespace and the class name is bound '
+ 'locally to the\n'
+ 'result of "type(name, bases, namespace)".\n'
+ '\n'
+ 'The class creation process can be customised by passing the\n'
+ '"metaclass" keyword argument in the class definition line, '
+ 'or by\n'
+ 'inheriting from an existing class that included such an '
+ 'argument. In\n'
+ 'the following example, both "MyClass" and "MySubclass" are '
+ 'instances\n'
+ 'of "Meta":\n'
+ '\n'
+ ' class Meta(type):\n'
+ ' pass\n'
+ '\n'
+ ' class MyClass(metaclass=Meta):\n'
+ ' pass\n'
+ '\n'
+ ' class MySubclass(MyClass):\n'
+ ' pass\n'
+ '\n'
+ 'Any other keyword arguments that are specified in the class '
+ 'definition\n'
+ 'are passed through to all metaclass operations described '
+ 'below.\n'
+ '\n'
+ 'When a class definition is executed, the following steps '
+ 'occur:\n'
+ '\n'
+ '* the appropriate metaclass is determined\n'
+ '\n'
+ '* the class namespace is prepared\n'
+ '\n'
+ '* the class body is executed\n'
+ '\n'
+ '* the class object is created\n'
+ '\n'
+ '\n'
+ 'Determining the appropriate metaclass\n'
+ '-------------------------------------\n'
+ '\n'
+ 'The appropriate metaclass for a class definition is '
+ 'determined as\n'
+ 'follows:\n'
+ '\n'
+ '* if no bases and no explicit metaclass are given, then '
+ '"type()" is\n'
+ ' used\n'
+ '\n'
+ '* if an explicit metaclass is given and it is *not* an '
+ 'instance of\n'
+ ' "type()", then it is used directly as the metaclass\n'
+ '\n'
+ '* if an instance of "type()" is given as the explicit '
+ 'metaclass, or\n'
+ ' bases are defined, then the most derived metaclass is '
+ 'used\n'
+ '\n'
+ 'The most derived metaclass is selected from the explicitly '
+ 'specified\n'
+ 'metaclass (if any) and the metaclasses (i.e. "type(cls)") of '
+ 'all\n'
+ 'specified base classes. The most derived metaclass is one '
+ 'which is a\n'
+ 'subtype of *all* of these candidate metaclasses. If none of '
+ 'the\n'
+ 'candidate metaclasses meets that criterion, then the class '
+ 'definition\n'
+ 'will fail with "TypeError".\n'
+ '\n'
+ '\n'
+ 'Preparing the class namespace\n'
+ '-----------------------------\n'
+ '\n'
+ 'Once the appropriate metaclass has been identified, then the '
+ 'class\n'
+ 'namespace is prepared. If the metaclass has a "__prepare__" '
+ 'attribute,\n'
+ 'it is called as "namespace = metaclass.__prepare__(name, '
+ 'bases,\n'
+ '**kwds)" (where the additional keyword arguments, if any, '
+ 'come from\n'
+ 'the class definition).\n'
+ '\n'
+ 'If the metaclass has no "__prepare__" attribute, then the '
+ 'class\n'
+ 'namespace is initialised as an empty "dict()" instance.\n'
+ '\n'
+ 'See also:\n'
+ '\n'
+ ' **PEP 3115** - Metaclasses in Python 3000\n'
+ ' Introduced the "__prepare__" namespace hook\n'
+ '\n'
+ '\n'
+ 'Executing the class body\n'
+ '------------------------\n'
+ '\n'
+ 'The class body is executed (approximately) as "exec(body, '
+ 'globals(),\n'
+ 'namespace)". The key difference from a normal call to '
+ '"exec()" is that\n'
+ 'lexical scoping allows the class body (including any '
+ 'methods) to\n'
+ 'reference names from the current and outer scopes when the '
+ 'class\n'
+ 'definition occurs inside a function.\n'
+ '\n'
+ 'However, even when the class definition occurs inside the '
+ 'function,\n'
+ 'methods defined inside the class still cannot see names '
+ 'defined at the\n'
+ 'class scope. Class variables must be accessed through the '
+ 'first\n'
+ 'parameter of instance or class methods, and cannot be '
+ 'accessed at all\n'
+ 'from static methods.\n'
+ '\n'
+ '\n'
+ 'Creating the class object\n'
+ '-------------------------\n'
+ '\n'
+ 'Once the class namespace has been populated by executing the '
+ 'class\n'
+ 'body, the class object is created by calling '
+ '"metaclass(name, bases,\n'
+ 'namespace, **kwds)" (the additional keywords passed here are '
+ 'the same\n'
+ 'as those passed to "__prepare__").\n'
+ '\n'
+ 'This class object is the one that will be referenced by the '
+ 'zero-\n'
+ 'argument form of "super()". "__class__" is an implicit '
+ 'closure\n'
+ 'reference created by the compiler if any methods in a class '
+ 'body refer\n'
+ 'to either "__class__" or "super". This allows the zero '
+ 'argument form\n'
+ 'of "super()" to correctly identify the class being defined '
+ 'based on\n'
+ 'lexical scoping, while the class or instance that was used '
+ 'to make the\n'
+ 'current call is identified based on the first argument '
+ 'passed to the\n'
+ 'method.\n'
+ '\n'
+ 'After the class object is created, it is passed to the '
+ 'class\n'
+ 'decorators included in the class definition (if any) and the '
+ 'resulting\n'
+ 'object is bound in the local namespace as the defined '
+ 'class.\n'
+ '\n'
+ 'When a new class is created by "type.__new__", the object '
+ 'provided as\n'
+ 'the namespace parameter is copied to a standard Python '
+ 'dictionary and\n'
+ 'the original object is discarded. The new copy becomes the '
+ '"__dict__"\n'
+ 'attribute of the class object.\n'
+ '\n'
+ 'See also:\n'
+ '\n'
+ ' **PEP 3135** - New super\n'
+ ' Describes the implicit "__class__" closure reference\n'
+ '\n'
+ '\n'
+ 'Metaclass example\n'
+ '-----------------\n'
+ '\n'
+ 'The potential uses for metaclasses are boundless. Some ideas '
+ 'that have\n'
+ 'been explored include logging, interface checking, '
+ 'automatic\n'
+ 'delegation, automatic property creation, proxies, '
+ 'frameworks, and\n'
+ 'automatic resource locking/synchronization.\n'
+ '\n'
+ 'Here is an example of a metaclass that uses an\n'
+ '"collections.OrderedDict" to remember the order that class '
+ 'variables\n'
+ 'are defined:\n'
+ '\n'
+ ' class OrderedClass(type):\n'
+ '\n'
+ ' @classmethod\n'
+ ' def __prepare__(metacls, name, bases, **kwds):\n'
+ ' return collections.OrderedDict()\n'
+ '\n'
+ ' def __new__(cls, name, bases, namespace, **kwds):\n'
+ ' result = type.__new__(cls, name, bases, '
+ 'dict(namespace))\n'
+ ' result.members = tuple(namespace)\n'
+ ' return result\n'
+ '\n'
+ ' class A(metaclass=OrderedClass):\n'
+ ' def one(self): pass\n'
+ ' def two(self): pass\n'
+ ' def three(self): pass\n'
+ ' def four(self): pass\n'
+ '\n'
+ ' >>> A.members\n'
+ " ('__module__', 'one', 'two', 'three', 'four')\n"
+ '\n'
+ 'When the class definition for *A* gets executed, the process '
+ 'begins\n'
+ 'with calling the metaclass\'s "__prepare__()" method which '
+ 'returns an\n'
+ 'empty "collections.OrderedDict". That mapping records the '
+ 'methods and\n'
+ 'attributes of *A* as they are defined within the body of the '
+ 'class\n'
+ 'statement. Once those definitions are executed, the ordered '
+ 'dictionary\n'
+ 'is fully populated and the metaclass\'s "__new__()" method '
+ 'gets\n'
+ 'invoked. That method builds the new type and it saves the '
+ 'ordered\n'
+ 'dictionary keys in an attribute called "members".\n'
+ '\n'
+ '\n'
+ 'Customizing instance and subclass checks\n'
+ '========================================\n'
+ '\n'
+ 'The following methods are used to override the default '
+ 'behavior of the\n'
+ '"isinstance()" and "issubclass()" built-in functions.\n'
+ '\n'
+ 'In particular, the metaclass "abc.ABCMeta" implements these '
+ 'methods in\n'
+ 'order to allow the addition of Abstract Base Classes (ABCs) '
+ 'as\n'
+ '"virtual base classes" to any class or type (including '
+ 'built-in\n'
+ 'types), including other ABCs.\n'
+ '\n'
+ 'class.__instancecheck__(self, instance)\n'
+ '\n'
+ ' Return true if *instance* should be considered a (direct '
+ 'or\n'
+ ' indirect) instance of *class*. If defined, called to '
+ 'implement\n'
+ ' "isinstance(instance, class)".\n'
+ '\n'
+ 'class.__subclasscheck__(self, subclass)\n'
+ '\n'
+ ' Return true if *subclass* should be considered a (direct '
+ 'or\n'
+ ' indirect) subclass of *class*. If defined, called to '
+ 'implement\n'
+ ' "issubclass(subclass, class)".\n'
+ '\n'
+ 'Note that these methods are looked up on the type '
+ '(metaclass) of a\n'
+ 'class. They cannot be defined as class methods in the '
+ 'actual class.\n'
+ 'This is consistent with the lookup of special methods that '
+ 'are called\n'
+ 'on instances, only in this case the instance is itself a '
+ 'class.\n'
+ '\n'
+ 'See also:\n'
+ '\n'
+ ' **PEP 3119** - Introducing Abstract Base Classes\n'
+ ' Includes the specification for customizing '
+ '"isinstance()" and\n'
+ ' "issubclass()" behavior through "__instancecheck__()" '
+ 'and\n'
+ ' "__subclasscheck__()", with motivation for this '
+ 'functionality in\n'
+ ' the context of adding Abstract Base Classes (see the '
+ '"abc"\n'
+ ' module) to the language.\n'
+ '\n'
+ '\n'
+ 'Emulating callable objects\n'
+ '==========================\n'
+ '\n'
+ 'object.__call__(self[, args...])\n'
+ '\n'
+ ' Called when the instance is "called" as a function; if '
+ 'this method\n'
+ ' is defined, "x(arg1, arg2, ...)" is a shorthand for\n'
+ ' "x.__call__(arg1, arg2, ...)".\n'
+ '\n'
+ '\n'
+ 'Emulating container types\n'
+ '=========================\n'
+ '\n'
+ 'The following methods can be defined to implement container '
+ 'objects.\n'
+ 'Containers usually are sequences (such as lists or tuples) '
+ 'or mappings\n'
+ '(like dictionaries), but can represent other containers as '
+ 'well. The\n'
+ 'first set of methods is used either to emulate a sequence or '
+ 'to\n'
+ 'emulate a mapping; the difference is that for a sequence, '
+ 'the\n'
+ 'allowable keys should be the integers *k* for which "0 <= k '
+ '< N" where\n'
+ '*N* is the length of the sequence, or slice objects, which '
+ 'define a\n'
+ 'range of items. It is also recommended that mappings '
+ 'provide the\n'
+ 'methods "keys()", "values()", "items()", "get()", '
+ '"clear()",\n'
+ '"setdefault()", "pop()", "popitem()", "copy()", and '
+ '"update()"\n'
+ "behaving similar to those for Python's standard dictionary "
+ 'objects.\n'
+ 'The "collections" module provides a "MutableMapping" '
+ 'abstract base\n'
+ 'class to help create those methods from a base set of '
+ '"__getitem__()",\n'
+ '"__setitem__()", "__delitem__()", and "keys()". Mutable '
+ 'sequences\n'
+ 'should provide methods "append()", "count()", "index()", '
+ '"extend()",\n'
+ '"insert()", "pop()", "remove()", "reverse()" and "sort()", '
+ 'like Python\n'
+ 'standard list objects. Finally, sequence types should '
+ 'implement\n'
+ 'addition (meaning concatenation) and multiplication '
+ '(meaning\n'
+ 'repetition) by defining the methods "__add__()", '
+ '"__radd__()",\n'
+ '"__iadd__()", "__mul__()", "__rmul__()" and "__imul__()" '
+ 'described\n'
+ 'below; they should not define other numerical operators. It '
+ 'is\n'
+ 'recommended that both mappings and sequences implement the\n'
+ '"__contains__()" method to allow efficient use of the "in" '
+ 'operator;\n'
+ 'for mappings, "in" should search the mapping\'s keys; for '
+ 'sequences, it\n'
+ 'should search through the values. It is further recommended '
+ 'that both\n'
+ 'mappings and sequences implement the "__iter__()" method to '
+ 'allow\n'
+ 'efficient iteration through the container; for mappings, '
+ '"__iter__()"\n'
+ 'should be the same as "keys()"; for sequences, it should '
+ 'iterate\n'
+ 'through the values.\n'
+ '\n'
+ 'object.__len__(self)\n'
+ '\n'
+ ' Called to implement the built-in function "len()". '
+ 'Should return\n'
+ ' the length of the object, an integer ">=" 0. Also, an '
+ 'object that\n'
+ ' doesn\'t define a "__bool__()" method and whose '
+ '"__len__()" method\n'
+ ' returns zero is considered to be false in a Boolean '
+ 'context.\n'
+ '\n'
+ 'object.__length_hint__(self)\n'
+ '\n'
+ ' Called to implement "operator.length_hint()". Should '
+ 'return an\n'
+ ' estimated length for the object (which may be greater or '
+ 'less than\n'
+ ' the actual length). The length must be an integer ">=" 0. '
+ 'This\n'
+ ' method is purely an optimization and is never required '
+ 'for\n'
+ ' correctness.\n'
+ '\n'
+ ' New in version 3.4.\n'
+ '\n'
+ 'Note: Slicing is done exclusively with the following three '
+ 'methods.\n'
+ ' A call like\n'
+ '\n'
+ ' a[1:2] = b\n'
+ '\n'
+ ' is translated to\n'
+ '\n'
+ ' a[slice(1, 2, None)] = b\n'
+ '\n'
+ ' and so forth. Missing slice items are always filled in '
+ 'with "None".\n'
+ '\n'
+ 'object.__getitem__(self, key)\n'
+ '\n'
+ ' Called to implement evaluation of "self[key]". For '
+ 'sequence types,\n'
+ ' the accepted keys should be integers and slice objects. '
+ 'Note that\n'
+ ' the special interpretation of negative indexes (if the '
+ 'class wishes\n'
+ ' to emulate a sequence type) is up to the "__getitem__()" '
+ 'method. If\n'
+ ' *key* is of an inappropriate type, "TypeError" may be '
+ 'raised; if of\n'
+ ' a value outside the set of indexes for the sequence '
+ '(after any\n'
+ ' special interpretation of negative values), "IndexError" '
+ 'should be\n'
+ ' raised. For mapping types, if *key* is missing (not in '
+ 'the\n'
+ ' container), "KeyError" should be raised.\n'
+ '\n'
+ ' Note: "for" loops expect that an "IndexError" will be '
+ 'raised for\n'
+ ' illegal indexes to allow proper detection of the end of '
+ 'the\n'
+ ' sequence.\n'
+ '\n'
+ 'object.__missing__(self, key)\n'
+ '\n'
+ ' Called by "dict"."__getitem__()" to implement "self[key]" '
+ 'for dict\n'
+ ' subclasses when key is not in the dictionary.\n'
+ '\n'
+ 'object.__setitem__(self, key, value)\n'
+ '\n'
+ ' Called to implement assignment to "self[key]". Same note '
+ 'as for\n'
+ ' "__getitem__()". This should only be implemented for '
+ 'mappings if\n'
+ ' the objects support changes to the values for keys, or if '
+ 'new keys\n'
+ ' can be added, or for sequences if elements can be '
+ 'replaced. The\n'
+ ' same exceptions should be raised for improper *key* '
+ 'values as for\n'
+ ' the "__getitem__()" method.\n'
+ '\n'
+ 'object.__delitem__(self, key)\n'
+ '\n'
+ ' Called to implement deletion of "self[key]". Same note '
+ 'as for\n'
+ ' "__getitem__()". This should only be implemented for '
+ 'mappings if\n'
+ ' the objects support removal of keys, or for sequences if '
+ 'elements\n'
+ ' can be removed from the sequence. The same exceptions '
+ 'should be\n'
+ ' raised for improper *key* values as for the '
+ '"__getitem__()" method.\n'
+ '\n'
+ 'object.__iter__(self)\n'
+ '\n'
+ ' This method is called when an iterator is required for a '
+ 'container.\n'
+ ' This method should return a new iterator object that can '
+ 'iterate\n'
+ ' over all the objects in the container. For mappings, it '
+ 'should\n'
+ ' iterate over the keys of the container.\n'
+ '\n'
+ ' Iterator objects also need to implement this method; they '
+ 'are\n'
+ ' required to return themselves. For more information on '
+ 'iterator\n'
+ ' objects, see Iterator Types.\n'
+ '\n'
+ 'object.__reversed__(self)\n'
+ '\n'
+ ' Called (if present) by the "reversed()" built-in to '
+ 'implement\n'
+ ' reverse iteration. It should return a new iterator '
+ 'object that\n'
+ ' iterates over all the objects in the container in reverse '
+ 'order.\n'
+ '\n'
+ ' If the "__reversed__()" method is not provided, the '
+ '"reversed()"\n'
+ ' built-in will fall back to using the sequence protocol '
+ '("__len__()"\n'
+ ' and "__getitem__()"). Objects that support the sequence '
+ 'protocol\n'
+ ' should only provide "__reversed__()" if they can provide '
+ 'an\n'
+ ' implementation that is more efficient than the one '
+ 'provided by\n'
+ ' "reversed()".\n'
+ '\n'
+ 'The membership test operators ("in" and "not in") are '
+ 'normally\n'
+ 'implemented as an iteration through a sequence. However, '
+ 'container\n'
+ 'objects can supply the following special method with a more '
+ 'efficient\n'
+ 'implementation, which also does not require the object be a '
+ 'sequence.\n'
+ '\n'
+ 'object.__contains__(self, item)\n'
+ '\n'
+ ' Called to implement membership test operators. Should '
+ 'return true\n'
+ ' if *item* is in *self*, false otherwise. For mapping '
+ 'objects, this\n'
+ ' should consider the keys of the mapping rather than the '
+ 'values or\n'
+ ' the key-item pairs.\n'
+ '\n'
+ ' For objects that don\'t define "__contains__()", the '
+ 'membership test\n'
+ ' first tries iteration via "__iter__()", then the old '
+ 'sequence\n'
+ ' iteration protocol via "__getitem__()", see this section '
+ 'in the\n'
+ ' language reference.\n'
+ '\n'
+ '\n'
+ 'Emulating numeric types\n'
+ '=======================\n'
+ '\n'
+ 'The following methods can be defined to emulate numeric '
+ 'objects.\n'
+ 'Methods corresponding to operations that are not supported '
+ 'by the\n'
+ 'particular kind of number implemented (e.g., bitwise '
+ 'operations for\n'
+ 'non-integral numbers) should be left undefined.\n'
+ '\n'
+ 'object.__add__(self, other)\n'
+ 'object.__sub__(self, other)\n'
+ 'object.__mul__(self, other)\n'
+ 'object.__matmul__(self, other)\n'
+ 'object.__truediv__(self, other)\n'
+ 'object.__floordiv__(self, other)\n'
+ 'object.__mod__(self, other)\n'
+ 'object.__divmod__(self, other)\n'
+ 'object.__pow__(self, other[, modulo])\n'
+ 'object.__lshift__(self, other)\n'
+ 'object.__rshift__(self, other)\n'
+ 'object.__and__(self, other)\n'
+ 'object.__xor__(self, other)\n'
+ 'object.__or__(self, other)\n'
+ '\n'
+ ' These methods are called to implement the binary '
+ 'arithmetic\n'
+ ' operations ("+", "-", "*", "@", "/", "//", "%", '
+ '"divmod()",\n'
+ ' "pow()", "**", "<<", ">>", "&", "^", "|"). For instance, '
+ 'to\n'
+ ' evaluate the expression "x + y", where *x* is an instance '
+ 'of a\n'
+ ' class that has an "__add__()" method, "x.__add__(y)" is '
+ 'called.\n'
+ ' The "__divmod__()" method should be the equivalent to '
+ 'using\n'
+ ' "__floordiv__()" and "__mod__()"; it should not be '
+ 'related to\n'
+ ' "__truediv__()". Note that "__pow__()" should be defined '
+ 'to accept\n'
+ ' an optional third argument if the ternary version of the '
+ 'built-in\n'
+ ' "pow()" function is to be supported.\n'
+ '\n'
+ ' If one of those methods does not support the operation '
+ 'with the\n'
+ ' supplied arguments, it should return "NotImplemented".\n'
+ '\n'
+ 'object.__radd__(self, other)\n'
+ 'object.__rsub__(self, other)\n'
+ 'object.__rmul__(self, other)\n'
+ 'object.__rmatmul__(self, other)\n'
+ 'object.__rtruediv__(self, other)\n'
+ 'object.__rfloordiv__(self, other)\n'
+ 'object.__rmod__(self, other)\n'
+ 'object.__rdivmod__(self, other)\n'
+ 'object.__rpow__(self, other)\n'
+ 'object.__rlshift__(self, other)\n'
+ 'object.__rrshift__(self, other)\n'
+ 'object.__rand__(self, other)\n'
+ 'object.__rxor__(self, other)\n'
+ 'object.__ror__(self, other)\n'
+ '\n'
+ ' These methods are called to implement the binary '
+ 'arithmetic\n'
+ ' operations ("+", "-", "*", "@", "/", "//", "%", '
+ '"divmod()",\n'
+ ' "pow()", "**", "<<", ">>", "&", "^", "|") with reflected '
+ '(swapped)\n'
+ ' operands. These functions are only called if the left '
+ 'operand does\n'
+ ' not support the corresponding operation and the operands '
+ 'are of\n'
+ ' different types. [2] For instance, to evaluate the '
+ 'expression "x -\n'
+ ' y", where *y* is an instance of a class that has an '
+ '"__rsub__()"\n'
+ ' method, "y.__rsub__(x)" is called if "x.__sub__(y)" '
+ 'returns\n'
+ ' *NotImplemented*.\n'
+ '\n'
+ ' Note that ternary "pow()" will not try calling '
+ '"__rpow__()" (the\n'
+ ' coercion rules would become too complicated).\n'
+ '\n'
+ " Note: If the right operand's type is a subclass of the "
+ 'left\n'
+ " operand's type and that subclass provides the reflected "
+ 'method\n'
+ ' for the operation, this method will be called before '
+ 'the left\n'
+ " operand's non-reflected method. This behavior allows "
+ 'subclasses\n'
+ " to override their ancestors' operations.\n"
+ '\n'
+ 'object.__iadd__(self, other)\n'
+ 'object.__isub__(self, other)\n'
+ 'object.__imul__(self, other)\n'
+ 'object.__imatmul__(self, other)\n'
+ 'object.__itruediv__(self, other)\n'
+ 'object.__ifloordiv__(self, other)\n'
+ 'object.__imod__(self, other)\n'
+ 'object.__ipow__(self, other[, modulo])\n'
+ 'object.__ilshift__(self, other)\n'
+ 'object.__irshift__(self, other)\n'
+ 'object.__iand__(self, other)\n'
+ 'object.__ixor__(self, other)\n'
+ 'object.__ior__(self, other)\n'
+ '\n'
+ ' These methods are called to implement the augmented '
+ 'arithmetic\n'
+ ' assignments ("+=", "-=", "*=", "@=", "/=", "//=", "%=", '
+ '"**=",\n'
+ ' "<<=", ">>=", "&=", "^=", "|="). These methods should '
+ 'attempt to\n'
+ ' do the operation in-place (modifying *self*) and return '
+ 'the result\n'
+ ' (which could be, but does not have to be, *self*). If a '
+ 'specific\n'
+ ' method is not defined, the augmented assignment falls '
+ 'back to the\n'
+ ' normal methods. For instance, if *x* is an instance of a '
+ 'class\n'
+ ' with an "__iadd__()" method, "x += y" is equivalent to "x '
+ '=\n'
+ ' x.__iadd__(y)" . Otherwise, "x.__add__(y)" and '
+ '"y.__radd__(x)" are\n'
+ ' considered, as with the evaluation of "x + y". In '
+ 'certain\n'
+ ' situations, augmented assignment can result in unexpected '
+ 'errors\n'
+ " (see Why does a_tuple[i] += ['item'] raise an exception "
+ 'when the\n'
+ ' addition works?), but this behavior is in fact part of '
+ 'the data\n'
+ ' model.\n'
+ '\n'
+ 'object.__neg__(self)\n'
+ 'object.__pos__(self)\n'
+ 'object.__abs__(self)\n'
+ 'object.__invert__(self)\n'
+ '\n'
+ ' Called to implement the unary arithmetic operations ("-", '
+ '"+",\n'
+ ' "abs()" and "~").\n'
+ '\n'
+ 'object.__complex__(self)\n'
+ 'object.__int__(self)\n'
+ 'object.__float__(self)\n'
+ 'object.__round__(self[, n])\n'
+ '\n'
+ ' Called to implement the built-in functions "complex()", '
+ '"int()",\n'
+ ' "float()" and "round()". Should return a value of the '
+ 'appropriate\n'
+ ' type.\n'
+ '\n'
+ 'object.__index__(self)\n'
+ '\n'
+ ' Called to implement "operator.index()", and whenever '
+ 'Python needs\n'
+ ' to losslessly convert the numeric object to an integer '
+ 'object (such\n'
+ ' as in slicing, or in the built-in "bin()", "hex()" and '
+ '"oct()"\n'
+ ' functions). Presence of this method indicates that the '
+ 'numeric\n'
+ ' object is an integer type. Must return an integer.\n'
+ '\n'
+ ' Note: In order to have a coherent integer type class, '
+ 'when\n'
+ ' "__index__()" is defined "__int__()" should also be '
+ 'defined, and\n'
+ ' both should return the same value.\n'
+ '\n'
+ '\n'
+ 'With Statement Context Managers\n'
+ '===============================\n'
+ '\n'
+ 'A *context manager* is an object that defines the runtime '
+ 'context to\n'
+ 'be established when executing a "with" statement. The '
+ 'context manager\n'
+ 'handles the entry into, and the exit from, the desired '
+ 'runtime context\n'
+ 'for the execution of the block of code. Context managers '
+ 'are normally\n'
+ 'invoked using the "with" statement (described in section The '
+ 'with\n'
+ 'statement), but can also be used by directly invoking their '
+ 'methods.\n'
+ '\n'
+ 'Typical uses of context managers include saving and '
+ 'restoring various\n'
+ 'kinds of global state, locking and unlocking resources, '
+ 'closing opened\n'
+ 'files, etc.\n'
+ '\n'
+ 'For more information on context managers, see Context '
+ 'Manager Types.\n'
+ '\n'
+ 'object.__enter__(self)\n'
+ '\n'
+ ' Enter the runtime context related to this object. The '
+ '"with"\n'
+ " statement will bind this method's return value to the "
+ 'target(s)\n'
+ ' specified in the "as" clause of the statement, if any.\n'
+ '\n'
+ 'object.__exit__(self, exc_type, exc_value, traceback)\n'
+ '\n'
+ ' Exit the runtime context related to this object. The '
+ 'parameters\n'
+ ' describe the exception that caused the context to be '
+ 'exited. If the\n'
+ ' context was exited without an exception, all three '
+ 'arguments will\n'
+ ' be "None".\n'
+ '\n'
+ ' If an exception is supplied, and the method wishes to '
+ 'suppress the\n'
+ ' exception (i.e., prevent it from being propagated), it '
+ 'should\n'
+ ' return a true value. Otherwise, the exception will be '
+ 'processed\n'
+ ' normally upon exit from this method.\n'
+ '\n'
+ ' Note that "__exit__()" methods should not reraise the '
+ 'passed-in\n'
+ " exception; this is the caller's responsibility.\n"
+ '\n'
+ 'See also:\n'
+ '\n'
+ ' **PEP 343** - The "with" statement\n'
+ ' The specification, background, and examples for the '
+ 'Python "with"\n'
+ ' statement.\n'
+ '\n'
+ '\n'
+ 'Special method lookup\n'
+ '=====================\n'
+ '\n'
+ 'For custom classes, implicit invocations of special methods '
+ 'are only\n'
+ "guaranteed to work correctly if defined on an object's type, "
+ 'not in\n'
+ "the object's instance dictionary. That behaviour is the "
+ 'reason why\n'
+ 'the following code raises an exception:\n'
+ '\n'
+ ' >>> class C:\n'
+ ' ... pass\n'
+ ' ...\n'
+ ' >>> c = C()\n'
+ ' >>> c.__len__ = lambda: 5\n'
+ ' >>> len(c)\n'
+ ' Traceback (most recent call last):\n'
+ ' File "<stdin>", line 1, in <module>\n'
+ " TypeError: object of type 'C' has no len()\n"
+ '\n'
+ 'The rationale behind this behaviour lies with a number of '
+ 'special\n'
+ 'methods such as "__hash__()" and "__repr__()" that are '
+ 'implemented by\n'
+ 'all objects, including type objects. If the implicit lookup '
+ 'of these\n'
+ 'methods used the conventional lookup process, they would '
+ 'fail when\n'
+ 'invoked on the type object itself:\n'
+ '\n'
+ ' >>> 1 .__hash__() == hash(1)\n'
+ ' True\n'
+ ' >>> int.__hash__() == hash(int)\n'
+ ' Traceback (most recent call last):\n'
+ ' File "<stdin>", line 1, in <module>\n'
+ " TypeError: descriptor '__hash__' of 'int' object needs an "
+ 'argument\n'
+ '\n'
+ 'Incorrectly attempting to invoke an unbound method of a '
+ 'class in this\n'
+ "way is sometimes referred to as 'metaclass confusion', and "
+ 'is avoided\n'
+ 'by bypassing the instance when looking up special methods:\n'
+ '\n'
+ ' >>> type(1).__hash__(1) == hash(1)\n'
+ ' True\n'
+ ' >>> type(int).__hash__(int) == hash(int)\n'
+ ' True\n'
+ '\n'
+ 'In addition to bypassing any instance attributes in the '
+ 'interest of\n'
+ 'correctness, implicit special method lookup generally also '
+ 'bypasses\n'
+ 'the "__getattribute__()" method even of the object\'s '
+ 'metaclass:\n'
+ '\n'
+ ' >>> class Meta(type):\n'
+ ' ... def __getattribute__(*args):\n'
+ ' ... print("Metaclass getattribute invoked")\n'
+ ' ... return type.__getattribute__(*args)\n'
+ ' ...\n'
+ ' >>> class C(object, metaclass=Meta):\n'
+ ' ... def __len__(self):\n'
+ ' ... return 10\n'
+ ' ... def __getattribute__(*args):\n'
+ ' ... print("Class getattribute invoked")\n'
+ ' ... return object.__getattribute__(*args)\n'
+ ' ...\n'
+ ' >>> c = C()\n'
+ ' >>> c.__len__() # Explicit lookup via '
+ 'instance\n'
+ ' Class getattribute invoked\n'
+ ' 10\n'
+ ' >>> type(c).__len__(c) # Explicit lookup via '
+ 'type\n'
+ ' Metaclass getattribute invoked\n'
+ ' 10\n'
+ ' >>> len(c) # Implicit lookup\n'
+ ' 10\n'
+ '\n'
+ 'Bypassing the "__getattribute__()" machinery in this fashion '
+ 'provides\n'
+ 'significant scope for speed optimisations within the '
+ 'interpreter, at\n'
+ 'the cost of some flexibility in the handling of special '
+ 'methods (the\n'
+ 'special method *must* be set on the class object itself in '
+ 'order to be\n'
+ 'consistently invoked by the interpreter).\n',
+ 'string-methods': '\n'
+ 'String Methods\n'
+ '**************\n'
+ '\n'
+ 'Strings implement all of the common sequence operations, '
+ 'along with\n'
+ 'the additional methods described below.\n'
+ '\n'
+ 'Strings also support two styles of string formatting, one '
+ 'providing a\n'
+ 'large degree of flexibility and customization (see '
+ '"str.format()",\n'
+ 'Format String Syntax and Custom String Formatting) and the '
+ 'other based\n'
+ 'on C "printf" style formatting that handles a narrower '
+ 'range of types\n'
+ 'and is slightly harder to use correctly, but is often '
+ 'faster for the\n'
+ 'cases it can handle (printf-style String Formatting).\n'
+ '\n'
+ 'The Text Processing Services section of the standard '
+ 'library covers a\n'
+ 'number of other modules that provide various text related '
+ 'utilities\n'
+ '(including regular expression support in the "re" '
+ 'module).\n'
+ '\n'
+ 'str.capitalize()\n'
+ '\n'
+ ' Return a copy of the string with its first character '
+ 'capitalized\n'
+ ' and the rest lowercased.\n'
+ '\n'
+ 'str.casefold()\n'
+ '\n'
+ ' Return a casefolded copy of the string. Casefolded '
+ 'strings may be\n'
+ ' used for caseless matching.\n'
+ '\n'
+ ' Casefolding is similar to lowercasing but more '
+ 'aggressive because\n'
+ ' it is intended to remove all case distinctions in a '
+ 'string. For\n'
+ ' example, the German lowercase letter "\'ß\'" is '
+ 'equivalent to ""ss"".\n'
+ ' Since it is already lowercase, "lower()" would do '
+ 'nothing to "\'ß\'";\n'
+ ' "casefold()" converts it to ""ss"".\n'
+ '\n'
+ ' The casefolding algorithm is described in section 3.13 '
+ 'of the\n'
+ ' Unicode Standard.\n'
+ '\n'
+ ' New in version 3.3.\n'
+ '\n'
+ 'str.center(width[, fillchar])\n'
+ '\n'
+ ' Return centered in a string of length *width*. Padding '
+ 'is done\n'
+ ' using the specified *fillchar* (default is an ASCII '
+ 'space). The\n'
+ ' original string is returned if *width* is less than or '
+ 'equal to\n'
+ ' "len(s)".\n'
+ '\n'
+ 'str.count(sub[, start[, end]])\n'
+ '\n'
+ ' Return the number of non-overlapping occurrences of '
+ 'substring *sub*\n'
+ ' in the range [*start*, *end*]. Optional arguments '
+ '*start* and\n'
+ ' *end* are interpreted as in slice notation.\n'
+ '\n'
+ 'str.encode(encoding="utf-8", errors="strict")\n'
+ '\n'
+ ' Return an encoded version of the string as a bytes '
+ 'object. Default\n'
+ ' encoding is "\'utf-8\'". *errors* may be given to set a '
+ 'different\n'
+ ' error handling scheme. The default for *errors* is '
+ '"\'strict\'",\n'
+ ' meaning that encoding errors raise a "UnicodeError". '
+ 'Other possible\n'
+ ' values are "\'ignore\'", "\'replace\'", '
+ '"\'xmlcharrefreplace\'",\n'
+ ' "\'backslashreplace\'" and any other name registered '
+ 'via\n'
+ ' "codecs.register_error()", see section Error Handlers. '
+ 'For a list\n'
+ ' of possible encodings, see section Standard Encodings.\n'
+ '\n'
+ ' Changed in version 3.1: Support for keyword arguments '
+ 'added.\n'
+ '\n'
+ 'str.endswith(suffix[, start[, end]])\n'
+ '\n'
+ ' Return "True" if the string ends with the specified '
+ '*suffix*,\n'
+ ' otherwise return "False". *suffix* can also be a tuple '
+ 'of suffixes\n'
+ ' to look for. With optional *start*, test beginning at '
+ 'that\n'
+ ' position. With optional *end*, stop comparing at that '
+ 'position.\n'
+ '\n'
+ 'str.expandtabs(tabsize=8)\n'
+ '\n'
+ ' Return a copy of the string where all tab characters '
+ 'are replaced\n'
+ ' by one or more spaces, depending on the current column '
+ 'and the\n'
+ ' given tab size. Tab positions occur every *tabsize* '
+ 'characters\n'
+ ' (default is 8, giving tab positions at columns 0, 8, 16 '
+ 'and so on).\n'
+ ' To expand the string, the current column is set to zero '
+ 'and the\n'
+ ' string is examined character by character. If the '
+ 'character is a\n'
+ ' tab ("\\t"), one or more space characters are inserted '
+ 'in the result\n'
+ ' until the current column is equal to the next tab '
+ 'position. (The\n'
+ ' tab character itself is not copied.) If the character '
+ 'is a newline\n'
+ ' ("\\n") or return ("\\r"), it is copied and the current '
+ 'column is\n'
+ ' reset to zero. Any other character is copied unchanged '
+ 'and the\n'
+ ' current column is incremented by one regardless of how '
+ 'the\n'
+ ' character is represented when printed.\n'
+ '\n'
+ " >>> '01\\t012\\t0123\\t01234'.expandtabs()\n"
+ " '01 012 0123 01234'\n"
+ " >>> '01\\t012\\t0123\\t01234'.expandtabs(4)\n"
+ " '01 012 0123 01234'\n"
+ '\n'
+ 'str.find(sub[, start[, end]])\n'
+ '\n'
+ ' Return the lowest index in the string where substring '
+ '*sub* is\n'
+ ' found within the slice "s[start:end]". Optional '
+ 'arguments *start*\n'
+ ' and *end* are interpreted as in slice notation. Return '
+ '"-1" if\n'
+ ' *sub* is not found.\n'
+ '\n'
+ ' Note: The "find()" method should be used only if you '
+ 'need to know\n'
+ ' the position of *sub*. To check if *sub* is a '
+ 'substring or not,\n'
+ ' use the "in" operator:\n'
+ '\n'
+ " >>> 'Py' in 'Python'\n"
+ ' True\n'
+ '\n'
+ 'str.format(*args, **kwargs)\n'
+ '\n'
+ ' Perform a string formatting operation. The string on '
+ 'which this\n'
+ ' method is called can contain literal text or '
+ 'replacement fields\n'
+ ' delimited by braces "{}". Each replacement field '
+ 'contains either\n'
+ ' the numeric index of a positional argument, or the name '
+ 'of a\n'
+ ' keyword argument. Returns a copy of the string where '
+ 'each\n'
+ ' replacement field is replaced with the string value of '
+ 'the\n'
+ ' corresponding argument.\n'
+ '\n'
+ ' >>> "The sum of 1 + 2 is {0}".format(1+2)\n'
+ " 'The sum of 1 + 2 is 3'\n"
+ '\n'
+ ' See Format String Syntax for a description of the '
+ 'various\n'
+ ' formatting options that can be specified in format '
+ 'strings.\n'
+ '\n'
+ 'str.format_map(mapping)\n'
+ '\n'
+ ' Similar to "str.format(**mapping)", except that '
+ '"mapping" is used\n'
+ ' directly and not copied to a "dict". This is useful if '
+ 'for example\n'
+ ' "mapping" is a dict subclass:\n'
+ '\n'
+ ' >>> class Default(dict):\n'
+ ' ... def __missing__(self, key):\n'
+ ' ... return key\n'
+ ' ...\n'
+ " >>> '{name} was born in "
+ "{country}'.format_map(Default(name='Guido'))\n"
+ " 'Guido was born in country'\n"
+ '\n'
+ ' New in version 3.2.\n'
+ '\n'
+ 'str.index(sub[, start[, end]])\n'
+ '\n'
+ ' Like "find()", but raise "ValueError" when the '
+ 'substring is not\n'
+ ' found.\n'
+ '\n'
+ 'str.isalnum()\n'
+ '\n'
+ ' Return true if all characters in the string are '
+ 'alphanumeric and\n'
+ ' there is at least one character, false otherwise. A '
+ 'character "c"\n'
+ ' is alphanumeric if one of the following returns '
+ '"True":\n'
+ ' "c.isalpha()", "c.isdecimal()", "c.isdigit()", or '
+ '"c.isnumeric()".\n'
+ '\n'
+ 'str.isalpha()\n'
+ '\n'
+ ' Return true if all characters in the string are '
+ 'alphabetic and\n'
+ ' there is at least one character, false otherwise. '
+ 'Alphabetic\n'
+ ' characters are those characters defined in the Unicode '
+ 'character\n'
+ ' database as "Letter", i.e., those with general category '
+ 'property\n'
+ ' being one of "Lm", "Lt", "Lu", "Ll", or "Lo". Note '
+ 'that this is\n'
+ ' different from the "Alphabetic" property defined in the '
+ 'Unicode\n'
+ ' Standard.\n'
+ '\n'
+ 'str.isdecimal()\n'
+ '\n'
+ ' Return true if all characters in the string are decimal '
+ 'characters\n'
+ ' and there is at least one character, false otherwise. '
+ 'Decimal\n'
+ ' characters are those from general category "Nd". This '
+ 'category\n'
+ ' includes digit characters, and all characters that can '
+ 'be used to\n'
+ ' form decimal-radix numbers, e.g. U+0660, ARABIC-INDIC '
+ 'DIGIT ZERO.\n'
+ '\n'
+ 'str.isdigit()\n'
+ '\n'
+ ' Return true if all characters in the string are digits '
+ 'and there is\n'
+ ' at least one character, false otherwise. Digits '
+ 'include decimal\n'
+ ' characters and digits that need special handling, such '
+ 'as the\n'
+ ' compatibility superscript digits. Formally, a digit is '
+ 'a character\n'
+ ' that has the property value Numeric_Type=Digit or\n'
+ ' Numeric_Type=Decimal.\n'
+ '\n'
+ 'str.isidentifier()\n'
+ '\n'
+ ' Return true if the string is a valid identifier '
+ 'according to the\n'
+ ' language definition, section Identifiers and keywords.\n'
+ '\n'
+ ' Use "keyword.iskeyword()" to test for reserved '
+ 'identifiers such as\n'
+ ' "def" and "class".\n'
+ '\n'
+ 'str.islower()\n'
+ '\n'
+ ' Return true if all cased characters [4] in the string '
+ 'are lowercase\n'
+ ' and there is at least one cased character, false '
+ 'otherwise.\n'
+ '\n'
+ 'str.isnumeric()\n'
+ '\n'
+ ' Return true if all characters in the string are numeric '
+ 'characters,\n'
+ ' and there is at least one character, false otherwise. '
+ 'Numeric\n'
+ ' characters include digit characters, and all characters '
+ 'that have\n'
+ ' the Unicode numeric value property, e.g. U+2155, VULGAR '
+ 'FRACTION\n'
+ ' ONE FIFTH. Formally, numeric characters are those with '
+ 'the\n'
+ ' property value Numeric_Type=Digit, Numeric_Type=Decimal '
+ 'or\n'
+ ' Numeric_Type=Numeric.\n'
+ '\n'
+ 'str.isprintable()\n'
+ '\n'
+ ' Return true if all characters in the string are '
+ 'printable or the\n'
+ ' string is empty, false otherwise. Nonprintable '
+ 'characters are\n'
+ ' those characters defined in the Unicode character '
+ 'database as\n'
+ ' "Other" or "Separator", excepting the ASCII space '
+ '(0x20) which is\n'
+ ' considered printable. (Note that printable characters '
+ 'in this\n'
+ ' context are those which should not be escaped when '
+ '"repr()" is\n'
+ ' invoked on a string. It has no bearing on the handling '
+ 'of strings\n'
+ ' written to "sys.stdout" or "sys.stderr".)\n'
+ '\n'
+ 'str.isspace()\n'
+ '\n'
+ ' Return true if there are only whitespace characters in '
+ 'the string\n'
+ ' and there is at least one character, false otherwise. '
+ 'Whitespace\n'
+ ' characters are those characters defined in the Unicode '
+ 'character\n'
+ ' database as "Other" or "Separator" and those with '
+ 'bidirectional\n'
+ ' property being one of "WS", "B", or "S".\n'
+ '\n'
+ 'str.istitle()\n'
+ '\n'
+ ' Return true if the string is a titlecased string and '
+ 'there is at\n'
+ ' least one character, for example uppercase characters '
+ 'may only\n'
+ ' follow uncased characters and lowercase characters only '
+ 'cased ones.\n'
+ ' Return false otherwise.\n'
+ '\n'
+ 'str.isupper()\n'
+ '\n'
+ ' Return true if all cased characters [4] in the string '
+ 'are uppercase\n'
+ ' and there is at least one cased character, false '
+ 'otherwise.\n'
+ '\n'
+ 'str.join(iterable)\n'
+ '\n'
+ ' Return a string which is the concatenation of the '
+ 'strings in the\n'
+ ' *iterable* *iterable*. A "TypeError" will be raised if '
+ 'there are\n'
+ ' any non-string values in *iterable*, including "bytes" '
+ 'objects.\n'
+ ' The separator between elements is the string providing '
+ 'this method.\n'
+ '\n'
+ 'str.ljust(width[, fillchar])\n'
+ '\n'
+ ' Return the string left justified in a string of length '
+ '*width*.\n'
+ ' Padding is done using the specified *fillchar* (default '
+ 'is an ASCII\n'
+ ' space). The original string is returned if *width* is '
+ 'less than or\n'
+ ' equal to "len(s)".\n'
+ '\n'
+ 'str.lower()\n'
+ '\n'
+ ' Return a copy of the string with all the cased '
+ 'characters [4]\n'
+ ' converted to lowercase.\n'
+ '\n'
+ ' The lowercasing algorithm used is described in section '
+ '3.13 of the\n'
+ ' Unicode Standard.\n'
+ '\n'
+ 'str.lstrip([chars])\n'
+ '\n'
+ ' Return a copy of the string with leading characters '
+ 'removed. The\n'
+ ' *chars* argument is a string specifying the set of '
+ 'characters to be\n'
+ ' removed. If omitted or "None", the *chars* argument '
+ 'defaults to\n'
+ ' removing whitespace. The *chars* argument is not a '
+ 'prefix; rather,\n'
+ ' all combinations of its values are stripped:\n'
+ '\n'
+ " >>> ' spacious '.lstrip()\n"
+ " 'spacious '\n"
+ " >>> 'www.example.com'.lstrip('cmowz.')\n"
+ " 'example.com'\n"
+ '\n'
+ 'static str.maketrans(x[, y[, z]])\n'
+ '\n'
+ ' This static method returns a translation table usable '
+ 'for\n'
+ ' "str.translate()".\n'
+ '\n'
+ ' If there is only one argument, it must be a dictionary '
+ 'mapping\n'
+ ' Unicode ordinals (integers) or characters (strings of '
+ 'length 1) to\n'
+ ' Unicode ordinals, strings (of arbitrary lengths) or '
+ 'None.\n'
+ ' Character keys will then be converted to ordinals.\n'
+ '\n'
+ ' If there are two arguments, they must be strings of '
+ 'equal length,\n'
+ ' and in the resulting dictionary, each character in x '
+ 'will be mapped\n'
+ ' to the character at the same position in y. If there '
+ 'is a third\n'
+ ' argument, it must be a string, whose characters will be '
+ 'mapped to\n'
+ ' None in the result.\n'
+ '\n'
+ 'str.partition(sep)\n'
+ '\n'
+ ' Split the string at the first occurrence of *sep*, and '
+ 'return a\n'
+ ' 3-tuple containing the part before the separator, the '
+ 'separator\n'
+ ' itself, and the part after the separator. If the '
+ 'separator is not\n'
+ ' found, return a 3-tuple containing the string itself, '
+ 'followed by\n'
+ ' two empty strings.\n'
+ '\n'
+ 'str.replace(old, new[, count])\n'
+ '\n'
+ ' Return a copy of the string with all occurrences of '
+ 'substring *old*\n'
+ ' replaced by *new*. If the optional argument *count* is '
+ 'given, only\n'
+ ' the first *count* occurrences are replaced.\n'
+ '\n'
+ 'str.rfind(sub[, start[, end]])\n'
+ '\n'
+ ' Return the highest index in the string where substring '
+ '*sub* is\n'
+ ' found, such that *sub* is contained within '
+ '"s[start:end]".\n'
+ ' Optional arguments *start* and *end* are interpreted as '
+ 'in slice\n'
+ ' notation. Return "-1" on failure.\n'
+ '\n'
+ 'str.rindex(sub[, start[, end]])\n'
+ '\n'
+ ' Like "rfind()" but raises "ValueError" when the '
+ 'substring *sub* is\n'
+ ' not found.\n'
+ '\n'
+ 'str.rjust(width[, fillchar])\n'
+ '\n'
+ ' Return the string right justified in a string of length '
+ '*width*.\n'
+ ' Padding is done using the specified *fillchar* (default '
+ 'is an ASCII\n'
+ ' space). The original string is returned if *width* is '
+ 'less than or\n'
+ ' equal to "len(s)".\n'
+ '\n'
+ 'str.rpartition(sep)\n'
+ '\n'
+ ' Split the string at the last occurrence of *sep*, and '
+ 'return a\n'
+ ' 3-tuple containing the part before the separator, the '
+ 'separator\n'
+ ' itself, and the part after the separator. If the '
+ 'separator is not\n'
+ ' found, return a 3-tuple containing two empty strings, '
+ 'followed by\n'
+ ' the string itself.\n'
+ '\n'
+ 'str.rsplit(sep=None, maxsplit=-1)\n'
+ '\n'
+ ' Return a list of the words in the string, using *sep* '
+ 'as the\n'
+ ' delimiter string. If *maxsplit* is given, at most '
+ '*maxsplit* splits\n'
+ ' are done, the *rightmost* ones. If *sep* is not '
+ 'specified or\n'
+ ' "None", any whitespace string is a separator. Except '
+ 'for splitting\n'
+ ' from the right, "rsplit()" behaves like "split()" which '
+ 'is\n'
+ ' described in detail below.\n'
+ '\n'
+ 'str.rstrip([chars])\n'
+ '\n'
+ ' Return a copy of the string with trailing characters '
+ 'removed. The\n'
+ ' *chars* argument is a string specifying the set of '
+ 'characters to be\n'
+ ' removed. If omitted or "None", the *chars* argument '
+ 'defaults to\n'
+ ' removing whitespace. The *chars* argument is not a '
+ 'suffix; rather,\n'
+ ' all combinations of its values are stripped:\n'
+ '\n'
+ " >>> ' spacious '.rstrip()\n"
+ " ' spacious'\n"
+ " >>> 'mississippi'.rstrip('ipz')\n"
+ " 'mississ'\n"
+ '\n'
+ 'str.split(sep=None, maxsplit=-1)\n'
+ '\n'
+ ' Return a list of the words in the string, using *sep* '
+ 'as the\n'
+ ' delimiter string. If *maxsplit* is given, at most '
+ '*maxsplit*\n'
+ ' splits are done (thus, the list will have at most '
+ '"maxsplit+1"\n'
+ ' elements). If *maxsplit* is not specified or "-1", '
+ 'then there is\n'
+ ' no limit on the number of splits (all possible splits '
+ 'are made).\n'
+ '\n'
+ ' If *sep* is given, consecutive delimiters are not '
+ 'grouped together\n'
+ ' and are deemed to delimit empty strings (for example,\n'
+ ' "\'1,,2\'.split(\',\')" returns "[\'1\', \'\', '
+ '\'2\']"). The *sep* argument\n'
+ ' may consist of multiple characters (for example,\n'
+ ' "\'1<>2<>3\'.split(\'<>\')" returns "[\'1\', \'2\', '
+ '\'3\']"). Splitting an\n'
+ ' empty string with a specified separator returns '
+ '"[\'\']".\n'
+ '\n'
+ ' For example:\n'
+ '\n'
+ " >>> '1,2,3'.split(',')\n"
+ " ['1', '2', '3']\n"
+ " >>> '1,2,3'.split(',', maxsplit=1)\n"
+ " ['1', '2,3']\n"
+ " >>> '1,2,,3,'.split(',')\n"
+ " ['1', '2', '', '3', '']\n"
+ '\n'
+ ' If *sep* is not specified or is "None", a different '
+ 'splitting\n'
+ ' algorithm is applied: runs of consecutive whitespace '
+ 'are regarded\n'
+ ' as a single separator, and the result will contain no '
+ 'empty strings\n'
+ ' at the start or end if the string has leading or '
+ 'trailing\n'
+ ' whitespace. Consequently, splitting an empty string or '
+ 'a string\n'
+ ' consisting of just whitespace with a "None" separator '
+ 'returns "[]".\n'
+ '\n'
+ ' For example:\n'
+ '\n'
+ " >>> '1 2 3'.split()\n"
+ " ['1', '2', '3']\n"
+ " >>> '1 2 3'.split(maxsplit=1)\n"
+ " ['1', '2 3']\n"
+ " >>> ' 1 2 3 '.split()\n"
+ " ['1', '2', '3']\n"
+ '\n'
+ 'str.splitlines([keepends])\n'
+ '\n'
+ ' Return a list of the lines in the string, breaking at '
+ 'line\n'
+ ' boundaries. Line breaks are not included in the '
+ 'resulting list\n'
+ ' unless *keepends* is given and true.\n'
+ '\n'
+ ' This method splits on the following line boundaries. '
+ 'In\n'
+ ' particular, the boundaries are a superset of *universal '
+ 'newlines*.\n'
+ '\n'
+ ' '
+ '+-------------------------+-------------------------------+\n'
+ ' | Representation | '
+ 'Description |\n'
+ ' '
+ '+=========================+===============================+\n'
+ ' | "\\n" | Line '
+ 'Feed |\n'
+ ' '
+ '+-------------------------+-------------------------------+\n'
+ ' | "\\r" | Carriage '
+ 'Return |\n'
+ ' '
+ '+-------------------------+-------------------------------+\n'
+ ' | "\\r\\n" | Carriage Return + Line '
+ 'Feed |\n'
+ ' '
+ '+-------------------------+-------------------------------+\n'
+ ' | "\\v" or "\\x0b" | Line '
+ 'Tabulation |\n'
+ ' '
+ '+-------------------------+-------------------------------+\n'
+ ' | "\\f" or "\\x0c" | Form '
+ 'Feed |\n'
+ ' '
+ '+-------------------------+-------------------------------+\n'
+ ' | "\\x1c" | File '
+ 'Separator |\n'
+ ' '
+ '+-------------------------+-------------------------------+\n'
+ ' | "\\x1d" | Group '
+ 'Separator |\n'
+ ' '
+ '+-------------------------+-------------------------------+\n'
+ ' | "\\x1e" | Record '
+ 'Separator |\n'
+ ' '
+ '+-------------------------+-------------------------------+\n'
+ ' | "\\x85" | Next Line (C1 Control '
+ 'Code) |\n'
+ ' '
+ '+-------------------------+-------------------------------+\n'
+ ' | "\\u2028" | Line '
+ 'Separator |\n'
+ ' '
+ '+-------------------------+-------------------------------+\n'
+ ' | "\\u2029" | Paragraph '
+ 'Separator |\n'
+ ' '
+ '+-------------------------+-------------------------------+\n'
+ '\n'
+ ' Changed in version 3.2: "\\v" and "\\f" added to list '
+ 'of line\n'
+ ' boundaries.\n'
+ '\n'
+ ' For example:\n'
+ '\n'
+ " >>> 'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines()\n"
+ " ['ab c', '', 'de fg', 'kl']\n"
+ " >>> 'ab c\\n\\nde "
+ "fg\\rkl\\r\\n'.splitlines(keepends=True)\n"
+ " ['ab c\\n', '\\n', 'de fg\\r', 'kl\\r\\n']\n"
+ '\n'
+ ' Unlike "split()" when a delimiter string *sep* is '
+ 'given, this\n'
+ ' method returns an empty list for the empty string, and '
+ 'a terminal\n'
+ ' line break does not result in an extra line:\n'
+ '\n'
+ ' >>> "".splitlines()\n'
+ ' []\n'
+ ' >>> "One line\\n".splitlines()\n'
+ " ['One line']\n"
+ '\n'
+ ' For comparison, "split(\'\\n\')" gives:\n'
+ '\n'
+ " >>> ''.split('\\n')\n"
+ " ['']\n"
+ " >>> 'Two lines\\n'.split('\\n')\n"
+ " ['Two lines', '']\n"
+ '\n'
+ 'str.startswith(prefix[, start[, end]])\n'
+ '\n'
+ ' Return "True" if string starts with the *prefix*, '
+ 'otherwise return\n'
+ ' "False". *prefix* can also be a tuple of prefixes to '
+ 'look for.\n'
+ ' With optional *start*, test string beginning at that '
+ 'position.\n'
+ ' With optional *end*, stop comparing string at that '
+ 'position.\n'
+ '\n'
+ 'str.strip([chars])\n'
+ '\n'
+ ' Return a copy of the string with the leading and '
+ 'trailing\n'
+ ' characters removed. The *chars* argument is a string '
+ 'specifying the\n'
+ ' set of characters to be removed. If omitted or "None", '
+ 'the *chars*\n'
+ ' argument defaults to removing whitespace. The *chars* '
+ 'argument is\n'
+ ' not a prefix or suffix; rather, all combinations of its '
+ 'values are\n'
+ ' stripped:\n'
+ '\n'
+ " >>> ' spacious '.strip()\n"
+ " 'spacious'\n"
+ " >>> 'www.example.com'.strip('cmowz.')\n"
+ " 'example'\n"
+ '\n'
+ ' The outermost leading and trailing *chars* argument '
+ 'values are\n'
+ ' stripped from the string. Characters are removed from '
+ 'the leading\n'
+ ' end until reaching a string character that is not '
+ 'contained in the\n'
+ ' set of characters in *chars*. A similar action takes '
+ 'place on the\n'
+ ' trailing end. For example:\n'
+ '\n'
+ " >>> comment_string = '#....... Section 3.2.1 Issue "
+ "#32 .......'\n"
+ " >>> comment_string.strip('.#! ')\n"
+ " 'Section 3.2.1 Issue #32'\n"
+ '\n'
+ 'str.swapcase()\n'
+ '\n'
+ ' Return a copy of the string with uppercase characters '
+ 'converted to\n'
+ ' lowercase and vice versa. Note that it is not '
+ 'necessarily true that\n'
+ ' "s.swapcase().swapcase() == s".\n'
+ '\n'
+ 'str.title()\n'
+ '\n'
+ ' Return a titlecased version of the string where words '
+ 'start with an\n'
+ ' uppercase character and the remaining characters are '
+ 'lowercase.\n'
+ '\n'
+ ' For example:\n'
+ '\n'
+ " >>> 'Hello world'.title()\n"
+ " 'Hello World'\n"
+ '\n'
+ ' The algorithm uses a simple language-independent '
+ 'definition of a\n'
+ ' word as groups of consecutive letters. The definition '
+ 'works in\n'
+ ' many contexts but it means that apostrophes in '
+ 'contractions and\n'
+ ' possessives form word boundaries, which may not be the '
+ 'desired\n'
+ ' result:\n'
+ '\n'
+ ' >>> "they\'re bill\'s friends from the UK".title()\n'
+ ' "They\'Re Bill\'S Friends From The Uk"\n'
+ '\n'
+ ' A workaround for apostrophes can be constructed using '
+ 'regular\n'
+ ' expressions:\n'
+ '\n'
+ ' >>> import re\n'
+ ' >>> def titlecase(s):\n'
+ ' ... return re.sub(r"[A-Za-z]+(\'[A-Za-z]+)?",\n'
+ ' ... lambda mo: '
+ 'mo.group(0)[0].upper() +\n'
+ ' ... '
+ 'mo.group(0)[1:].lower(),\n'
+ ' ... s)\n'
+ ' ...\n'
+ ' >>> titlecase("they\'re bill\'s friends.")\n'
+ ' "They\'re Bill\'s Friends."\n'
+ '\n'
+ 'str.translate(table)\n'
+ '\n'
+ ' Return a copy of the string in which each character has '
+ 'been mapped\n'
+ ' through the given translation table. The table must be '
+ 'an object\n'
+ ' that implements indexing via "__getitem__()", typically '
+ 'a *mapping*\n'
+ ' or *sequence*. When indexed by a Unicode ordinal (an '
+ 'integer), the\n'
+ ' table object can do any of the following: return a '
+ 'Unicode ordinal\n'
+ ' or a string, to map the character to one or more other '
+ 'characters;\n'
+ ' return "None", to delete the character from the return '
+ 'string; or\n'
+ ' raise a "LookupError" exception, to map the character '
+ 'to itself.\n'
+ '\n'
+ ' You can use "str.maketrans()" to create a translation '
+ 'map from\n'
+ ' character-to-character mappings in different formats.\n'
+ '\n'
+ ' See also the "codecs" module for a more flexible '
+ 'approach to custom\n'
+ ' character mappings.\n'
+ '\n'
+ 'str.upper()\n'
+ '\n'
+ ' Return a copy of the string with all the cased '
+ 'characters [4]\n'
+ ' converted to uppercase. Note that '
+ '"str.upper().isupper()" might be\n'
+ ' "False" if "s" contains uncased characters or if the '
+ 'Unicode\n'
+ ' category of the resulting character(s) is not "Lu" '
+ '(Letter,\n'
+ ' uppercase), but e.g. "Lt" (Letter, titlecase).\n'
+ '\n'
+ ' The uppercasing algorithm used is described in section '
+ '3.13 of the\n'
+ ' Unicode Standard.\n'
+ '\n'
+ 'str.zfill(width)\n'
+ '\n'
+ ' Return a copy of the string left filled with ASCII '
+ '"\'0\'" digits to\n'
+ ' make a string of length *width*. A leading sign prefix\n'
+ ' ("\'+\'"/"\'-\'") is handled by inserting the padding '
+ '*after* the sign\n'
+ ' character rather than before. The original string is '
+ 'returned if\n'
+ ' *width* is less than or equal to "len(s)".\n'
+ '\n'
+ ' For example:\n'
+ '\n'
+ ' >>> "42".zfill(5)\n'
+ " '00042'\n"
+ ' >>> "-42".zfill(5)\n'
+ " '-0042'\n",
+ 'strings': '\n'
+ 'String and Bytes literals\n'
+ '*************************\n'
+ '\n'
+ 'String literals are described by the following lexical '
+ 'definitions:\n'
+ '\n'
+ ' stringliteral ::= [stringprefix](shortstring | longstring)\n'
+ ' stringprefix ::= "r" | "u" | "R" | "U" | "f" | "F"\n'
+ ' | "fr" | "Fr" | "fR" | "FR" | "rf" | "rF" | '
+ '"Rf" | "RF"\n'
+ ' shortstring ::= "\'" shortstringitem* "\'" | \'"\' '
+ 'shortstringitem* \'"\'\n'
+ ' longstring ::= "\'\'\'" longstringitem* "\'\'\'" | '
+ '\'"""\' longstringitem* \'"""\'\n'
+ ' shortstringitem ::= shortstringchar | stringescapeseq\n'
+ ' longstringitem ::= longstringchar | stringescapeseq\n'
+ ' shortstringchar ::= <any source character except "\\" or '
+ 'newline or the quote>\n'
+ ' longstringchar ::= <any source character except "\\">\n'
+ ' stringescapeseq ::= "\\" <any source character>\n'
+ '\n'
+ ' bytesliteral ::= bytesprefix(shortbytes | longbytes)\n'
+ ' bytesprefix ::= "b" | "B" | "br" | "Br" | "bR" | "BR" | '
+ '"rb" | "rB" | "Rb" | "RB"\n'
+ ' shortbytes ::= "\'" shortbytesitem* "\'" | \'"\' '
+ 'shortbytesitem* \'"\'\n'
+ ' longbytes ::= "\'\'\'" longbytesitem* "\'\'\'" | \'"""\' '
+ 'longbytesitem* \'"""\'\n'
+ ' shortbytesitem ::= shortbyteschar | bytesescapeseq\n'
+ ' longbytesitem ::= longbyteschar | bytesescapeseq\n'
+ ' shortbyteschar ::= <any ASCII character except "\\" or newline '
+ 'or the quote>\n'
+ ' longbyteschar ::= <any ASCII character except "\\">\n'
+ ' bytesescapeseq ::= "\\" <any ASCII character>\n'
+ '\n'
+ 'One syntactic restriction not indicated by these productions is '
+ 'that\n'
+ 'whitespace is not allowed between the "stringprefix" or '
+ '"bytesprefix"\n'
+ 'and the rest of the literal. The source character set is defined '
+ 'by\n'
+ 'the encoding declaration; it is UTF-8 if no encoding declaration '
+ 'is\n'
+ 'given in the source file; see section Encoding declarations.\n'
+ '\n'
+ 'In plain English: Both types of literals can be enclosed in '
+ 'matching\n'
+ 'single quotes ("\'") or double quotes ("""). They can also be '
+ 'enclosed\n'
+ 'in matching groups of three single or double quotes (these are\n'
+ 'generally referred to as *triple-quoted strings*). The '
+ 'backslash\n'
+ '("\\") character is used to escape characters that otherwise have '
+ 'a\n'
+ 'special meaning, such as newline, backslash itself, or the quote\n'
+ 'character.\n'
+ '\n'
+ 'Bytes literals are always prefixed with "\'b\'" or "\'B\'"; they '
+ 'produce\n'
+ 'an instance of the "bytes" type instead of the "str" type. They '
+ 'may\n'
+ 'only contain ASCII characters; bytes with a numeric value of 128 '
+ 'or\n'
+ 'greater must be expressed with escapes.\n'
+ '\n'
+ 'As of Python 3.3 it is possible again to prefix string literals '
+ 'with a\n'
+ '"u" prefix to simplify maintenance of dual 2.x and 3.x '
+ 'codebases.\n'
+ '\n'
+ 'Both string and bytes literals may optionally be prefixed with a\n'
+ 'letter "\'r\'" or "\'R\'"; such strings are called *raw strings* '
+ 'and treat\n'
+ 'backslashes as literal characters. As a result, in string '
+ 'literals,\n'
+ '"\'\\U\'" and "\'\\u\'" escapes in raw strings are not treated '
+ 'specially.\n'
+ "Given that Python 2.x's raw unicode literals behave differently "
+ 'than\n'
+ 'Python 3.x\'s the "\'ur\'" syntax is not supported.\n'
+ '\n'
+ 'New in version 3.3: The "\'rb\'" prefix of raw bytes literals has '
+ 'been\n'
+ 'added as a synonym of "\'br\'".\n'
+ '\n'
+ 'New in version 3.3: Support for the unicode legacy literal\n'
+ '("u\'value\'") was reintroduced to simplify the maintenance of '
+ 'dual\n'
+ 'Python 2.x and 3.x codebases. See **PEP 414** for more '
+ 'information.\n'
+ '\n'
+ 'A string literal with "\'f\'" or "\'F\'" in its prefix is a '
+ '*formatted\n'
+ 'string literal*; see Formatted string literals. The "\'f\'" may '
+ 'be\n'
+ 'combined with "\'r\'", but not with "\'b\'" or "\'u\'", therefore '
+ 'raw\n'
+ 'formatted strings are possible, but formatted bytes literals are '
+ 'not.\n'
+ '\n'
+ 'In triple-quoted literals, unescaped newlines and quotes are '
+ 'allowed\n'
+ '(and are retained), except that three unescaped quotes in a row\n'
+ 'terminate the literal. (A "quote" is the character used to open '
+ 'the\n'
+ 'literal, i.e. either "\'" or """.)\n'
+ '\n'
+ 'Unless an "\'r\'" or "\'R\'" prefix is present, escape sequences '
+ 'in string\n'
+ 'and bytes literals are interpreted according to rules similar to '
+ 'those\n'
+ 'used by Standard C. The recognized escape sequences are:\n'
+ '\n'
+ '+-------------------+-----------------------------------+---------+\n'
+ '| Escape Sequence | Meaning | Notes '
+ '|\n'
+ '+===================+===================================+=========+\n'
+ '| "\\newline" | Backslash and newline ignored '
+ '| |\n'
+ '+-------------------+-----------------------------------+---------+\n'
+ '| "\\\\" | Backslash ("\\") '
+ '| |\n'
+ '+-------------------+-----------------------------------+---------+\n'
+ '| "\\\'" | Single quote ("\'") '
+ '| |\n'
+ '+-------------------+-----------------------------------+---------+\n'
+ '| "\\"" | Double quote (""") '
+ '| |\n'
+ '+-------------------+-----------------------------------+---------+\n'
+ '| "\\a" | ASCII Bell (BEL) '
+ '| |\n'
+ '+-------------------+-----------------------------------+---------+\n'
+ '| "\\b" | ASCII Backspace (BS) '
+ '| |\n'
+ '+-------------------+-----------------------------------+---------+\n'
+ '| "\\f" | ASCII Formfeed (FF) '
+ '| |\n'
+ '+-------------------+-----------------------------------+---------+\n'
+ '| "\\n" | ASCII Linefeed (LF) '
+ '| |\n'
+ '+-------------------+-----------------------------------+---------+\n'
+ '| "\\r" | ASCII Carriage Return (CR) '
+ '| |\n'
+ '+-------------------+-----------------------------------+---------+\n'
+ '| "\\t" | ASCII Horizontal Tab (TAB) '
+ '| |\n'
+ '+-------------------+-----------------------------------+---------+\n'
+ '| "\\v" | ASCII Vertical Tab (VT) '
+ '| |\n'
+ '+-------------------+-----------------------------------+---------+\n'
+ '| "\\ooo" | Character with octal value *ooo* | '
+ '(1,3) |\n'
+ '+-------------------+-----------------------------------+---------+\n'
+ '| "\\xhh" | Character with hex value *hh* | '
+ '(2,3) |\n'
+ '+-------------------+-----------------------------------+---------+\n'
+ '\n'
+ 'Escape sequences only recognized in string literals are:\n'
+ '\n'
+ '+-------------------+-----------------------------------+---------+\n'
+ '| Escape Sequence | Meaning | Notes '
+ '|\n'
+ '+===================+===================================+=========+\n'
+ '| "\\N{name}" | Character named *name* in the | '
+ '(4) |\n'
+ '| | Unicode database | '
+ '|\n'
+ '+-------------------+-----------------------------------+---------+\n'
+ '| "\\uxxxx" | Character with 16-bit hex value | '
+ '(5) |\n'
+ '| | *xxxx* | '
+ '|\n'
+ '+-------------------+-----------------------------------+---------+\n'
+ '| "\\Uxxxxxxxx" | Character with 32-bit hex value | '
+ '(6) |\n'
+ '| | *xxxxxxxx* | '
+ '|\n'
+ '+-------------------+-----------------------------------+---------+\n'
+ '\n'
+ 'Notes:\n'
+ '\n'
+ '1. As in Standard C, up to three octal digits are accepted.\n'
+ '\n'
+ '2. Unlike in Standard C, exactly two hex digits are required.\n'
+ '\n'
+ '3. In a bytes literal, hexadecimal and octal escapes denote the\n'
+ ' byte with the given value. In a string literal, these escapes\n'
+ ' denote a Unicode character with the given value.\n'
+ '\n'
+ '4. Changed in version 3.3: Support for name aliases [1] has been\n'
+ ' added.\n'
+ '\n'
+ '5. Exactly four hex digits are required.\n'
+ '\n'
+ '6. Any Unicode character can be encoded this way. Exactly eight\n'
+ ' hex digits are required.\n'
+ '\n'
+ 'Unlike Standard C, all unrecognized escape sequences are left in '
+ 'the\n'
+ 'string unchanged, i.e., *the backslash is left in the result*. '
+ '(This\n'
+ 'behavior is useful when debugging: if an escape sequence is '
+ 'mistyped,\n'
+ 'the resulting output is more easily recognized as broken.) It is '
+ 'also\n'
+ 'important to note that the escape sequences only recognized in '
+ 'string\n'
+ 'literals fall into the category of unrecognized escapes for '
+ 'bytes\n'
+ 'literals.\n'
+ '\n'
+ 'Even in a raw literal, quotes can be escaped with a backslash, '
+ 'but the\n'
+ 'backslash remains in the result; for example, "r"\\""" is a '
+ 'valid\n'
+ 'string literal consisting of two characters: a backslash and a '
+ 'double\n'
+ 'quote; "r"\\"" is not a valid string literal (even a raw string '
+ 'cannot\n'
+ 'end in an odd number of backslashes). Specifically, *a raw '
+ 'literal\n'
+ 'cannot end in a single backslash* (since the backslash would '
+ 'escape\n'
+ 'the following quote character). Note also that a single '
+ 'backslash\n'
+ 'followed by a newline is interpreted as those two characters as '
+ 'part\n'
+ 'of the literal, *not* as a line continuation.\n',
+ 'subscriptions': '\n'
+ 'Subscriptions\n'
+ '*************\n'
+ '\n'
+ 'A subscription selects an item of a sequence (string, tuple '
+ 'or list)\n'
+ 'or mapping (dictionary) object:\n'
+ '\n'
+ ' subscription ::= primary "[" expression_list "]"\n'
+ '\n'
+ 'The primary must evaluate to an object that supports '
+ 'subscription\n'
+ '(lists or dictionaries for example). User-defined objects '
+ 'can support\n'
+ 'subscription by defining a "__getitem__()" method.\n'
+ '\n'
+ 'For built-in objects, there are two types of objects that '
+ 'support\n'
+ 'subscription:\n'
+ '\n'
+ 'If the primary is a mapping, the expression list must '
+ 'evaluate to an\n'
+ 'object whose value is one of the keys of the mapping, and '
+ 'the\n'
+ 'subscription selects the value in the mapping that '
+ 'corresponds to that\n'
+ 'key. (The expression list is a tuple except if it has '
+ 'exactly one\n'
+ 'item.)\n'
+ '\n'
+ 'If the primary is a sequence, the expression (list) must '
+ 'evaluate to\n'
+ 'an integer or a slice (as discussed in the following '
+ 'section).\n'
+ '\n'
+ 'The formal syntax makes no special provision for negative '
+ 'indices in\n'
+ 'sequences; however, built-in sequences all provide a '
+ '"__getitem__()"\n'
+ 'method that interprets negative indices by adding the '
+ 'length of the\n'
+ 'sequence to the index (so that "x[-1]" selects the last '
+ 'item of "x").\n'
+ 'The resulting value must be a nonnegative integer less than '
+ 'the number\n'
+ 'of items in the sequence, and the subscription selects the '
+ 'item whose\n'
+ 'index is that value (counting from zero). Since the support '
+ 'for\n'
+ "negative indices and slicing occurs in the object's "
+ '"__getitem__()"\n'
+ 'method, subclasses overriding this method will need to '
+ 'explicitly add\n'
+ 'that support.\n'
+ '\n'
+ "A string's items are characters. A character is not a "
+ 'separate data\n'
+ 'type but a string of exactly one character.\n',
+ 'truth': '\n'
+ 'Truth Value Testing\n'
+ '*******************\n'
+ '\n'
+ 'Any object can be tested for truth value, for use in an "if" or\n'
+ '"while" condition or as operand of the Boolean operations below. '
+ 'The\n'
+ 'following values are considered false:\n'
+ '\n'
+ '* "None"\n'
+ '\n'
+ '* "False"\n'
+ '\n'
+ '* zero of any numeric type, for example, "0", "0.0", "0j".\n'
+ '\n'
+ '* any empty sequence, for example, "\'\'", "()", "[]".\n'
+ '\n'
+ '* any empty mapping, for example, "{}".\n'
+ '\n'
+ '* instances of user-defined classes, if the class defines a\n'
+ ' "__bool__()" or "__len__()" method, when that method returns the\n'
+ ' integer zero or "bool" value "False". [1]\n'
+ '\n'
+ 'All other values are considered true --- so objects of many types '
+ 'are\n'
+ 'always true.\n'
+ '\n'
+ 'Operations and built-in functions that have a Boolean result '
+ 'always\n'
+ 'return "0" or "False" for false and "1" or "True" for true, unless\n'
+ 'otherwise stated. (Important exception: the Boolean operations '
+ '"or"\n'
+ 'and "and" always return one of their operands.)\n',
+ 'try': '\n'
+ 'The "try" statement\n'
+ '*******************\n'
+ '\n'
+ 'The "try" statement specifies exception handlers and/or cleanup code\n'
+ 'for a group of statements:\n'
+ '\n'
+ ' try_stmt ::= try1_stmt | try2_stmt\n'
+ ' try1_stmt ::= "try" ":" suite\n'
+ ' ("except" [expression ["as" identifier]] ":" '
+ 'suite)+\n'
+ ' ["else" ":" suite]\n'
+ ' ["finally" ":" suite]\n'
+ ' try2_stmt ::= "try" ":" suite\n'
+ ' "finally" ":" suite\n'
+ '\n'
+ 'The "except" clause(s) specify one or more exception handlers. When '
+ 'no\n'
+ 'exception occurs in the "try" clause, no exception handler is\n'
+ 'executed. When an exception occurs in the "try" suite, a search for '
+ 'an\n'
+ 'exception handler is started. This search inspects the except '
+ 'clauses\n'
+ 'in turn until one is found that matches the exception. An '
+ 'expression-\n'
+ 'less except clause, if present, must be last; it matches any\n'
+ 'exception. For an except clause with an expression, that expression\n'
+ 'is evaluated, and the clause matches the exception if the resulting\n'
+ 'object is "compatible" with the exception. An object is compatible\n'
+ 'with an exception if it is the class or a base class of the '
+ 'exception\n'
+ 'object or a tuple containing an item compatible with the exception.\n'
+ '\n'
+ 'If no except clause matches the exception, the search for an '
+ 'exception\n'
+ 'handler continues in the surrounding code and on the invocation '
+ 'stack.\n'
+ '[1]\n'
+ '\n'
+ 'If the evaluation of an expression in the header of an except clause\n'
+ 'raises an exception, the original search for a handler is canceled '
+ 'and\n'
+ 'a search starts for the new exception in the surrounding code and on\n'
+ 'the call stack (it is treated as if the entire "try" statement '
+ 'raised\n'
+ 'the exception).\n'
+ '\n'
+ 'When a matching except clause is found, the exception is assigned to\n'
+ 'the target specified after the "as" keyword in that except clause, '
+ 'if\n'
+ "present, and the except clause's suite is executed. All except\n"
+ 'clauses must have an executable block. When the end of this block '
+ 'is\n'
+ 'reached, execution continues normally after the entire try '
+ 'statement.\n'
+ '(This means that if two nested handlers exist for the same '
+ 'exception,\n'
+ 'and the exception occurs in the try clause of the inner handler, the\n'
+ 'outer handler will not handle the exception.)\n'
+ '\n'
+ 'When an exception has been assigned using "as target", it is cleared\n'
+ 'at the end of the except clause. This is as if\n'
+ '\n'
+ ' except E as N:\n'
+ ' foo\n'
+ '\n'
+ 'was translated to\n'
+ '\n'
+ ' except E as N:\n'
+ ' try:\n'
+ ' foo\n'
+ ' finally:\n'
+ ' del N\n'
+ '\n'
+ 'This means the exception must be assigned to a different name to be\n'
+ 'able to refer to it after the except clause. Exceptions are cleared\n'
+ 'because with the traceback attached to them, they form a reference\n'
+ 'cycle with the stack frame, keeping all locals in that frame alive\n'
+ 'until the next garbage collection occurs.\n'
+ '\n'
+ "Before an except clause's suite is executed, details about the\n"
+ 'exception are stored in the "sys" module and can be accessed via\n'
+ '"sys.exc_info()". "sys.exc_info()" returns a 3-tuple consisting of '
+ 'the\n'
+ 'exception class, the exception instance and a traceback object (see\n'
+ 'section The standard type hierarchy) identifying the point in the\n'
+ 'program where the exception occurred. "sys.exc_info()" values are\n'
+ 'restored to their previous values (before the call) when returning\n'
+ 'from a function that handled an exception.\n'
+ '\n'
+ 'The optional "else" clause is executed if and when control flows off\n'
+ 'the end of the "try" clause. [2] Exceptions in the "else" clause are\n'
+ 'not handled by the preceding "except" clauses.\n'
+ '\n'
+ 'If "finally" is present, it specifies a \'cleanup\' handler. The '
+ '"try"\n'
+ 'clause is executed, including any "except" and "else" clauses. If '
+ 'an\n'
+ 'exception occurs in any of the clauses and is not handled, the\n'
+ 'exception is temporarily saved. The "finally" clause is executed. '
+ 'If\n'
+ 'there is a saved exception it is re-raised at the end of the '
+ '"finally"\n'
+ 'clause. If the "finally" clause raises another exception, the saved\n'
+ 'exception is set as the context of the new exception. If the '
+ '"finally"\n'
+ 'clause executes a "return" or "break" statement, the saved exception\n'
+ 'is discarded:\n'
+ '\n'
+ ' >>> def f():\n'
+ ' ... try:\n'
+ ' ... 1/0\n'
+ ' ... finally:\n'
+ ' ... return 42\n'
+ ' ...\n'
+ ' >>> f()\n'
+ ' 42\n'
+ '\n'
+ 'The exception information is not available to the program during\n'
+ 'execution of the "finally" clause.\n'
+ '\n'
+ 'When a "return", "break" or "continue" statement is executed in the\n'
+ '"try" suite of a "try"..."finally" statement, the "finally" clause '
+ 'is\n'
+ 'also executed \'on the way out.\' A "continue" statement is illegal '
+ 'in\n'
+ 'the "finally" clause. (The reason is a problem with the current\n'
+ 'implementation --- this restriction may be lifted in the future).\n'
+ '\n'
+ 'The return value of a function is determined by the last "return"\n'
+ 'statement executed. Since the "finally" clause always executes, a\n'
+ '"return" statement executed in the "finally" clause will always be '
+ 'the\n'
+ 'last one executed:\n'
+ '\n'
+ ' >>> def foo():\n'
+ ' ... try:\n'
+ " ... return 'try'\n"
+ ' ... finally:\n'
+ " ... return 'finally'\n"
+ ' ...\n'
+ ' >>> foo()\n'
+ " 'finally'\n"
+ '\n'
+ 'Additional information on exceptions can be found in section\n'
+ 'Exceptions, and information on using the "raise" statement to '
+ 'generate\n'
+ 'exceptions may be found in section The raise statement.\n',
+ 'types': '\n'
+ 'The standard type hierarchy\n'
+ '***************************\n'
+ '\n'
+ 'Below is a list of the types that are built into Python. '
+ 'Extension\n'
+ 'modules (written in C, Java, or other languages, depending on the\n'
+ 'implementation) can define additional types. Future versions of\n'
+ 'Python may add types to the type hierarchy (e.g., rational '
+ 'numbers,\n'
+ 'efficiently stored arrays of integers, etc.), although such '
+ 'additions\n'
+ 'will often be provided via the standard library instead.\n'
+ '\n'
+ 'Some of the type descriptions below contain a paragraph listing\n'
+ "'special attributes.' These are attributes that provide access to "
+ 'the\n'
+ 'implementation and are not intended for general use. Their '
+ 'definition\n'
+ 'may change in the future.\n'
+ '\n'
+ 'None\n'
+ ' This type has a single value. There is a single object with '
+ 'this\n'
+ ' value. This object is accessed through the built-in name "None". '
+ 'It\n'
+ ' is used to signify the absence of a value in many situations, '
+ 'e.g.,\n'
+ " it is returned from functions that don't explicitly return\n"
+ ' anything. Its truth value is false.\n'
+ '\n'
+ 'NotImplemented\n'
+ ' This type has a single value. There is a single object with '
+ 'this\n'
+ ' value. This object is accessed through the built-in name\n'
+ ' "NotImplemented". Numeric methods and rich comparison methods\n'
+ ' should return this value if they do not implement the operation '
+ 'for\n'
+ ' the operands provided. (The interpreter will then try the\n'
+ ' reflected operation, or some other fallback, depending on the\n'
+ ' operator.) Its truth value is true.\n'
+ '\n'
+ ' See Implementing the arithmetic operations for more details.\n'
+ '\n'
+ 'Ellipsis\n'
+ ' This type has a single value. There is a single object with '
+ 'this\n'
+ ' value. This object is accessed through the literal "..." or the\n'
+ ' built-in name "Ellipsis". Its truth value is true.\n'
+ '\n'
+ '"numbers.Number"\n'
+ ' These are created by numeric literals and returned as results '
+ 'by\n'
+ ' arithmetic operators and arithmetic built-in functions. '
+ 'Numeric\n'
+ ' objects are immutable; once created their value never changes.\n'
+ ' Python numbers are of course strongly related to mathematical\n'
+ ' numbers, but subject to the limitations of numerical '
+ 'representation\n'
+ ' in computers.\n'
+ '\n'
+ ' Python distinguishes between integers, floating point numbers, '
+ 'and\n'
+ ' complex numbers:\n'
+ '\n'
+ ' "numbers.Integral"\n'
+ ' These represent elements from the mathematical set of '
+ 'integers\n'
+ ' (positive and negative).\n'
+ '\n'
+ ' There are two types of integers:\n'
+ '\n'
+ ' Integers ("int")\n'
+ '\n'
+ ' These represent numbers in an unlimited range, subject to\n'
+ ' available (virtual) memory only. For the purpose of '
+ 'shift\n'
+ ' and mask operations, a binary representation is assumed, '
+ 'and\n'
+ " negative numbers are represented in a variant of 2's\n"
+ ' complement which gives the illusion of an infinite string '
+ 'of\n'
+ ' sign bits extending to the left.\n'
+ '\n'
+ ' Booleans ("bool")\n'
+ ' These represent the truth values False and True. The two\n'
+ ' objects representing the values "False" and "True" are '
+ 'the\n'
+ ' only Boolean objects. The Boolean type is a subtype of '
+ 'the\n'
+ ' integer type, and Boolean values behave like the values 0 '
+ 'and\n'
+ ' 1, respectively, in almost all contexts, the exception '
+ 'being\n'
+ ' that when converted to a string, the strings ""False"" or\n'
+ ' ""True"" are returned, respectively.\n'
+ '\n'
+ ' The rules for integer representation are intended to give '
+ 'the\n'
+ ' most meaningful interpretation of shift and mask operations\n'
+ ' involving negative integers.\n'
+ '\n'
+ ' "numbers.Real" ("float")\n'
+ ' These represent machine-level double precision floating '
+ 'point\n'
+ ' numbers. You are at the mercy of the underlying machine\n'
+ ' architecture (and C or Java implementation) for the accepted\n'
+ ' range and handling of overflow. Python does not support '
+ 'single-\n'
+ ' precision floating point numbers; the savings in processor '
+ 'and\n'
+ ' memory usage that are usually the reason for using these are\n'
+ ' dwarfed by the overhead of using objects in Python, so there '
+ 'is\n'
+ ' no reason to complicate the language with two kinds of '
+ 'floating\n'
+ ' point numbers.\n'
+ '\n'
+ ' "numbers.Complex" ("complex")\n'
+ ' These represent complex numbers as a pair of machine-level\n'
+ ' double precision floating point numbers. The same caveats '
+ 'apply\n'
+ ' as for floating point numbers. The real and imaginary parts '
+ 'of a\n'
+ ' complex number "z" can be retrieved through the read-only\n'
+ ' attributes "z.real" and "z.imag".\n'
+ '\n'
+ 'Sequences\n'
+ ' These represent finite ordered sets indexed by non-negative\n'
+ ' numbers. The built-in function "len()" returns the number of '
+ 'items\n'
+ ' of a sequence. When the length of a sequence is *n*, the index '
+ 'set\n'
+ ' contains the numbers 0, 1, ..., *n*-1. Item *i* of sequence *a* '
+ 'is\n'
+ ' selected by "a[i]".\n'
+ '\n'
+ ' Sequences also support slicing: "a[i:j]" selects all items with\n'
+ ' index *k* such that *i* "<=" *k* "<" *j*. When used as an\n'
+ ' expression, a slice is a sequence of the same type. This '
+ 'implies\n'
+ ' that the index set is renumbered so that it starts at 0.\n'
+ '\n'
+ ' Some sequences also support "extended slicing" with a third '
+ '"step"\n'
+ ' parameter: "a[i:j:k]" selects all items of *a* with index *x* '
+ 'where\n'
+ ' "x = i + n*k", *n* ">=" "0" and *i* "<=" *x* "<" *j*.\n'
+ '\n'
+ ' Sequences are distinguished according to their mutability:\n'
+ '\n'
+ ' Immutable sequences\n'
+ ' An object of an immutable sequence type cannot change once it '
+ 'is\n'
+ ' created. (If the object contains references to other '
+ 'objects,\n'
+ ' these other objects may be mutable and may be changed; '
+ 'however,\n'
+ ' the collection of objects directly referenced by an '
+ 'immutable\n'
+ ' object cannot change.)\n'
+ '\n'
+ ' The following types are immutable sequences:\n'
+ '\n'
+ ' Strings\n'
+ ' A string is a sequence of values that represent Unicode '
+ 'code\n'
+ ' points. All the code points in the range "U+0000 - '
+ 'U+10FFFF"\n'
+ " can be represented in a string. Python doesn't have a "
+ '"char"\n'
+ ' type; instead, every code point in the string is '
+ 'represented\n'
+ ' as a string object with length "1". The built-in '
+ 'function\n'
+ ' "ord()" converts a code point from its string form to an\n'
+ ' integer in the range "0 - 10FFFF"; "chr()" converts an\n'
+ ' integer in the range "0 - 10FFFF" to the corresponding '
+ 'length\n'
+ ' "1" string object. "str.encode()" can be used to convert '
+ 'a\n'
+ ' "str" to "bytes" using the given text encoding, and\n'
+ ' "bytes.decode()" can be used to achieve the opposite.\n'
+ '\n'
+ ' Tuples\n'
+ ' The items of a tuple are arbitrary Python objects. Tuples '
+ 'of\n'
+ ' two or more items are formed by comma-separated lists of\n'
+ " expressions. A tuple of one item (a 'singleton') can be\n"
+ ' formed by affixing a comma to an expression (an expression '
+ 'by\n'
+ ' itself does not create a tuple, since parentheses must be\n'
+ ' usable for grouping of expressions). An empty tuple can '
+ 'be\n'
+ ' formed by an empty pair of parentheses.\n'
+ '\n'
+ ' Bytes\n'
+ ' A bytes object is an immutable array. The items are '
+ '8-bit\n'
+ ' bytes, represented by integers in the range 0 <= x < 256.\n'
+ ' Bytes literals (like "b\'abc\'") and the built-in '
+ 'function\n'
+ ' "bytes()" can be used to construct bytes objects. Also,\n'
+ ' bytes objects can be decoded to strings via the '
+ '"decode()"\n'
+ ' method.\n'
+ '\n'
+ ' Mutable sequences\n'
+ ' Mutable sequences can be changed after they are created. '
+ 'The\n'
+ ' subscription and slicing notations can be used as the target '
+ 'of\n'
+ ' assignment and "del" (delete) statements.\n'
+ '\n'
+ ' There are currently two intrinsic mutable sequence types:\n'
+ '\n'
+ ' Lists\n'
+ ' The items of a list are arbitrary Python objects. Lists '
+ 'are\n'
+ ' formed by placing a comma-separated list of expressions '
+ 'in\n'
+ ' square brackets. (Note that there are no special cases '
+ 'needed\n'
+ ' to form lists of length 0 or 1.)\n'
+ '\n'
+ ' Byte Arrays\n'
+ ' A bytearray object is a mutable array. They are created '
+ 'by\n'
+ ' the built-in "bytearray()" constructor. Aside from being\n'
+ ' mutable (and hence unhashable), byte arrays otherwise '
+ 'provide\n'
+ ' the same interface and functionality as immutable bytes\n'
+ ' objects.\n'
+ '\n'
+ ' The extension module "array" provides an additional example '
+ 'of a\n'
+ ' mutable sequence type, as does the "collections" module.\n'
+ '\n'
+ 'Set types\n'
+ ' These represent unordered, finite sets of unique, immutable\n'
+ ' objects. As such, they cannot be indexed by any subscript. '
+ 'However,\n'
+ ' they can be iterated over, and the built-in function "len()"\n'
+ ' returns the number of items in a set. Common uses for sets are '
+ 'fast\n'
+ ' membership testing, removing duplicates from a sequence, and\n'
+ ' computing mathematical operations such as intersection, union,\n'
+ ' difference, and symmetric difference.\n'
+ '\n'
+ ' For set elements, the same immutability rules apply as for\n'
+ ' dictionary keys. Note that numeric types obey the normal rules '
+ 'for\n'
+ ' numeric comparison: if two numbers compare equal (e.g., "1" and\n'
+ ' "1.0"), only one of them can be contained in a set.\n'
+ '\n'
+ ' There are currently two intrinsic set types:\n'
+ '\n'
+ ' Sets\n'
+ ' These represent a mutable set. They are created by the '
+ 'built-in\n'
+ ' "set()" constructor and can be modified afterwards by '
+ 'several\n'
+ ' methods, such as "add()".\n'
+ '\n'
+ ' Frozen sets\n'
+ ' These represent an immutable set. They are created by the\n'
+ ' built-in "frozenset()" constructor. As a frozenset is '
+ 'immutable\n'
+ ' and *hashable*, it can be used again as an element of '
+ 'another\n'
+ ' set, or as a dictionary key.\n'
+ '\n'
+ 'Mappings\n'
+ ' These represent finite sets of objects indexed by arbitrary '
+ 'index\n'
+ ' sets. The subscript notation "a[k]" selects the item indexed by '
+ '"k"\n'
+ ' from the mapping "a"; this can be used in expressions and as '
+ 'the\n'
+ ' target of assignments or "del" statements. The built-in '
+ 'function\n'
+ ' "len()" returns the number of items in a mapping.\n'
+ '\n'
+ ' There is currently a single intrinsic mapping type:\n'
+ '\n'
+ ' Dictionaries\n'
+ ' These represent finite sets of objects indexed by nearly\n'
+ ' arbitrary values. The only types of values not acceptable '
+ 'as\n'
+ ' keys are values containing lists or dictionaries or other\n'
+ ' mutable types that are compared by value rather than by '
+ 'object\n'
+ ' identity, the reason being that the efficient implementation '
+ 'of\n'
+ " dictionaries requires a key's hash value to remain constant.\n"
+ ' Numeric types used for keys obey the normal rules for '
+ 'numeric\n'
+ ' comparison: if two numbers compare equal (e.g., "1" and '
+ '"1.0")\n'
+ ' then they can be used interchangeably to index the same\n'
+ ' dictionary entry.\n'
+ '\n'
+ ' Dictionaries are mutable; they can be created by the "{...}"\n'
+ ' notation (see section Dictionary displays).\n'
+ '\n'
+ ' The extension modules "dbm.ndbm" and "dbm.gnu" provide\n'
+ ' additional examples of mapping types, as does the '
+ '"collections"\n'
+ ' module.\n'
+ '\n'
+ 'Callable types\n'
+ ' These are the types to which the function call operation (see\n'
+ ' section Calls) can be applied:\n'
+ '\n'
+ ' User-defined functions\n'
+ ' A user-defined function object is created by a function\n'
+ ' definition (see section Function definitions). It should be\n'
+ ' called with an argument list containing the same number of '
+ 'items\n'
+ " as the function's formal parameter list.\n"
+ '\n'
+ ' Special attributes:\n'
+ '\n'
+ ' '
+ '+---------------------------+---------------------------------+-------------+\n'
+ ' | Attribute | Meaning '
+ '| |\n'
+ ' '
+ '+===========================+=================================+=============+\n'
+ ' | "__doc__" | The function\'s '
+ 'documentation | Writable |\n'
+ ' | | string, or "None" if '
+ '| |\n'
+ ' | | unavailable; not inherited by '
+ '| |\n'
+ ' | | subclasses '
+ '| |\n'
+ ' '
+ '+---------------------------+---------------------------------+-------------+\n'
+ ' | "__name__" | The function\'s '
+ 'name | Writable |\n'
+ ' '
+ '+---------------------------+---------------------------------+-------------+\n'
+ ' | "__qualname__" | The function\'s *qualified '
+ 'name* | Writable |\n'
+ ' | | New in version 3.3. '
+ '| |\n'
+ ' '
+ '+---------------------------+---------------------------------+-------------+\n'
+ ' | "__module__" | The name of the module the '
+ '| Writable |\n'
+ ' | | function was defined in, or '
+ '| |\n'
+ ' | | "None" if unavailable. '
+ '| |\n'
+ ' '
+ '+---------------------------+---------------------------------+-------------+\n'
+ ' | "__defaults__" | A tuple containing default '
+ '| Writable |\n'
+ ' | | argument values for those '
+ '| |\n'
+ ' | | arguments that have defaults, '
+ '| |\n'
+ ' | | or "None" if no arguments have '
+ '| |\n'
+ ' | | a default value '
+ '| |\n'
+ ' '
+ '+---------------------------+---------------------------------+-------------+\n'
+ ' | "__code__" | The code object representing '
+ '| Writable |\n'
+ ' | | the compiled function body. '
+ '| |\n'
+ ' '
+ '+---------------------------+---------------------------------+-------------+\n'
+ ' | "__globals__" | A reference to the dictionary '
+ '| Read-only |\n'
+ " | | that holds the function's "
+ '| |\n'
+ ' | | global variables --- the global '
+ '| |\n'
+ ' | | namespace of the module in '
+ '| |\n'
+ ' | | which the function was defined. '
+ '| |\n'
+ ' '
+ '+---------------------------+---------------------------------+-------------+\n'
+ ' | "__dict__" | The namespace supporting '
+ '| Writable |\n'
+ ' | | arbitrary function attributes. '
+ '| |\n'
+ ' '
+ '+---------------------------+---------------------------------+-------------+\n'
+ ' | "__closure__" | "None" or a tuple of cells that '
+ '| Read-only |\n'
+ ' | | contain bindings for the '
+ '| |\n'
+ " | | function's free variables. "
+ '| |\n'
+ ' '
+ '+---------------------------+---------------------------------+-------------+\n'
+ ' | "__annotations__" | A dict containing annotations '
+ '| Writable |\n'
+ ' | | of parameters. The keys of the '
+ '| |\n'
+ ' | | dict are the parameter names, '
+ '| |\n'
+ ' | | and "\'return\'" for the '
+ 'return | |\n'
+ ' | | annotation, if provided. '
+ '| |\n'
+ ' '
+ '+---------------------------+---------------------------------+-------------+\n'
+ ' | "__kwdefaults__" | A dict containing defaults for '
+ '| Writable |\n'
+ ' | | keyword-only parameters. '
+ '| |\n'
+ ' '
+ '+---------------------------+---------------------------------+-------------+\n'
+ '\n'
+ ' Most of the attributes labelled "Writable" check the type of '
+ 'the\n'
+ ' assigned value.\n'
+ '\n'
+ ' Function objects also support getting and setting arbitrary\n'
+ ' attributes, which can be used, for example, to attach '
+ 'metadata\n'
+ ' to functions. Regular attribute dot-notation is used to get '
+ 'and\n'
+ ' set such attributes. *Note that the current implementation '
+ 'only\n'
+ ' supports function attributes on user-defined functions. '
+ 'Function\n'
+ ' attributes on built-in functions may be supported in the\n'
+ ' future.*\n'
+ '\n'
+ " Additional information about a function's definition can be\n"
+ ' retrieved from its code object; see the description of '
+ 'internal\n'
+ ' types below.\n'
+ '\n'
+ ' Instance methods\n'
+ ' An instance method object combines a class, a class instance '
+ 'and\n'
+ ' any callable object (normally a user-defined function).\n'
+ '\n'
+ ' Special read-only attributes: "__self__" is the class '
+ 'instance\n'
+ ' object, "__func__" is the function object; "__doc__" is the\n'
+ ' method\'s documentation (same as "__func__.__doc__"); '
+ '"__name__"\n'
+ ' is the method name (same as "__func__.__name__"); '
+ '"__module__"\n'
+ ' is the name of the module the method was defined in, or '
+ '"None"\n'
+ ' if unavailable.\n'
+ '\n'
+ ' Methods also support accessing (but not setting) the '
+ 'arbitrary\n'
+ ' function attributes on the underlying function object.\n'
+ '\n'
+ ' User-defined method objects may be created when getting an\n'
+ ' attribute of a class (perhaps via an instance of that class), '
+ 'if\n'
+ ' that attribute is a user-defined function object or a class\n'
+ ' method object.\n'
+ '\n'
+ ' When an instance method object is created by retrieving a '
+ 'user-\n'
+ ' defined function object from a class via one of its '
+ 'instances,\n'
+ ' its "__self__" attribute is the instance, and the method '
+ 'object\n'
+ ' is said to be bound. The new method\'s "__func__" attribute '
+ 'is\n'
+ ' the original function object.\n'
+ '\n'
+ ' When a user-defined method object is created by retrieving\n'
+ ' another method object from a class or instance, the behaviour '
+ 'is\n'
+ ' the same as for a function object, except that the '
+ '"__func__"\n'
+ ' attribute of the new instance is not the original method '
+ 'object\n'
+ ' but its "__func__" attribute.\n'
+ '\n'
+ ' When an instance method object is created by retrieving a '
+ 'class\n'
+ ' method object from a class or instance, its "__self__" '
+ 'attribute\n'
+ ' is the class itself, and its "__func__" attribute is the\n'
+ ' function object underlying the class method.\n'
+ '\n'
+ ' When an instance method object is called, the underlying\n'
+ ' function ("__func__") is called, inserting the class '
+ 'instance\n'
+ ' ("__self__") in front of the argument list. For instance, '
+ 'when\n'
+ ' "C" is a class which contains a definition for a function '
+ '"f()",\n'
+ ' and "x" is an instance of "C", calling "x.f(1)" is equivalent '
+ 'to\n'
+ ' calling "C.f(x, 1)".\n'
+ '\n'
+ ' When an instance method object is derived from a class '
+ 'method\n'
+ ' object, the "class instance" stored in "__self__" will '
+ 'actually\n'
+ ' be the class itself, so that calling either "x.f(1)" or '
+ '"C.f(1)"\n'
+ ' is equivalent to calling "f(C,1)" where "f" is the '
+ 'underlying\n'
+ ' function.\n'
+ '\n'
+ ' Note that the transformation from function object to '
+ 'instance\n'
+ ' method object happens each time the attribute is retrieved '
+ 'from\n'
+ ' the instance. In some cases, a fruitful optimization is to\n'
+ ' assign the attribute to a local variable and call that local\n'
+ ' variable. Also notice that this transformation only happens '
+ 'for\n'
+ ' user-defined functions; other callable objects (and all non-\n'
+ ' callable objects) are retrieved without transformation. It '
+ 'is\n'
+ ' also important to note that user-defined functions which are\n'
+ ' attributes of a class instance are not converted to bound\n'
+ ' methods; this *only* happens when the function is an '
+ 'attribute\n'
+ ' of the class.\n'
+ '\n'
+ ' Generator functions\n'
+ ' A function or method which uses the "yield" statement (see\n'
+ ' section The yield statement) is called a *generator '
+ 'function*.\n'
+ ' Such a function, when called, always returns an iterator '
+ 'object\n'
+ ' which can be used to execute the body of the function: '
+ 'calling\n'
+ ' the iterator\'s "iterator.__next__()" method will cause the\n'
+ ' function to execute until it provides a value using the '
+ '"yield"\n'
+ ' statement. When the function executes a "return" statement '
+ 'or\n'
+ ' falls off the end, a "StopIteration" exception is raised and '
+ 'the\n'
+ ' iterator will have reached the end of the set of values to '
+ 'be\n'
+ ' returned.\n'
+ '\n'
+ ' Coroutine functions\n'
+ ' A function or method which is defined using "async def" is\n'
+ ' called a *coroutine function*. Such a function, when '
+ 'called,\n'
+ ' returns a *coroutine* object. It may contain "await"\n'
+ ' expressions, as well as "async with" and "async for" '
+ 'statements.\n'
+ ' See also the Coroutine Objects section.\n'
+ '\n'
+ ' Built-in functions\n'
+ ' A built-in function object is a wrapper around a C function.\n'
+ ' Examples of built-in functions are "len()" and "math.sin()"\n'
+ ' ("math" is a standard built-in module). The number and type '
+ 'of\n'
+ ' the arguments are determined by the C function. Special '
+ 'read-\n'
+ ' only attributes: "__doc__" is the function\'s documentation\n'
+ ' string, or "None" if unavailable; "__name__" is the '
+ "function's\n"
+ ' name; "__self__" is set to "None" (but see the next item);\n'
+ ' "__module__" is the name of the module the function was '
+ 'defined\n'
+ ' in or "None" if unavailable.\n'
+ '\n'
+ ' Built-in methods\n'
+ ' This is really a different disguise of a built-in function, '
+ 'this\n'
+ ' time containing an object passed to the C function as an\n'
+ ' implicit extra argument. An example of a built-in method is\n'
+ ' "alist.append()", assuming *alist* is a list object. In this\n'
+ ' case, the special read-only attribute "__self__" is set to '
+ 'the\n'
+ ' object denoted by *alist*.\n'
+ '\n'
+ ' Classes\n'
+ ' Classes are callable. These objects normally act as '
+ 'factories\n'
+ ' for new instances of themselves, but variations are possible '
+ 'for\n'
+ ' class types that override "__new__()". The arguments of the\n'
+ ' call are passed to "__new__()" and, in the typical case, to\n'
+ ' "__init__()" to initialize the new instance.\n'
+ '\n'
+ ' Class Instances\n'
+ ' Instances of arbitrary classes can be made callable by '
+ 'defining\n'
+ ' a "__call__()" method in their class.\n'
+ '\n'
+ 'Modules\n'
+ ' Modules are a basic organizational unit of Python code, and are\n'
+ ' created by the import system as invoked either by the "import"\n'
+ ' statement (see "import"), or by calling functions such as\n'
+ ' "importlib.import_module()" and built-in "__import__()". A '
+ 'module\n'
+ ' object has a namespace implemented by a dictionary object (this '
+ 'is\n'
+ ' the dictionary referenced by the "__globals__" attribute of\n'
+ ' functions defined in the module). Attribute references are\n'
+ ' translated to lookups in this dictionary, e.g., "m.x" is '
+ 'equivalent\n'
+ ' to "m.__dict__["x"]". A module object does not contain the code\n'
+ " object used to initialize the module (since it isn't needed "
+ 'once\n'
+ ' the initialization is done).\n'
+ '\n'
+ " Attribute assignment updates the module's namespace dictionary,\n"
+ ' e.g., "m.x = 1" is equivalent to "m.__dict__["x"] = 1".\n'
+ '\n'
+ ' Special read-only attribute: "__dict__" is the module\'s '
+ 'namespace\n'
+ ' as a dictionary object.\n'
+ '\n'
+ ' **CPython implementation detail:** Because of the way CPython\n'
+ ' clears module dictionaries, the module dictionary will be '
+ 'cleared\n'
+ ' when the module falls out of scope even if the dictionary still '
+ 'has\n'
+ ' live references. To avoid this, copy the dictionary or keep '
+ 'the\n'
+ ' module around while using its dictionary directly.\n'
+ '\n'
+ ' Predefined (writable) attributes: "__name__" is the module\'s '
+ 'name;\n'
+ ' "__doc__" is the module\'s documentation string, or "None" if\n'
+ ' unavailable; "__file__" is the pathname of the file from which '
+ 'the\n'
+ ' module was loaded, if it was loaded from a file. The "__file__"\n'
+ ' attribute may be missing for certain types of modules, such as '
+ 'C\n'
+ ' modules that are statically linked into the interpreter; for\n'
+ ' extension modules loaded dynamically from a shared library, it '
+ 'is\n'
+ ' the pathname of the shared library file.\n'
+ '\n'
+ 'Custom classes\n'
+ ' Custom class types are typically created by class definitions '
+ '(see\n'
+ ' section Class definitions). A class has a namespace implemented '
+ 'by\n'
+ ' a dictionary object. Class attribute references are translated '
+ 'to\n'
+ ' lookups in this dictionary, e.g., "C.x" is translated to\n'
+ ' "C.__dict__["x"]" (although there are a number of hooks which '
+ 'allow\n'
+ ' for other means of locating attributes). When the attribute name '
+ 'is\n'
+ ' not found there, the attribute search continues in the base\n'
+ ' classes. This search of the base classes uses the C3 method\n'
+ ' resolution order which behaves correctly even in the presence '
+ 'of\n'
+ " 'diamond' inheritance structures where there are multiple\n"
+ ' inheritance paths leading back to a common ancestor. Additional\n'
+ ' details on the C3 MRO used by Python can be found in the\n'
+ ' documentation accompanying the 2.3 release at\n'
+ ' https://www.python.org/download/releases/2.3/mro/.\n'
+ '\n'
+ ' When a class attribute reference (for class "C", say) would '
+ 'yield a\n'
+ ' class method object, it is transformed into an instance method\n'
+ ' object whose "__self__" attributes is "C". When it would yield '
+ 'a\n'
+ ' static method object, it is transformed into the object wrapped '
+ 'by\n'
+ ' the static method object. See section Implementing Descriptors '
+ 'for\n'
+ ' another way in which attributes retrieved from a class may '
+ 'differ\n'
+ ' from those actually contained in its "__dict__".\n'
+ '\n'
+ " Class attribute assignments update the class's dictionary, "
+ 'never\n'
+ ' the dictionary of a base class.\n'
+ '\n'
+ ' A class object can be called (see above) to yield a class '
+ 'instance\n'
+ ' (see below).\n'
+ '\n'
+ ' Special attributes: "__name__" is the class name; "__module__" '
+ 'is\n'
+ ' the module name in which the class was defined; "__dict__" is '
+ 'the\n'
+ ' dictionary containing the class\'s namespace; "__bases__" is a '
+ 'tuple\n'
+ ' (possibly empty or a singleton) containing the base classes, in '
+ 'the\n'
+ ' order of their occurrence in the base class list; "__doc__" is '
+ 'the\n'
+ " class's documentation string, or None if undefined.\n"
+ '\n'
+ 'Class instances\n'
+ ' A class instance is created by calling a class object (see '
+ 'above).\n'
+ ' A class instance has a namespace implemented as a dictionary '
+ 'which\n'
+ ' is the first place in which attribute references are searched.\n'
+ " When an attribute is not found there, and the instance's class "
+ 'has\n'
+ ' an attribute by that name, the search continues with the class\n'
+ ' attributes. If a class attribute is found that is a '
+ 'user-defined\n'
+ ' function object, it is transformed into an instance method '
+ 'object\n'
+ ' whose "__self__" attribute is the instance. Static method and\n'
+ ' class method objects are also transformed; see above under\n'
+ ' "Classes". See section Implementing Descriptors for another way '
+ 'in\n'
+ ' which attributes of a class retrieved via its instances may '
+ 'differ\n'
+ ' from the objects actually stored in the class\'s "__dict__". If '
+ 'no\n'
+ " class attribute is found, and the object's class has a\n"
+ ' "__getattr__()" method, that is called to satisfy the lookup.\n'
+ '\n'
+ " Attribute assignments and deletions update the instance's\n"
+ " dictionary, never a class's dictionary. If the class has a\n"
+ ' "__setattr__()" or "__delattr__()" method, this is called '
+ 'instead\n'
+ ' of updating the instance dictionary directly.\n'
+ '\n'
+ ' Class instances can pretend to be numbers, sequences, or '
+ 'mappings\n'
+ ' if they have methods with certain special names. See section\n'
+ ' Special method names.\n'
+ '\n'
+ ' Special attributes: "__dict__" is the attribute dictionary;\n'
+ ' "__class__" is the instance\'s class.\n'
+ '\n'
+ 'I/O objects (also known as file objects)\n'
+ ' A *file object* represents an open file. Various shortcuts are\n'
+ ' available to create file objects: the "open()" built-in '
+ 'function,\n'
+ ' and also "os.popen()", "os.fdopen()", and the "makefile()" '
+ 'method\n'
+ ' of socket objects (and perhaps by other functions or methods\n'
+ ' provided by extension modules).\n'
+ '\n'
+ ' The objects "sys.stdin", "sys.stdout" and "sys.stderr" are\n'
+ " initialized to file objects corresponding to the interpreter's\n"
+ ' standard input, output and error streams; they are all open in '
+ 'text\n'
+ ' mode and therefore follow the interface defined by the\n'
+ ' "io.TextIOBase" abstract class.\n'
+ '\n'
+ 'Internal types\n'
+ ' A few types used internally by the interpreter are exposed to '
+ 'the\n'
+ ' user. Their definitions may change with future versions of the\n'
+ ' interpreter, but they are mentioned here for completeness.\n'
+ '\n'
+ ' Code objects\n'
+ ' Code objects represent *byte-compiled* executable Python '
+ 'code,\n'
+ ' or *bytecode*. The difference between a code object and a\n'
+ ' function object is that the function object contains an '
+ 'explicit\n'
+ " reference to the function's globals (the module in which it "
+ 'was\n'
+ ' defined), while a code object contains no context; also the\n'
+ ' default argument values are stored in the function object, '
+ 'not\n'
+ ' in the code object (because they represent values calculated '
+ 'at\n'
+ ' run-time). Unlike function objects, code objects are '
+ 'immutable\n'
+ ' and contain no references (directly or indirectly) to '
+ 'mutable\n'
+ ' objects.\n'
+ '\n'
+ ' Special read-only attributes: "co_name" gives the function '
+ 'name;\n'
+ ' "co_argcount" is the number of positional arguments '
+ '(including\n'
+ ' arguments with default values); "co_nlocals" is the number '
+ 'of\n'
+ ' local variables used by the function (including arguments);\n'
+ ' "co_varnames" is a tuple containing the names of the local\n'
+ ' variables (starting with the argument names); "co_cellvars" '
+ 'is a\n'
+ ' tuple containing the names of local variables that are\n'
+ ' referenced by nested functions; "co_freevars" is a tuple\n'
+ ' containing the names of free variables; "co_code" is a '
+ 'string\n'
+ ' representing the sequence of bytecode instructions; '
+ '"co_consts"\n'
+ ' is a tuple containing the literals used by the bytecode;\n'
+ ' "co_names" is a tuple containing the names used by the '
+ 'bytecode;\n'
+ ' "co_filename" is the filename from which the code was '
+ 'compiled;\n'
+ ' "co_firstlineno" is the first line number of the function;\n'
+ ' "co_lnotab" is a string encoding the mapping from bytecode\n'
+ ' offsets to line numbers (for details see the source code of '
+ 'the\n'
+ ' interpreter); "co_stacksize" is the required stack size\n'
+ ' (including local variables); "co_flags" is an integer '
+ 'encoding a\n'
+ ' number of flags for the interpreter.\n'
+ '\n'
+ ' The following flag bits are defined for "co_flags": bit '
+ '"0x04"\n'
+ ' is set if the function uses the "*arguments" syntax to accept '
+ 'an\n'
+ ' arbitrary number of positional arguments; bit "0x08" is set '
+ 'if\n'
+ ' the function uses the "**keywords" syntax to accept '
+ 'arbitrary\n'
+ ' keyword arguments; bit "0x20" is set if the function is a\n'
+ ' generator.\n'
+ '\n'
+ ' Future feature declarations ("from __future__ import '
+ 'division")\n'
+ ' also use bits in "co_flags" to indicate whether a code '
+ 'object\n'
+ ' was compiled with a particular feature enabled: bit "0x2000" '
+ 'is\n'
+ ' set if the function was compiled with future division '
+ 'enabled;\n'
+ ' bits "0x10" and "0x1000" were used in earlier versions of\n'
+ ' Python.\n'
+ '\n'
+ ' Other bits in "co_flags" are reserved for internal use.\n'
+ '\n'
+ ' If a code object represents a function, the first item in\n'
+ ' "co_consts" is the documentation string of the function, or\n'
+ ' "None" if undefined.\n'
+ '\n'
+ ' Frame objects\n'
+ ' Frame objects represent execution frames. They may occur in\n'
+ ' traceback objects (see below).\n'
+ '\n'
+ ' Special read-only attributes: "f_back" is to the previous '
+ 'stack\n'
+ ' frame (towards the caller), or "None" if this is the bottom\n'
+ ' stack frame; "f_code" is the code object being executed in '
+ 'this\n'
+ ' frame; "f_locals" is the dictionary used to look up local\n'
+ ' variables; "f_globals" is used for global variables;\n'
+ ' "f_builtins" is used for built-in (intrinsic) names; '
+ '"f_lasti"\n'
+ ' gives the precise instruction (this is an index into the\n'
+ ' bytecode string of the code object).\n'
+ '\n'
+ ' Special writable attributes: "f_trace", if not "None", is a\n'
+ ' function called at the start of each source code line (this '
+ 'is\n'
+ ' used by the debugger); "f_lineno" is the current line number '
+ 'of\n'
+ ' the frame --- writing to this from within a trace function '
+ 'jumps\n'
+ ' to the given line (only for the bottom-most frame). A '
+ 'debugger\n'
+ ' can implement a Jump command (aka Set Next Statement) by '
+ 'writing\n'
+ ' to f_lineno.\n'
+ '\n'
+ ' Frame objects support one method:\n'
+ '\n'
+ ' frame.clear()\n'
+ '\n'
+ ' This method clears all references to local variables held '
+ 'by\n'
+ ' the frame. Also, if the frame belonged to a generator, '
+ 'the\n'
+ ' generator is finalized. This helps break reference '
+ 'cycles\n'
+ ' involving frame objects (for example when catching an\n'
+ ' exception and storing its traceback for later use).\n'
+ '\n'
+ ' "RuntimeError" is raised if the frame is currently '
+ 'executing.\n'
+ '\n'
+ ' New in version 3.4.\n'
+ '\n'
+ ' Traceback objects\n'
+ ' Traceback objects represent a stack trace of an exception. '
+ 'A\n'
+ ' traceback object is created when an exception occurs. When '
+ 'the\n'
+ ' search for an exception handler unwinds the execution stack, '
+ 'at\n'
+ ' each unwound level a traceback object is inserted in front '
+ 'of\n'
+ ' the current traceback. When an exception handler is '
+ 'entered,\n'
+ ' the stack trace is made available to the program. (See '
+ 'section\n'
+ ' The try statement.) It is accessible as the third item of '
+ 'the\n'
+ ' tuple returned by "sys.exc_info()". When the program contains '
+ 'no\n'
+ ' suitable handler, the stack trace is written (nicely '
+ 'formatted)\n'
+ ' to the standard error stream; if the interpreter is '
+ 'interactive,\n'
+ ' it is also made available to the user as '
+ '"sys.last_traceback".\n'
+ '\n'
+ ' Special read-only attributes: "tb_next" is the next level in '
+ 'the\n'
+ ' stack trace (towards the frame where the exception occurred), '
+ 'or\n'
+ ' "None" if there is no next level; "tb_frame" points to the\n'
+ ' execution frame of the current level; "tb_lineno" gives the '
+ 'line\n'
+ ' number where the exception occurred; "tb_lasti" indicates '
+ 'the\n'
+ ' precise instruction. The line number and last instruction '
+ 'in\n'
+ ' the traceback may differ from the line number of its frame\n'
+ ' object if the exception occurred in a "try" statement with '
+ 'no\n'
+ ' matching except clause or with a finally clause.\n'
+ '\n'
+ ' Slice objects\n'
+ ' Slice objects are used to represent slices for '
+ '"__getitem__()"\n'
+ ' methods. They are also created by the built-in "slice()"\n'
+ ' function.\n'
+ '\n'
+ ' Special read-only attributes: "start" is the lower bound; '
+ '"stop"\n'
+ ' is the upper bound; "step" is the step value; each is "None" '
+ 'if\n'
+ ' omitted. These attributes can have any type.\n'
+ '\n'
+ ' Slice objects support one method:\n'
+ '\n'
+ ' slice.indices(self, length)\n'
+ '\n'
+ ' This method takes a single integer argument *length* and\n'
+ ' computes information about the slice that the slice '
+ 'object\n'
+ ' would describe if applied to a sequence of *length* '
+ 'items.\n'
+ ' It returns a tuple of three integers; respectively these '
+ 'are\n'
+ ' the *start* and *stop* indices and the *step* or stride\n'
+ ' length of the slice. Missing or out-of-bounds indices are\n'
+ ' handled in a manner consistent with regular slices.\n'
+ '\n'
+ ' Static method objects\n'
+ ' Static method objects provide a way of defeating the\n'
+ ' transformation of function objects to method objects '
+ 'described\n'
+ ' above. A static method object is a wrapper around any other\n'
+ ' object, usually a user-defined method object. When a static\n'
+ ' method object is retrieved from a class or a class instance, '
+ 'the\n'
+ ' object actually returned is the wrapped object, which is not\n'
+ ' subject to any further transformation. Static method objects '
+ 'are\n'
+ ' not themselves callable, although the objects they wrap '
+ 'usually\n'
+ ' are. Static method objects are created by the built-in\n'
+ ' "staticmethod()" constructor.\n'
+ '\n'
+ ' Class method objects\n'
+ ' A class method object, like a static method object, is a '
+ 'wrapper\n'
+ ' around another object that alters the way in which that '
+ 'object\n'
+ ' is retrieved from classes and class instances. The behaviour '
+ 'of\n'
+ ' class method objects upon such retrieval is described above,\n'
+ ' under "User-defined methods". Class method objects are '
+ 'created\n'
+ ' by the built-in "classmethod()" constructor.\n',
+ 'typesfunctions': '\n'
+ 'Functions\n'
+ '*********\n'
+ '\n'
+ 'Function objects are created by function definitions. The '
+ 'only\n'
+ 'operation on a function object is to call it: '
+ '"func(argument-list)".\n'
+ '\n'
+ 'There are really two flavors of function objects: built-in '
+ 'functions\n'
+ 'and user-defined functions. Both support the same '
+ 'operation (to call\n'
+ 'the function), but the implementation is different, hence '
+ 'the\n'
+ 'different object types.\n'
+ '\n'
+ 'See Function definitions for more information.\n',
+ 'typesmapping': '\n'
+ 'Mapping Types --- "dict"\n'
+ '************************\n'
+ '\n'
+ 'A *mapping* object maps *hashable* values to arbitrary '
+ 'objects.\n'
+ 'Mappings are mutable objects. There is currently only one '
+ 'standard\n'
+ 'mapping type, the *dictionary*. (For other containers see '
+ 'the built-\n'
+ 'in "list", "set", and "tuple" classes, and the "collections" '
+ 'module.)\n'
+ '\n'
+ "A dictionary's keys are *almost* arbitrary values. Values "
+ 'that are\n'
+ 'not *hashable*, that is, values containing lists, '
+ 'dictionaries or\n'
+ 'other mutable types (that are compared by value rather than '
+ 'by object\n'
+ 'identity) may not be used as keys. Numeric types used for '
+ 'keys obey\n'
+ 'the normal rules for numeric comparison: if two numbers '
+ 'compare equal\n'
+ '(such as "1" and "1.0") then they can be used '
+ 'interchangeably to index\n'
+ 'the same dictionary entry. (Note however, that since '
+ 'computers store\n'
+ 'floating-point numbers as approximations it is usually '
+ 'unwise to use\n'
+ 'them as dictionary keys.)\n'
+ '\n'
+ 'Dictionaries can be created by placing a comma-separated '
+ 'list of "key:\n'
+ 'value" pairs within braces, for example: "{\'jack\': 4098, '
+ "'sjoerd':\n"
+ '4127}" or "{4098: \'jack\', 4127: \'sjoerd\'}", or by the '
+ '"dict"\n'
+ 'constructor.\n'
+ '\n'
+ 'class dict(**kwarg)\n'
+ 'class dict(mapping, **kwarg)\n'
+ 'class dict(iterable, **kwarg)\n'
+ '\n'
+ ' Return a new dictionary initialized from an optional '
+ 'positional\n'
+ ' argument and a possibly empty set of keyword arguments.\n'
+ '\n'
+ ' If no positional argument is given, an empty dictionary '
+ 'is created.\n'
+ ' If a positional argument is given and it is a mapping '
+ 'object, a\n'
+ ' dictionary is created with the same key-value pairs as '
+ 'the mapping\n'
+ ' object. Otherwise, the positional argument must be an '
+ '*iterable*\n'
+ ' object. Each item in the iterable must itself be an '
+ 'iterable with\n'
+ ' exactly two objects. The first object of each item '
+ 'becomes a key\n'
+ ' in the new dictionary, and the second object the '
+ 'corresponding\n'
+ ' value. If a key occurs more than once, the last value '
+ 'for that key\n'
+ ' becomes the corresponding value in the new dictionary.\n'
+ '\n'
+ ' If keyword arguments are given, the keyword arguments and '
+ 'their\n'
+ ' values are added to the dictionary created from the '
+ 'positional\n'
+ ' argument. If a key being added is already present, the '
+ 'value from\n'
+ ' the keyword argument replaces the value from the '
+ 'positional\n'
+ ' argument.\n'
+ '\n'
+ ' To illustrate, the following examples all return a '
+ 'dictionary equal\n'
+ ' to "{"one": 1, "two": 2, "three": 3}":\n'
+ '\n'
+ ' >>> a = dict(one=1, two=2, three=3)\n'
+ " >>> b = {'one': 1, 'two': 2, 'three': 3}\n"
+ " >>> c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))\n"
+ " >>> d = dict([('two', 2), ('one', 1), ('three', 3)])\n"
+ " >>> e = dict({'three': 3, 'one': 1, 'two': 2})\n"
+ ' >>> a == b == c == d == e\n'
+ ' True\n'
+ '\n'
+ ' Providing keyword arguments as in the first example only '
+ 'works for\n'
+ ' keys that are valid Python identifiers. Otherwise, any '
+ 'valid keys\n'
+ ' can be used.\n'
+ '\n'
+ ' These are the operations that dictionaries support (and '
+ 'therefore,\n'
+ ' custom mapping types should support too):\n'
+ '\n'
+ ' len(d)\n'
+ '\n'
+ ' Return the number of items in the dictionary *d*.\n'
+ '\n'
+ ' d[key]\n'
+ '\n'
+ ' Return the item of *d* with key *key*. Raises a '
+ '"KeyError" if\n'
+ ' *key* is not in the map.\n'
+ '\n'
+ ' If a subclass of dict defines a method "__missing__()" '
+ 'and *key*\n'
+ ' is not present, the "d[key]" operation calls that '
+ 'method with\n'
+ ' the key *key* as argument. The "d[key]" operation '
+ 'then returns\n'
+ ' or raises whatever is returned or raised by the\n'
+ ' "__missing__(key)" call. No other operations or '
+ 'methods invoke\n'
+ ' "__missing__()". If "__missing__()" is not defined, '
+ '"KeyError"\n'
+ ' is raised. "__missing__()" must be a method; it cannot '
+ 'be an\n'
+ ' instance variable:\n'
+ '\n'
+ ' >>> class Counter(dict):\n'
+ ' ... def __missing__(self, key):\n'
+ ' ... return 0\n'
+ ' >>> c = Counter()\n'
+ " >>> c['red']\n"
+ ' 0\n'
+ " >>> c['red'] += 1\n"
+ " >>> c['red']\n"
+ ' 1\n'
+ '\n'
+ ' The example above shows part of the implementation of\n'
+ ' "collections.Counter". A different "__missing__" '
+ 'method is used\n'
+ ' by "collections.defaultdict".\n'
+ '\n'
+ ' d[key] = value\n'
+ '\n'
+ ' Set "d[key]" to *value*.\n'
+ '\n'
+ ' del d[key]\n'
+ '\n'
+ ' Remove "d[key]" from *d*. Raises a "KeyError" if '
+ '*key* is not\n'
+ ' in the map.\n'
+ '\n'
+ ' key in d\n'
+ '\n'
+ ' Return "True" if *d* has a key *key*, else "False".\n'
+ '\n'
+ ' key not in d\n'
+ '\n'
+ ' Equivalent to "not key in d".\n'
+ '\n'
+ ' iter(d)\n'
+ '\n'
+ ' Return an iterator over the keys of the dictionary. '
+ 'This is a\n'
+ ' shortcut for "iter(d.keys())".\n'
+ '\n'
+ ' clear()\n'
+ '\n'
+ ' Remove all items from the dictionary.\n'
+ '\n'
+ ' copy()\n'
+ '\n'
+ ' Return a shallow copy of the dictionary.\n'
+ '\n'
+ ' classmethod fromkeys(seq[, value])\n'
+ '\n'
+ ' Create a new dictionary with keys from *seq* and '
+ 'values set to\n'
+ ' *value*.\n'
+ '\n'
+ ' "fromkeys()" is a class method that returns a new '
+ 'dictionary.\n'
+ ' *value* defaults to "None".\n'
+ '\n'
+ ' get(key[, default])\n'
+ '\n'
+ ' Return the value for *key* if *key* is in the '
+ 'dictionary, else\n'
+ ' *default*. If *default* is not given, it defaults to '
+ '"None", so\n'
+ ' that this method never raises a "KeyError".\n'
+ '\n'
+ ' items()\n'
+ '\n'
+ ' Return a new view of the dictionary\'s items ("(key, '
+ 'value)"\n'
+ ' pairs). See the documentation of view objects.\n'
+ '\n'
+ ' keys()\n'
+ '\n'
+ " Return a new view of the dictionary's keys. See the\n"
+ ' documentation of view objects.\n'
+ '\n'
+ ' pop(key[, default])\n'
+ '\n'
+ ' If *key* is in the dictionary, remove it and return '
+ 'its value,\n'
+ ' else return *default*. If *default* is not given and '
+ '*key* is\n'
+ ' not in the dictionary, a "KeyError" is raised.\n'
+ '\n'
+ ' popitem()\n'
+ '\n'
+ ' Remove and return an arbitrary "(key, value)" pair '
+ 'from the\n'
+ ' dictionary.\n'
+ '\n'
+ ' "popitem()" is useful to destructively iterate over a\n'
+ ' dictionary, as often used in set algorithms. If the '
+ 'dictionary\n'
+ ' is empty, calling "popitem()" raises a "KeyError".\n'
+ '\n'
+ ' setdefault(key[, default])\n'
+ '\n'
+ ' If *key* is in the dictionary, return its value. If '
+ 'not, insert\n'
+ ' *key* with a value of *default* and return *default*. '
+ '*default*\n'
+ ' defaults to "None".\n'
+ '\n'
+ ' update([other])\n'
+ '\n'
+ ' Update the dictionary with the key/value pairs from '
+ '*other*,\n'
+ ' overwriting existing keys. Return "None".\n'
+ '\n'
+ ' "update()" accepts either another dictionary object or '
+ 'an\n'
+ ' iterable of key/value pairs (as tuples or other '
+ 'iterables of\n'
+ ' length two). If keyword arguments are specified, the '
+ 'dictionary\n'
+ ' is then updated with those key/value pairs: '
+ '"d.update(red=1,\n'
+ ' blue=2)".\n'
+ '\n'
+ ' values()\n'
+ '\n'
+ " Return a new view of the dictionary's values. See "
+ 'the\n'
+ ' documentation of view objects.\n'
+ '\n'
+ ' Dictionaries compare equal if and only if they have the '
+ 'same "(key,\n'
+ ' value)" pairs. Order comparisons (\'<\', \'<=\', \'>=\', '
+ "'>') raise\n"
+ ' "TypeError".\n'
+ '\n'
+ 'See also: "types.MappingProxyType" can be used to create a '
+ 'read-only\n'
+ ' view of a "dict".\n'
+ '\n'
+ '\n'
+ 'Dictionary view objects\n'
+ '=======================\n'
+ '\n'
+ 'The objects returned by "dict.keys()", "dict.values()" and\n'
+ '"dict.items()" are *view objects*. They provide a dynamic '
+ 'view on the\n'
+ "dictionary's entries, which means that when the dictionary "
+ 'changes,\n'
+ 'the view reflects these changes.\n'
+ '\n'
+ 'Dictionary views can be iterated over to yield their '
+ 'respective data,\n'
+ 'and support membership tests:\n'
+ '\n'
+ 'len(dictview)\n'
+ '\n'
+ ' Return the number of entries in the dictionary.\n'
+ '\n'
+ 'iter(dictview)\n'
+ '\n'
+ ' Return an iterator over the keys, values or items '
+ '(represented as\n'
+ ' tuples of "(key, value)") in the dictionary.\n'
+ '\n'
+ ' Keys and values are iterated over in an arbitrary order '
+ 'which is\n'
+ ' non-random, varies across Python implementations, and '
+ 'depends on\n'
+ " the dictionary's history of insertions and deletions. If "
+ 'keys,\n'
+ ' values and items views are iterated over with no '
+ 'intervening\n'
+ ' modifications to the dictionary, the order of items will '
+ 'directly\n'
+ ' correspond. This allows the creation of "(value, key)" '
+ 'pairs using\n'
+ ' "zip()": "pairs = zip(d.values(), d.keys())". Another '
+ 'way to\n'
+ ' create the same list is "pairs = [(v, k) for (k, v) in '
+ 'd.items()]".\n'
+ '\n'
+ ' Iterating views while adding or deleting entries in the '
+ 'dictionary\n'
+ ' may raise a "RuntimeError" or fail to iterate over all '
+ 'entries.\n'
+ '\n'
+ 'x in dictview\n'
+ '\n'
+ ' Return "True" if *x* is in the underlying dictionary\'s '
+ 'keys, values\n'
+ ' or items (in the latter case, *x* should be a "(key, '
+ 'value)"\n'
+ ' tuple).\n'
+ '\n'
+ 'Keys views are set-like since their entries are unique and '
+ 'hashable.\n'
+ 'If all values are hashable, so that "(key, value)" pairs are '
+ 'unique\n'
+ 'and hashable, then the items view is also set-like. (Values '
+ 'views are\n'
+ 'not treated as set-like since the entries are generally not '
+ 'unique.)\n'
+ 'For set-like views, all of the operations defined for the '
+ 'abstract\n'
+ 'base class "collections.abc.Set" are available (for example, '
+ '"==",\n'
+ '"<", or "^").\n'
+ '\n'
+ 'An example of dictionary view usage:\n'
+ '\n'
+ " >>> dishes = {'eggs': 2, 'sausage': 1, 'bacon': 1, "
+ "'spam': 500}\n"
+ ' >>> keys = dishes.keys()\n'
+ ' >>> values = dishes.values()\n'
+ '\n'
+ ' >>> # iteration\n'
+ ' >>> n = 0\n'
+ ' >>> for val in values:\n'
+ ' ... n += val\n'
+ ' >>> print(n)\n'
+ ' 504\n'
+ '\n'
+ ' >>> # keys and values are iterated over in the same '
+ 'order\n'
+ ' >>> list(keys)\n'
+ " ['eggs', 'bacon', 'sausage', 'spam']\n"
+ ' >>> list(values)\n'
+ ' [2, 1, 1, 500]\n'
+ '\n'
+ ' >>> # view objects are dynamic and reflect dict changes\n'
+ " >>> del dishes['eggs']\n"
+ " >>> del dishes['sausage']\n"
+ ' >>> list(keys)\n'
+ " ['spam', 'bacon']\n"
+ '\n'
+ ' >>> # set operations\n'
+ " >>> keys & {'eggs', 'bacon', 'salad'}\n"
+ " {'bacon'}\n"
+ " >>> keys ^ {'sausage', 'juice'}\n"
+ " {'juice', 'sausage', 'bacon', 'spam'}\n",
+ 'typesmethods': '\n'
+ 'Methods\n'
+ '*******\n'
+ '\n'
+ 'Methods are functions that are called using the attribute '
+ 'notation.\n'
+ 'There are two flavors: built-in methods (such as "append()" '
+ 'on lists)\n'
+ 'and class instance methods. Built-in methods are described '
+ 'with the\n'
+ 'types that support them.\n'
+ '\n'
+ 'If you access a method (a function defined in a class '
+ 'namespace)\n'
+ 'through an instance, you get a special object: a *bound '
+ 'method* (also\n'
+ 'called *instance method*) object. When called, it will add '
+ 'the "self"\n'
+ 'argument to the argument list. Bound methods have two '
+ 'special read-\n'
+ 'only attributes: "m.__self__" is the object on which the '
+ 'method\n'
+ 'operates, and "m.__func__" is the function implementing the '
+ 'method.\n'
+ 'Calling "m(arg-1, arg-2, ..., arg-n)" is completely '
+ 'equivalent to\n'
+ 'calling "m.__func__(m.__self__, arg-1, arg-2, ..., arg-n)".\n'
+ '\n'
+ 'Like function objects, bound method objects support getting '
+ 'arbitrary\n'
+ 'attributes. However, since method attributes are actually '
+ 'stored on\n'
+ 'the underlying function object ("meth.__func__"), setting '
+ 'method\n'
+ 'attributes on bound methods is disallowed. Attempting to '
+ 'set an\n'
+ 'attribute on a method results in an "AttributeError" being '
+ 'raised. In\n'
+ 'order to set a method attribute, you need to explicitly set '
+ 'it on the\n'
+ 'underlying function object:\n'
+ '\n'
+ ' >>> class C:\n'
+ ' ... def method(self):\n'
+ ' ... pass\n'
+ ' ...\n'
+ ' >>> c = C()\n'
+ " >>> c.method.whoami = 'my name is method' # can't set on "
+ 'the method\n'
+ ' Traceback (most recent call last):\n'
+ ' File "<stdin>", line 1, in <module>\n'
+ " AttributeError: 'method' object has no attribute "
+ "'whoami'\n"
+ " >>> c.method.__func__.whoami = 'my name is method'\n"
+ ' >>> c.method.whoami\n'
+ " 'my name is method'\n"
+ '\n'
+ 'See The standard type hierarchy for more information.\n',
+ 'typesmodules': '\n'
+ 'Modules\n'
+ '*******\n'
+ '\n'
+ 'The only special operation on a module is attribute access: '
+ '"m.name",\n'
+ 'where *m* is a module and *name* accesses a name defined in '
+ "*m*'s\n"
+ 'symbol table. Module attributes can be assigned to. (Note '
+ 'that the\n'
+ '"import" statement is not, strictly speaking, an operation '
+ 'on a module\n'
+ 'object; "import foo" does not require a module object named '
+ '*foo* to\n'
+ 'exist, rather it requires an (external) *definition* for a '
+ 'module\n'
+ 'named *foo* somewhere.)\n'
+ '\n'
+ 'A special attribute of every module is "__dict__". This is '
+ 'the\n'
+ "dictionary containing the module's symbol table. Modifying "
+ 'this\n'
+ "dictionary will actually change the module's symbol table, "
+ 'but direct\n'
+ 'assignment to the "__dict__" attribute is not possible (you '
+ 'can write\n'
+ '"m.__dict__[\'a\'] = 1", which defines "m.a" to be "1", but '
+ "you can't\n"
+ 'write "m.__dict__ = {}"). Modifying "__dict__" directly is '
+ 'not\n'
+ 'recommended.\n'
+ '\n'
+ 'Modules built into the interpreter are written like this: '
+ '"<module\n'
+ '\'sys\' (built-in)>". If loaded from a file, they are '
+ 'written as\n'
+ '"<module \'os\' from '
+ '\'/usr/local/lib/pythonX.Y/os.pyc\'>".\n',
+ 'typesseq': '\n'
+ 'Sequence Types --- "list", "tuple", "range"\n'
+ '*******************************************\n'
+ '\n'
+ 'There are three basic sequence types: lists, tuples, and range\n'
+ 'objects. Additional sequence types tailored for processing of '
+ 'binary\n'
+ 'data and text strings are described in dedicated sections.\n'
+ '\n'
+ '\n'
+ 'Common Sequence Operations\n'
+ '==========================\n'
+ '\n'
+ 'The operations in the following table are supported by most '
+ 'sequence\n'
+ 'types, both mutable and immutable. The '
+ '"collections.abc.Sequence" ABC\n'
+ 'is provided to make it easier to correctly implement these '
+ 'operations\n'
+ 'on custom sequence types.\n'
+ '\n'
+ 'This table lists the sequence operations sorted in ascending '
+ 'priority.\n'
+ 'In the table, *s* and *t* are sequences of the same type, *n*, '
+ '*i*,\n'
+ '*j* and *k* are integers and *x* is an arbitrary object that '
+ 'meets any\n'
+ 'type and value restrictions imposed by *s*.\n'
+ '\n'
+ 'The "in" and "not in" operations have the same priorities as '
+ 'the\n'
+ 'comparison operations. The "+" (concatenation) and "*" '
+ '(repetition)\n'
+ 'operations have the same priority as the corresponding numeric\n'
+ 'operations.\n'
+ '\n'
+ '+----------------------------+----------------------------------+------------+\n'
+ '| Operation | Result '
+ '| Notes |\n'
+ '+============================+==================================+============+\n'
+ '| "x in s" | "True" if an item of *s* is '
+ '| (1) |\n'
+ '| | equal to *x*, else "False" '
+ '| |\n'
+ '+----------------------------+----------------------------------+------------+\n'
+ '| "x not in s" | "False" if an item of *s* is '
+ '| (1) |\n'
+ '| | equal to *x*, else "True" '
+ '| |\n'
+ '+----------------------------+----------------------------------+------------+\n'
+ '| "s + t" | the concatenation of *s* and *t* '
+ '| (6)(7) |\n'
+ '+----------------------------+----------------------------------+------------+\n'
+ '| "s * n" or "n * s" | equivalent to adding *s* to '
+ '| (2)(7) |\n'
+ '| | itself *n* times '
+ '| |\n'
+ '+----------------------------+----------------------------------+------------+\n'
+ '| "s[i]" | *i*th item of *s*, origin 0 '
+ '| (3) |\n'
+ '+----------------------------+----------------------------------+------------+\n'
+ '| "s[i:j]" | slice of *s* from *i* to *j* '
+ '| (3)(4) |\n'
+ '+----------------------------+----------------------------------+------------+\n'
+ '| "s[i:j:k]" | slice of *s* from *i* to *j* '
+ '| (3)(5) |\n'
+ '| | with step *k* '
+ '| |\n'
+ '+----------------------------+----------------------------------+------------+\n'
+ '| "len(s)" | length of *s* '
+ '| |\n'
+ '+----------------------------+----------------------------------+------------+\n'
+ '| "min(s)" | smallest item of *s* '
+ '| |\n'
+ '+----------------------------+----------------------------------+------------+\n'
+ '| "max(s)" | largest item of *s* '
+ '| |\n'
+ '+----------------------------+----------------------------------+------------+\n'
+ '| "s.index(x[, i[, j]])" | index of the first occurrence of '
+ '| (8) |\n'
+ '| | *x* in *s* (at or after index '
+ '| |\n'
+ '| | *i* and before index *j*) '
+ '| |\n'
+ '+----------------------------+----------------------------------+------------+\n'
+ '| "s.count(x)" | total number of occurrences of '
+ '| |\n'
+ '| | *x* in *s* '
+ '| |\n'
+ '+----------------------------+----------------------------------+------------+\n'
+ '\n'
+ 'Sequences of the same type also support comparisons. In '
+ 'particular,\n'
+ 'tuples and lists are compared lexicographically by comparing\n'
+ 'corresponding elements. This means that to compare equal, every\n'
+ 'element must compare equal and the two sequences must be of the '
+ 'same\n'
+ 'type and have the same length. (For full details see '
+ 'Comparisons in\n'
+ 'the language reference.)\n'
+ '\n'
+ 'Notes:\n'
+ '\n'
+ '1. While the "in" and "not in" operations are used only for '
+ 'simple\n'
+ ' containment testing in the general case, some specialised '
+ 'sequences\n'
+ ' (such as "str", "bytes" and "bytearray") also use them for\n'
+ ' subsequence testing:\n'
+ '\n'
+ ' >>> "gg" in "eggs"\n'
+ ' True\n'
+ '\n'
+ '2. Values of *n* less than "0" are treated as "0" (which yields '
+ 'an\n'
+ ' empty sequence of the same type as *s*). Note that items in '
+ 'the\n'
+ ' sequence *s* are not copied; they are referenced multiple '
+ 'times.\n'
+ ' This often haunts new Python programmers; consider:\n'
+ '\n'
+ ' >>> lists = [[]] * 3\n'
+ ' >>> lists\n'
+ ' [[], [], []]\n'
+ ' >>> lists[0].append(3)\n'
+ ' >>> lists\n'
+ ' [[3], [3], [3]]\n'
+ '\n'
+ ' What has happened is that "[[]]" is a one-element list '
+ 'containing\n'
+ ' an empty list, so all three elements of "[[]] * 3" are '
+ 'references\n'
+ ' to this single empty list. Modifying any of the elements of\n'
+ ' "lists" modifies this single list. You can create a list of\n'
+ ' different lists this way:\n'
+ '\n'
+ ' >>> lists = [[] for i in range(3)]\n'
+ ' >>> lists[0].append(3)\n'
+ ' >>> lists[1].append(5)\n'
+ ' >>> lists[2].append(7)\n'
+ ' >>> lists\n'
+ ' [[3], [5], [7]]\n'
+ '\n'
+ ' Further explanation is available in the FAQ entry How do I '
+ 'create a\n'
+ ' multidimensional list?.\n'
+ '\n'
+ '3. If *i* or *j* is negative, the index is relative to the end '
+ 'of\n'
+ ' the string: "len(s) + i" or "len(s) + j" is substituted. But '
+ 'note\n'
+ ' that "-0" is still "0".\n'
+ '\n'
+ '4. The slice of *s* from *i* to *j* is defined as the sequence '
+ 'of\n'
+ ' items with index *k* such that "i <= k < j". If *i* or *j* '
+ 'is\n'
+ ' greater than "len(s)", use "len(s)". If *i* is omitted or '
+ '"None",\n'
+ ' use "0". If *j* is omitted or "None", use "len(s)". If *i* '
+ 'is\n'
+ ' greater than or equal to *j*, the slice is empty.\n'
+ '\n'
+ '5. The slice of *s* from *i* to *j* with step *k* is defined as '
+ 'the\n'
+ ' sequence of items with index "x = i + n*k" such that "0 <= n '
+ '<\n'
+ ' (j-i)/k". In other words, the indices are "i", "i+k", '
+ '"i+2*k",\n'
+ ' "i+3*k" and so on, stopping when *j* is reached (but never\n'
+ ' including *j*). If *i* or *j* is greater than "len(s)", use\n'
+ ' "len(s)". If *i* or *j* are omitted or "None", they become '
+ '"end"\n'
+ ' values (which end depends on the sign of *k*). Note, *k* '
+ 'cannot be\n'
+ ' zero. If *k* is "None", it is treated like "1".\n'
+ '\n'
+ '6. Concatenating immutable sequences always results in a new\n'
+ ' object. This means that building up a sequence by repeated\n'
+ ' concatenation will have a quadratic runtime cost in the '
+ 'total\n'
+ ' sequence length. To get a linear runtime cost, you must '
+ 'switch to\n'
+ ' one of the alternatives below:\n'
+ '\n'
+ ' * if concatenating "str" objects, you can build a list and '
+ 'use\n'
+ ' "str.join()" at the end or else write to an "io.StringIO"\n'
+ ' instance and retrieve its value when complete\n'
+ '\n'
+ ' * if concatenating "bytes" objects, you can similarly use\n'
+ ' "bytes.join()" or "io.BytesIO", or you can do in-place\n'
+ ' concatenation with a "bytearray" object. "bytearray" '
+ 'objects are\n'
+ ' mutable and have an efficient overallocation mechanism\n'
+ '\n'
+ ' * if concatenating "tuple" objects, extend a "list" instead\n'
+ '\n'
+ ' * for other types, investigate the relevant class '
+ 'documentation\n'
+ '\n'
+ '7. Some sequence types (such as "range") only support item\n'
+ " sequences that follow specific patterns, and hence don't "
+ 'support\n'
+ ' sequence concatenation or repetition.\n'
+ '\n'
+ '8. "index" raises "ValueError" when *x* is not found in *s*. '
+ 'When\n'
+ ' supported, the additional arguments to the index method '
+ 'allow\n'
+ ' efficient searching of subsections of the sequence. Passing '
+ 'the\n'
+ ' extra arguments is roughly equivalent to using '
+ '"s[i:j].index(x)",\n'
+ ' only without copying any data and with the returned index '
+ 'being\n'
+ ' relative to the start of the sequence rather than the start '
+ 'of the\n'
+ ' slice.\n'
+ '\n'
+ '\n'
+ 'Immutable Sequence Types\n'
+ '========================\n'
+ '\n'
+ 'The only operation that immutable sequence types generally '
+ 'implement\n'
+ 'that is not also implemented by mutable sequence types is '
+ 'support for\n'
+ 'the "hash()" built-in.\n'
+ '\n'
+ 'This support allows immutable sequences, such as "tuple" '
+ 'instances, to\n'
+ 'be used as "dict" keys and stored in "set" and "frozenset" '
+ 'instances.\n'
+ '\n'
+ 'Attempting to hash an immutable sequence that contains '
+ 'unhashable\n'
+ 'values will result in "TypeError".\n'
+ '\n'
+ '\n'
+ 'Mutable Sequence Types\n'
+ '======================\n'
+ '\n'
+ 'The operations in the following table are defined on mutable '
+ 'sequence\n'
+ 'types. The "collections.abc.MutableSequence" ABC is provided to '
+ 'make\n'
+ 'it easier to correctly implement these operations on custom '
+ 'sequence\n'
+ 'types.\n'
+ '\n'
+ 'In the table *s* is an instance of a mutable sequence type, *t* '
+ 'is any\n'
+ 'iterable object and *x* is an arbitrary object that meets any '
+ 'type and\n'
+ 'value restrictions imposed by *s* (for example, "bytearray" '
+ 'only\n'
+ 'accepts integers that meet the value restriction "0 <= x <= '
+ '255").\n'
+ '\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| Operation | '
+ 'Result | Notes |\n'
+ '+================================+==================================+=======================+\n'
+ '| "s[i] = x" | item *i* of *s* is replaced '
+ 'by | |\n'
+ '| | '
+ '*x* | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s[i:j] = t" | slice of *s* from *i* to *j* '
+ 'is | |\n'
+ '| | replaced by the contents of '
+ 'the | |\n'
+ '| | iterable '
+ '*t* | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "del s[i:j]" | same as "s[i:j] = '
+ '[]" | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s[i:j:k] = t" | the elements of "s[i:j:k]" '
+ 'are | (1) |\n'
+ '| | replaced by those of '
+ '*t* | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "del s[i:j:k]" | removes the elements '
+ 'of | |\n'
+ '| | "s[i:j:k]" from the '
+ 'list | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s.append(x)" | appends *x* to the end of '
+ 'the | |\n'
+ '| | sequence (same '
+ 'as | |\n'
+ '| | "s[len(s):len(s)] = '
+ '[x]") | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s.clear()" | removes all items from "s" '
+ '(same | (5) |\n'
+ '| | as "del '
+ 's[:]") | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s.copy()" | creates a shallow copy of '
+ '"s" | (5) |\n'
+ '| | (same as '
+ '"s[:]") | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s.extend(t)" or "s += t" | extends *s* with the contents '
+ 'of | |\n'
+ '| | *t* (for the most part the '
+ 'same | |\n'
+ '| | as "s[len(s):len(s)] = '
+ 't") | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s *= n" | updates *s* with its '
+ 'contents | (6) |\n'
+ '| | repeated *n* '
+ 'times | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s.insert(i, x)" | inserts *x* into *s* at '
+ 'the | |\n'
+ '| | index given by *i* (same '
+ 'as | |\n'
+ '| | "s[i:i] = '
+ '[x]") | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s.pop([i])" | retrieves the item at *i* '
+ 'and | (2) |\n'
+ '| | also removes it from '
+ '*s* | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s.remove(x)" | remove the first item from '
+ '*s* | (3) |\n'
+ '| | where "s[i] == '
+ 'x" | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s.reverse()" | reverses the items of *s* '
+ 'in | (4) |\n'
+ '| | '
+ 'place | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '\n'
+ 'Notes:\n'
+ '\n'
+ '1. *t* must have the same length as the slice it is replacing.\n'
+ '\n'
+ '2. The optional argument *i* defaults to "-1", so that by '
+ 'default\n'
+ ' the last item is removed and returned.\n'
+ '\n'
+ '3. "remove" raises "ValueError" when *x* is not found in *s*.\n'
+ '\n'
+ '4. The "reverse()" method modifies the sequence in place for\n'
+ ' economy of space when reversing a large sequence. To remind '
+ 'users\n'
+ ' that it operates by side effect, it does not return the '
+ 'reversed\n'
+ ' sequence.\n'
+ '\n'
+ '5. "clear()" and "copy()" are included for consistency with the\n'
+ " interfaces of mutable containers that don't support slicing\n"
+ ' operations (such as "dict" and "set")\n'
+ '\n'
+ ' New in version 3.3: "clear()" and "copy()" methods.\n'
+ '\n'
+ '6. The value *n* is an integer, or an object implementing\n'
+ ' "__index__()". Zero and negative values of *n* clear the '
+ 'sequence.\n'
+ ' Items in the sequence are not copied; they are referenced '
+ 'multiple\n'
+ ' times, as explained for "s * n" under Common Sequence '
+ 'Operations.\n'
+ '\n'
+ '\n'
+ 'Lists\n'
+ '=====\n'
+ '\n'
+ 'Lists are mutable sequences, typically used to store collections '
+ 'of\n'
+ 'homogeneous items (where the precise degree of similarity will '
+ 'vary by\n'
+ 'application).\n'
+ '\n'
+ 'class list([iterable])\n'
+ '\n'
+ ' Lists may be constructed in several ways:\n'
+ '\n'
+ ' * Using a pair of square brackets to denote the empty list: '
+ '"[]"\n'
+ '\n'
+ ' * Using square brackets, separating items with commas: '
+ '"[a]",\n'
+ ' "[a, b, c]"\n'
+ '\n'
+ ' * Using a list comprehension: "[x for x in iterable]"\n'
+ '\n'
+ ' * Using the type constructor: "list()" or "list(iterable)"\n'
+ '\n'
+ ' The constructor builds a list whose items are the same and in '
+ 'the\n'
+ " same order as *iterable*'s items. *iterable* may be either "
+ 'a\n'
+ ' sequence, a container that supports iteration, or an '
+ 'iterator\n'
+ ' object. If *iterable* is already a list, a copy is made and\n'
+ ' returned, similar to "iterable[:]". For example, '
+ '"list(\'abc\')"\n'
+ ' returns "[\'a\', \'b\', \'c\']" and "list( (1, 2, 3) )" '
+ 'returns "[1, 2,\n'
+ ' 3]". If no argument is given, the constructor creates a new '
+ 'empty\n'
+ ' list, "[]".\n'
+ '\n'
+ ' Many other operations also produce lists, including the '
+ '"sorted()"\n'
+ ' built-in.\n'
+ '\n'
+ ' Lists implement all of the common and mutable sequence '
+ 'operations.\n'
+ ' Lists also provide the following additional method:\n'
+ '\n'
+ ' sort(*, key=None, reverse=None)\n'
+ '\n'
+ ' This method sorts the list in place, using only "<" '
+ 'comparisons\n'
+ ' between items. Exceptions are not suppressed - if any '
+ 'comparison\n'
+ ' operations fail, the entire sort operation will fail (and '
+ 'the\n'
+ ' list will likely be left in a partially modified state).\n'
+ '\n'
+ ' "sort()" accepts two arguments that can only be passed by\n'
+ ' keyword (keyword-only arguments):\n'
+ '\n'
+ ' *key* specifies a function of one argument that is used '
+ 'to\n'
+ ' extract a comparison key from each list element (for '
+ 'example,\n'
+ ' "key=str.lower"). The key corresponding to each item in '
+ 'the list\n'
+ ' is calculated once and then used for the entire sorting '
+ 'process.\n'
+ ' The default value of "None" means that list items are '
+ 'sorted\n'
+ ' directly without calculating a separate key value.\n'
+ '\n'
+ ' The "functools.cmp_to_key()" utility is available to '
+ 'convert a\n'
+ ' 2.x style *cmp* function to a *key* function.\n'
+ '\n'
+ ' *reverse* is a boolean value. If set to "True", then the '
+ 'list\n'
+ ' elements are sorted as if each comparison were reversed.\n'
+ '\n'
+ ' This method modifies the sequence in place for economy of '
+ 'space\n'
+ ' when sorting a large sequence. To remind users that it '
+ 'operates\n'
+ ' by side effect, it does not return the sorted sequence '
+ '(use\n'
+ ' "sorted()" to explicitly request a new sorted list '
+ 'instance).\n'
+ '\n'
+ ' The "sort()" method is guaranteed to be stable. A sort '
+ 'is\n'
+ ' stable if it guarantees not to change the relative order '
+ 'of\n'
+ ' elements that compare equal --- this is helpful for '
+ 'sorting in\n'
+ ' multiple passes (for example, sort by department, then by '
+ 'salary\n'
+ ' grade).\n'
+ '\n'
+ ' **CPython implementation detail:** While a list is being '
+ 'sorted,\n'
+ ' the effect of attempting to mutate, or even inspect, the '
+ 'list is\n'
+ ' undefined. The C implementation of Python makes the list '
+ 'appear\n'
+ ' empty for the duration, and raises "ValueError" if it can '
+ 'detect\n'
+ ' that the list has been mutated during a sort.\n'
+ '\n'
+ '\n'
+ 'Tuples\n'
+ '======\n'
+ '\n'
+ 'Tuples are immutable sequences, typically used to store '
+ 'collections of\n'
+ 'heterogeneous data (such as the 2-tuples produced by the '
+ '"enumerate()"\n'
+ 'built-in). Tuples are also used for cases where an immutable '
+ 'sequence\n'
+ 'of homogeneous data is needed (such as allowing storage in a '
+ '"set" or\n'
+ '"dict" instance).\n'
+ '\n'
+ 'class tuple([iterable])\n'
+ '\n'
+ ' Tuples may be constructed in a number of ways:\n'
+ '\n'
+ ' * Using a pair of parentheses to denote the empty tuple: '
+ '"()"\n'
+ '\n'
+ ' * Using a trailing comma for a singleton tuple: "a," or '
+ '"(a,)"\n'
+ '\n'
+ ' * Separating items with commas: "a, b, c" or "(a, b, c)"\n'
+ '\n'
+ ' * Using the "tuple()" built-in: "tuple()" or '
+ '"tuple(iterable)"\n'
+ '\n'
+ ' The constructor builds a tuple whose items are the same and '
+ 'in the\n'
+ " same order as *iterable*'s items. *iterable* may be either "
+ 'a\n'
+ ' sequence, a container that supports iteration, or an '
+ 'iterator\n'
+ ' object. If *iterable* is already a tuple, it is returned\n'
+ ' unchanged. For example, "tuple(\'abc\')" returns "(\'a\', '
+ '\'b\', \'c\')"\n'
+ ' and "tuple( [1, 2, 3] )" returns "(1, 2, 3)". If no argument '
+ 'is\n'
+ ' given, the constructor creates a new empty tuple, "()".\n'
+ '\n'
+ ' Note that it is actually the comma which makes a tuple, not '
+ 'the\n'
+ ' parentheses. The parentheses are optional, except in the '
+ 'empty\n'
+ ' tuple case, or when they are needed to avoid syntactic '
+ 'ambiguity.\n'
+ ' For example, "f(a, b, c)" is a function call with three '
+ 'arguments,\n'
+ ' while "f((a, b, c))" is a function call with a 3-tuple as the '
+ 'sole\n'
+ ' argument.\n'
+ '\n'
+ ' Tuples implement all of the common sequence operations.\n'
+ '\n'
+ 'For heterogeneous collections of data where access by name is '
+ 'clearer\n'
+ 'than access by index, "collections.namedtuple()" may be a more\n'
+ 'appropriate choice than a simple tuple object.\n'
+ '\n'
+ '\n'
+ 'Ranges\n'
+ '======\n'
+ '\n'
+ 'The "range" type represents an immutable sequence of numbers and '
+ 'is\n'
+ 'commonly used for looping a specific number of times in "for" '
+ 'loops.\n'
+ '\n'
+ 'class range(stop)\n'
+ 'class range(start, stop[, step])\n'
+ '\n'
+ ' The arguments to the range constructor must be integers '
+ '(either\n'
+ ' built-in "int" or any object that implements the "__index__"\n'
+ ' special method). If the *step* argument is omitted, it '
+ 'defaults to\n'
+ ' "1". If the *start* argument is omitted, it defaults to "0". '
+ 'If\n'
+ ' *step* is zero, "ValueError" is raised.\n'
+ '\n'
+ ' For a positive *step*, the contents of a range "r" are '
+ 'determined\n'
+ ' by the formula "r[i] = start + step*i" where "i >= 0" and '
+ '"r[i] <\n'
+ ' stop".\n'
+ '\n'
+ ' For a negative *step*, the contents of the range are still\n'
+ ' determined by the formula "r[i] = start + step*i", but the\n'
+ ' constraints are "i >= 0" and "r[i] > stop".\n'
+ '\n'
+ ' A range object will be empty if "r[0]" does not meet the '
+ 'value\n'
+ ' constraint. Ranges do support negative indices, but these '
+ 'are\n'
+ ' interpreted as indexing from the end of the sequence '
+ 'determined by\n'
+ ' the positive indices.\n'
+ '\n'
+ ' Ranges containing absolute values larger than "sys.maxsize" '
+ 'are\n'
+ ' permitted but some features (such as "len()") may raise\n'
+ ' "OverflowError".\n'
+ '\n'
+ ' Range examples:\n'
+ '\n'
+ ' >>> list(range(10))\n'
+ ' [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n'
+ ' >>> list(range(1, 11))\n'
+ ' [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n'
+ ' >>> list(range(0, 30, 5))\n'
+ ' [0, 5, 10, 15, 20, 25]\n'
+ ' >>> list(range(0, 10, 3))\n'
+ ' [0, 3, 6, 9]\n'
+ ' >>> list(range(0, -10, -1))\n'
+ ' [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]\n'
+ ' >>> list(range(0))\n'
+ ' []\n'
+ ' >>> list(range(1, 0))\n'
+ ' []\n'
+ '\n'
+ ' Ranges implement all of the common sequence operations '
+ 'except\n'
+ ' concatenation and repetition (due to the fact that range '
+ 'objects\n'
+ ' can only represent sequences that follow a strict pattern '
+ 'and\n'
+ ' repetition and concatenation will usually violate that '
+ 'pattern).\n'
+ '\n'
+ ' start\n'
+ '\n'
+ ' The value of the *start* parameter (or "0" if the '
+ 'parameter was\n'
+ ' not supplied)\n'
+ '\n'
+ ' stop\n'
+ '\n'
+ ' The value of the *stop* parameter\n'
+ '\n'
+ ' step\n'
+ '\n'
+ ' The value of the *step* parameter (or "1" if the parameter '
+ 'was\n'
+ ' not supplied)\n'
+ '\n'
+ 'The advantage of the "range" type over a regular "list" or '
+ '"tuple" is\n'
+ 'that a "range" object will always take the same (small) amount '
+ 'of\n'
+ 'memory, no matter the size of the range it represents (as it '
+ 'only\n'
+ 'stores the "start", "stop" and "step" values, calculating '
+ 'individual\n'
+ 'items and subranges as needed).\n'
+ '\n'
+ 'Range objects implement the "collections.abc.Sequence" ABC, and\n'
+ 'provide features such as containment tests, element index '
+ 'lookup,\n'
+ 'slicing and support for negative indices (see Sequence Types --- '
+ 'list,\n'
+ 'tuple, range):\n'
+ '\n'
+ '>>> r = range(0, 20, 2)\n'
+ '>>> r\n'
+ 'range(0, 20, 2)\n'
+ '>>> 11 in r\n'
+ 'False\n'
+ '>>> 10 in r\n'
+ 'True\n'
+ '>>> r.index(10)\n'
+ '5\n'
+ '>>> r[5]\n'
+ '10\n'
+ '>>> r[:5]\n'
+ 'range(0, 10, 2)\n'
+ '>>> r[-1]\n'
+ '18\n'
+ '\n'
+ 'Testing range objects for equality with "==" and "!=" compares '
+ 'them as\n'
+ 'sequences. That is, two range objects are considered equal if '
+ 'they\n'
+ 'represent the same sequence of values. (Note that two range '
+ 'objects\n'
+ 'that compare equal might have different "start", "stop" and '
+ '"step"\n'
+ 'attributes, for example "range(0) == range(2, 1, 3)" or '
+ '"range(0, 3,\n'
+ '2) == range(0, 4, 2)".)\n'
+ '\n'
+ 'Changed in version 3.2: Implement the Sequence ABC. Support '
+ 'slicing\n'
+ 'and negative indices. Test "int" objects for membership in '
+ 'constant\n'
+ 'time instead of iterating through all items.\n'
+ '\n'
+ "Changed in version 3.3: Define '==' and '!=' to compare range "
+ 'objects\n'
+ 'based on the sequence of values they define (instead of '
+ 'comparing\n'
+ 'based on object identity).\n'
+ '\n'
+ 'New in version 3.3: The "start", "stop" and "step" attributes.\n',
+ 'typesseq-mutable': '\n'
+ 'Mutable Sequence Types\n'
+ '**********************\n'
+ '\n'
+ 'The operations in the following table are defined on '
+ 'mutable sequence\n'
+ 'types. The "collections.abc.MutableSequence" ABC is '
+ 'provided to make\n'
+ 'it easier to correctly implement these operations on '
+ 'custom sequence\n'
+ 'types.\n'
+ '\n'
+ 'In the table *s* is an instance of a mutable sequence '
+ 'type, *t* is any\n'
+ 'iterable object and *x* is an arbitrary object that '
+ 'meets any type and\n'
+ 'value restrictions imposed by *s* (for example, '
+ '"bytearray" only\n'
+ 'accepts integers that meet the value restriction "0 <= x '
+ '<= 255").\n'
+ '\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| Operation | '
+ 'Result | Notes '
+ '|\n'
+ '+================================+==================================+=======================+\n'
+ '| "s[i] = x" | item *i* of *s* is '
+ 'replaced by | |\n'
+ '| | '
+ '*x* | '
+ '|\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s[i:j] = t" | slice of *s* from *i* '
+ 'to *j* is | |\n'
+ '| | replaced by the '
+ 'contents of the | |\n'
+ '| | iterable '
+ '*t* | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "del s[i:j]" | same as "s[i:j] = '
+ '[]" | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s[i:j:k] = t" | the elements of '
+ '"s[i:j:k]" are | (1) |\n'
+ '| | replaced by those of '
+ '*t* | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "del s[i:j:k]" | removes the elements '
+ 'of | |\n'
+ '| | "s[i:j:k]" from the '
+ 'list | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s.append(x)" | appends *x* to the '
+ 'end of the | |\n'
+ '| | sequence (same '
+ 'as | |\n'
+ '| | "s[len(s):len(s)] = '
+ '[x]") | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s.clear()" | removes all items '
+ 'from "s" (same | (5) |\n'
+ '| | as "del '
+ 's[:]") | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s.copy()" | creates a shallow '
+ 'copy of "s" | (5) |\n'
+ '| | (same as '
+ '"s[:]") | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s.extend(t)" or "s += t" | extends *s* with the '
+ 'contents of | |\n'
+ '| | *t* (for the most '
+ 'part the same | |\n'
+ '| | as "s[len(s):len(s)] '
+ '= t") | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s *= n" | updates *s* with its '
+ 'contents | (6) |\n'
+ '| | repeated *n* '
+ 'times | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s.insert(i, x)" | inserts *x* into *s* '
+ 'at the | |\n'
+ '| | index given by *i* '
+ '(same as | |\n'
+ '| | "s[i:i] = '
+ '[x]") | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s.pop([i])" | retrieves the item at '
+ '*i* and | (2) |\n'
+ '| | also removes it from '
+ '*s* | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s.remove(x)" | remove the first item '
+ 'from *s* | (3) |\n'
+ '| | where "s[i] == '
+ 'x" | |\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '| "s.reverse()" | reverses the items of '
+ '*s* in | (4) |\n'
+ '| | '
+ 'place | '
+ '|\n'
+ '+--------------------------------+----------------------------------+-----------------------+\n'
+ '\n'
+ 'Notes:\n'
+ '\n'
+ '1. *t* must have the same length as the slice it is '
+ 'replacing.\n'
+ '\n'
+ '2. The optional argument *i* defaults to "-1", so that '
+ 'by default\n'
+ ' the last item is removed and returned.\n'
+ '\n'
+ '3. "remove" raises "ValueError" when *x* is not found in '
+ '*s*.\n'
+ '\n'
+ '4. The "reverse()" method modifies the sequence in place '
+ 'for\n'
+ ' economy of space when reversing a large sequence. To '
+ 'remind users\n'
+ ' that it operates by side effect, it does not return '
+ 'the reversed\n'
+ ' sequence.\n'
+ '\n'
+ '5. "clear()" and "copy()" are included for consistency '
+ 'with the\n'
+ " interfaces of mutable containers that don't support "
+ 'slicing\n'
+ ' operations (such as "dict" and "set")\n'
+ '\n'
+ ' New in version 3.3: "clear()" and "copy()" methods.\n'
+ '\n'
+ '6. The value *n* is an integer, or an object '
+ 'implementing\n'
+ ' "__index__()". Zero and negative values of *n* clear '
+ 'the sequence.\n'
+ ' Items in the sequence are not copied; they are '
+ 'referenced multiple\n'
+ ' times, as explained for "s * n" under Common Sequence '
+ 'Operations.\n',
+ 'unary': '\n'
+ 'Unary arithmetic and bitwise operations\n'
+ '***************************************\n'
+ '\n'
+ 'All unary arithmetic and bitwise operations have the same '
+ 'priority:\n'
+ '\n'
+ ' u_expr ::= power | "-" u_expr | "+" u_expr | "~" u_expr\n'
+ '\n'
+ 'The unary "-" (minus) operator yields the negation of its numeric\n'
+ 'argument.\n'
+ '\n'
+ 'The unary "+" (plus) operator yields its numeric argument '
+ 'unchanged.\n'
+ '\n'
+ 'The unary "~" (invert) operator yields the bitwise inversion of '
+ 'its\n'
+ 'integer argument. The bitwise inversion of "x" is defined as\n'
+ '"-(x+1)". It only applies to integral numbers.\n'
+ '\n'
+ 'In all three cases, if the argument does not have the proper type, '
+ 'a\n'
+ '"TypeError" exception is raised.\n',
+ 'while': '\n'
+ 'The "while" statement\n'
+ '*********************\n'
+ '\n'
+ 'The "while" statement is used for repeated execution as long as an\n'
+ 'expression is true:\n'
+ '\n'
+ ' while_stmt ::= "while" expression ":" suite\n'
+ ' ["else" ":" suite]\n'
+ '\n'
+ 'This repeatedly tests the expression and, if it is true, executes '
+ 'the\n'
+ 'first suite; if the expression is false (which may be the first '
+ 'time\n'
+ 'it is tested) the suite of the "else" clause, if present, is '
+ 'executed\n'
+ 'and the loop terminates.\n'
+ '\n'
+ 'A "break" statement executed in the first suite terminates the '
+ 'loop\n'
+ 'without executing the "else" clause\'s suite. A "continue" '
+ 'statement\n'
+ 'executed in the first suite skips the rest of the suite and goes '
+ 'back\n'
+ 'to testing the expression.\n',
+ 'with': '\n'
+ 'The "with" statement\n'
+ '********************\n'
+ '\n'
+ 'The "with" statement is used to wrap the execution of a block with\n'
+ 'methods defined by a context manager (see section With Statement\n'
+ 'Context Managers). This allows common "try"..."except"..."finally"\n'
+ 'usage patterns to be encapsulated for convenient reuse.\n'
+ '\n'
+ ' with_stmt ::= "with" with_item ("," with_item)* ":" suite\n'
+ ' with_item ::= expression ["as" target]\n'
+ '\n'
+ 'The execution of the "with" statement with one "item" proceeds as\n'
+ 'follows:\n'
+ '\n'
+ '1. The context expression (the expression given in the "with_item")\n'
+ ' is evaluated to obtain a context manager.\n'
+ '\n'
+ '2. The context manager\'s "__exit__()" is loaded for later use.\n'
+ '\n'
+ '3. The context manager\'s "__enter__()" method is invoked.\n'
+ '\n'
+ '4. If a target was included in the "with" statement, the return\n'
+ ' value from "__enter__()" is assigned to it.\n'
+ '\n'
+ ' Note: The "with" statement guarantees that if the "__enter__()"\n'
+ ' method returns without an error, then "__exit__()" will always '
+ 'be\n'
+ ' called. Thus, if an error occurs during the assignment to the\n'
+ ' target list, it will be treated the same as an error occurring\n'
+ ' within the suite would be. See step 6 below.\n'
+ '\n'
+ '5. The suite is executed.\n'
+ '\n'
+ '6. The context manager\'s "__exit__()" method is invoked. If an\n'
+ ' exception caused the suite to be exited, its type, value, and\n'
+ ' traceback are passed as arguments to "__exit__()". Otherwise, '
+ 'three\n'
+ ' "None" arguments are supplied.\n'
+ '\n'
+ ' If the suite was exited due to an exception, and the return '
+ 'value\n'
+ ' from the "__exit__()" method was false, the exception is '
+ 'reraised.\n'
+ ' If the return value was true, the exception is suppressed, and\n'
+ ' execution continues with the statement following the "with"\n'
+ ' statement.\n'
+ '\n'
+ ' If the suite was exited for any reason other than an exception, '
+ 'the\n'
+ ' return value from "__exit__()" is ignored, and execution '
+ 'proceeds\n'
+ ' at the normal location for the kind of exit that was taken.\n'
+ '\n'
+ 'With more than one item, the context managers are processed as if\n'
+ 'multiple "with" statements were nested:\n'
+ '\n'
+ ' with A() as a, B() as b:\n'
+ ' suite\n'
+ '\n'
+ 'is equivalent to\n'
+ '\n'
+ ' with A() as a:\n'
+ ' with B() as b:\n'
+ ' suite\n'
+ '\n'
+ 'Changed in version 3.1: Support for multiple context expressions.\n'
+ '\n'
+ 'See also:\n'
+ '\n'
+ ' **PEP 343** - The "with" statement\n'
+ ' The specification, background, and examples for the Python '
+ '"with"\n'
+ ' statement.\n',
+ 'yield': '\n'
+ 'The "yield" statement\n'
+ '*********************\n'
+ '\n'
+ ' yield_stmt ::= yield_expression\n'
+ '\n'
+ 'A "yield" statement is semantically equivalent to a yield '
+ 'expression.\n'
+ 'The yield statement can be used to omit the parentheses that would\n'
+ 'otherwise be required in the equivalent yield expression '
+ 'statement.\n'
+ 'For example, the yield statements\n'
+ '\n'
+ ' yield <expr>\n'
+ ' yield from <expr>\n'
+ '\n'
+ 'are equivalent to the yield expression statements\n'
+ '\n'
+ ' (yield <expr>)\n'
+ ' (yield from <expr>)\n'
+ '\n'
+ 'Yield expressions and statements are only used when defining a\n'
+ '*generator* function, and are only used in the body of the '
+ 'generator\n'
+ 'function. Using yield in a function definition is sufficient to '
+ 'cause\n'
+ 'that definition to create a generator function instead of a normal\n'
+ 'function.\n'
+ '\n'
+ 'For full details of "yield" semantics, refer to the Yield '
+ 'expressions\n'
+ 'section.\n'}
diff --git a/Lib/random.py b/Lib/random.py
index 5950735..1cffb0a 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -606,11 +606,11 @@
# This version due to Janne Sinkkonen, and matches all the std
# texts (e.g., Knuth Vol 2 Ed 3 pg 134 "the beta distribution").
- y = self.gammavariate(alpha, 1.)
+ y = self.gammavariate(alpha, 1.0)
if y == 0:
return 0.0
else:
- return y / (y + self.gammavariate(beta, 1.))
+ return y / (y + self.gammavariate(beta, 1.0))
## -------------------- Pareto --------------------
diff --git a/Lib/re.py b/Lib/re.py
index dde8901..661929e 100644
--- a/Lib/re.py
+++ b/Lib/re.py
@@ -119,7 +119,6 @@
"""
-import sys
import sre_compile
import sre_parse
try:
diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py
index 401a626..bca4a7b 100644
--- a/Lib/rlcompleter.py
+++ b/Lib/rlcompleter.py
@@ -113,6 +113,12 @@
for word in keyword.kwlist:
if word[:n] == text:
seen.add(word)
+ if word in {'finally', 'try'}:
+ word = word + ':'
+ elif word not in {'False', 'None', 'True',
+ 'break', 'continue', 'pass',
+ 'else'}:
+ word = word + ' '
matches.append(word)
for nspace in [self.namespace, builtins.__dict__]:
for word, val in nspace.items():
@@ -152,14 +158,30 @@
words.update(get_class_members(thisobject.__class__))
matches = []
n = len(attr)
- for word in words:
- if word[:n] == attr:
- try:
- val = getattr(thisobject, word)
- except Exception:
- continue # Exclude properties that are not set
- word = self._callable_postfix(val, "%s.%s" % (expr, word))
- matches.append(word)
+ if attr == '':
+ noprefix = '_'
+ elif attr == '_':
+ noprefix = '__'
+ else:
+ noprefix = None
+ while True:
+ for word in words:
+ if (word[:n] == attr and
+ not (noprefix and word[:n+1] == noprefix)):
+ match = "%s.%s" % (expr, word)
+ try:
+ val = getattr(thisobject, word)
+ except Exception:
+ pass # Include even if attribute not set
+ else:
+ match = self._callable_postfix(val, match)
+ matches.append(match)
+ if matches or not noprefix:
+ break
+ if noprefix == '_':
+ noprefix = '__'
+ else:
+ noprefix = None
matches.sort()
return matches
diff --git a/Lib/sched.py b/Lib/sched.py
index b47648d..bd7c0f1 100644
--- a/Lib/sched.py
+++ b/Lib/sched.py
@@ -46,6 +46,17 @@
def __gt__(s, o): return (s.time, s.priority) > (o.time, o.priority)
def __ge__(s, o): return (s.time, s.priority) >= (o.time, o.priority)
+Event.time.__doc__ = ('''Numeric type compatible with the return value of the
+timefunc function passed to the constructor.''')
+Event.priority.__doc__ = ('''Events scheduled for the same time will be executed
+in the order of their priority.''')
+Event.action.__doc__ = ('''Executing the event means executing
+action(*argument, **kwargs)''')
+Event.argument.__doc__ = ('''argument is a sequence holding the positional
+arguments for the action.''')
+Event.kwargs.__doc__ = ('''kwargs is a dictionary holding the keyword
+arguments for the action.''')
+
_sentinel = object()
class scheduler:
diff --git a/Lib/secrets.py b/Lib/secrets.py
new file mode 100644
index 0000000..27fa450
--- /dev/null
+++ b/Lib/secrets.py
@@ -0,0 +1,71 @@
+"""Generate cryptographically strong pseudo-random numbers suitable for
+managing secrets such as account authentication, tokens, and similar.
+
+See PEP 506 for more information.
+https://www.python.org/dev/peps/pep-0506/
+
+"""
+
+__all__ = ['choice', 'randbelow', 'randbits', 'SystemRandom',
+ 'token_bytes', 'token_hex', 'token_urlsafe',
+ 'compare_digest',
+ ]
+
+
+import base64
+import binascii
+import os
+
+from hmac import compare_digest
+from random import SystemRandom
+
+_sysrand = SystemRandom()
+
+randbits = _sysrand.getrandbits
+choice = _sysrand.choice
+
+def randbelow(exclusive_upper_bound):
+ """Return a random int in the range [0, n)."""
+ return _sysrand._randbelow(exclusive_upper_bound)
+
+DEFAULT_ENTROPY = 32 # number of bytes to return by default
+
+def token_bytes(nbytes=None):
+ """Return a random byte string containing *nbytes* bytes.
+
+ If *nbytes* is ``None`` or not supplied, a reasonable
+ default is used.
+
+ >>> token_bytes(16) #doctest:+SKIP
+ b'\\xebr\\x17D*t\\xae\\xd4\\xe3S\\xb6\\xe2\\xebP1\\x8b'
+
+ """
+ if nbytes is None:
+ nbytes = DEFAULT_ENTROPY
+ return os.urandom(nbytes)
+
+def token_hex(nbytes=None):
+ """Return a random text string, in hexadecimal.
+
+ The string has *nbytes* random bytes, each byte converted to two
+ hex digits. If *nbytes* is ``None`` or not supplied, a reasonable
+ default is used.
+
+ >>> token_hex(16) #doctest:+SKIP
+ 'f9bf78b9a18ce6d46a0cd2b0b86df9da'
+
+ """
+ return binascii.hexlify(token_bytes(nbytes)).decode('ascii')
+
+def token_urlsafe(nbytes=None):
+ """Return a random URL-safe text string, in Base64 encoding.
+
+ The string has *nbytes* random bytes. If *nbytes* is ``None``
+ or not supplied, a reasonable default is used.
+
+ >>> token_urlsafe(16) #doctest:+SKIP
+ 'Drmhze6EPcv0fN_81Bj-nA'
+
+ """
+ tok = token_bytes(nbytes)
+ return base64.urlsafe_b64encode(tok).rstrip(b'=').decode('ascii')
diff --git a/Lib/shutil.py b/Lib/shutil.py
index 37124a0..b1953cc 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -974,6 +974,9 @@
__all__.append('disk_usage')
_ntuple_diskusage = collections.namedtuple('usage', 'total used free')
+ _ntuple_diskusage.total.__doc__ = 'Total space in bytes'
+ _ntuple_diskusage.used.__doc__ = 'Used space in bytes'
+ _ntuple_diskusage.free.__doc__ = 'Free space in bytes'
def disk_usage(path):
"""Return disk usage statistics about the given path.
diff --git a/Lib/site-packages/README.txt b/Lib/site-packages/README.txt
new file mode 100644
index 0000000..273f625
--- /dev/null
+++ b/Lib/site-packages/README.txt
@@ -0,0 +1,2 @@
+This directory exists so that 3rd party packages can be installed
+here. Read the source for site.py for more details.
diff --git a/Lib/site.py b/Lib/site.py
index 3f78ef5..a84e3bb 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -131,13 +131,13 @@
def _init_pathinfo():
- """Return a set containing all existing directory entries from sys.path"""
+ """Return a set containing all existing file system items from sys.path."""
d = set()
- for dir in sys.path:
+ for item in sys.path:
try:
- if os.path.isdir(dir):
- dir, dircase = makepath(dir)
- d.add(dircase)
+ if os.path.exists(item):
+ _, itemcase = makepath(item)
+ d.add(itemcase)
except TypeError:
continue
return d
@@ -150,9 +150,9 @@
"""
if known_paths is None:
known_paths = _init_pathinfo()
- reset = 1
+ reset = True
else:
- reset = 0
+ reset = False
fullname = os.path.join(sitedir, name)
try:
f = open(fullname, "r")
@@ -190,9 +190,9 @@
'sitedir'"""
if known_paths is None:
known_paths = _init_pathinfo()
- reset = 1
+ reset = True
else:
- reset = 0
+ reset = False
sitedir, sitedircase = makepath(sitedir)
if not sitedircase in known_paths:
sys.path.append(sitedir) # Add path component
@@ -304,7 +304,7 @@
if os.sep == '/':
sitepackages.append(os.path.join(prefix, "lib",
- "python" + sys.version[:3],
+ "python%d.%d" % sys.version_info[:2],
"site-packages"))
else:
sitepackages.append(prefix)
@@ -317,7 +317,7 @@
if framework:
sitepackages.append(
os.path.join("/Library", framework,
- sys.version[:3], "site-packages"))
+ '%d.%d' % sys.version_info[:2], "site-packages"))
return sitepackages
def addsitepackages(known_paths, prefixes=None):
@@ -504,9 +504,13 @@
def execsitecustomize():
"""Run custom site specific code, if available."""
try:
- import sitecustomize
- except ImportError:
- pass
+ try:
+ import sitecustomize
+ except ImportError as exc:
+ if exc.name == 'sitecustomize':
+ pass
+ else:
+ raise
except Exception as err:
if os.environ.get("PYTHONVERBOSE"):
sys.excepthook(*sys.exc_info())
@@ -520,9 +524,13 @@
def execusercustomize():
"""Run custom user specific code, if available."""
try:
- import usercustomize
- except ImportError:
- pass
+ try:
+ import usercustomize
+ except ImportError as exc:
+ if exc.name == 'usercustomize':
+ pass
+ else:
+ raise
except Exception as err:
if os.environ.get("PYTHONVERBOSE"):
sys.excepthook(*sys.exc_info())
diff --git a/Lib/smtpd.py b/Lib/smtpd.py
index 732066e..8103ca9 100755
--- a/Lib/smtpd.py
+++ b/Lib/smtpd.py
@@ -89,7 +89,10 @@
from warnings import warn
from email._header_value_parser import get_addr_spec, get_angle_addr
-__all__ = ["SMTPServer","DebuggingServer","PureProxy","MailmanProxy"]
+__all__ = [
+ "SMTPChannel", "SMTPServer", "DebuggingServer", "PureProxy",
+ "MailmanProxy",
+]
program = sys.argv[0]
__version__ = 'Python SMTP proxy version 0.3'
@@ -128,24 +131,17 @@
return self.command_size_limit
def __init__(self, server, conn, addr, data_size_limit=DATA_SIZE_DEFAULT,
- map=None, enable_SMTPUTF8=False, decode_data=None):
+ map=None, enable_SMTPUTF8=False, decode_data=False):
asynchat.async_chat.__init__(self, conn, map=map)
self.smtp_server = server
self.conn = conn
self.addr = addr
self.data_size_limit = data_size_limit
self.enable_SMTPUTF8 = enable_SMTPUTF8
- if enable_SMTPUTF8:
- if decode_data:
- raise ValueError("decode_data and enable_SMTPUTF8 cannot"
- " be set to True at the same time")
- decode_data = False
- if decode_data is None:
- warn("The decode_data default of True will change to False in 3.6;"
- " specify an explicit value for this keyword",
- DeprecationWarning, 2)
- decode_data = True
self._decode_data = decode_data
+ if enable_SMTPUTF8 and decode_data:
+ raise ValueError("decode_data and enable_SMTPUTF8 cannot"
+ " be set to True at the same time")
if decode_data:
self._emptystring = ''
self._linesep = '\r\n'
@@ -635,23 +631,15 @@
def __init__(self, localaddr, remoteaddr,
data_size_limit=DATA_SIZE_DEFAULT, map=None,
- enable_SMTPUTF8=False, decode_data=None):
+ enable_SMTPUTF8=False, decode_data=False):
self._localaddr = localaddr
self._remoteaddr = remoteaddr
self.data_size_limit = data_size_limit
self.enable_SMTPUTF8 = enable_SMTPUTF8
- if enable_SMTPUTF8:
- if decode_data:
- raise ValueError("The decode_data and enable_SMTPUTF8"
- " parameters cannot be set to True at the"
- " same time.")
- decode_data = False
- if decode_data is None:
- warn("The decode_data default of True will change to False in 3.6;"
- " specify an explicit value for this keyword",
- DeprecationWarning, 2)
- decode_data = True
self._decode_data = decode_data
+ if enable_SMTPUTF8 and decode_data:
+ raise ValueError("decode_data and enable_SMTPUTF8 cannot"
+ " be set to True at the same time")
asyncore.dispatcher.__init__(self, map=map)
try:
gai_results = socket.getaddrinfo(*localaddr,
@@ -698,9 +686,9 @@
containing a `.' followed by other text has had the leading dot
removed.
- kwargs is a dictionary containing additional information. It is empty
- unless decode_data=False or enable_SMTPUTF8=True was given as init
- parameter, in which case ut will contain the following keys:
+ kwargs is a dictionary containing additional information. It is
+ empty if decode_data=True was given as init parameter, otherwise
+ it will contain the following keys:
'mail_options': list of parameters to the mail command. All
elements are uppercase strings. Example:
['BODY=8BITMIME', 'SMTPUTF8'].
diff --git a/Lib/sndhdr.py b/Lib/sndhdr.py
index e5901ec..7ecafb4 100644
--- a/Lib/sndhdr.py
+++ b/Lib/sndhdr.py
@@ -37,6 +37,18 @@
SndHeaders = namedtuple('SndHeaders',
'filetype framerate nchannels nframes sampwidth')
+SndHeaders.filetype.__doc__ = ("""The value for type indicates the data type
+and will be one of the strings 'aifc', 'aiff', 'au','hcom',
+'sndr', 'sndt', 'voc', 'wav', '8svx', 'sb', 'ub', or 'ul'.""")
+SndHeaders.framerate.__doc__ = ("""The sampling_rate will be either the actual
+value or 0 if unknown or difficult to decode.""")
+SndHeaders.nchannels.__doc__ = ("""The number of channels or 0 if it cannot be
+determined or if the value is difficult to decode.""")
+SndHeaders.nframes.__doc__ = ("""The value for frames will be either the number
+of frames or -1.""")
+SndHeaders.sampwidth.__doc__ = ("""Either the sample size in bits or
+'A' for A-LAW or 'U' for u-LAW.""")
+
def what(filename):
"""Guess the type of a sound file."""
res = whathdr(filename)
diff --git a/Lib/socketserver.py b/Lib/socketserver.py
index 8808813..41a3766 100644
--- a/Lib/socketserver.py
+++ b/Lib/socketserver.py
@@ -127,16 +127,20 @@
import selectors
import os
import errno
+import sys
try:
import threading
except ImportError:
import dummy_threading as threading
+from io import BufferedIOBase
from time import monotonic as time
-__all__ = ["BaseServer", "TCPServer", "UDPServer", "ForkingUDPServer",
- "ForkingTCPServer", "ThreadingUDPServer", "ThreadingTCPServer",
+__all__ = ["BaseServer", "TCPServer", "UDPServer",
+ "ThreadingUDPServer", "ThreadingTCPServer",
"BaseRequestHandler", "StreamRequestHandler",
- "DatagramRequestHandler", "ThreadingMixIn", "ForkingMixIn"]
+ "DatagramRequestHandler", "ThreadingMixIn"]
+if hasattr(os, "fork"):
+ __all__.extend(["ForkingUDPServer","ForkingTCPServer", "ForkingMixIn"])
if hasattr(socket, "AF_UNIX"):
__all__.extend(["UnixStreamServer","UnixDatagramServer",
"ThreadingUnixStreamServer",
@@ -311,9 +315,12 @@
if self.verify_request(request, client_address):
try:
self.process_request(request, client_address)
- except:
+ except Exception:
self.handle_error(request, client_address)
self.shutdown_request(request)
+ except:
+ self.shutdown_request(request)
+ raise
else:
self.shutdown_request(request)
@@ -367,12 +374,18 @@
The default is to print a traceback and continue.
"""
- print('-'*40)
- print('Exception happened during processing of request from', end=' ')
- print(client_address)
+ print('-'*40, file=sys.stderr)
+ print('Exception happened during processing of request from',
+ client_address, file=sys.stderr)
import traceback
- traceback.print_exc() # XXX But this goes to stderr!
- print('-'*40)
+ traceback.print_exc()
+ print('-'*40, file=sys.stderr)
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self, *args):
+ self.server_close()
class TCPServer(BaseServer):
@@ -527,85 +540,86 @@
# No need to close anything.
pass
-class ForkingMixIn:
+if hasattr(os, "fork"):
+ class ForkingMixIn:
+ """Mix-in class to handle each request in a new process."""
- """Mix-in class to handle each request in a new process."""
+ timeout = 300
+ active_children = None
+ max_children = 40
- timeout = 300
- active_children = None
- max_children = 40
-
- def collect_children(self):
- """Internal routine to wait for children that have exited."""
- if self.active_children is None:
- return
-
- # If we're above the max number of children, wait and reap them until
- # we go back below threshold. Note that we use waitpid(-1) below to be
- # able to collect children in size(<defunct children>) syscalls instead
- # of size(<children>): the downside is that this might reap children
- # which we didn't spawn, which is why we only resort to this when we're
- # above max_children.
- while len(self.active_children) >= self.max_children:
- try:
- pid, _ = os.waitpid(-1, 0)
- self.active_children.discard(pid)
- except ChildProcessError:
- # we don't have any children, we're done
- self.active_children.clear()
- except OSError:
- break
-
- # Now reap all defunct children.
- for pid in self.active_children.copy():
- try:
- pid, _ = os.waitpid(pid, os.WNOHANG)
- # if the child hasn't exited yet, pid will be 0 and ignored by
- # discard() below
- self.active_children.discard(pid)
- except ChildProcessError:
- # someone else reaped it
- self.active_children.discard(pid)
- except OSError:
- pass
-
- def handle_timeout(self):
- """Wait for zombies after self.timeout seconds of inactivity.
-
- May be extended, do not override.
- """
- self.collect_children()
-
- def service_actions(self):
- """Collect the zombie child processes regularly in the ForkingMixIn.
-
- service_actions is called in the BaseServer's serve_forver loop.
- """
- self.collect_children()
-
- def process_request(self, request, client_address):
- """Fork a new subprocess to process the request."""
- pid = os.fork()
- if pid:
- # Parent process
+ def collect_children(self):
+ """Internal routine to wait for children that have exited."""
if self.active_children is None:
- self.active_children = set()
- self.active_children.add(pid)
- self.close_request(request)
- return
- else:
- # Child process.
- # This must never return, hence os._exit()!
- try:
- self.finish_request(request, client_address)
- self.shutdown_request(request)
- os._exit(0)
- except:
+ return
+
+ # If we're above the max number of children, wait and reap them until
+ # we go back below threshold. Note that we use waitpid(-1) below to be
+ # able to collect children in size(<defunct children>) syscalls instead
+ # of size(<children>): the downside is that this might reap children
+ # which we didn't spawn, which is why we only resort to this when we're
+ # above max_children.
+ while len(self.active_children) >= self.max_children:
try:
+ pid, _ = os.waitpid(-1, 0)
+ self.active_children.discard(pid)
+ except ChildProcessError:
+ # we don't have any children, we're done
+ self.active_children.clear()
+ except OSError:
+ break
+
+ # Now reap all defunct children.
+ for pid in self.active_children.copy():
+ try:
+ pid, _ = os.waitpid(pid, os.WNOHANG)
+ # if the child hasn't exited yet, pid will be 0 and ignored by
+ # discard() below
+ self.active_children.discard(pid)
+ except ChildProcessError:
+ # someone else reaped it
+ self.active_children.discard(pid)
+ except OSError:
+ pass
+
+ def handle_timeout(self):
+ """Wait for zombies after self.timeout seconds of inactivity.
+
+ May be extended, do not override.
+ """
+ self.collect_children()
+
+ def service_actions(self):
+ """Collect the zombie child processes regularly in the ForkingMixIn.
+
+ service_actions is called in the BaseServer's serve_forver loop.
+ """
+ self.collect_children()
+
+ def process_request(self, request, client_address):
+ """Fork a new subprocess to process the request."""
+ pid = os.fork()
+ if pid:
+ # Parent process
+ if self.active_children is None:
+ self.active_children = set()
+ self.active_children.add(pid)
+ self.close_request(request)
+ return
+ else:
+ # Child process.
+ # This must never return, hence os._exit()!
+ status = 1
+ try:
+ self.finish_request(request, client_address)
+ status = 0
+ except Exception:
self.handle_error(request, client_address)
- self.shutdown_request(request)
finally:
- os._exit(1)
+ try:
+ self.shutdown_request(request)
+ finally:
+ os._exit(status)
class ThreadingMixIn:
@@ -623,9 +637,9 @@
"""
try:
self.finish_request(request, client_address)
- self.shutdown_request(request)
- except:
+ except Exception:
self.handle_error(request, client_address)
+ finally:
self.shutdown_request(request)
def process_request(self, request, client_address):
@@ -636,8 +650,9 @@
t.start()
-class ForkingUDPServer(ForkingMixIn, UDPServer): pass
-class ForkingTCPServer(ForkingMixIn, TCPServer): pass
+if hasattr(os, "fork"):
+ class ForkingUDPServer(ForkingMixIn, UDPServer): pass
+ class ForkingTCPServer(ForkingMixIn, TCPServer): pass
class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass
class ThreadingTCPServer(ThreadingMixIn, TCPServer): pass
@@ -729,7 +744,10 @@
self.connection.setsockopt(socket.IPPROTO_TCP,
socket.TCP_NODELAY, True)
self.rfile = self.connection.makefile('rb', self.rbufsize)
- self.wfile = self.connection.makefile('wb', self.wbufsize)
+ if self.wbufsize == 0:
+ self.wfile = _SocketWriter(self.connection)
+ else:
+ self.wfile = self.connection.makefile('wb', self.wbufsize)
def finish(self):
if not self.wfile.closed:
@@ -742,6 +760,24 @@
self.wfile.close()
self.rfile.close()
+class _SocketWriter(BufferedIOBase):
+ """Simple writable BufferedIOBase implementation for a socket
+
+ Does not hold data in a buffer, avoiding any need to call flush()."""
+
+ def __init__(self, sock):
+ self._sock = sock
+
+ def writable(self):
+ return True
+
+ def write(self, b):
+ self._sock.sendall(b)
+ with memoryview(b) as view:
+ return view.nbytes
+
+ def fileno(self):
+ return self._sock.fileno()
class DatagramRequestHandler(BaseRequestHandler):
diff --git a/Lib/sqlite3/test/dbapi.py b/Lib/sqlite3/test/dbapi.py
index ec42eb7..51c4d53 100644
--- a/Lib/sqlite3/test/dbapi.py
+++ b/Lib/sqlite3/test/dbapi.py
@@ -188,7 +188,10 @@
def setUp(self):
self.cx = sqlite.connect(":memory:")
self.cu = self.cx.cursor()
- self.cu.execute("create table test(id integer primary key, name text, income number)")
+ self.cu.execute(
+ "create table test(id integer primary key, name text, "
+ "income number, unique_test text unique)"
+ )
self.cu.execute("insert into test(name) values (?)", ("foo",))
def tearDown(self):
@@ -462,6 +465,44 @@
with self.assertRaises(TypeError):
cur = sqlite.Cursor(foo)
+ def CheckLastRowIDOnReplace(self):
+ """
+ INSERT OR REPLACE and REPLACE INTO should produce the same behavior.
+ """
+ sql = '{} INTO test(id, unique_test) VALUES (?, ?)'
+ for statement in ('INSERT OR REPLACE', 'REPLACE'):
+ with self.subTest(statement=statement):
+ self.cu.execute(sql.format(statement), (1, 'foo'))
+ self.assertEqual(self.cu.lastrowid, 1)
+
+ def CheckLastRowIDOnIgnore(self):
+ self.cu.execute(
+ "insert or ignore into test(unique_test) values (?)",
+ ('test',))
+ self.assertEqual(self.cu.lastrowid, 2)
+ self.cu.execute(
+ "insert or ignore into test(unique_test) values (?)",
+ ('test',))
+ self.assertEqual(self.cu.lastrowid, 2)
+
+ def CheckLastRowIDInsertOR(self):
+ results = []
+ for statement in ('FAIL', 'ABORT', 'ROLLBACK'):
+ sql = 'INSERT OR {} INTO test(unique_test) VALUES (?)'
+ with self.subTest(statement='INSERT OR {}'.format(statement)):
+ self.cu.execute(sql.format(statement), (statement,))
+ results.append((statement, self.cu.lastrowid))
+ with self.assertRaises(sqlite.IntegrityError):
+ self.cu.execute(sql.format(statement), (statement,))
+ results.append((statement, self.cu.lastrowid))
+ expected = [
+ ('FAIL', 2), ('FAIL', 2),
+ ('ABORT', 3), ('ABORT', 3),
+ ('ROLLBACK', 4), ('ROLLBACK', 4),
+ ]
+ self.assertEqual(results, expected)
+
+
@unittest.skipUnless(threading, 'This test requires threading.')
class ThreadTests(unittest.TestCase):
def setUp(self):
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py
index 502b061..4edb03f 100644
--- a/Lib/sre_compile.py
+++ b/Lib/sre_compile.py
@@ -409,57 +409,39 @@
table[i] = idx + 1
return table
-def _compile_info(code, pattern, flags):
- # internal: compile an info block. in the current version,
- # this contains min/max pattern width, and an optional literal
- # prefix or a character map
- lo, hi = pattern.getwidth()
- if hi > MAXCODE:
- hi = MAXCODE
- if lo == 0:
- code.extend([INFO, 4, 0, lo, hi])
- return
- # look for a literal prefix
+def _get_literal_prefix(pattern):
+ # look for literal prefix
prefix = []
prefixappend = prefix.append
- prefix_skip = 0
+ prefix_skip = None
+ got_all = True
+ for op, av in pattern.data:
+ if op is LITERAL:
+ prefixappend(av)
+ elif op is SUBPATTERN:
+ prefix1, prefix_skip1, got_all = _get_literal_prefix(av[1])
+ if prefix_skip is None:
+ if av[0] is not None:
+ prefix_skip = len(prefix)
+ elif prefix_skip1 is not None:
+ prefix_skip = len(prefix) + prefix_skip1
+ prefix.extend(prefix1)
+ if not got_all:
+ break
+ else:
+ got_all = False
+ break
+ return prefix, prefix_skip, got_all
+
+def _get_charset_prefix(pattern):
charset = [] # not used
charsetappend = charset.append
- if not (flags & SRE_FLAG_IGNORECASE):
- # look for literal prefix
- for op, av in pattern.data:
+ if pattern.data:
+ op, av = pattern.data[0]
+ if op is SUBPATTERN and av[1]:
+ op, av = av[1][0]
if op is LITERAL:
- if len(prefix) == prefix_skip:
- prefix_skip = prefix_skip + 1
- prefixappend(av)
- elif op is SUBPATTERN and len(av[1]) == 1:
- op, av = av[1][0]
- if op is LITERAL:
- prefixappend(av)
- else:
- break
- else:
- break
- # if no prefix, look for charset prefix
- if not prefix and pattern.data:
- op, av = pattern.data[0]
- if op is SUBPATTERN and av[1]:
- op, av = av[1][0]
- if op is LITERAL:
- charsetappend((op, av))
- elif op is BRANCH:
- c = []
- cappend = c.append
- for p in av[1]:
- if not p:
- break
- op, av = p[0]
- if op is LITERAL:
- cappend((op, av))
- else:
- break
- else:
- charset = c
+ charsetappend((op, av))
elif op is BRANCH:
c = []
cappend = c.append
@@ -473,8 +455,43 @@
break
else:
charset = c
- elif op is IN:
- charset = av
+ elif op is BRANCH:
+ c = []
+ cappend = c.append
+ for p in av[1]:
+ if not p:
+ break
+ op, av = p[0]
+ if op is LITERAL:
+ cappend((op, av))
+ else:
+ break
+ else:
+ charset = c
+ elif op is IN:
+ charset = av
+ return charset
+
+def _compile_info(code, pattern, flags):
+ # internal: compile an info block. in the current version,
+ # this contains min/max pattern width, and an optional literal
+ # prefix or a character map
+ lo, hi = pattern.getwidth()
+ if hi > MAXCODE:
+ hi = MAXCODE
+ if lo == 0:
+ code.extend([INFO, 4, 0, lo, hi])
+ return
+ # look for a literal prefix
+ prefix = []
+ prefix_skip = 0
+ charset = [] # not used
+ if not (flags & SRE_FLAG_IGNORECASE):
+ # look for literal prefix
+ prefix, prefix_skip, got_all = _get_literal_prefix(pattern)
+ # if no prefix, look for charset prefix
+ if not prefix:
+ charset = _get_charset_prefix(pattern)
## if prefix:
## print("*** PREFIX", prefix, prefix_skip)
## if charset:
@@ -487,7 +504,7 @@
mask = 0
if prefix:
mask = SRE_INFO_PREFIX
- if len(prefix) == prefix_skip == len(pattern.data):
+ if prefix_skip is None and got_all:
mask = mask | SRE_INFO_LITERAL
elif charset:
mask = mask | SRE_INFO_CHARSET
@@ -502,6 +519,8 @@
# add literal prefix
if prefix:
emit(len(prefix)) # length
+ if prefix_skip is None:
+ prefix_skip = len(prefix)
emit(prefix_skip) # skip
code.extend(prefix)
# generate overlap table
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py
index 4ff50d1..521e379 100644
--- a/Lib/sre_parse.py
+++ b/Lib/sre_parse.py
@@ -282,33 +282,6 @@
def error(self, msg, offset=0):
return error(msg, self.string, self.tell() - offset)
-# The following three functions are not used in this module anymore, but we keep
-# them here (with DeprecationWarnings) for backwards compatibility.
-
-def isident(char):
- import warnings
- warnings.warn('sre_parse.isident() will be removed in 3.5',
- DeprecationWarning, stacklevel=2)
- return "a" <= char <= "z" or "A" <= char <= "Z" or char == "_"
-
-def isdigit(char):
- import warnings
- warnings.warn('sre_parse.isdigit() will be removed in 3.5',
- DeprecationWarning, stacklevel=2)
- return "0" <= char <= "9"
-
-def isname(name):
- import warnings
- warnings.warn('sre_parse.isname() will be removed in 3.5',
- DeprecationWarning, stacklevel=2)
- # check that group name is a valid string
- if not isident(name[0]):
- return False
- for char in name[1:]:
- if not isident(char) and not isdigit(char):
- return False
- return True
-
def _class_escape(source, escape):
# handle escape code inside character class
code = ESCAPES.get(escape)
@@ -351,9 +324,7 @@
raise ValueError
if len(escape) == 2:
if c in ASCIILETTERS:
- import warnings
- warnings.warn('bad escape %s' % escape,
- DeprecationWarning, stacklevel=8)
+ raise source.error('bad escape %s' % escape, len(escape))
return LITERAL, ord(escape[1])
except ValueError:
pass
@@ -418,9 +389,7 @@
raise source.error("invalid group reference", len(escape))
if len(escape) == 2:
if c in ASCIILETTERS:
- import warnings
- warnings.warn('bad escape %s' % escape,
- DeprecationWarning, stacklevel=8)
+ raise source.error("bad escape %s" % escape, len(escape))
return LITERAL, ord(escape[1])
except ValueError:
pass
@@ -798,10 +767,7 @@
# Check and fix flags according to the type of pattern (str or bytes)
if isinstance(src, str):
if flags & SRE_FLAG_LOCALE:
- import warnings
- warnings.warn("LOCALE flag with a str pattern is deprecated. "
- "Will be an error in 3.6",
- DeprecationWarning, stacklevel=6)
+ raise ValueError("cannot use LOCALE flag with a str pattern")
if not flags & SRE_FLAG_ASCII:
flags |= SRE_FLAG_UNICODE
elif flags & SRE_FLAG_UNICODE:
@@ -810,10 +776,7 @@
if flags & SRE_FLAG_UNICODE:
raise ValueError("cannot use UNICODE flag with a bytes pattern")
if flags & SRE_FLAG_LOCALE and flags & SRE_FLAG_ASCII:
- import warnings
- warnings.warn("ASCII and LOCALE flags are incompatible. "
- "Will be an error in 3.6",
- DeprecationWarning, stacklevel=6)
+ raise ValueError("ASCII and LOCALE flags are incompatible")
return flags
def parse(str, flags=0, pattern=None):
@@ -914,9 +877,7 @@
this = chr(ESCAPES[this][1])
except KeyError:
if c in ASCIILETTERS:
- import warnings
- warnings.warn('bad escape %s' % this,
- DeprecationWarning, stacklevel=4)
+ raise s.error('bad escape %s' % this, len(this))
lappend(this)
else:
lappend(this)
diff --git a/Lib/ssl.py b/Lib/ssl.py
index 3f5c3c4..560cfef 100644
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -890,7 +890,6 @@
while (count < amount):
v = self.send(data[count:])
count += v
- return amount
else:
return socket.sendall(self, data, flags)
diff --git a/Lib/statistics.py b/Lib/statistics.py
index 4f5c1c1..63adc1a 100644
--- a/Lib/statistics.py
+++ b/Lib/statistics.py
@@ -105,6 +105,7 @@
from fractions import Fraction
from decimal import Decimal
from itertools import groupby
+from bisect import bisect_left, bisect_right
@@ -130,23 +131,23 @@
--------
>>> _sum([3, 2.25, 4.5, -0.5, 1.0], 0.75)
- (<class 'float'>, Fraction(11, 1), 5)
+ (<class 'float' ...>, Fraction(11, 1), 5)
Some sources of round-off error will be avoided:
>>> _sum([1e50, 1, -1e50] * 1000) # Built-in sum returns zero.
- (<class 'float'>, Fraction(1000, 1), 3000)
+ (<class 'float' ...>, Fraction(1000, 1), 3000)
Fractions and Decimals are also supported:
>>> from fractions import Fraction as F
>>> _sum([F(2, 3), F(7, 5), F(1, 4), F(5, 6)])
- (<class 'fractions.Fraction'>, Fraction(63, 20), 4)
+ (<class 'fractions.Fraction' ...>, Fraction(63, 20), 4)
>>> from decimal import Decimal as D
>>> data = [D("0.1375"), D("0.2108"), D("0.3061"), D("0.0419")]
>>> _sum(data)
- (<class 'decimal.Decimal'>, Fraction(6963, 10000), 4)
+ (<class 'decimal.Decimal' ...>, Fraction(6963, 10000), 4)
Mixed types are currently treated as an error, except that int is
allowed.
@@ -223,56 +224,26 @@
# Optimise the common case of floats. We expect that the most often
# used numeric type will be builtin floats, so try to make this as
# fast as possible.
- if type(x) is float:
+ if type(x) is float or type(x) is Decimal:
return x.as_integer_ratio()
try:
# x may be an int, Fraction, or Integral ABC.
return (x.numerator, x.denominator)
except AttributeError:
try:
- # x may be a float subclass.
+ # x may be a float or Decimal subclass.
return x.as_integer_ratio()
except AttributeError:
- try:
- # x may be a Decimal.
- return _decimal_to_ratio(x)
- except AttributeError:
- # Just give up?
- pass
+ # Just give up?
+ pass
except (OverflowError, ValueError):
# float NAN or INF.
- assert not math.isfinite(x)
+ assert not _isfinite(x)
return (x, None)
msg = "can't convert type '{}' to numerator/denominator"
raise TypeError(msg.format(type(x).__name__))
-# FIXME This is faster than Fraction.from_decimal, but still too slow.
-def _decimal_to_ratio(d):
- """Convert Decimal d to exact integer ratio (numerator, denominator).
-
- >>> from decimal import Decimal
- >>> _decimal_to_ratio(Decimal("2.6"))
- (26, 10)
-
- """
- sign, digits, exp = d.as_tuple()
- if exp in ('F', 'n', 'N'): # INF, NAN, sNAN
- assert not d.is_finite()
- return (d, None)
- num = 0
- for digit in digits:
- num = num*10 + digit
- if exp < 0:
- den = 10**-exp
- else:
- num *= 10**exp
- den = 1
- if sign:
- num = -num
- return (num, den)
-
-
def _convert(value, T):
"""Convert value to given numeric type T."""
if type(value) is T:
@@ -305,6 +276,21 @@
return table
+def _find_lteq(a, x):
+ 'Locate the leftmost value exactly equal to x'
+ i = bisect_left(a, x)
+ if i != len(a) and a[i] == x:
+ return i
+ raise ValueError
+
+
+def _find_rteq(a, l, x):
+ 'Locate the rightmost value exactly equal to x'
+ i = bisect_right(a, x, lo=l)
+ if i != (len(a)+1) and a[i-1] == x:
+ return i-1
+ raise ValueError
+
# === Measures of central tendency (averages) ===
def mean(data):
@@ -442,9 +428,15 @@
except TypeError:
# Mixed type. For now we just coerce to float.
L = float(x) - float(interval)/2
- cf = data.index(x) # Number of values below the median interval.
- # FIXME The following line could be more efficient for big lists.
- f = data.count(x) # Number of data points in the median interval.
+
+ # Uses bisection search to search for x in data with log(n) time complexity
+ # Find the position of leftmost occurrence of x in data
+ l1 = _find_lteq(data, x)
+ # Find the position of rightmost occurrence of x in data[l1...len(data)]
+ # Assuming always l1 <= l2
+ l2 = _find_rteq(data, l1, x)
+ cf = l1
+ f = l2 - l1 + 1
return L + interval*(n/2 - cf)/f
diff --git a/Lib/string.py b/Lib/string.py
index 89287c4..7298c89 100644
--- a/Lib/string.py
+++ b/Lib/string.py
@@ -116,10 +116,7 @@
# Check the most common path first.
named = mo.group('named') or mo.group('braced')
if named is not None:
- val = mapping[named]
- # We use this idiom instead of str() because the latter will
- # fail if val is a Unicode containing non-ASCII characters.
- return '%s' % (val,)
+ return str(mapping[named])
if mo.group('escaped') is not None:
return self.delimiter
if mo.group('invalid') is not None:
@@ -146,9 +143,7 @@
named = mo.group('named') or mo.group('braced')
if named is not None:
try:
- # We use this idiom instead of str() because the latter
- # will fail if val is a Unicode containing non-ASCII
- return '%s' % (mapping[named],)
+ return str(mapping[named])
except KeyError:
return mo.group()
if mo.group('escaped') is not None:
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index d8d6ab2..3dea089 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -372,9 +372,11 @@
class CalledProcessError(SubprocessError):
- """This exception is raised when a process run by check_call() or
- check_output() returns a non-zero exit status.
- The exit status will be stored in the returncode attribute;
+ """Raised when a check_call() or check_output() process returns non-zero.
+
+ The exit status will be stored in the returncode attribute, negative
+ if it represents a signal number.
+
check_output() will also store the output in the output attribute.
"""
def __init__(self, returncode, cmd, output=None, stderr=None):
@@ -384,7 +386,16 @@
self.stderr = stderr
def __str__(self):
- return "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode)
+ if self.returncode and self.returncode < 0:
+ try:
+ return "Command '%s' died with %r." % (
+ self.cmd, signal.Signals(-self.returncode))
+ except ValueError:
+ return "Command '%s' died with unknown signal %d." % (
+ self.cmd, -self.returncode)
+ else:
+ return "Command '%s' returned non-zero exit status %d." % (
+ self.cmd, self.returncode)
@property
def stdout(self):
@@ -471,7 +482,8 @@
__all__.extend(["CREATE_NEW_CONSOLE", "CREATE_NEW_PROCESS_GROUP",
"STD_INPUT_HANDLE", "STD_OUTPUT_HANDLE",
"STD_ERROR_HANDLE", "SW_HIDE",
- "STARTF_USESTDHANDLES", "STARTF_USESHOWWINDOW"])
+ "STARTF_USESTDHANDLES", "STARTF_USESHOWWINDOW",
+ "STARTUPINFO"])
class Handle(int):
closed = False
@@ -520,6 +532,16 @@
# but it's here so that it can be imported when Python is compiled without
# threads.
+def _optim_args_from_interpreter_flags():
+ """Return a list of command-line arguments reproducing the current
+ optimization settings in sys.flags."""
+ args = []
+ value = sys.flags.optimize
+ if value > 0:
+ args.append('-' + 'O' * value)
+ return args
+
+
def _args_from_interpreter_flags():
"""Return a list of command-line arguments reproducing the current
settings in sys.flags and sys.warnoptions."""
@@ -527,7 +549,6 @@
'debug': 'd',
# 'inspect': 'i',
# 'interactive': 'i',
- 'optimize': 'O',
'dont_write_bytecode': 'B',
'no_user_site': 's',
'no_site': 'S',
@@ -535,8 +556,9 @@
'verbose': 'v',
'bytes_warning': 'b',
'quiet': 'q',
+ # -O is handled in _optim_args_from_interpreter_flags()
}
- args = []
+ args = _optim_args_from_interpreter_flags()
for flag, opt in flag_opt_map.items():
v = getattr(sys.flags, flag)
if v > 0:
@@ -971,7 +993,6 @@
raise
-
def _translate_newlines(self, data, encoding):
data = data.decode(encoding)
return data.replace("\r\n", "\n").replace("\r", "\n")
@@ -995,6 +1016,11 @@
if not self._child_created:
# We didn't get to successfully create a child process.
return
+ if self.returncode is None:
+ # Not reading subprocess exit status creates a zombi process which
+ # is only destroyed at the parent python process exit
+ warnings.warn("subprocess %s is still running" % self.pid,
+ ResourceWarning, source=self)
# In case the child hasn't been waited on, check if it's done.
self._internal_poll(_deadstate=_maxsize)
if self.returncode is None and _active is not None:
@@ -1520,9 +1546,14 @@
if errpipe_data:
try:
- os.waitpid(self.pid, 0)
+ pid, sts = os.waitpid(self.pid, 0)
+ if pid == self.pid:
+ self._handle_exitstatus(sts)
+ else:
+ self.returncode = sys.maxsize
except ChildProcessError:
pass
+
try:
exception_name, hex_errno, err_msg = (
errpipe_data.split(b':', 2))
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
index 9c34be0..ef53061 100644
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -86,8 +86,8 @@
# FIXME don't rely on sys.version here, its format is an implementation detail
# of CPython, use sys.version_info or sys.hexversion
_PY_VERSION = sys.version.split()[0]
-_PY_VERSION_SHORT = sys.version[:3]
-_PY_VERSION_SHORT_NO_DOT = _PY_VERSION[0] + _PY_VERSION[2]
+_PY_VERSION_SHORT = '%d.%d' % sys.version_info[:2]
+_PY_VERSION_SHORT_NO_DOT = '%d%d' % sys.version_info[:2]
_PREFIX = os.path.normpath(sys.prefix)
_BASE_PREFIX = os.path.normpath(sys.base_prefix)
_EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
@@ -337,6 +337,8 @@
config_dir_name = 'config-%s%s' % (_PY_VERSION_SHORT, sys.abiflags)
else:
config_dir_name = 'config'
+ if hasattr(sys.implementation, '_multiarch'):
+ config_dir_name += '-%s' % sys.implementation._multiarch
return os.path.join(get_path('stdlib'), config_dir_name, 'Makefile')
def _generate_posix_vars():
@@ -379,14 +381,14 @@
# _sysconfigdata module manually and populate it with the build vars.
# This is more than sufficient for ensuring the subsequent call to
# get_platform() succeeds.
- name = '_sysconfigdata'
+ name = '_sysconfigdata_' + sys.abiflags
if 'darwin' in sys.platform:
import types
module = types.ModuleType(name)
module.build_time_vars = vars
sys.modules[name] = module
- pybuilddir = 'build/lib.%s-%s' % (get_platform(), sys.version[:3])
+ pybuilddir = 'build/lib.%s-%s' % (get_platform(), _PY_VERSION_SHORT)
if hasattr(sys, "gettotalrefcount"):
pybuilddir += '-pydebug'
os.makedirs(pybuilddir, exist_ok=True)
@@ -405,7 +407,9 @@
def _init_posix(vars):
"""Initialize the module as appropriate for POSIX systems."""
# _sysconfigdata is generated at build time, see _generate_posix_vars()
- from _sysconfigdata import build_time_vars
+ name = '_sysconfigdata_' + sys.abiflags
+ _temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
+ build_time_vars = _temp.build_time_vars
vars.update(build_time_vars)
def _init_non_posix(vars):
@@ -518,7 +522,7 @@
_CONFIG_VARS['exec_prefix'] = _EXEC_PREFIX
_CONFIG_VARS['py_version'] = _PY_VERSION
_CONFIG_VARS['py_version_short'] = _PY_VERSION_SHORT
- _CONFIG_VARS['py_version_nodot'] = _PY_VERSION[0] + _PY_VERSION[2]
+ _CONFIG_VARS['py_version_nodot'] = _PY_VERSION_SHORT_NO_DOT
_CONFIG_VARS['installed_base'] = _BASE_PREFIX
_CONFIG_VARS['base'] = _PREFIX
_CONFIG_VARS['installed_platbase'] = _BASE_EXEC_PREFIX
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 721f9d7..df4745d 100755
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -64,7 +64,10 @@
pass
# from tarfile import *
-__all__ = ["TarFile", "TarInfo", "is_tarfile", "TarError"]
+__all__ = ["TarFile", "TarInfo", "is_tarfile", "TarError", "ReadError",
+ "CompressionError", "StreamError", "ExtractError", "HeaderError",
+ "ENCODING", "USTAR_FORMAT", "GNU_FORMAT", "PAX_FORMAT",
+ "DEFAULT_FORMAT", "open"]
#---------------------------------------------------------
# tar constants
@@ -2374,9 +2377,32 @@
"""Provide an iterator object.
"""
if self._loaded:
- return iter(self.members)
- else:
- return TarIter(self)
+ yield from self.members
+ return
+
+ # Yield items using TarFile's next() method.
+ # When all members have been read, set TarFile as _loaded.
+ index = 0
+ # Fix for SF #1100429: Under rare circumstances it can
+ # happen that getmembers() is called during iteration,
+ # which will have already exhausted the next() method.
+ if self.firstmember is not None:
+ tarinfo = self.next()
+ index += 1
+ yield tarinfo
+
+ while True:
+ if index < len(self.members):
+ tarinfo = self.members[index]
+ elif not self._loaded:
+ tarinfo = self.next()
+ if not tarinfo:
+ self._loaded = True
+ return
+ else:
+ return
+ index += 1
+ yield tarinfo
def _dbg(self, level, msg):
"""Write debugging output to sys.stderr.
@@ -2397,45 +2423,6 @@
if not self._extfileobj:
self.fileobj.close()
self.closed = True
-# class TarFile
-
-class TarIter:
- """Iterator Class.
-
- for tarinfo in TarFile(...):
- suite...
- """
-
- def __init__(self, tarfile):
- """Construct a TarIter object.
- """
- self.tarfile = tarfile
- self.index = 0
- def __iter__(self):
- """Return iterator object.
- """
- return self
- def __next__(self):
- """Return the next item using TarFile's next() method.
- When all members have been read, set TarFile as _loaded.
- """
- # Fix for SF #1100429: Under rare circumstances it can
- # happen that getmembers() is called during iteration,
- # which will cause TarIter to stop prematurely.
-
- if self.index == 0 and self.tarfile.firstmember is not None:
- tarinfo = self.tarfile.next()
- elif self.index < len(self.tarfile.members):
- tarinfo = self.tarfile.members[self.index]
- elif not self.tarfile._loaded:
- tarinfo = self.tarfile.next()
- if not tarinfo:
- self.tarfile._loaded = True
- raise StopIteration
- else:
- raise StopIteration
- self.index += 1
- return tarinfo
#--------------------
# exported functions
diff --git a/Lib/telnetlib.py b/Lib/telnetlib.py
index 72dabc7..b0863b1 100644
--- a/Lib/telnetlib.py
+++ b/Lib/telnetlib.py
@@ -637,6 +637,12 @@
raise EOFError
return (-1, None, text)
+ def __enter__(self):
+ return self
+
+ def __exit__(self, type, value, traceback):
+ self.close()
+
def test():
"""Test program for telnetlib.
@@ -660,11 +666,10 @@
port = int(portstr)
except ValueError:
port = socket.getservbyname(portstr, 'tcp')
- tn = Telnet()
- tn.set_debuglevel(debuglevel)
- tn.open(host, port, timeout=0.5)
- tn.interact()
- tn.close()
+ with Telnet() as tn:
+ tn.set_debuglevel(debuglevel)
+ tn.open(host, port, timeout=0.5)
+ tn.interact()
if __name__ == '__main__':
test()
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index ad687b9..6146235 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -797,7 +797,6 @@
_shutil.rmtree(name)
_warnings.warn(warn_message, ResourceWarning)
-
def __repr__(self):
return "<{} {!r}>".format(self.__class__.__name__, self.name)
diff --git a/Lib/test/__main__.py b/Lib/test/__main__.py
index d5fbe15..19a6b2b 100644
--- a/Lib/test/__main__.py
+++ b/Lib/test/__main__.py
@@ -1,3 +1,2 @@
-from test import regrtest
-
-regrtest.main_in_temp_cwd()
+from test.libregrtest import main
+main()
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index 11a6310..16407db 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -1668,6 +1668,10 @@
def mul(x, y):
return x*y
+def raise_large_valuerror(wait):
+ time.sleep(wait)
+ raise ValueError("x" * 1024**2)
+
class SayWhenError(ValueError): pass
def exception_throwing_generator(total, when):
@@ -1910,6 +1914,26 @@
with self.assertRaises(RuntimeError):
p.apply(self._test_wrapped_exception)
+ def test_map_no_failfast(self):
+ # Issue #23992: the fail-fast behaviour when an exception is raised
+ # during map() would make Pool.join() deadlock, because a worker
+ # process would fill the result queue (after the result handler thread
+ # terminated, hence not draining it anymore).
+
+ t_start = time.time()
+
+ with self.assertRaises(ValueError):
+ with self.Pool(2) as p:
+ try:
+ p.map(raise_large_valuerror, [0, 1])
+ finally:
+ time.sleep(0.5)
+ p.close()
+ p.join()
+
+ # check that we indeed waited for all jobs
+ self.assertGreater(time.time() - t_start, 0.9)
+
def raising():
raise KeyError("key")
diff --git a/Lib/test/audiotests.py b/Lib/test/audiotests.py
index 0ae2242..d3e8e9e 100644
--- a/Lib/test/audiotests.py
+++ b/Lib/test/audiotests.py
@@ -1,9 +1,8 @@
from test.support import findfile, TESTFN, unlink
-import unittest
import array
import io
import pickle
-import sys
+
class UnseekableIO(io.FileIO):
def tell(self):
diff --git a/Lib/test/autotest.py b/Lib/test/autotest.py
index 41c2088..fa85cc1 100644
--- a/Lib/test/autotest.py
+++ b/Lib/test/autotest.py
@@ -1,6 +1,5 @@
# This should be equivalent to running regrtest.py from the cmdline.
# It can be especially handy if you're in an interactive shell, e.g.,
# from test import autotest.
-
-from test import regrtest
-regrtest.main()
+from test.libregrtest import main
+main()
diff --git a/Lib/test/capath/0e4015b9.0 b/Lib/test/capath/0e4015b9.0
deleted file mode 100644
index b6d259b..0000000
--- a/Lib/test/capath/0e4015b9.0
+++ /dev/null
@@ -1,16 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIClTCCAf6gAwIBAgIJAKGU95wKR8pTMA0GCSqGSIb3DQEBBQUAMHAxCzAJBgNV
-BAYTAlhZMRcwFQYDVQQHDA5DYXN0bGUgQW50aHJheDEjMCEGA1UECgwaUHl0aG9u
-IFNvZnR3YXJlIEZvdW5kYXRpb24xIzAhBgNVBAMMGnNlbGYtc2lnbmVkLnB5dGhv
-bnRlc3QubmV0MB4XDTE0MTEwMjE4MDkyOVoXDTI0MTAzMDE4MDkyOVowcDELMAkG
-A1UEBhMCWFkxFzAVBgNVBAcMDkNhc3RsZSBBbnRocmF4MSMwIQYDVQQKDBpQeXRo
-b24gU29mdHdhcmUgRm91bmRhdGlvbjEjMCEGA1UEAwwac2VsZi1zaWduZWQucHl0
-aG9udGVzdC5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANDXQXW9tjyZ
-Xt0Iv2tLL1+jinr4wGg36ioLDLFkMf+2Y1GL0v0BnKYG4N1OKlAU15LXGeGer8vm
-Sv/yIvmdrELvhAbbo3w4a9TMYQA4XkIVLdvu3mvNOAet+8PMJxn26dbDhG809ALv
-EHY57lQsBS3G59RZyBPVqAqmImWNJnVzAgMBAAGjNzA1MCUGA1UdEQQeMByCGnNl
-bGYtc2lnbmVkLnB5dGhvbnRlc3QubmV0MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcN
-AQEFBQADgYEAIuzAhgMouJpNdf3URCHIineyoSt6WK/9+eyUcjlKOrDoXNZaD72h
-TXMeKYoWvJyVcSLKL8ckPtDobgP2OTt0UkyAaj0n+ZHaqq1lH2yVfGUA1ILJv515
-C8BqbvVZuqm3i7ygmw3bqE/lYMgOrYtXXnqOrz6nvsE6Yc9V9rFflOM=
------END CERTIFICATE-----
diff --git a/Lib/test/capath/b1930218.0 b/Lib/test/capath/b1930218.0
new file mode 100644
index 0000000..373349c
--- /dev/null
+++ b/Lib/test/capath/b1930218.0
@@ -0,0 +1,21 @@
+-----BEGIN CERTIFICATE-----
+MIIDbTCCAlWgAwIBAgIJALCSZLHy2iHQMA0GCSqGSIb3DQEBBQUAME0xCzAJBgNV
+BAYTAlhZMSYwJAYDVQQKDB1QeXRob24gU29mdHdhcmUgRm91bmRhdGlvbiBDQTEW
+MBQGA1UEAwwNb3VyLWNhLXNlcnZlcjAeFw0xMzAxMDQxOTQ3MDdaFw0yMzAxMDIx
+OTQ3MDdaME0xCzAJBgNVBAYTAlhZMSYwJAYDVQQKDB1QeXRob24gU29mdHdhcmUg
+Rm91bmRhdGlvbiBDQTEWMBQGA1UEAwwNb3VyLWNhLXNlcnZlcjCCASIwDQYJKoZI
+hvcNAQEBBQADggEPADCCAQoCggEBAOfe6eMMnwC2of0rW5bSb8zgvoa5IF7sA3pV
+q+qk6flJhdJm1e3HeupWji2P50LiYiipn9Ybjuu1tJyfFKvf5pSLdh0+bSRh7Qy/
+AIphDN9cyDZzFgDNR7ptpKR0iIMjChn8Cac8SkvT5x0t5OpMVCHzJtuJNxjUArtA
+Ml+k/y0c99S77I7PXIKs5nwIbEiFYQd/JeBc4Lw0X+C5BEd1yEcLjbzWyGhfM4Ni
+0iBENbGtgRqKzbw1sFyLR9YY6ZwYl8wBPCnM6B7k5MG43ufCERiHWpM02KYl9xRx
+6+QhotIPLi7UYgA109bvXGBLTKkU4t0VWEY3Mya35y5d7ULkxU0CAwEAAaNQME4w
+HQYDVR0OBBYEFLzdYtl22hvSVGvP4GabHh57VgwLMB8GA1UdIwQYMBaAFLzdYtl2
+2hvSVGvP4GabHh57VgwLMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEB
+AH0K9cuN0129mY74Kw+668LZpidPLnsvDmTYHDVQTu78kLmNbajFxgawr/Mtvzu4
+QgfdGH1tlVRXhRhgRy/reBv56Bf9Wg2HFyisTGrmvCn09FVwKULeheqrbCMGZDB1
+Ao5TvF4BMzfMHs24pP3K5F9lO4MchvFVAqA6j9uRt0AUtOeN0u5zuuPlNC28lG9O
+JAb3X4sOp45r3l519DKaULFEM5rQBeJ4gv/b2opj66nd0b+gYa3jnookXWIO50yR
+f+/fNDY7L131hLIvxG2TlhpvMCjx2hKaZLRAMx293itTqOq+1rxOlvVE+zIYrtUf
+9mmvtk57HVjsO6lTo15YyJ4=
+-----END CERTIFICATE-----
diff --git a/Lib/test/capath/ce7b8643.0 b/Lib/test/capath/ce7b8643.0
deleted file mode 100644
index b6d259b..0000000
--- a/Lib/test/capath/ce7b8643.0
+++ /dev/null
@@ -1,16 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIClTCCAf6gAwIBAgIJAKGU95wKR8pTMA0GCSqGSIb3DQEBBQUAMHAxCzAJBgNV
-BAYTAlhZMRcwFQYDVQQHDA5DYXN0bGUgQW50aHJheDEjMCEGA1UECgwaUHl0aG9u
-IFNvZnR3YXJlIEZvdW5kYXRpb24xIzAhBgNVBAMMGnNlbGYtc2lnbmVkLnB5dGhv
-bnRlc3QubmV0MB4XDTE0MTEwMjE4MDkyOVoXDTI0MTAzMDE4MDkyOVowcDELMAkG
-A1UEBhMCWFkxFzAVBgNVBAcMDkNhc3RsZSBBbnRocmF4MSMwIQYDVQQKDBpQeXRo
-b24gU29mdHdhcmUgRm91bmRhdGlvbjEjMCEGA1UEAwwac2VsZi1zaWduZWQucHl0
-aG9udGVzdC5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANDXQXW9tjyZ
-Xt0Iv2tLL1+jinr4wGg36ioLDLFkMf+2Y1GL0v0BnKYG4N1OKlAU15LXGeGer8vm
-Sv/yIvmdrELvhAbbo3w4a9TMYQA4XkIVLdvu3mvNOAet+8PMJxn26dbDhG809ALv
-EHY57lQsBS3G59RZyBPVqAqmImWNJnVzAgMBAAGjNzA1MCUGA1UdEQQeMByCGnNl
-bGYtc2lnbmVkLnB5dGhvbnRlc3QubmV0MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcN
-AQEFBQADgYEAIuzAhgMouJpNdf3URCHIineyoSt6WK/9+eyUcjlKOrDoXNZaD72h
-TXMeKYoWvJyVcSLKL8ckPtDobgP2OTt0UkyAaj0n+ZHaqq1lH2yVfGUA1ILJv515
-C8BqbvVZuqm3i7ygmw3bqE/lYMgOrYtXXnqOrz6nvsE6Yc9V9rFflOM=
------END CERTIFICATE-----
diff --git a/Lib/test/capath/ceff1710.0 b/Lib/test/capath/ceff1710.0
new file mode 100644
index 0000000..373349c
--- /dev/null
+++ b/Lib/test/capath/ceff1710.0
@@ -0,0 +1,21 @@
+-----BEGIN CERTIFICATE-----
+MIIDbTCCAlWgAwIBAgIJALCSZLHy2iHQMA0GCSqGSIb3DQEBBQUAME0xCzAJBgNV
+BAYTAlhZMSYwJAYDVQQKDB1QeXRob24gU29mdHdhcmUgRm91bmRhdGlvbiBDQTEW
+MBQGA1UEAwwNb3VyLWNhLXNlcnZlcjAeFw0xMzAxMDQxOTQ3MDdaFw0yMzAxMDIx
+OTQ3MDdaME0xCzAJBgNVBAYTAlhZMSYwJAYDVQQKDB1QeXRob24gU29mdHdhcmUg
+Rm91bmRhdGlvbiBDQTEWMBQGA1UEAwwNb3VyLWNhLXNlcnZlcjCCASIwDQYJKoZI
+hvcNAQEBBQADggEPADCCAQoCggEBAOfe6eMMnwC2of0rW5bSb8zgvoa5IF7sA3pV
+q+qk6flJhdJm1e3HeupWji2P50LiYiipn9Ybjuu1tJyfFKvf5pSLdh0+bSRh7Qy/
+AIphDN9cyDZzFgDNR7ptpKR0iIMjChn8Cac8SkvT5x0t5OpMVCHzJtuJNxjUArtA
+Ml+k/y0c99S77I7PXIKs5nwIbEiFYQd/JeBc4Lw0X+C5BEd1yEcLjbzWyGhfM4Ni
+0iBENbGtgRqKzbw1sFyLR9YY6ZwYl8wBPCnM6B7k5MG43ufCERiHWpM02KYl9xRx
+6+QhotIPLi7UYgA109bvXGBLTKkU4t0VWEY3Mya35y5d7ULkxU0CAwEAAaNQME4w
+HQYDVR0OBBYEFLzdYtl22hvSVGvP4GabHh57VgwLMB8GA1UdIwQYMBaAFLzdYtl2
+2hvSVGvP4GabHh57VgwLMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEB
+AH0K9cuN0129mY74Kw+668LZpidPLnsvDmTYHDVQTu78kLmNbajFxgawr/Mtvzu4
+QgfdGH1tlVRXhRhgRy/reBv56Bf9Wg2HFyisTGrmvCn09FVwKULeheqrbCMGZDB1
+Ao5TvF4BMzfMHs24pP3K5F9lO4MchvFVAqA6j9uRt0AUtOeN0u5zuuPlNC28lG9O
+JAb3X4sOp45r3l519DKaULFEM5rQBeJ4gv/b2opj66nd0b+gYa3jnookXWIO50yR
+f+/fNDY7L131hLIvxG2TlhpvMCjx2hKaZLRAMx293itTqOq+1rxOlvVE+zIYrtUf
+9mmvtk57HVjsO6lTo15YyJ4=
+-----END CERTIFICATE-----
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
index f5222c7..8fc0139 100644
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -284,7 +284,8 @@
with self.assertRaises(TypeError): self.EST.dst(5)
def test_tzname(self):
- self.assertEqual('UTC+00:00', timezone(ZERO).tzname(None))
+ self.assertEqual('UTC', timezone.utc.tzname(None))
+ self.assertEqual('UTC', timezone(ZERO).tzname(None))
self.assertEqual('UTC-05:00', timezone(-5 * HOUR).tzname(None))
self.assertEqual('UTC+09:30', timezone(9.5 * HOUR).tzname(None))
self.assertEqual('UTC-00:01', timezone(timedelta(minutes=-1)).tzname(None))
@@ -1558,13 +1559,32 @@
self.assertEqual(dt, dt2)
def test_isoformat(self):
- t = self.theclass(2, 3, 2, 4, 5, 1, 123)
- self.assertEqual(t.isoformat(), "0002-03-02T04:05:01.000123")
- self.assertEqual(t.isoformat('T'), "0002-03-02T04:05:01.000123")
- self.assertEqual(t.isoformat(' '), "0002-03-02 04:05:01.000123")
- self.assertEqual(t.isoformat('\x00'), "0002-03-02\x0004:05:01.000123")
+ t = self.theclass(1, 2, 3, 4, 5, 1, 123)
+ self.assertEqual(t.isoformat(), "0001-02-03T04:05:01.000123")
+ self.assertEqual(t.isoformat('T'), "0001-02-03T04:05:01.000123")
+ self.assertEqual(t.isoformat(' '), "0001-02-03 04:05:01.000123")
+ self.assertEqual(t.isoformat('\x00'), "0001-02-03\x0004:05:01.000123")
+ self.assertEqual(t.isoformat(timespec='hours'), "0001-02-03T04")
+ self.assertEqual(t.isoformat(timespec='minutes'), "0001-02-03T04:05")
+ self.assertEqual(t.isoformat(timespec='seconds'), "0001-02-03T04:05:01")
+ self.assertEqual(t.isoformat(timespec='milliseconds'), "0001-02-03T04:05:01.000")
+ self.assertEqual(t.isoformat(timespec='microseconds'), "0001-02-03T04:05:01.000123")
+ self.assertEqual(t.isoformat(timespec='auto'), "0001-02-03T04:05:01.000123")
+ self.assertEqual(t.isoformat(sep=' ', timespec='minutes'), "0001-02-03 04:05")
+ self.assertRaises(ValueError, t.isoformat, timespec='foo')
# str is ISO format with the separator forced to a blank.
- self.assertEqual(str(t), "0002-03-02 04:05:01.000123")
+ self.assertEqual(str(t), "0001-02-03 04:05:01.000123")
+
+ t = self.theclass(1, 2, 3, 4, 5, 1, 999500, tzinfo=timezone.utc)
+ self.assertEqual(t.isoformat(timespec='milliseconds'), "0001-02-03T04:05:01.999+00:00")
+
+ t = self.theclass(1, 2, 3, 4, 5, 1, 999500)
+ self.assertEqual(t.isoformat(timespec='milliseconds'), "0001-02-03T04:05:01.999")
+
+ t = self.theclass(1, 2, 3, 4, 5, 1)
+ self.assertEqual(t.isoformat(timespec='auto'), "0001-02-03T04:05:01")
+ self.assertEqual(t.isoformat(timespec='milliseconds'), "0001-02-03T04:05:01.000")
+ self.assertEqual(t.isoformat(timespec='microseconds'), "0001-02-03T04:05:01.000000")
t = self.theclass(2, 3, 2)
self.assertEqual(t.isoformat(), "0002-03-02T00:00:00")
@@ -2324,6 +2344,23 @@
self.assertEqual(t.isoformat(), "00:00:00.100000")
self.assertEqual(t.isoformat(), str(t))
+ t = self.theclass(hour=12, minute=34, second=56, microsecond=123456)
+ self.assertEqual(t.isoformat(timespec='hours'), "12")
+ self.assertEqual(t.isoformat(timespec='minutes'), "12:34")
+ self.assertEqual(t.isoformat(timespec='seconds'), "12:34:56")
+ self.assertEqual(t.isoformat(timespec='milliseconds'), "12:34:56.123")
+ self.assertEqual(t.isoformat(timespec='microseconds'), "12:34:56.123456")
+ self.assertEqual(t.isoformat(timespec='auto'), "12:34:56.123456")
+ self.assertRaises(ValueError, t.isoformat, timespec='monkey')
+
+ t = self.theclass(hour=12, minute=34, second=56, microsecond=999500)
+ self.assertEqual(t.isoformat(timespec='milliseconds'), "12:34:56.999")
+
+ t = self.theclass(hour=12, minute=34, second=56, microsecond=0)
+ self.assertEqual(t.isoformat(timespec='milliseconds'), "12:34:56.000")
+ self.assertEqual(t.isoformat(timespec='microseconds'), "12:34:56.000000")
+ self.assertEqual(t.isoformat(timespec='auto'), "12:34:56")
+
def test_1653736(self):
# verify it doesn't accept extra keyword arguments
t = self.theclass(second=1)
diff --git a/Lib/test/eintrdata/eintr_tester.py b/Lib/test/eintrdata/eintr_tester.py
index 9931a55..ffcdb98 100644
--- a/Lib/test/eintrdata/eintr_tester.py
+++ b/Lib/test/eintrdata/eintr_tester.py
@@ -9,7 +9,7 @@
"""
import contextlib
-import io
+import faulthandler
import os
import select
import signal
@@ -50,6 +50,10 @@
signal.setitimer(signal.ITIMER_REAL, cls.signal_delay,
cls.signal_period)
+ # Issue #25277: Use faulthandler to try to debug a hang on FreeBSD
+ if hasattr(faulthandler, 'dump_traceback_later'):
+ faulthandler.dump_traceback_later(10 * 60, exit=True)
+
@classmethod
def stop_alarm(cls):
signal.setitimer(signal.ITIMER_REAL, 0, 0)
@@ -58,6 +62,8 @@
def tearDownClass(cls):
cls.stop_alarm()
signal.signal(signal.SIGALRM, cls.orig_handler)
+ if hasattr(faulthandler, 'cancel_dump_traceback_later'):
+ faulthandler.cancel_dump_traceback_later()
def subprocess(self, *args, **kw):
cmd_args = (sys.executable, '-c') + args
diff --git a/Lib/test/libregrtest/__init__.py b/Lib/test/libregrtest/__init__.py
new file mode 100644
index 0000000..7ba0e6e
--- /dev/null
+++ b/Lib/test/libregrtest/__init__.py
@@ -0,0 +1,5 @@
+# We import importlib *ASAP* in order to test #15386
+import importlib
+
+from test.libregrtest.cmdline import _parse_args, RESOURCE_NAMES
+from test.libregrtest.main import main
diff --git a/Lib/test/libregrtest/cmdline.py b/Lib/test/libregrtest/cmdline.py
new file mode 100644
index 0000000..de09a01
--- /dev/null
+++ b/Lib/test/libregrtest/cmdline.py
@@ -0,0 +1,342 @@
+import argparse
+import os
+import sys
+from test import support
+
+
+USAGE = """\
+python -m test [options] [test_name1 [test_name2 ...]]
+python path/to/Lib/test/regrtest.py [options] [test_name1 [test_name2 ...]]
+"""
+
+DESCRIPTION = """\
+Run Python regression tests.
+
+If no arguments or options are provided, finds all files matching
+the pattern "test_*" in the Lib/test subdirectory and runs
+them in alphabetical order (but see -M and -u, below, for exceptions).
+
+For more rigorous testing, it is useful to use the following
+command line:
+
+python -E -Wd -m test [options] [test_name1 ...]
+"""
+
+EPILOG = """\
+Additional option details:
+
+-r randomizes test execution order. You can use --randseed=int to provide an
+int seed value for the randomizer; this is useful for reproducing troublesome
+test orders.
+
+-s On the first invocation of regrtest using -s, the first test file found
+or the first test file given on the command line is run, and the name of
+the next test is recorded in a file named pynexttest. If run from the
+Python build directory, pynexttest is located in the 'build' subdirectory,
+otherwise it is located in tempfile.gettempdir(). On subsequent runs,
+the test in pynexttest is run, and the next test is written to pynexttest.
+When the last test has been run, pynexttest is deleted. In this way it
+is possible to single step through the test files. This is useful when
+doing memory analysis on the Python interpreter, which process tends to
+consume too many resources to run the full regression test non-stop.
+
+-S is used to continue running tests after an aborted run. It will
+maintain the order a standard run (ie, this assumes -r is not used).
+This is useful after the tests have prematurely stopped for some external
+reason and you want to start running from where you left off rather
+than starting from the beginning.
+
+-f reads the names of tests from the file given as f's argument, one
+or more test names per line. Whitespace is ignored. Blank lines and
+lines beginning with '#' are ignored. This is especially useful for
+whittling down failures involving interactions among tests.
+
+-L causes the leaks(1) command to be run just before exit if it exists.
+leaks(1) is available on Mac OS X and presumably on some other
+FreeBSD-derived systems.
+
+-R runs each test several times and examines sys.gettotalrefcount() to
+see if the test appears to be leaking references. The argument should
+be of the form stab:run:fname where 'stab' is the number of times the
+test is run to let gettotalrefcount settle down, 'run' is the number
+of times further it is run and 'fname' is the name of the file the
+reports are written to. These parameters all have defaults (5, 4 and
+"reflog.txt" respectively), and the minimal invocation is '-R :'.
+
+-M runs tests that require an exorbitant amount of memory. These tests
+typically try to ascertain containers keep working when containing more than
+2 billion objects, which only works on 64-bit systems. There are also some
+tests that try to exhaust the address space of the process, which only makes
+sense on 32-bit systems with at least 2Gb of memory. The passed-in memlimit,
+which is a string in the form of '2.5Gb', determines howmuch memory the
+tests will limit themselves to (but they may go slightly over.) The number
+shouldn't be more memory than the machine has (including swap memory). You
+should also keep in mind that swap memory is generally much, much slower
+than RAM, and setting memlimit to all available RAM or higher will heavily
+tax the machine. On the other hand, it is no use running these tests with a
+limit of less than 2.5Gb, and many require more than 20Gb. Tests that expect
+to use more than memlimit memory will be skipped. The big-memory tests
+generally run very, very long.
+
+-u is used to specify which special resource intensive tests to run,
+such as those requiring large file support or network connectivity.
+The argument is a comma-separated list of words indicating the
+resources to test. Currently only the following are defined:
+
+ all - Enable all special resources.
+
+ none - Disable all special resources (this is the default).
+
+ audio - Tests that use the audio device. (There are known
+ cases of broken audio drivers that can crash Python or
+ even the Linux kernel.)
+
+ curses - Tests that use curses and will modify the terminal's
+ state and output modes.
+
+ largefile - It is okay to run some test that may create huge
+ files. These tests can take a long time and may
+ consume >2GB of disk space temporarily.
+
+ network - It is okay to run tests that use external network
+ resource, e.g. testing SSL support for sockets.
+
+ decimal - Test the decimal module against a large suite that
+ verifies compliance with standards.
+
+ cpu - Used for certain CPU-heavy tests.
+
+ subprocess Run all tests for the subprocess module.
+
+ urlfetch - It is okay to download files required on testing.
+
+ gui - Run tests that require a running GUI.
+
+To enable all resources except one, use '-uall,-<resource>'. For
+example, to run all the tests except for the gui tests, give the
+option '-uall,-gui'.
+"""
+
+
+RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network',
+ 'decimal', 'cpu', 'subprocess', 'urlfetch', 'gui')
+
+class _ArgParser(argparse.ArgumentParser):
+
+ def error(self, message):
+ super().error(message + "\nPass -h or --help for complete help.")
+
+
+def _create_parser():
+ # Set prog to prevent the uninformative "__main__.py" from displaying in
+ # error messages when using "python -m test ...".
+ parser = _ArgParser(prog='regrtest.py',
+ usage=USAGE,
+ description=DESCRIPTION,
+ epilog=EPILOG,
+ add_help=False,
+ formatter_class=argparse.RawDescriptionHelpFormatter)
+
+ # Arguments with this clause added to its help are described further in
+ # the epilog's "Additional option details" section.
+ more_details = ' See the section at bottom for more details.'
+
+ group = parser.add_argument_group('General options')
+ # We add help explicitly to control what argument group it renders under.
+ group.add_argument('-h', '--help', action='help',
+ help='show this help message and exit')
+ group.add_argument('--timeout', metavar='TIMEOUT', type=float,
+ help='dump the traceback and exit if a test takes '
+ 'more than TIMEOUT seconds; disabled if TIMEOUT '
+ 'is negative or equals to zero')
+ group.add_argument('--wait', action='store_true',
+ help='wait for user input, e.g., allow a debugger '
+ 'to be attached')
+ group.add_argument('--slaveargs', metavar='ARGS')
+ group.add_argument('-S', '--start', metavar='START',
+ help='the name of the test at which to start.' +
+ more_details)
+
+ group = parser.add_argument_group('Verbosity')
+ group.add_argument('-v', '--verbose', action='count',
+ help='run tests in verbose mode with output to stdout')
+ group.add_argument('-w', '--verbose2', action='store_true',
+ help='re-run failed tests in verbose mode')
+ group.add_argument('-W', '--verbose3', action='store_true',
+ help='display test output on failure')
+ group.add_argument('-q', '--quiet', action='store_true',
+ help='no output unless one or more tests fail')
+ group.add_argument('-o', '--slow', action='store_true', dest='print_slow',
+ help='print the slowest 10 tests')
+ group.add_argument('--header', action='store_true',
+ help='print header with interpreter info')
+
+ group = parser.add_argument_group('Selecting tests')
+ group.add_argument('-r', '--randomize', action='store_true',
+ help='randomize test execution order.' + more_details)
+ group.add_argument('--randseed', metavar='SEED',
+ dest='random_seed', type=int,
+ help='pass a random seed to reproduce a previous '
+ 'random run')
+ group.add_argument('-f', '--fromfile', metavar='FILE',
+ help='read names of tests to run from a file.' +
+ more_details)
+ group.add_argument('-x', '--exclude', action='store_true',
+ help='arguments are tests to *exclude*')
+ group.add_argument('-s', '--single', action='store_true',
+ help='single step through a set of tests.' +
+ more_details)
+ group.add_argument('-m', '--match', metavar='PAT',
+ dest='match_tests',
+ help='match test cases and methods with glob pattern PAT')
+ group.add_argument('-G', '--failfast', action='store_true',
+ help='fail as soon as a test fails (only with -v or -W)')
+ group.add_argument('-u', '--use', metavar='RES1,RES2,...',
+ action='append', type=resources_list,
+ help='specify which special resource intensive tests '
+ 'to run.' + more_details)
+ group.add_argument('-M', '--memlimit', metavar='LIMIT',
+ help='run very large memory-consuming tests.' +
+ more_details)
+ group.add_argument('--testdir', metavar='DIR',
+ type=relative_filename,
+ help='execute test files in the specified directory '
+ '(instead of the Python stdlib test suite)')
+
+ group = parser.add_argument_group('Special runs')
+ group.add_argument('-l', '--findleaks', action='store_true',
+ help='if GC is available detect tests that leak memory')
+ group.add_argument('-L', '--runleaks', action='store_true',
+ help='run the leaks(1) command just before exit.' +
+ more_details)
+ group.add_argument('-R', '--huntrleaks', metavar='RUNCOUNTS',
+ type=huntrleaks,
+ help='search for reference leaks (needs debug build, '
+ 'very slow).' + more_details)
+ group.add_argument('-j', '--multiprocess', metavar='PROCESSES',
+ dest='use_mp', type=int,
+ help='run PROCESSES processes at once')
+ group.add_argument('-T', '--coverage', action='store_true',
+ dest='trace',
+ help='turn on code coverage tracing using the trace '
+ 'module')
+ group.add_argument('-D', '--coverdir', metavar='DIR',
+ type=relative_filename,
+ help='directory where coverage files are put')
+ group.add_argument('-N', '--nocoverdir',
+ action='store_const', const=None, dest='coverdir',
+ help='put coverage files alongside modules')
+ group.add_argument('-t', '--threshold', metavar='THRESHOLD',
+ type=int,
+ help='call gc.set_threshold(THRESHOLD)')
+ group.add_argument('-n', '--nowindows', action='store_true',
+ help='suppress error message boxes on Windows')
+ group.add_argument('-F', '--forever', action='store_true',
+ help='run the specified tests in a loop, until an '
+ 'error happens')
+ group.add_argument('--list-tests', action='store_true',
+ help="only write the name of tests that will be run, "
+ "don't execute them")
+ group.add_argument('-P', '--pgo', dest='pgo', action='store_true',
+ help='enable Profile Guided Optimization training')
+
+ parser.add_argument('args', nargs=argparse.REMAINDER,
+ help=argparse.SUPPRESS)
+
+ return parser
+
+
+def relative_filename(string):
+ # CWD is replaced with a temporary dir before calling main(), so we
+ # join it with the saved CWD so it ends up where the user expects.
+ return os.path.join(support.SAVEDCWD, string)
+
+
+def huntrleaks(string):
+ args = string.split(':')
+ if len(args) not in (2, 3):
+ raise argparse.ArgumentTypeError(
+ 'needs 2 or 3 colon-separated arguments')
+ nwarmup = int(args[0]) if args[0] else 5
+ ntracked = int(args[1]) if args[1] else 4
+ fname = args[2] if len(args) > 2 and args[2] else 'reflog.txt'
+ return nwarmup, ntracked, fname
+
+
+def resources_list(string):
+ u = [x.lower() for x in string.split(',')]
+ for r in u:
+ if r == 'all' or r == 'none':
+ continue
+ if r[0] == '-':
+ r = r[1:]
+ if r not in RESOURCE_NAMES:
+ raise argparse.ArgumentTypeError('invalid resource: ' + r)
+ return u
+
+
+def _parse_args(args, **kwargs):
+ # Defaults
+ ns = argparse.Namespace(testdir=None, verbose=0, quiet=False,
+ exclude=False, single=False, randomize=False, fromfile=None,
+ findleaks=False, use_resources=None, trace=False, coverdir='coverage',
+ runleaks=False, huntrleaks=False, verbose2=False, print_slow=False,
+ random_seed=None, use_mp=None, verbose3=False, forever=False,
+ header=False, failfast=False, match_tests=None, pgo=False)
+ for k, v in kwargs.items():
+ if not hasattr(ns, k):
+ raise TypeError('%r is an invalid keyword argument '
+ 'for this function' % k)
+ setattr(ns, k, v)
+ if ns.use_resources is None:
+ ns.use_resources = []
+
+ parser = _create_parser()
+ parser.parse_args(args=args, namespace=ns)
+
+ if ns.single and ns.fromfile:
+ parser.error("-s and -f don't go together!")
+ if ns.use_mp and ns.trace:
+ parser.error("-T and -j don't go together!")
+ if ns.use_mp and ns.findleaks:
+ parser.error("-l and -j don't go together!")
+ if ns.failfast and not (ns.verbose or ns.verbose3):
+ parser.error("-G/--failfast needs either -v or -W")
+ if ns.pgo and (ns.verbose or ns.verbose2 or ns.verbose3):
+ parser.error("--pgo/-v don't go together!")
+
+ if ns.nowindows:
+ print("Warning: the --nowindows (-n) option is deprecated. "
+ "Use -vv to display assertions in stderr.", file=sys.stderr)
+
+ if ns.quiet:
+ ns.verbose = 0
+ if ns.timeout is not None:
+ if ns.timeout <= 0:
+ ns.timeout = None
+ if ns.use_mp is not None:
+ if ns.use_mp <= 0:
+ # Use all cores + extras for tests that like to sleep
+ ns.use_mp = 2 + (os.cpu_count() or 1)
+ if ns.use:
+ for a in ns.use:
+ for r in a:
+ if r == 'all':
+ ns.use_resources[:] = RESOURCE_NAMES
+ continue
+ if r == 'none':
+ del ns.use_resources[:]
+ continue
+ remove = False
+ if r[0] == '-':
+ remove = True
+ r = r[1:]
+ if remove:
+ if r in ns.use_resources:
+ ns.use_resources.remove(r)
+ elif r not in ns.use_resources:
+ ns.use_resources.append(r)
+ if ns.random_seed is not None:
+ ns.randomize = True
+
+ return ns
diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
new file mode 100644
index 0000000..e503c13
--- /dev/null
+++ b/Lib/test/libregrtest/main.py
@@ -0,0 +1,508 @@
+import datetime
+import faulthandler
+import math
+import os
+import platform
+import random
+import re
+import sys
+import sysconfig
+import tempfile
+import textwrap
+import time
+from test.libregrtest.cmdline import _parse_args
+from test.libregrtest.runtest import (
+ findtests, runtest,
+ STDTESTS, NOTTESTS, PASSED, FAILED, ENV_CHANGED, SKIPPED, RESOURCE_DENIED,
+ INTERRUPTED, CHILD_ERROR,
+ PROGRESS_MIN_TIME, format_test_result)
+from test.libregrtest.setup import setup_tests
+from test import support
+try:
+ import gc
+except ImportError:
+ gc = None
+
+
+# When tests are run from the Python build directory, it is best practice
+# to keep the test files in a subfolder. This eases the cleanup of leftover
+# files using the "make distclean" command.
+if sysconfig.is_python_build():
+ TEMPDIR = os.path.join(sysconfig.get_config_var('srcdir'), 'build')
+else:
+ TEMPDIR = tempfile.gettempdir()
+TEMPDIR = os.path.abspath(TEMPDIR)
+
+
+class Regrtest:
+ """Execute a test suite.
+
+ This also parses command-line options and modifies its behavior
+ accordingly.
+
+ tests -- a list of strings containing test names (optional)
+ testdir -- the directory in which to look for tests (optional)
+
+ Users other than the Python test suite will certainly want to
+ specify testdir; if it's omitted, the directory containing the
+ Python test suite is searched for.
+
+ If the tests argument is omitted, the tests listed on the
+ command-line will be used. If that's empty, too, then all *.py
+ files beginning with test_ will be used.
+
+ The other default arguments (verbose, quiet, exclude,
+ single, randomize, findleaks, use_resources, trace, coverdir,
+ print_slow, and random_seed) allow programmers calling main()
+ directly to set the values that would normally be set by flags
+ on the command line.
+ """
+ def __init__(self):
+ # Namespace of command line options
+ self.ns = None
+
+ # tests
+ self.tests = []
+ self.selected = []
+
+ # test results
+ self.good = []
+ self.bad = []
+ self.skipped = []
+ self.resource_denieds = []
+ self.environment_changed = []
+ self.interrupted = False
+
+ # used by --slow
+ self.test_times = []
+
+ # used by --coverage, trace.Trace instance
+ self.tracer = None
+
+ # used by --findleaks, store for gc.garbage
+ self.found_garbage = []
+
+ # used to display the progress bar "[ 3/100]"
+ self.start_time = time.monotonic()
+ self.test_count = ''
+ self.test_count_width = 1
+
+ # used by --single
+ self.next_single_test = None
+ self.next_single_filename = None
+
+ def accumulate_result(self, test, result):
+ ok, test_time = result
+ if ok not in (CHILD_ERROR, INTERRUPTED):
+ self.test_times.append((test_time, test))
+ if ok == PASSED:
+ self.good.append(test)
+ elif ok == FAILED:
+ self.bad.append(test)
+ elif ok == ENV_CHANGED:
+ self.environment_changed.append(test)
+ elif ok == SKIPPED:
+ self.skipped.append(test)
+ elif ok == RESOURCE_DENIED:
+ self.skipped.append(test)
+ self.resource_denieds.append(test)
+
+ def time_delta(self, ceil=False):
+ seconds = time.monotonic() - self.start_time
+ if ceil:
+ seconds = math.ceil(seconds)
+ else:
+ seconds = int(seconds)
+ return datetime.timedelta(seconds=seconds)
+
+ def display_progress(self, test_index, test):
+ if self.ns.quiet:
+ return
+ if self.bad and not self.ns.pgo:
+ fmt = "{time} [{test_index:{count_width}}{test_count}/{nbad}] {test_name}"
+ else:
+ fmt = "{time} [{test_index:{count_width}}{test_count}] {test_name}"
+ line = fmt.format(count_width=self.test_count_width,
+ test_index=test_index,
+ test_count=self.test_count,
+ nbad=len(self.bad),
+ test_name=test,
+ time=self.time_delta())
+ print(line, flush=True)
+
+ def parse_args(self, kwargs):
+ ns = _parse_args(sys.argv[1:], **kwargs)
+
+ if ns.timeout and not hasattr(faulthandler, 'dump_traceback_later'):
+ print("Warning: The timeout option requires "
+ "faulthandler.dump_traceback_later", file=sys.stderr)
+ ns.timeout = None
+
+ if ns.threshold is not None and gc is None:
+ print('No GC available, ignore --threshold.', file=sys.stderr)
+ ns.threshold = None
+
+ if ns.findleaks:
+ if gc is not None:
+ # Uncomment the line below to report garbage that is not
+ # freeable by reference counting alone. By default only
+ # garbage that is not collectable by the GC is reported.
+ pass
+ #gc.set_debug(gc.DEBUG_SAVEALL)
+ else:
+ print('No GC available, disabling --findleaks',
+ file=sys.stderr)
+ ns.findleaks = False
+
+ # Strip .py extensions.
+ removepy(ns.args)
+
+ return ns
+
+ def find_tests(self, tests):
+ self.tests = tests
+
+ if self.ns.single:
+ self.next_single_filename = os.path.join(TEMPDIR, 'pynexttest')
+ try:
+ with open(self.next_single_filename, 'r') as fp:
+ next_test = fp.read().strip()
+ self.tests = [next_test]
+ except OSError:
+ pass
+
+ if self.ns.fromfile:
+ self.tests = []
+ # regex to match 'test_builtin' in line:
+ # '0:00:00 [ 4/400] test_builtin -- test_dict took 1 sec'
+ regex = (r'^(?:[0-9]+:[0-9]+:[0-9]+ *)?'
+ r'(?:\[[0-9/ ]+\] *)?'
+ r'(test_[a-zA-Z0-9_]+)')
+ regex = re.compile(regex)
+ with open(os.path.join(support.SAVEDCWD, self.ns.fromfile)) as fp:
+ for line in fp:
+ line = line.strip()
+ if line.startswith('#'):
+ continue
+ match = regex.match(line)
+ if match is None:
+ continue
+ self.tests.append(match.group(1))
+
+ removepy(self.tests)
+
+ stdtests = STDTESTS[:]
+ nottests = NOTTESTS.copy()
+ if self.ns.exclude:
+ for arg in self.ns.args:
+ if arg in stdtests:
+ stdtests.remove(arg)
+ nottests.add(arg)
+ self.ns.args = []
+
+ # if testdir is set, then we are not running the python tests suite, so
+ # don't add default tests to be executed or skipped (pass empty values)
+ if self.ns.testdir:
+ alltests = findtests(self.ns.testdir, list(), set())
+ else:
+ alltests = findtests(self.ns.testdir, stdtests, nottests)
+
+ if not self.ns.fromfile:
+ self.selected = self.tests or self.ns.args or alltests
+ else:
+ self.selected = self.tests
+ if self.ns.single:
+ self.selected = self.selected[:1]
+ try:
+ pos = alltests.index(self.selected[0])
+ self.next_single_test = alltests[pos + 1]
+ except IndexError:
+ pass
+
+ # Remove all the selected tests that precede start if it's set.
+ if self.ns.start:
+ try:
+ del self.selected[:self.selected.index(self.ns.start)]
+ except ValueError:
+ print("Couldn't find starting test (%s), using all tests"
+ % self.ns.start, file=sys.stderr)
+
+ if self.ns.randomize:
+ if self.ns.random_seed is None:
+ self.ns.random_seed = random.randrange(10000000)
+ random.seed(self.ns.random_seed)
+ random.shuffle(self.selected)
+
+ def list_tests(self):
+ for name in self.selected:
+ print(name)
+
+ def rerun_failed_tests(self):
+ self.ns.verbose = True
+ self.ns.failfast = False
+ self.ns.verbose3 = False
+ self.ns.match_tests = None
+
+ print("Re-running failed tests in verbose mode")
+ for test in self.bad[:]:
+ print("Re-running test %r in verbose mode" % test, flush=True)
+ try:
+ self.ns.verbose = True
+ ok = runtest(self.ns, test)
+ except KeyboardInterrupt:
+ # print a newline separate from the ^C
+ print()
+ break
+ else:
+ if ok[0] in {PASSED, ENV_CHANGED, SKIPPED, RESOURCE_DENIED}:
+ self.bad.remove(test)
+ else:
+ if self.bad:
+ print(count(len(self.bad), 'test'), "failed again:")
+ printlist(self.bad)
+
+ def display_result(self):
+ if self.interrupted:
+ # print a newline after ^C
+ print()
+ print("Test suite interrupted by signal SIGINT.")
+ executed = set(self.good) | set(self.bad) | set(self.skipped)
+ omitted = set(self.selected) - executed
+ print(count(len(omitted), "test"), "omitted:")
+ printlist(omitted)
+
+ # If running the test suite for PGO then no one cares about
+ # results.
+ if self.ns.pgo:
+ return
+
+ if self.good and not self.ns.quiet:
+ if (not self.bad
+ and not self.skipped
+ and not self.interrupted
+ and len(self.good) > 1):
+ print("All", end=' ')
+ print(count(len(self.good), "test"), "OK.")
+
+ if self.ns.print_slow:
+ self.test_times.sort(reverse=True)
+ print("10 slowest tests:")
+ for time, test in self.test_times[:10]:
+ print("%s: %.1fs" % (test, time))
+
+ if self.bad:
+ print(count(len(self.bad), "test"), "failed:")
+ printlist(self.bad)
+
+ if self.environment_changed:
+ print("{} altered the execution environment:".format(
+ count(len(self.environment_changed), "test")))
+ printlist(self.environment_changed)
+
+ if self.skipped and not self.ns.quiet:
+ print(count(len(self.skipped), "test"), "skipped:")
+ printlist(self.skipped)
+
+ def run_tests_sequential(self):
+ if self.ns.trace:
+ import trace
+ self.tracer = trace.Trace(trace=False, count=True)
+
+ save_modules = sys.modules.keys()
+
+ print("Run tests sequentially")
+
+ previous_test = None
+ for test_index, test in enumerate(self.tests, 1):
+ start_time = time.monotonic()
+
+ text = test
+ if previous_test:
+ text = '%s -- %s' % (text, previous_test)
+ self.display_progress(test_index, text)
+
+ if self.tracer:
+ # If we're tracing code coverage, then we don't exit with status
+ # if on a false return value from main.
+ cmd = ('result = runtest(self.ns, test); '
+ 'self.accumulate_result(test, result)')
+ ns = dict(locals())
+ self.tracer.runctx(cmd, globals=globals(), locals=ns)
+ result = ns['result']
+ else:
+ try:
+ result = runtest(self.ns, test)
+ except KeyboardInterrupt:
+ self.accumulate_result(test, (INTERRUPTED, None))
+ self.interrupted = True
+ break
+ else:
+ self.accumulate_result(test, result)
+
+ previous_test = format_test_result(test, result[0])
+ test_time = time.monotonic() - start_time
+ if test_time >= PROGRESS_MIN_TIME:
+ previous_test = "%s in %.0f sec" % (previous_test, test_time)
+ elif result[0] == PASSED:
+ # be quiet: say nothing if the test passed shortly
+ previous_test = None
+
+ if self.ns.findleaks:
+ gc.collect()
+ if gc.garbage:
+ print("Warning: test created", len(gc.garbage), end=' ')
+ print("uncollectable object(s).")
+ # move the uncollectable objects somewhere so we don't see
+ # them again
+ self.found_garbage.extend(gc.garbage)
+ del gc.garbage[:]
+
+ # Unload the newly imported modules (best effort finalization)
+ for module in sys.modules.keys():
+ if module not in save_modules and module.startswith("test."):
+ support.unload(module)
+
+ if previous_test:
+ print(previous_test)
+
+ def _test_forever(self, tests):
+ while True:
+ for test in tests:
+ yield test
+ if self.bad:
+ return
+
+ def run_tests(self):
+ # For a partial run, we do not need to clutter the output.
+ if (self.ns.verbose
+ or self.ns.header
+ or not (self.ns.pgo or self.ns.quiet or self.ns.single
+ or self.tests or self.ns.args)):
+ # Print basic platform information
+ print("==", platform.python_implementation(), *sys.version.split())
+ print("== ", platform.platform(aliased=True),
+ "%s-endian" % sys.byteorder)
+ print("== ", "hash algorithm:", sys.hash_info.algorithm,
+ "64bit" if sys.maxsize > 2**32 else "32bit")
+ print("== ", os.getcwd())
+ print("Testing with flags:", sys.flags)
+
+ if self.ns.randomize:
+ print("Using random seed", self.ns.random_seed)
+
+ if self.ns.forever:
+ self.tests = self._test_forever(list(self.selected))
+ self.test_count = ''
+ self.test_count_width = 3
+ else:
+ self.tests = iter(self.selected)
+ self.test_count = '/{}'.format(len(self.selected))
+ self.test_count_width = len(self.test_count) - 1
+
+ if self.ns.use_mp:
+ from test.libregrtest.runtest_mp import run_tests_multiprocess
+ run_tests_multiprocess(self)
+ else:
+ self.run_tests_sequential()
+
+ def finalize(self):
+ if self.next_single_filename:
+ if self.next_single_test:
+ with open(self.next_single_filename, 'w') as fp:
+ fp.write(self.next_single_test + '\n')
+ else:
+ os.unlink(self.next_single_filename)
+
+ if self.tracer:
+ r = self.tracer.results()
+ r.write_results(show_missing=True, summary=True,
+ coverdir=self.ns.coverdir)
+
+ print("Total duration: %s" % self.time_delta(ceil=True))
+
+ if self.ns.runleaks:
+ os.system("leaks %d" % os.getpid())
+
+ def main(self, tests=None, **kwargs):
+ global TEMPDIR
+
+ if sysconfig.is_python_build():
+ try:
+ os.mkdir(TEMPDIR)
+ except FileExistsError:
+ pass
+
+ # Define a writable temp dir that will be used as cwd while running
+ # the tests. The name of the dir includes the pid to allow parallel
+ # testing (see the -j option).
+ test_cwd = 'test_python_{}'.format(os.getpid())
+ test_cwd = os.path.join(TEMPDIR, test_cwd)
+
+ # Run the tests in a context manager that temporarily changes the CWD to a
+ # temporary and writable directory. If it's not possible to create or
+ # change the CWD, the original CWD will be used. The original CWD is
+ # available from support.SAVEDCWD.
+ with support.temp_cwd(test_cwd, quiet=True):
+ self._main(tests, kwargs)
+
+ def _main(self, tests, kwargs):
+ self.ns = self.parse_args(kwargs)
+
+ if self.ns.slaveargs is not None:
+ from test.libregrtest.runtest_mp import run_tests_slave
+ run_tests_slave(self.ns.slaveargs)
+
+ if self.ns.wait:
+ input("Press any key to continue...")
+
+ setup_tests(self.ns)
+
+ self.find_tests(tests)
+
+ if self.ns.list_tests:
+ self.list_tests()
+ sys.exit(0)
+
+ self.run_tests()
+ self.display_result()
+
+ if self.ns.verbose2 and self.bad:
+ self.rerun_failed_tests()
+
+ self.finalize()
+ sys.exit(len(self.bad) > 0 or self.interrupted)
+
+
+def removepy(names):
+ if not names:
+ return
+ for idx, name in enumerate(names):
+ basename, ext = os.path.splitext(name)
+ if ext == '.py':
+ names[idx] = basename
+
+
+def count(n, word):
+ if n == 1:
+ return "%d %s" % (n, word)
+ else:
+ return "%d %ss" % (n, word)
+
+
+def printlist(x, width=70, indent=4):
+ """Print the elements of iterable x to stdout.
+
+ Optional arg width (default 70) is the maximum line length.
+ Optional arg indent (default 4) is the number of blanks with which to
+ begin each line.
+ """
+
+ blanks = ' ' * indent
+ # Print the sorted list: 'x' may be a '--random' list or a set()
+ print(textwrap.fill(' '.join(str(elt) for elt in sorted(x)), width,
+ initial_indent=blanks, subsequent_indent=blanks))
+
+
+def main(tests=None, **kwargs):
+ """Run the Python suite."""
+ Regrtest().main(tests=tests, **kwargs)
diff --git a/Lib/test/libregrtest/refleak.py b/Lib/test/libregrtest/refleak.py
new file mode 100644
index 0000000..59dc49f
--- /dev/null
+++ b/Lib/test/libregrtest/refleak.py
@@ -0,0 +1,202 @@
+import errno
+import os
+import re
+import sys
+import warnings
+from inspect import isabstract
+from test import support
+
+
+try:
+ MAXFD = os.sysconf("SC_OPEN_MAX")
+except Exception:
+ MAXFD = 256
+
+
+def fd_count():
+ """Count the number of open file descriptors"""
+ if sys.platform.startswith(('linux', 'freebsd')):
+ try:
+ names = os.listdir("/proc/self/fd")
+ return len(names)
+ except FileNotFoundError:
+ pass
+
+ count = 0
+ for fd in range(MAXFD):
+ try:
+ # Prefer dup() over fstat(). fstat() can require input/output
+ # whereas dup() doesn't.
+ fd2 = os.dup(fd)
+ except OSError as e:
+ if e.errno != errno.EBADF:
+ raise
+ else:
+ os.close(fd2)
+ count += 1
+ return count
+
+
+def dash_R(the_module, test, indirect_test, huntrleaks):
+ """Run a test multiple times, looking for reference leaks.
+
+ Returns:
+ False if the test didn't leak references; True if we detected refleaks.
+ """
+ # This code is hackish and inelegant, but it seems to do the job.
+ import copyreg
+ import collections.abc
+
+ if not hasattr(sys, 'gettotalrefcount'):
+ raise Exception("Tracking reference leaks requires a debug build "
+ "of Python")
+
+ # Save current values for dash_R_cleanup() to restore.
+ fs = warnings.filters[:]
+ ps = copyreg.dispatch_table.copy()
+ pic = sys.path_importer_cache.copy()
+ try:
+ import zipimport
+ except ImportError:
+ zdc = None # Run unmodified on platforms without zipimport support
+ else:
+ zdc = zipimport._zip_directory_cache.copy()
+ abcs = {}
+ for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]:
+ if not isabstract(abc):
+ continue
+ for obj in abc.__subclasses__() + [abc]:
+ abcs[obj] = obj._abc_registry.copy()
+
+ nwarmup, ntracked, fname = huntrleaks
+ fname = os.path.join(support.SAVEDCWD, fname)
+ repcount = nwarmup + ntracked
+ rc_deltas = [0] * repcount
+ alloc_deltas = [0] * repcount
+ fd_deltas = [0] * repcount
+
+ print("beginning", repcount, "repetitions", file=sys.stderr)
+ print(("1234567890"*(repcount//10 + 1))[:repcount], file=sys.stderr,
+ flush=True)
+ # initialize variables to make pyflakes quiet
+ rc_before = alloc_before = fd_before = 0
+ for i in range(repcount):
+ indirect_test()
+ alloc_after, rc_after, fd_after = dash_R_cleanup(fs, ps, pic, zdc,
+ abcs)
+ print('.', end='', flush=True)
+ if i >= nwarmup:
+ rc_deltas[i] = rc_after - rc_before
+ alloc_deltas[i] = alloc_after - alloc_before
+ fd_deltas[i] = fd_after - fd_before
+ alloc_before = alloc_after
+ rc_before = rc_after
+ fd_before = fd_after
+ print(file=sys.stderr)
+ # These checkers return False on success, True on failure
+ def check_rc_deltas(deltas):
+ return any(deltas)
+ def check_alloc_deltas(deltas):
+ # At least 1/3rd of 0s
+ if 3 * deltas.count(0) < len(deltas):
+ return True
+ # Nothing else than 1s, 0s and -1s
+ if not set(deltas) <= {1,0,-1}:
+ return True
+ return False
+ failed = False
+ for deltas, item_name, checker in [
+ (rc_deltas, 'references', check_rc_deltas),
+ (alloc_deltas, 'memory blocks', check_alloc_deltas),
+ (fd_deltas, 'file descriptors', check_rc_deltas)]:
+ if checker(deltas):
+ msg = '%s leaked %s %s, sum=%s' % (
+ test, deltas[nwarmup:], item_name, sum(deltas))
+ print(msg, file=sys.stderr, flush=True)
+ with open(fname, "a") as refrep:
+ print(msg, file=refrep)
+ refrep.flush()
+ failed = True
+ return failed
+
+
+def dash_R_cleanup(fs, ps, pic, zdc, abcs):
+ import gc, copyreg
+ import _strptime, linecache
+ import urllib.parse, urllib.request, mimetypes, doctest
+ import struct, filecmp, collections.abc
+ from distutils.dir_util import _path_created
+ from weakref import WeakSet
+
+ # Clear the warnings registry, so they can be displayed again
+ for mod in sys.modules.values():
+ if hasattr(mod, '__warningregistry__'):
+ del mod.__warningregistry__
+
+ # Restore some original values.
+ warnings.filters[:] = fs
+ copyreg.dispatch_table.clear()
+ copyreg.dispatch_table.update(ps)
+ sys.path_importer_cache.clear()
+ sys.path_importer_cache.update(pic)
+ try:
+ import zipimport
+ except ImportError:
+ pass # Run unmodified on platforms without zipimport support
+ else:
+ zipimport._zip_directory_cache.clear()
+ zipimport._zip_directory_cache.update(zdc)
+
+ # clear type cache
+ sys._clear_type_cache()
+
+ # Clear ABC registries, restoring previously saved ABC registries.
+ for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]:
+ if not isabstract(abc):
+ continue
+ for obj in abc.__subclasses__() + [abc]:
+ obj._abc_registry = abcs.get(obj, WeakSet()).copy()
+ obj._abc_cache.clear()
+ obj._abc_negative_cache.clear()
+
+ # Flush standard output, so that buffered data is sent to the OS and
+ # associated Python objects are reclaimed.
+ for stream in (sys.stdout, sys.stderr, sys.__stdout__, sys.__stderr__):
+ if stream is not None:
+ stream.flush()
+
+ # Clear assorted module caches.
+ _path_created.clear()
+ re.purge()
+ _strptime._regex_cache.clear()
+ urllib.parse.clear_cache()
+ urllib.request.urlcleanup()
+ linecache.clearcache()
+ mimetypes._default_mime_types()
+ filecmp._cache.clear()
+ struct._clearcache()
+ doctest.master = None
+ try:
+ import ctypes
+ except ImportError:
+ # Don't worry about resetting the cache if ctypes is not supported
+ pass
+ else:
+ ctypes._reset_cache()
+
+ # Collect cyclic trash and read memory statistics immediately after.
+ func1 = sys.getallocatedblocks
+ func2 = sys.gettotalrefcount
+ gc.collect()
+ return func1(), func2(), fd_count()
+
+
+def warm_caches():
+ # char cache
+ s = bytes(range(256))
+ for i in range(256):
+ s[i:i+1]
+ # unicode cache
+ [chr(i) for i in range(256)]
+ # int cache
+ list(range(-5, 257))
diff --git a/Lib/test/libregrtest/runtest.py b/Lib/test/libregrtest/runtest.py
new file mode 100644
index 0000000..ef1feb7
--- /dev/null
+++ b/Lib/test/libregrtest/runtest.py
@@ -0,0 +1,260 @@
+import faulthandler
+import importlib
+import io
+import os
+import sys
+import time
+import traceback
+import unittest
+from test import support
+from test.libregrtest.refleak import dash_R
+from test.libregrtest.save_env import saved_test_environment
+
+
+# Test result constants.
+PASSED = 1
+FAILED = 0
+ENV_CHANGED = -1
+SKIPPED = -2
+RESOURCE_DENIED = -3
+INTERRUPTED = -4
+CHILD_ERROR = -5 # error in a child process
+
+_FORMAT_TEST_RESULT = {
+ PASSED: '%s passed',
+ FAILED: '%s failed',
+ ENV_CHANGED: '%s failed (env changed)',
+ SKIPPED: '%s skipped',
+ RESOURCE_DENIED: '%s skipped (resource denied)',
+ INTERRUPTED: '%s interrupted',
+ CHILD_ERROR: '%s crashed',
+}
+
+# Minimum duration of a test to display its duration or to mention that
+# the test is running in background
+PROGRESS_MIN_TIME = 30.0 # seconds
+
+# small set of tests to determine if we have a basically functioning interpreter
+# (i.e. if any of these fail, then anything else is likely to follow)
+STDTESTS = [
+ 'test_grammar',
+ 'test_opcodes',
+ 'test_dict',
+ 'test_builtin',
+ 'test_exceptions',
+ 'test_types',
+ 'test_unittest',
+ 'test_doctest',
+ 'test_doctest2',
+ 'test_support'
+]
+
+# set of tests that we don't want to be executed when using regrtest
+NOTTESTS = set()
+
+
+def format_test_result(test_name, result):
+ fmt = _FORMAT_TEST_RESULT.get(result, "%s")
+ return fmt % test_name
+
+
+def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
+ """Return a list of all applicable test modules."""
+ testdir = findtestdir(testdir)
+ names = os.listdir(testdir)
+ tests = []
+ others = set(stdtests) | nottests
+ for name in names:
+ mod, ext = os.path.splitext(name)
+ if mod[:5] == "test_" and ext in (".py", "") and mod not in others:
+ tests.append(mod)
+ return stdtests + sorted(tests)
+
+
+def runtest(ns, test):
+ """Run a single test.
+
+ test -- the name of the test
+ verbose -- if true, print more messages
+ quiet -- if true, don't print 'skipped' messages (probably redundant)
+ huntrleaks -- run multiple times to test for leaks; requires a debug
+ build; a triple corresponding to -R's three arguments
+ output_on_failure -- if true, display test output on failure
+ timeout -- dump the traceback and exit if a test takes more than
+ timeout seconds
+ failfast, match_tests -- See regrtest command-line flags for these.
+ pgo -- if true, suppress any info irrelevant to a generating a PGO build
+
+ Returns the tuple result, test_time, where result is one of the constants:
+ INTERRUPTED KeyboardInterrupt when run under -j
+ RESOURCE_DENIED test skipped because resource denied
+ SKIPPED test skipped for some other reason
+ ENV_CHANGED test failed because it changed the execution environment
+ FAILED test failed
+ PASSED test passed
+ """
+
+ verbose = ns.verbose
+ quiet = ns.quiet
+ huntrleaks = ns.huntrleaks
+ output_on_failure = ns.verbose3
+ failfast = ns.failfast
+ match_tests = ns.match_tests
+ timeout = ns.timeout
+ pgo = ns.pgo
+
+ use_timeout = (timeout is not None)
+ if use_timeout:
+ faulthandler.dump_traceback_later(timeout, exit=True)
+ try:
+ support.match_tests = match_tests
+ if failfast:
+ support.failfast = True
+ if output_on_failure:
+ support.verbose = True
+
+ # Reuse the same instance to all calls to runtest(). Some
+ # tests keep a reference to sys.stdout or sys.stderr
+ # (eg. test_argparse).
+ if runtest.stringio is None:
+ stream = io.StringIO()
+ runtest.stringio = stream
+ else:
+ stream = runtest.stringio
+ stream.seek(0)
+ stream.truncate()
+
+ orig_stdout = sys.stdout
+ orig_stderr = sys.stderr
+ try:
+ sys.stdout = stream
+ sys.stderr = stream
+ result = runtest_inner(ns, test, verbose, quiet, huntrleaks,
+ display_failure=False, pgo=pgo)
+ if result[0] == FAILED:
+ output = stream.getvalue()
+ orig_stderr.write(output)
+ orig_stderr.flush()
+ finally:
+ sys.stdout = orig_stdout
+ sys.stderr = orig_stderr
+ else:
+ support.verbose = verbose # Tell tests to be moderately quiet
+ result = runtest_inner(ns, test, verbose, quiet, huntrleaks,
+ display_failure=not verbose, pgo=pgo)
+ return result
+ finally:
+ if use_timeout:
+ faulthandler.cancel_dump_traceback_later()
+ cleanup_test_droppings(test, verbose)
+runtest.stringio = None
+
+
+def runtest_inner(ns, test, verbose, quiet,
+ huntrleaks=False, display_failure=True, *, pgo=False):
+ support.unload(test)
+
+ test_time = 0.0
+ refleak = False # True if the test leaked references.
+ try:
+ if test.startswith('test.') or ns.testdir:
+ abstest = test
+ else:
+ # Always import it from the test package
+ abstest = 'test.' + test
+ with saved_test_environment(test, verbose, quiet, pgo=pgo) as environment:
+ start_time = time.time()
+ the_module = importlib.import_module(abstest)
+ # If the test has a test_main, that will run the appropriate
+ # tests. If not, use normal unittest test loading.
+ test_runner = getattr(the_module, "test_main", None)
+ if test_runner is None:
+ def test_runner():
+ loader = unittest.TestLoader()
+ tests = loader.loadTestsFromModule(the_module)
+ for error in loader.errors:
+ print(error, file=sys.stderr)
+ if loader.errors:
+ raise Exception("errors while loading tests")
+ support.run_unittest(tests)
+ test_runner()
+ if huntrleaks:
+ refleak = dash_R(the_module, test, test_runner, huntrleaks)
+ test_time = time.time() - start_time
+ except support.ResourceDenied as msg:
+ if not quiet and not pgo:
+ print(test, "skipped --", msg, flush=True)
+ return RESOURCE_DENIED, test_time
+ except unittest.SkipTest as msg:
+ if not quiet and not pgo:
+ print(test, "skipped --", msg, flush=True)
+ return SKIPPED, test_time
+ except KeyboardInterrupt:
+ raise
+ except support.TestFailed as msg:
+ if not pgo:
+ if display_failure:
+ print("test", test, "failed --", msg, file=sys.stderr,
+ flush=True)
+ else:
+ print("test", test, "failed", file=sys.stderr, flush=True)
+ return FAILED, test_time
+ except:
+ msg = traceback.format_exc()
+ if not pgo:
+ print("test", test, "crashed --", msg, file=sys.stderr,
+ flush=True)
+ return FAILED, test_time
+ else:
+ if refleak:
+ return FAILED, test_time
+ if environment.changed:
+ return ENV_CHANGED, test_time
+ return PASSED, test_time
+
+
+def cleanup_test_droppings(testname, verbose):
+ import shutil
+ import stat
+ import gc
+
+ # First kill any dangling references to open files etc.
+ # This can also issue some ResourceWarnings which would otherwise get
+ # triggered during the following test run, and possibly produce failures.
+ gc.collect()
+
+ # Try to clean up junk commonly left behind. While tests shouldn't leave
+ # any files or directories behind, when a test fails that can be tedious
+ # for it to arrange. The consequences can be especially nasty on Windows,
+ # since if a test leaves a file open, it cannot be deleted by name (while
+ # there's nothing we can do about that here either, we can display the
+ # name of the offending test, which is a real help).
+ for name in (support.TESTFN,
+ "db_home",
+ ):
+ if not os.path.exists(name):
+ continue
+
+ if os.path.isdir(name):
+ kind, nuker = "directory", shutil.rmtree
+ elif os.path.isfile(name):
+ kind, nuker = "file", os.unlink
+ else:
+ raise SystemError("os.path says %r exists but is neither "
+ "directory nor file" % name)
+
+ if verbose:
+ print("%r left behind %s %r" % (testname, kind, name))
+ try:
+ # if we have chmod, fix possible permissions problems
+ # that might prevent cleanup
+ if (hasattr(os, 'chmod')):
+ os.chmod(name, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
+ nuker(name)
+ except Exception as msg:
+ print(("%r left behind %s %r and it couldn't be "
+ "removed: %s" % (testname, kind, name, msg)), file=sys.stderr)
+
+
+def findtestdir(path=None):
+ return path or os.path.dirname(os.path.dirname(__file__)) or os.curdir
diff --git a/Lib/test/libregrtest/runtest_mp.py b/Lib/test/libregrtest/runtest_mp.py
new file mode 100644
index 0000000..9604c16
--- /dev/null
+++ b/Lib/test/libregrtest/runtest_mp.py
@@ -0,0 +1,245 @@
+import faulthandler
+import json
+import os
+import queue
+import sys
+import time
+import traceback
+import types
+from test import support
+try:
+ import threading
+except ImportError:
+ print("Multiprocess option requires thread support")
+ sys.exit(2)
+
+from test.libregrtest.runtest import (
+ runtest, INTERRUPTED, CHILD_ERROR, PROGRESS_MIN_TIME,
+ format_test_result)
+from test.libregrtest.setup import setup_tests
+
+
+# Display the running tests if nothing happened last N seconds
+PROGRESS_UPDATE = 30.0 # seconds
+
+# If interrupted, display the wait progress every N seconds
+WAIT_PROGRESS = 2.0 # seconds
+
+
+def run_test_in_subprocess(testname, ns):
+ """Run the given test in a subprocess with --slaveargs.
+
+ ns is the option Namespace parsed from command-line arguments. regrtest
+ is invoked in a subprocess with the --slaveargs argument; when the
+ subprocess exits, its return code, stdout and stderr are returned as a
+ 3-tuple.
+ """
+ from subprocess import Popen, PIPE
+
+ ns_dict = vars(ns)
+ slaveargs = (ns_dict, testname)
+ slaveargs = json.dumps(slaveargs)
+
+ cmd = [sys.executable, *support.args_from_interpreter_flags(),
+ '-X', 'faulthandler',
+ '-m', 'test.regrtest',
+ '--slaveargs', slaveargs]
+ if ns.pgo:
+ cmd += ['--pgo']
+
+ # Running the child from the same working directory as regrtest's original
+ # invocation ensures that TEMPDIR for the child is the same when
+ # sysconfig.is_python_build() is true. See issue 15300.
+ popen = Popen(cmd,
+ stdout=PIPE, stderr=PIPE,
+ universal_newlines=True,
+ close_fds=(os.name != 'nt'),
+ cwd=support.SAVEDCWD)
+ with popen:
+ stdout, stderr = popen.communicate()
+ retcode = popen.wait()
+ return retcode, stdout, stderr
+
+
+def run_tests_slave(slaveargs):
+ ns_dict, testname = json.loads(slaveargs)
+ ns = types.SimpleNamespace(**ns_dict)
+
+ setup_tests(ns)
+
+ try:
+ result = runtest(ns, testname)
+ except KeyboardInterrupt:
+ result = INTERRUPTED, ''
+ except BaseException as e:
+ traceback.print_exc()
+ result = CHILD_ERROR, str(e)
+
+ print() # Force a newline (just in case)
+ print(json.dumps(result), flush=True)
+ sys.exit(0)
+
+
+# We do not use a generator so multiple threads can call next().
+class MultiprocessIterator:
+
+ """A thread-safe iterator over tests for multiprocess mode."""
+
+ def __init__(self, tests):
+ self.interrupted = False
+ self.lock = threading.Lock()
+ self.tests = tests
+
+ def __iter__(self):
+ return self
+
+ def __next__(self):
+ with self.lock:
+ if self.interrupted:
+ raise StopIteration('tests interrupted')
+ return next(self.tests)
+
+
+class MultiprocessThread(threading.Thread):
+ def __init__(self, pending, output, ns):
+ super().__init__()
+ self.pending = pending
+ self.output = output
+ self.ns = ns
+ self.current_test = None
+ self.start_time = None
+
+ def _runtest(self):
+ try:
+ test = next(self.pending)
+ except StopIteration:
+ self.output.put((None, None, None, None))
+ return True
+
+ try:
+ self.start_time = time.monotonic()
+ self.current_test = test
+
+ retcode, stdout, stderr = run_test_in_subprocess(test, self.ns)
+ finally:
+ self.current_test = None
+
+ stdout, _, result = stdout.strip().rpartition("\n")
+ if retcode != 0:
+ result = (CHILD_ERROR, "Exit code %s" % retcode)
+ self.output.put((test, stdout.rstrip(), stderr.rstrip(),
+ result))
+ return True
+
+ if not result:
+ self.output.put((None, None, None, None))
+ return True
+
+ result = json.loads(result)
+ self.output.put((test, stdout.rstrip(), stderr.rstrip(),
+ result))
+ return False
+
+ def run(self):
+ try:
+ stop = False
+ while not stop:
+ stop = self._runtest()
+ except BaseException:
+ self.output.put((None, None, None, None))
+ raise
+
+
+def run_tests_multiprocess(regrtest):
+ output = queue.Queue()
+ pending = MultiprocessIterator(regrtest.tests)
+ test_timeout = regrtest.ns.timeout
+ use_timeout = (test_timeout is not None)
+
+ workers = [MultiprocessThread(pending, output, regrtest.ns)
+ for i in range(regrtest.ns.use_mp)]
+ print("Run tests in parallel using %s child processes"
+ % len(workers))
+ for worker in workers:
+ worker.start()
+
+ def get_running(workers):
+ running = []
+ for worker in workers:
+ current_test = worker.current_test
+ if not current_test:
+ continue
+ dt = time.monotonic() - worker.start_time
+ if dt >= PROGRESS_MIN_TIME:
+ running.append('%s (%.0f sec)' % (current_test, dt))
+ return running
+
+ finished = 0
+ test_index = 1
+ get_timeout = max(PROGRESS_UPDATE, PROGRESS_MIN_TIME)
+ try:
+ while finished < regrtest.ns.use_mp:
+ if use_timeout:
+ faulthandler.dump_traceback_later(test_timeout, exit=True)
+
+ try:
+ item = output.get(timeout=get_timeout)
+ except queue.Empty:
+ running = get_running(workers)
+ if running and not regrtest.ns.pgo:
+ print('running: %s' % ', '.join(running))
+ continue
+
+ test, stdout, stderr, result = item
+ if test is None:
+ finished += 1
+ continue
+ regrtest.accumulate_result(test, result)
+
+ # Display progress
+ ok, test_time = result
+ text = format_test_result(test, ok)
+ if (ok not in (CHILD_ERROR, INTERRUPTED)
+ and test_time >= PROGRESS_MIN_TIME
+ and not regrtest.ns.pgo):
+ text += ' (%.0f sec)' % test_time
+ running = get_running(workers)
+ if running and not regrtest.ns.pgo:
+ text += ' -- running: %s' % ', '.join(running)
+ regrtest.display_progress(test_index, text)
+
+ # Copy stdout and stderr from the child process
+ if stdout:
+ print(stdout, flush=True)
+ if stderr and not regrtest.ns.pgo:
+ print(stderr, file=sys.stderr, flush=True)
+
+ if result[0] == INTERRUPTED:
+ raise KeyboardInterrupt
+ if result[0] == CHILD_ERROR:
+ msg = "Child error on {}: {}".format(test, result[1])
+ raise Exception(msg)
+ test_index += 1
+ except KeyboardInterrupt:
+ regrtest.interrupted = True
+ pending.interrupted = True
+ print()
+ finally:
+ if use_timeout:
+ faulthandler.cancel_dump_traceback_later()
+
+ # If tests are interrupted, wait until tests complete
+ wait_start = time.monotonic()
+ while True:
+ running = [worker.current_test for worker in workers]
+ running = list(filter(bool, running))
+ if not running:
+ break
+
+ dt = time.monotonic() - wait_start
+ line = "Waiting for %s (%s tests)" % (', '.join(running), len(running))
+ if dt >= WAIT_PROGRESS:
+ line = "%s since %.0f sec" % (line, dt)
+ print(line)
+ for worker in workers:
+ worker.join(WAIT_PROGRESS)
diff --git a/Lib/test/libregrtest/save_env.py b/Lib/test/libregrtest/save_env.py
new file mode 100644
index 0000000..5bb9e19
--- /dev/null
+++ b/Lib/test/libregrtest/save_env.py
@@ -0,0 +1,286 @@
+import builtins
+import locale
+import logging
+import os
+import shutil
+import sys
+import sysconfig
+import warnings
+from test import support
+try:
+ import threading
+except ImportError:
+ threading = None
+try:
+ import _multiprocessing, multiprocessing.process
+except ImportError:
+ multiprocessing = None
+
+
+# Unit tests are supposed to leave the execution environment unchanged
+# once they complete. But sometimes tests have bugs, especially when
+# tests fail, and the changes to environment go on to mess up other
+# tests. This can cause issues with buildbot stability, since tests
+# are run in random order and so problems may appear to come and go.
+# There are a few things we can save and restore to mitigate this, and
+# the following context manager handles this task.
+
+class saved_test_environment:
+ """Save bits of the test environment and restore them at block exit.
+
+ with saved_test_environment(testname, verbose, quiet):
+ #stuff
+
+ Unless quiet is True, a warning is printed to stderr if any of
+ the saved items was changed by the test. The attribute 'changed'
+ is initially False, but is set to True if a change is detected.
+
+ If verbose is more than 1, the before and after state of changed
+ items is also printed.
+ """
+
+ changed = False
+
+ def __init__(self, testname, verbose=0, quiet=False, *, pgo=False):
+ self.testname = testname
+ self.verbose = verbose
+ self.quiet = quiet
+ self.pgo = pgo
+
+ # To add things to save and restore, add a name XXX to the resources list
+ # and add corresponding get_XXX/restore_XXX functions. get_XXX should
+ # return the value to be saved and compared against a second call to the
+ # get function when test execution completes. restore_XXX should accept
+ # the saved value and restore the resource using it. It will be called if
+ # and only if a change in the value is detected.
+ #
+ # Note: XXX will have any '.' replaced with '_' characters when determining
+ # the corresponding method names.
+
+ resources = ('sys.argv', 'cwd', 'sys.stdin', 'sys.stdout', 'sys.stderr',
+ 'os.environ', 'sys.path', 'sys.path_hooks', '__import__',
+ 'warnings.filters', 'asyncore.socket_map',
+ 'logging._handlers', 'logging._handlerList', 'sys.gettrace',
+ 'sys.warnoptions',
+ # multiprocessing.process._cleanup() may release ref
+ # to a thread, so check processes first.
+ 'multiprocessing.process._dangling', 'threading._dangling',
+ 'sysconfig._CONFIG_VARS', 'sysconfig._INSTALL_SCHEMES',
+ 'files', 'locale', 'warnings.showwarning',
+ 'shutil_archive_formats', 'shutil_unpack_formats',
+ )
+
+ def get_sys_argv(self):
+ return id(sys.argv), sys.argv, sys.argv[:]
+ def restore_sys_argv(self, saved_argv):
+ sys.argv = saved_argv[1]
+ sys.argv[:] = saved_argv[2]
+
+ def get_cwd(self):
+ return os.getcwd()
+ def restore_cwd(self, saved_cwd):
+ os.chdir(saved_cwd)
+
+ def get_sys_stdout(self):
+ return sys.stdout
+ def restore_sys_stdout(self, saved_stdout):
+ sys.stdout = saved_stdout
+
+ def get_sys_stderr(self):
+ return sys.stderr
+ def restore_sys_stderr(self, saved_stderr):
+ sys.stderr = saved_stderr
+
+ def get_sys_stdin(self):
+ return sys.stdin
+ def restore_sys_stdin(self, saved_stdin):
+ sys.stdin = saved_stdin
+
+ def get_os_environ(self):
+ return id(os.environ), os.environ, dict(os.environ)
+ def restore_os_environ(self, saved_environ):
+ os.environ = saved_environ[1]
+ os.environ.clear()
+ os.environ.update(saved_environ[2])
+
+ def get_sys_path(self):
+ return id(sys.path), sys.path, sys.path[:]
+ def restore_sys_path(self, saved_path):
+ sys.path = saved_path[1]
+ sys.path[:] = saved_path[2]
+
+ def get_sys_path_hooks(self):
+ return id(sys.path_hooks), sys.path_hooks, sys.path_hooks[:]
+ def restore_sys_path_hooks(self, saved_hooks):
+ sys.path_hooks = saved_hooks[1]
+ sys.path_hooks[:] = saved_hooks[2]
+
+ def get_sys_gettrace(self):
+ return sys.gettrace()
+ def restore_sys_gettrace(self, trace_fxn):
+ sys.settrace(trace_fxn)
+
+ def get___import__(self):
+ return builtins.__import__
+ def restore___import__(self, import_):
+ builtins.__import__ = import_
+
+ def get_warnings_filters(self):
+ return id(warnings.filters), warnings.filters, warnings.filters[:]
+ def restore_warnings_filters(self, saved_filters):
+ warnings.filters = saved_filters[1]
+ warnings.filters[:] = saved_filters[2]
+
+ def get_asyncore_socket_map(self):
+ asyncore = sys.modules.get('asyncore')
+ # XXX Making a copy keeps objects alive until __exit__ gets called.
+ return asyncore and asyncore.socket_map.copy() or {}
+ def restore_asyncore_socket_map(self, saved_map):
+ asyncore = sys.modules.get('asyncore')
+ if asyncore is not None:
+ asyncore.close_all(ignore_all=True)
+ asyncore.socket_map.update(saved_map)
+
+ def get_shutil_archive_formats(self):
+ # we could call get_archives_formats() but that only returns the
+ # registry keys; we want to check the values too (the functions that
+ # are registered)
+ return shutil._ARCHIVE_FORMATS, shutil._ARCHIVE_FORMATS.copy()
+ def restore_shutil_archive_formats(self, saved):
+ shutil._ARCHIVE_FORMATS = saved[0]
+ shutil._ARCHIVE_FORMATS.clear()
+ shutil._ARCHIVE_FORMATS.update(saved[1])
+
+ def get_shutil_unpack_formats(self):
+ return shutil._UNPACK_FORMATS, shutil._UNPACK_FORMATS.copy()
+ def restore_shutil_unpack_formats(self, saved):
+ shutil._UNPACK_FORMATS = saved[0]
+ shutil._UNPACK_FORMATS.clear()
+ shutil._UNPACK_FORMATS.update(saved[1])
+
+ def get_logging__handlers(self):
+ # _handlers is a WeakValueDictionary
+ return id(logging._handlers), logging._handlers, logging._handlers.copy()
+ def restore_logging__handlers(self, saved_handlers):
+ # Can't easily revert the logging state
+ pass
+
+ def get_logging__handlerList(self):
+ # _handlerList is a list of weakrefs to handlers
+ return id(logging._handlerList), logging._handlerList, logging._handlerList[:]
+ def restore_logging__handlerList(self, saved_handlerList):
+ # Can't easily revert the logging state
+ pass
+
+ def get_sys_warnoptions(self):
+ return id(sys.warnoptions), sys.warnoptions, sys.warnoptions[:]
+ def restore_sys_warnoptions(self, saved_options):
+ sys.warnoptions = saved_options[1]
+ sys.warnoptions[:] = saved_options[2]
+
+ # Controlling dangling references to Thread objects can make it easier
+ # to track reference leaks.
+ def get_threading__dangling(self):
+ if not threading:
+ return None
+ # This copies the weakrefs without making any strong reference
+ return threading._dangling.copy()
+ def restore_threading__dangling(self, saved):
+ if not threading:
+ return
+ threading._dangling.clear()
+ threading._dangling.update(saved)
+
+ # Same for Process objects
+ def get_multiprocessing_process__dangling(self):
+ if not multiprocessing:
+ return None
+ # Unjoined process objects can survive after process exits
+ multiprocessing.process._cleanup()
+ # This copies the weakrefs without making any strong reference
+ return multiprocessing.process._dangling.copy()
+ def restore_multiprocessing_process__dangling(self, saved):
+ if not multiprocessing:
+ return
+ multiprocessing.process._dangling.clear()
+ multiprocessing.process._dangling.update(saved)
+
+ def get_sysconfig__CONFIG_VARS(self):
+ # make sure the dict is initialized
+ sysconfig.get_config_var('prefix')
+ return (id(sysconfig._CONFIG_VARS), sysconfig._CONFIG_VARS,
+ dict(sysconfig._CONFIG_VARS))
+ def restore_sysconfig__CONFIG_VARS(self, saved):
+ sysconfig._CONFIG_VARS = saved[1]
+ sysconfig._CONFIG_VARS.clear()
+ sysconfig._CONFIG_VARS.update(saved[2])
+
+ def get_sysconfig__INSTALL_SCHEMES(self):
+ return (id(sysconfig._INSTALL_SCHEMES), sysconfig._INSTALL_SCHEMES,
+ sysconfig._INSTALL_SCHEMES.copy())
+ def restore_sysconfig__INSTALL_SCHEMES(self, saved):
+ sysconfig._INSTALL_SCHEMES = saved[1]
+ sysconfig._INSTALL_SCHEMES.clear()
+ sysconfig._INSTALL_SCHEMES.update(saved[2])
+
+ def get_files(self):
+ return sorted(fn + ('/' if os.path.isdir(fn) else '')
+ for fn in os.listdir())
+ def restore_files(self, saved_value):
+ fn = support.TESTFN
+ if fn not in saved_value and (fn + '/') not in saved_value:
+ if os.path.isfile(fn):
+ support.unlink(fn)
+ elif os.path.isdir(fn):
+ support.rmtree(fn)
+
+ _lc = [getattr(locale, lc) for lc in dir(locale)
+ if lc.startswith('LC_')]
+ def get_locale(self):
+ pairings = []
+ for lc in self._lc:
+ try:
+ pairings.append((lc, locale.setlocale(lc, None)))
+ except (TypeError, ValueError):
+ continue
+ return pairings
+ def restore_locale(self, saved):
+ for lc, setting in saved:
+ locale.setlocale(lc, setting)
+
+ def get_warnings_showwarning(self):
+ return warnings.showwarning
+ def restore_warnings_showwarning(self, fxn):
+ warnings.showwarning = fxn
+
+ def resource_info(self):
+ for name in self.resources:
+ method_suffix = name.replace('.', '_')
+ get_name = 'get_' + method_suffix
+ restore_name = 'restore_' + method_suffix
+ yield name, getattr(self, get_name), getattr(self, restore_name)
+
+ def __enter__(self):
+ self.saved_values = dict((name, get()) for name, get, restore
+ in self.resource_info())
+ return self
+
+ def __exit__(self, exc_type, exc_val, exc_tb):
+ saved_values = self.saved_values
+ del self.saved_values
+ for name, get, restore in self.resource_info():
+ current = get()
+ original = saved_values.pop(name)
+ # Check for changes to the resource's value
+ if current != original:
+ self.changed = True
+ restore(original)
+ if not self.quiet and not self.pgo:
+ print("Warning -- {} was modified by {}".format(
+ name, self.testname),
+ file=sys.stderr)
+ if self.verbose > 1:
+ print(" Before: {}\n After: {} ".format(
+ original, current),
+ file=sys.stderr)
+ return False
diff --git a/Lib/test/libregrtest/setup.py b/Lib/test/libregrtest/setup.py
new file mode 100644
index 0000000..1d24531
--- /dev/null
+++ b/Lib/test/libregrtest/setup.py
@@ -0,0 +1,121 @@
+import atexit
+import faulthandler
+import os
+import signal
+import sys
+import unittest
+from test import support
+try:
+ import gc
+except ImportError:
+ gc = None
+
+from test.libregrtest.refleak import warm_caches
+
+
+def setup_tests(ns):
+ # Display the Python traceback on fatal errors (e.g. segfault)
+ faulthandler.enable(all_threads=True)
+
+ # Display the Python traceback on SIGALRM or SIGUSR1 signal
+ signals = []
+ if hasattr(signal, 'SIGALRM'):
+ signals.append(signal.SIGALRM)
+ if hasattr(signal, 'SIGUSR1'):
+ signals.append(signal.SIGUSR1)
+ for signum in signals:
+ faulthandler.register(signum, chain=True)
+
+ replace_stdout()
+ support.record_original_stdout(sys.stdout)
+
+ if ns.testdir:
+ # Prepend test directory to sys.path, so runtest() will be able
+ # to locate tests
+ sys.path.insert(0, os.path.abspath(ns.testdir))
+
+ # Some times __path__ and __file__ are not absolute (e.g. while running from
+ # Lib/) and, if we change the CWD to run the tests in a temporary dir, some
+ # imports might fail. This affects only the modules imported before os.chdir().
+ # These modules are searched first in sys.path[0] (so '' -- the CWD) and if
+ # they are found in the CWD their __file__ and __path__ will be relative (this
+ # happens before the chdir). All the modules imported after the chdir, are
+ # not found in the CWD, and since the other paths in sys.path[1:] are absolute
+ # (site.py absolutize them), the __file__ and __path__ will be absolute too.
+ # Therefore it is necessary to absolutize manually the __file__ and __path__ of
+ # the packages to prevent later imports to fail when the CWD is different.
+ for module in sys.modules.values():
+ if hasattr(module, '__path__'):
+ for index, path in enumerate(module.__path__):
+ module.__path__[index] = os.path.abspath(path)
+ if hasattr(module, '__file__'):
+ module.__file__ = os.path.abspath(module.__file__)
+
+ # MacOSX (a.k.a. Darwin) has a default stack size that is too small
+ # for deeply recursive regular expressions. We see this as crashes in
+ # the Python test suite when running test_re.py and test_sre.py. The
+ # fix is to set the stack limit to 2048.
+ # This approach may also be useful for other Unixy platforms that
+ # suffer from small default stack limits.
+ if sys.platform == 'darwin':
+ try:
+ import resource
+ except ImportError:
+ pass
+ else:
+ soft, hard = resource.getrlimit(resource.RLIMIT_STACK)
+ newsoft = min(hard, max(soft, 1024*2048))
+ resource.setrlimit(resource.RLIMIT_STACK, (newsoft, hard))
+
+ if ns.huntrleaks:
+ unittest.BaseTestSuite._cleanup = False
+
+ # Avoid false positives due to various caches
+ # filling slowly with random data:
+ warm_caches()
+
+ if ns.memlimit is not None:
+ support.set_memlimit(ns.memlimit)
+
+ if ns.threshold is not None:
+ gc.set_threshold(ns.threshold)
+
+ try:
+ import msvcrt
+ except ImportError:
+ pass
+ else:
+ msvcrt.SetErrorMode(msvcrt.SEM_FAILCRITICALERRORS|
+ msvcrt.SEM_NOALIGNMENTFAULTEXCEPT|
+ msvcrt.SEM_NOGPFAULTERRORBOX|
+ msvcrt.SEM_NOOPENFILEERRORBOX)
+ try:
+ msvcrt.CrtSetReportMode
+ except AttributeError:
+ # release build
+ pass
+ else:
+ for m in [msvcrt.CRT_WARN, msvcrt.CRT_ERROR, msvcrt.CRT_ASSERT]:
+ if ns.verbose and ns.verbose >= 2:
+ msvcrt.CrtSetReportMode(m, msvcrt.CRTDBG_MODE_FILE)
+ msvcrt.CrtSetReportFile(m, msvcrt.CRTDBG_FILE_STDERR)
+ else:
+ msvcrt.CrtSetReportMode(m, 0)
+
+ support.use_resources = ns.use_resources
+
+
+def replace_stdout():
+ """Set stdout encoder error handler to backslashreplace (as stderr error
+ handler) to avoid UnicodeEncodeError when printing a traceback"""
+ stdout = sys.stdout
+ sys.stdout = open(stdout.fileno(), 'w',
+ encoding=stdout.encoding,
+ errors="backslashreplace",
+ closefd=False,
+ newline='\n')
+
+ def restore_stdout():
+ sys.stdout.close()
+ sys.stdout = stdout
+ atexit.register(restore_stdout)
diff --git a/Lib/test/lock_tests.py b/Lib/test/lock_tests.py
index a64aa18..a6cb3b1 100644
--- a/Lib/test/lock_tests.py
+++ b/Lib/test/lock_tests.py
@@ -7,6 +7,7 @@
from _thread import start_new_thread, TIMEOUT_MAX
import threading
import unittest
+import weakref
from test import support
@@ -198,6 +199,17 @@
self.assertFalse(results[0])
self.assertTimeout(results[1], 0.5)
+ def test_weakref_exists(self):
+ lock = self.locktype()
+ ref = weakref.ref(lock)
+ self.assertIsNotNone(ref())
+
+ def test_weakref_deleted(self):
+ lock = self.locktype()
+ ref = weakref.ref(lock)
+ del lock
+ self.assertIsNone(ref())
+
class LockTests(BaseLockTests):
"""
diff --git a/Lib/test/make_ssl_certs.py b/Lib/test/make_ssl_certs.py
index 81d04f8..e4326d7 100644
--- a/Lib/test/make_ssl_certs.py
+++ b/Lib/test/make_ssl_certs.py
@@ -3,7 +3,6 @@
import os
import shutil
-import sys
import tempfile
from subprocess import *
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
index f252a0a..8deb56f 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -1000,7 +1000,7 @@
b'0', # POP
b'1', # POP_MARK
b'2', # DUP
- # b'(2', # PyUnpickler doesn't raise
+ b'(2',
b'R', # REDUCE
b')R',
b'a', # APPEND
@@ -1009,7 +1009,7 @@
b'Nb',
b'd', # DICT
b'e', # APPENDS
- # b'(e', # PyUnpickler raises AttributeError
+ b'(e',
b'ibuiltins\nlist\n', # INST
b'l', # LIST
b'o', # OBJ
@@ -1022,7 +1022,7 @@
b'NNs',
b't', # TUPLE
b'u', # SETITEMS
- # b'(u', # PyUnpickler doesn't raise
+ b'(u',
b'}(Nu',
b'\x81', # NEWOBJ
b')\x81',
@@ -1033,7 +1033,7 @@
b'N\x87',
b'NN\x87',
b'\x90', # ADDITEMS
- # b'(\x90', # PyUnpickler raises AttributeError
+ b'(\x90',
b'\x91', # FROZENSET
b'\x92', # NEWOBJ_EX
b')}\x92',
@@ -1046,7 +1046,7 @@
def test_bad_mark(self):
badpickles = [
- # b'N(.', # STOP
+ b'N(.', # STOP
b'N(2', # DUP
b'cbuiltins\nlist\n)(R', # REDUCE
b'cbuiltins\nlist\n()R',
@@ -1081,7 +1081,7 @@
b'N(\x94', # MEMOIZE
]
for p in badpickles:
- self.check_unpickling_error(self.bad_mark_errors, p)
+ self.check_unpickling_error(self.bad_stack_errors, p)
def test_truncated_data(self):
self.check_unpickling_error(EOFError, b'')
@@ -1855,16 +1855,14 @@
x.abc = 666
for proto in protocols:
with self.subTest(proto=proto):
- if 2 <= proto < 4:
- self.assertRaises(ValueError, self.dumps, x, proto)
- continue
s = self.dumps(x, proto)
if proto < 1:
self.assertIn(b'\nL64206', s) # LONG
elif proto < 2:
self.assertIn(b'M\xce\xfa', s) # BININT2
+ elif proto < 4:
+ self.assertIn(b'X\x04\x00\x00\x00FACE', s) # BINUNICODE
else:
- assert proto >= 4
self.assertIn(b'\x8c\x04FACE', s) # SHORT_BINUNICODE
self.assertFalse(opcode_in_pickle(pickle.NEWOBJ, s))
self.assertEqual(opcode_in_pickle(pickle.NEWOBJ_EX, s),
@@ -2583,11 +2581,6 @@
self.assertRaises(pickle.PicklingError, BadPickler().dump, 0)
self.assertRaises(pickle.UnpicklingError, BadUnpickler().load)
- def test_bad_input(self):
- # Test issue4298
- s = bytes([0x58, 0, 0, 0, 0x54])
- self.assertRaises(EOFError, pickle.loads, s)
-
class AbstractPersistentPicklerTests(unittest.TestCase):
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
old mode 100755
new mode 100644
index fecfd09..21b0edf
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -6,1604 +6,33 @@
Run this script with -h or --help for documentation.
"""
-USAGE = """\
-python -m test [options] [test_name1 [test_name2 ...]]
-python path/to/Lib/test/regrtest.py [options] [test_name1 [test_name2 ...]]
-"""
-
-DESCRIPTION = """\
-Run Python regression tests.
-
-If no arguments or options are provided, finds all files matching
-the pattern "test_*" in the Lib/test subdirectory and runs
-them in alphabetical order (but see -M and -u, below, for exceptions).
-
-For more rigorous testing, it is useful to use the following
-command line:
-
-python -E -Wd -m test [options] [test_name1 ...]
-"""
-
-EPILOG = """\
-Additional option details:
-
--r randomizes test execution order. You can use --randseed=int to provide an
-int seed value for the randomizer; this is useful for reproducing troublesome
-test orders.
-
--s On the first invocation of regrtest using -s, the first test file found
-or the first test file given on the command line is run, and the name of
-the next test is recorded in a file named pynexttest. If run from the
-Python build directory, pynexttest is located in the 'build' subdirectory,
-otherwise it is located in tempfile.gettempdir(). On subsequent runs,
-the test in pynexttest is run, and the next test is written to pynexttest.
-When the last test has been run, pynexttest is deleted. In this way it
-is possible to single step through the test files. This is useful when
-doing memory analysis on the Python interpreter, which process tends to
-consume too many resources to run the full regression test non-stop.
-
--S is used to continue running tests after an aborted run. It will
-maintain the order a standard run (ie, this assumes -r is not used).
-This is useful after the tests have prematurely stopped for some external
-reason and you want to start running from where you left off rather
-than starting from the beginning.
-
--f reads the names of tests from the file given as f's argument, one
-or more test names per line. Whitespace is ignored. Blank lines and
-lines beginning with '#' are ignored. This is especially useful for
-whittling down failures involving interactions among tests.
-
--L causes the leaks(1) command to be run just before exit if it exists.
-leaks(1) is available on Mac OS X and presumably on some other
-FreeBSD-derived systems.
-
--R runs each test several times and examines sys.gettotalrefcount() to
-see if the test appears to be leaking references. The argument should
-be of the form stab:run:fname where 'stab' is the number of times the
-test is run to let gettotalrefcount settle down, 'run' is the number
-of times further it is run and 'fname' is the name of the file the
-reports are written to. These parameters all have defaults (5, 4 and
-"reflog.txt" respectively), and the minimal invocation is '-R :'.
-
--M runs tests that require an exorbitant amount of memory. These tests
-typically try to ascertain containers keep working when containing more than
-2 billion objects, which only works on 64-bit systems. There are also some
-tests that try to exhaust the address space of the process, which only makes
-sense on 32-bit systems with at least 2Gb of memory. The passed-in memlimit,
-which is a string in the form of '2.5Gb', determines howmuch memory the
-tests will limit themselves to (but they may go slightly over.) The number
-shouldn't be more memory than the machine has (including swap memory). You
-should also keep in mind that swap memory is generally much, much slower
-than RAM, and setting memlimit to all available RAM or higher will heavily
-tax the machine. On the other hand, it is no use running these tests with a
-limit of less than 2.5Gb, and many require more than 20Gb. Tests that expect
-to use more than memlimit memory will be skipped. The big-memory tests
-generally run very, very long.
-
--u is used to specify which special resource intensive tests to run,
-such as those requiring large file support or network connectivity.
-The argument is a comma-separated list of words indicating the
-resources to test. Currently only the following are defined:
-
- all - Enable all special resources.
-
- none - Disable all special resources (this is the default).
-
- audio - Tests that use the audio device. (There are known
- cases of broken audio drivers that can crash Python or
- even the Linux kernel.)
-
- curses - Tests that use curses and will modify the terminal's
- state and output modes.
-
- largefile - It is okay to run some test that may create huge
- files. These tests can take a long time and may
- consume >2GB of disk space temporarily.
-
- network - It is okay to run tests that use external network
- resource, e.g. testing SSL support for sockets.
-
- decimal - Test the decimal module against a large suite that
- verifies compliance with standards.
-
- cpu - Used for certain CPU-heavy tests.
-
- subprocess Run all tests for the subprocess module.
-
- urlfetch - It is okay to download files required on testing.
-
- gui - Run tests that require a running GUI.
-
-To enable all resources except one, use '-uall,-<resource>'. For
-example, to run all the tests except for the gui tests, give the
-option '-uall,-gui'.
-"""
-
# We import importlib *ASAP* in order to test #15386
import importlib
-import argparse
-import builtins
-import faulthandler
-import io
-import json
-import locale
-import logging
import os
-import platform
-import random
-import re
-import shutil
-import signal
import sys
-import sysconfig
-import tempfile
-import time
-import traceback
-import unittest
-import warnings
-from inspect import isabstract
+from test.libregrtest import main
-try:
- import threading
-except ImportError:
- threading = None
-try:
- import _multiprocessing, multiprocessing.process
-except ImportError:
- multiprocessing = None
+# Alias for backward compatibility (just in case)
+main_in_temp_cwd = main
-# Some times __path__ and __file__ are not absolute (e.g. while running from
-# Lib/) and, if we change the CWD to run the tests in a temporary dir, some
-# imports might fail. This affects only the modules imported before os.chdir().
-# These modules are searched first in sys.path[0] (so '' -- the CWD) and if
-# they are found in the CWD their __file__ and __path__ will be relative (this
-# happens before the chdir). All the modules imported after the chdir, are
-# not found in the CWD, and since the other paths in sys.path[1:] are absolute
-# (site.py absolutize them), the __file__ and __path__ will be absolute too.
-# Therefore it is necessary to absolutize manually the __file__ and __path__ of
-# the packages to prevent later imports to fail when the CWD is different.
-for module in sys.modules.values():
- if hasattr(module, '__path__'):
- module.__path__ = [os.path.abspath(path) for path in module.__path__]
- if hasattr(module, '__file__'):
- module.__file__ = os.path.abspath(module.__file__)
-
-# MacOSX (a.k.a. Darwin) has a default stack size that is too small
-# for deeply recursive regular expressions. We see this as crashes in
-# the Python test suite when running test_re.py and test_sre.py. The
-# fix is to set the stack limit to 2048.
-# This approach may also be useful for other Unixy platforms that
-# suffer from small default stack limits.
-if sys.platform == 'darwin':
- try:
- import resource
- except ImportError:
- pass
- else:
- soft, hard = resource.getrlimit(resource.RLIMIT_STACK)
- newsoft = min(hard, max(soft, 1024*2048))
- resource.setrlimit(resource.RLIMIT_STACK, (newsoft, hard))
-
-# Test result constants.
-PASSED = 1
-FAILED = 0
-ENV_CHANGED = -1
-SKIPPED = -2
-RESOURCE_DENIED = -3
-INTERRUPTED = -4
-CHILD_ERROR = -5 # error in a child process
-
-from test import support
-
-RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network',
- 'decimal', 'cpu', 'subprocess', 'urlfetch', 'gui')
-
-# When tests are run from the Python build directory, it is best practice
-# to keep the test files in a subfolder. This eases the cleanup of leftover
-# files using the "make distclean" command.
-if sysconfig.is_python_build():
- TEMPDIR = os.path.join(sysconfig.get_config_var('srcdir'), 'build')
-else:
- TEMPDIR = tempfile.gettempdir()
-TEMPDIR = os.path.abspath(TEMPDIR)
-
-class _ArgParser(argparse.ArgumentParser):
-
- def error(self, message):
- super().error(message + "\nPass -h or --help for complete help.")
-
-def _create_parser():
- # Set prog to prevent the uninformative "__main__.py" from displaying in
- # error messages when using "python -m test ...".
- parser = _ArgParser(prog='regrtest.py',
- usage=USAGE,
- description=DESCRIPTION,
- epilog=EPILOG,
- add_help=False,
- formatter_class=argparse.RawDescriptionHelpFormatter)
-
- # Arguments with this clause added to its help are described further in
- # the epilog's "Additional option details" section.
- more_details = ' See the section at bottom for more details.'
-
- group = parser.add_argument_group('General options')
- # We add help explicitly to control what argument group it renders under.
- group.add_argument('-h', '--help', action='help',
- help='show this help message and exit')
- group.add_argument('--timeout', metavar='TIMEOUT', type=float,
- help='dump the traceback and exit if a test takes '
- 'more than TIMEOUT seconds; disabled if TIMEOUT '
- 'is negative or equals to zero')
- group.add_argument('--wait', action='store_true',
- help='wait for user input, e.g., allow a debugger '
- 'to be attached')
- group.add_argument('--slaveargs', metavar='ARGS')
- group.add_argument('-S', '--start', metavar='START',
- help='the name of the test at which to start.' +
- more_details)
-
- group = parser.add_argument_group('Verbosity')
- group.add_argument('-v', '--verbose', action='count',
- help='run tests in verbose mode with output to stdout')
- group.add_argument('-w', '--verbose2', action='store_true',
- help='re-run failed tests in verbose mode')
- group.add_argument('-W', '--verbose3', action='store_true',
- help='display test output on failure')
- group.add_argument('-q', '--quiet', action='store_true',
- help='no output unless one or more tests fail')
- group.add_argument('-o', '--slow', action='store_true', dest='print_slow',
- help='print the slowest 10 tests')
- group.add_argument('--header', action='store_true',
- help='print header with interpreter info')
-
- group = parser.add_argument_group('Selecting tests')
- group.add_argument('-r', '--randomize', action='store_true',
- help='randomize test execution order.' + more_details)
- group.add_argument('--randseed', metavar='SEED',
- dest='random_seed', type=int,
- help='pass a random seed to reproduce a previous '
- 'random run')
- group.add_argument('-f', '--fromfile', metavar='FILE',
- help='read names of tests to run from a file.' +
- more_details)
- group.add_argument('-x', '--exclude', action='store_true',
- help='arguments are tests to *exclude*')
- group.add_argument('-s', '--single', action='store_true',
- help='single step through a set of tests.' +
- more_details)
- group.add_argument('-m', '--match', metavar='PAT',
- dest='match_tests',
- help='match test cases and methods with glob pattern PAT')
- group.add_argument('-G', '--failfast', action='store_true',
- help='fail as soon as a test fails (only with -v or -W)')
- group.add_argument('-u', '--use', metavar='RES1,RES2,...',
- action='append', type=resources_list,
- help='specify which special resource intensive tests '
- 'to run.' + more_details)
- group.add_argument('-M', '--memlimit', metavar='LIMIT',
- help='run very large memory-consuming tests.' +
- more_details)
- group.add_argument('--testdir', metavar='DIR',
- type=relative_filename,
- help='execute test files in the specified directory '
- '(instead of the Python stdlib test suite)')
-
- group = parser.add_argument_group('Special runs')
- group.add_argument('-l', '--findleaks', action='store_true',
- help='if GC is available detect tests that leak memory')
- group.add_argument('-L', '--runleaks', action='store_true',
- help='run the leaks(1) command just before exit.' +
- more_details)
- group.add_argument('-R', '--huntrleaks', metavar='RUNCOUNTS',
- type=huntrleaks,
- help='search for reference leaks (needs debug build, '
- 'very slow).' + more_details)
- group.add_argument('-j', '--multiprocess', metavar='PROCESSES',
- dest='use_mp', type=int,
- help='run PROCESSES processes at once')
- group.add_argument('-T', '--coverage', action='store_true',
- dest='trace',
- help='turn on code coverage tracing using the trace '
- 'module')
- group.add_argument('-D', '--coverdir', metavar='DIR',
- type=relative_filename,
- help='directory where coverage files are put')
- group.add_argument('-N', '--nocoverdir',
- action='store_const', const=None, dest='coverdir',
- help='put coverage files alongside modules')
- group.add_argument('-t', '--threshold', metavar='THRESHOLD',
- type=int,
- help='call gc.set_threshold(THRESHOLD)')
- group.add_argument('-n', '--nowindows', action='store_true',
- help='suppress error message boxes on Windows')
- group.add_argument('-F', '--forever', action='store_true',
- help='run the specified tests in a loop, until an '
- 'error happens')
- group.add_argument('-P', '--pgo', dest='pgo', action='store_true',
- help='enable Profile Guided Optimization training')
-
- parser.add_argument('args', nargs=argparse.REMAINDER,
- help=argparse.SUPPRESS)
-
- return parser
-
-def relative_filename(string):
- # CWD is replaced with a temporary dir before calling main(), so we
- # join it with the saved CWD so it ends up where the user expects.
- return os.path.join(support.SAVEDCWD, string)
-
-def huntrleaks(string):
- args = string.split(':')
- if len(args) not in (2, 3):
- raise argparse.ArgumentTypeError(
- 'needs 2 or 3 colon-separated arguments')
- nwarmup = int(args[0]) if args[0] else 5
- ntracked = int(args[1]) if args[1] else 4
- fname = args[2] if len(args) > 2 and args[2] else 'reflog.txt'
- return nwarmup, ntracked, fname
-
-def resources_list(string):
- u = [x.lower() for x in string.split(',')]
- for r in u:
- if r == 'all' or r == 'none':
- continue
- if r[0] == '-':
- r = r[1:]
- if r not in RESOURCE_NAMES:
- raise argparse.ArgumentTypeError('invalid resource: ' + r)
- return u
-
-def _parse_args(args, **kwargs):
- # Defaults
- ns = argparse.Namespace(testdir=None, verbose=0, quiet=False,
- exclude=False, single=False, randomize=False, fromfile=None,
- findleaks=False, use_resources=None, trace=False, coverdir='coverage',
- runleaks=False, huntrleaks=False, verbose2=False, print_slow=False,
- random_seed=None, use_mp=None, verbose3=False, forever=False,
- header=False, failfast=False, match_tests=None, pgo=False)
- for k, v in kwargs.items():
- if not hasattr(ns, k):
- raise TypeError('%r is an invalid keyword argument '
- 'for this function' % k)
- setattr(ns, k, v)
- if ns.use_resources is None:
- ns.use_resources = []
-
- parser = _create_parser()
- parser.parse_args(args=args, namespace=ns)
-
- if ns.single and ns.fromfile:
- parser.error("-s and -f don't go together!")
- if ns.use_mp and ns.trace:
- parser.error("-T and -j don't go together!")
- if ns.use_mp and ns.findleaks:
- parser.error("-l and -j don't go together!")
- if ns.use_mp and ns.memlimit:
- parser.error("-M and -j don't go together!")
- if ns.failfast and not (ns.verbose or ns.verbose3):
- parser.error("-G/--failfast needs either -v or -W")
-
- if ns.quiet:
- ns.verbose = 0
- if ns.timeout is not None:
- if hasattr(faulthandler, 'dump_traceback_later'):
- if ns.timeout <= 0:
- ns.timeout = None
- else:
- print("Warning: The timeout option requires "
- "faulthandler.dump_traceback_later")
- ns.timeout = None
- if ns.use_mp is not None:
- if ns.use_mp <= 0:
- # Use all cores + extras for tests that like to sleep
- ns.use_mp = 2 + (os.cpu_count() or 1)
- if ns.use_mp == 1:
- ns.use_mp = None
- if ns.use:
- for a in ns.use:
- for r in a:
- if r == 'all':
- ns.use_resources[:] = RESOURCE_NAMES
- continue
- if r == 'none':
- del ns.use_resources[:]
- continue
- remove = False
- if r[0] == '-':
- remove = True
- r = r[1:]
- if remove:
- if r in ns.use_resources:
- ns.use_resources.remove(r)
- elif r not in ns.use_resources:
- ns.use_resources.append(r)
- if ns.random_seed is not None:
- ns.randomize = True
-
- return ns
-
-
-def run_test_in_subprocess(testname, ns):
- """Run the given test in a subprocess with --slaveargs.
-
- ns is the option Namespace parsed from command-line arguments. regrtest
- is invoked in a subprocess with the --slaveargs argument; when the
- subprocess exits, its return code, stdout and stderr are returned as a
- 3-tuple.
- """
- from subprocess import Popen, PIPE
- base_cmd = ([sys.executable] + support.args_from_interpreter_flags() +
- ['-X', 'faulthandler', '-m', 'test.regrtest'])
- # required to spawn a new process with PGO flag on/off
- if ns.pgo:
- base_cmd = base_cmd + ['--pgo']
- slaveargs = (
- (testname, ns.verbose, ns.quiet),
- dict(huntrleaks=ns.huntrleaks,
- use_resources=ns.use_resources,
- output_on_failure=ns.verbose3,
- timeout=ns.timeout, failfast=ns.failfast,
- match_tests=ns.match_tests, pgo=ns.pgo))
- # Running the child from the same working directory as regrtest's original
- # invocation ensures that TEMPDIR for the child is the same when
- # sysconfig.is_python_build() is true. See issue 15300.
- popen = Popen(base_cmd + ['--slaveargs', json.dumps(slaveargs)],
- stdout=PIPE, stderr=PIPE,
- universal_newlines=True,
- close_fds=(os.name != 'nt'),
- cwd=support.SAVEDCWD)
- stdout, stderr = popen.communicate()
- retcode = popen.wait()
- return retcode, stdout, stderr
-
-
-def main(tests=None, **kwargs):
- """Execute a test suite.
-
- This also parses command-line options and modifies its behavior
- accordingly.
-
- tests -- a list of strings containing test names (optional)
- testdir -- the directory in which to look for tests (optional)
-
- Users other than the Python test suite will certainly want to
- specify testdir; if it's omitted, the directory containing the
- Python test suite is searched for.
-
- If the tests argument is omitted, the tests listed on the
- command-line will be used. If that's empty, too, then all *.py
- files beginning with test_ will be used.
-
- The other default arguments (verbose, quiet, exclude,
- single, randomize, findleaks, use_resources, trace, coverdir,
- print_slow, and random_seed) allow programmers calling main()
- directly to set the values that would normally be set by flags
- on the command line.
- """
- # Display the Python traceback on fatal errors (e.g. segfault)
- faulthandler.enable(all_threads=True)
-
- # Display the Python traceback on SIGALRM or SIGUSR1 signal
- signals = []
- if hasattr(signal, 'SIGALRM'):
- signals.append(signal.SIGALRM)
- if hasattr(signal, 'SIGUSR1'):
- signals.append(signal.SIGUSR1)
- for signum in signals:
- faulthandler.register(signum, chain=True)
-
- replace_stdout()
-
- support.record_original_stdout(sys.stdout)
-
- ns = _parse_args(sys.argv[1:], **kwargs)
-
- if ns.huntrleaks:
- # Avoid false positives due to various caches
- # filling slowly with random data:
- warm_caches()
- if ns.memlimit is not None:
- support.set_memlimit(ns.memlimit)
- if ns.threshold is not None:
- import gc
- gc.set_threshold(ns.threshold)
- if ns.nowindows:
- print('The --nowindows (-n) option is deprecated. '
- 'Use -vv to display assertions in stderr.')
- try:
- import msvcrt
- except ImportError:
- pass
- else:
- msvcrt.SetErrorMode(msvcrt.SEM_FAILCRITICALERRORS|
- msvcrt.SEM_NOALIGNMENTFAULTEXCEPT|
- msvcrt.SEM_NOGPFAULTERRORBOX|
- msvcrt.SEM_NOOPENFILEERRORBOX)
- try:
- msvcrt.CrtSetReportMode
- except AttributeError:
- # release build
- pass
- else:
- for m in [msvcrt.CRT_WARN, msvcrt.CRT_ERROR, msvcrt.CRT_ASSERT]:
- if ns.verbose and ns.verbose >= 2:
- msvcrt.CrtSetReportMode(m, msvcrt.CRTDBG_MODE_FILE)
- msvcrt.CrtSetReportFile(m, msvcrt.CRTDBG_FILE_STDERR)
- else:
- msvcrt.CrtSetReportMode(m, 0)
- if ns.wait:
- input("Press any key to continue...")
-
- if ns.slaveargs is not None:
- args, kwargs = json.loads(ns.slaveargs)
- if kwargs.get('huntrleaks'):
- unittest.BaseTestSuite._cleanup = False
- try:
- result = runtest(*args, **kwargs)
- except KeyboardInterrupt:
- result = INTERRUPTED, ''
- except BaseException as e:
- traceback.print_exc()
- result = CHILD_ERROR, str(e)
- sys.stdout.flush()
- print() # Force a newline (just in case)
- print(json.dumps(result))
- sys.exit(0)
-
- good = []
- bad = []
- skipped = []
- resource_denieds = []
- environment_changed = []
- interrupted = False
-
- if ns.findleaks:
- try:
- import gc
- except ImportError:
- print('No GC available, disabling findleaks.')
- ns.findleaks = False
- else:
- # Uncomment the line below to report garbage that is not
- # freeable by reference counting alone. By default only
- # garbage that is not collectable by the GC is reported.
- #gc.set_debug(gc.DEBUG_SAVEALL)
- found_garbage = []
-
- if ns.huntrleaks:
- unittest.BaseTestSuite._cleanup = False
-
- if ns.single:
- filename = os.path.join(TEMPDIR, 'pynexttest')
- try:
- with open(filename, 'r') as fp:
- next_test = fp.read().strip()
- tests = [next_test]
- except OSError:
- pass
-
- if ns.fromfile:
- tests = []
- with open(os.path.join(support.SAVEDCWD, ns.fromfile)) as fp:
- count_pat = re.compile(r'\[\s*\d+/\s*\d+\]')
- for line in fp:
- line = count_pat.sub('', line)
- guts = line.split() # assuming no test has whitespace in its name
- if guts and not guts[0].startswith('#'):
- tests.extend(guts)
-
- # Strip .py extensions.
- removepy(ns.args)
- removepy(tests)
-
- stdtests = STDTESTS[:]
- nottests = NOTTESTS.copy()
- if ns.exclude:
- for arg in ns.args:
- if arg in stdtests:
- stdtests.remove(arg)
- nottests.add(arg)
- ns.args = []
-
- # For a partial run, we do not need to clutter the output.
- if (ns.verbose or ns.header or
- not (ns.pgo or ns.quiet or ns.single or tests or ns.args)):
- # Print basic platform information
- print("==", platform.python_implementation(), *sys.version.split())
- print("== ", platform.platform(aliased=True),
- "%s-endian" % sys.byteorder)
- print("== ", "hash algorithm:", sys.hash_info.algorithm,
- "64bit" if sys.maxsize > 2**32 else "32bit")
- print("== ", os.getcwd())
- print("Testing with flags:", sys.flags)
-
- # if testdir is set, then we are not running the python tests suite, so
- # don't add default tests to be executed or skipped (pass empty values)
- if ns.testdir:
- alltests = findtests(ns.testdir, list(), set())
- else:
- alltests = findtests(ns.testdir, stdtests, nottests)
-
- selected = tests or ns.args or alltests
- if ns.single:
- selected = selected[:1]
- try:
- next_single_test = alltests[alltests.index(selected[0])+1]
- except IndexError:
- next_single_test = None
- # Remove all the selected tests that precede start if it's set.
- if ns.start:
- try:
- del selected[:selected.index(ns.start)]
- except ValueError:
- print("Couldn't find starting test (%s), using all tests" % ns.start)
- if ns.randomize:
- if ns.random_seed is None:
- ns.random_seed = random.randrange(10000000)
- random.seed(ns.random_seed)
- print("Using random seed", ns.random_seed)
- random.shuffle(selected)
- if ns.trace:
- import trace, tempfile
- tracer = trace.Trace(ignoredirs=[sys.base_prefix, sys.base_exec_prefix,
- tempfile.gettempdir()],
- trace=False, count=True)
-
- test_times = []
- support.verbose = ns.verbose # Tell tests to be moderately quiet
- support.use_resources = ns.use_resources
- save_modules = sys.modules.keys()
-
- def accumulate_result(test, result):
- ok, test_time = result
- if ok not in (CHILD_ERROR, INTERRUPTED):
- test_times.append((test_time, test))
- if ok == PASSED:
- good.append(test)
- elif ok == FAILED:
- bad.append(test)
- elif ok == ENV_CHANGED:
- environment_changed.append(test)
- elif ok == SKIPPED:
- skipped.append(test)
- elif ok == RESOURCE_DENIED:
- skipped.append(test)
- resource_denieds.append(test)
-
- if ns.forever:
- def test_forever(tests=list(selected)):
- while True:
- for test in tests:
- yield test
- if bad:
- return
- tests = test_forever()
- test_count = ''
- test_count_width = 3
- else:
- tests = iter(selected)
- test_count = '/{}'.format(len(selected))
- test_count_width = len(test_count) - 1
-
- if ns.use_mp:
- try:
- from threading import Thread
- except ImportError:
- print("Multiprocess option requires thread support")
- sys.exit(2)
- from queue import Queue
- debug_output_pat = re.compile(r"\[\d+ refs, \d+ blocks\]$")
- output = Queue()
- pending = MultiprocessTests(tests)
- def work():
- # A worker thread.
- try:
- while True:
- try:
- test = next(pending)
- except StopIteration:
- output.put((None, None, None, None))
- return
- retcode, stdout, stderr = run_test_in_subprocess(test, ns)
- # Strip last refcount output line if it exists, since it
- # comes from the shutdown of the interpreter in the subcommand.
- stderr = debug_output_pat.sub("", stderr)
- stdout, _, result = stdout.strip().rpartition("\n")
- if retcode != 0:
- result = (CHILD_ERROR, "Exit code %s" % retcode)
- output.put((test, stdout.rstrip(), stderr.rstrip(), result))
- return
- if not result:
- output.put((None, None, None, None))
- return
- result = json.loads(result)
- output.put((test, stdout.rstrip(), stderr.rstrip(), result))
- except BaseException:
- output.put((None, None, None, None))
- raise
- workers = [Thread(target=work) for i in range(ns.use_mp)]
- for worker in workers:
- worker.start()
- finished = 0
- test_index = 1
- try:
- while finished < ns.use_mp:
- test, stdout, stderr, result = output.get()
- if test is None:
- finished += 1
- continue
- accumulate_result(test, result)
- if not ns.quiet:
- if bad and not ns.pgo:
- fmt = "[{1:{0}}{2}/{3}] {4}"
- else:
- fmt = "[{1:{0}}{2}] {4}"
- print(fmt.format(
- test_count_width, test_index, test_count,
- len(bad), test))
- if stdout:
- print(stdout)
- if stderr and not ns.pgo:
- print(stderr, file=sys.stderr)
- sys.stdout.flush()
- sys.stderr.flush()
- if result[0] == INTERRUPTED:
- raise KeyboardInterrupt
- if result[0] == CHILD_ERROR:
- raise Exception("Child error on {}: {}".format(test, result[1]))
- test_index += 1
- except KeyboardInterrupt:
- interrupted = True
- pending.interrupted = True
- for worker in workers:
- worker.join()
- else:
- for test_index, test in enumerate(tests, 1):
- if not ns.quiet:
- if bad and not ns.pgo:
- fmt = "[{1:{0}}{2}/{3}] {4}"
- else:
- fmt = "[{1:{0}}{2}] {4}"
- print(fmt.format(
- test_count_width, test_index, test_count, len(bad), test))
- sys.stdout.flush()
- if ns.trace:
- # If we're tracing code coverage, then we don't exit with status
- # if on a false return value from main.
- tracer.runctx('runtest(test, ns.verbose, ns.quiet, timeout=ns.timeout)',
- globals=globals(), locals=vars())
- else:
- try:
- result = runtest(test, ns.verbose, ns.quiet,
- ns.huntrleaks,
- output_on_failure=ns.verbose3,
- timeout=ns.timeout, failfast=ns.failfast,
- match_tests=ns.match_tests, pgo=ns.pgo)
- accumulate_result(test, result)
- except KeyboardInterrupt:
- interrupted = True
- break
- if ns.findleaks:
- gc.collect()
- if gc.garbage:
- print("Warning: test created", len(gc.garbage), end=' ')
- print("uncollectable object(s).")
- # move the uncollectable objects somewhere so we don't see
- # them again
- found_garbage.extend(gc.garbage)
- del gc.garbage[:]
- # Unload the newly imported modules (best effort finalization)
- for module in sys.modules.keys():
- if module not in save_modules and module.startswith("test."):
- support.unload(module)
-
- if interrupted and not ns.pgo:
- # print a newline after ^C
- print()
- print("Test suite interrupted by signal SIGINT.")
- omitted = set(selected) - set(good) - set(bad) - set(skipped)
- print(count(len(omitted), "test"), "omitted:")
- printlist(omitted)
- if good and not ns.quiet and not ns.pgo:
- if not bad and not skipped and not interrupted and len(good) > 1:
- print("All", end=' ')
- print(count(len(good), "test"), "OK.")
- if ns.print_slow:
- test_times.sort(reverse=True)
- print("10 slowest tests:")
- for time, test in test_times[:10]:
- print("%s: %.1fs" % (test, time))
- if bad and not ns.pgo:
- print(count(len(bad), "test"), "failed:")
- printlist(bad)
- if environment_changed and not ns.pgo:
- print("{} altered the execution environment:".format(
- count(len(environment_changed), "test")))
- printlist(environment_changed)
- if skipped and not ns.quiet and not ns.pgo:
- print(count(len(skipped), "test"), "skipped:")
- printlist(skipped)
-
- if ns.verbose2 and bad:
- print("Re-running failed tests in verbose mode")
- for test in bad[:]:
- if not ns.pgo:
- print("Re-running test %r in verbose mode" % test)
- sys.stdout.flush()
- try:
- ns.verbose = True
- ok = runtest(test, True, ns.quiet, ns.huntrleaks,
- timeout=ns.timeout, pgo=ns.pgo)
- except KeyboardInterrupt:
- # print a newline separate from the ^C
- print()
- break
- else:
- if ok[0] in {PASSED, ENV_CHANGED, SKIPPED, RESOURCE_DENIED}:
- bad.remove(test)
- else:
- if bad:
- print(count(len(bad), 'test'), "failed again:")
- printlist(bad)
-
- if ns.single:
- if next_single_test:
- with open(filename, 'w') as fp:
- fp.write(next_single_test + '\n')
- else:
- os.unlink(filename)
-
- if ns.trace:
- r = tracer.results()
- r.write_results(show_missing=True, summary=True, coverdir=ns.coverdir)
-
- if ns.runleaks:
- os.system("leaks %d" % os.getpid())
-
- sys.exit(len(bad) > 0 or interrupted)
-
-
-# small set of tests to determine if we have a basically functioning interpreter
-# (i.e. if any of these fail, then anything else is likely to follow)
-STDTESTS = [
- 'test_grammar',
- 'test_opcodes',
- 'test_dict',
- 'test_builtin',
- 'test_exceptions',
- 'test_types',
- 'test_unittest',
- 'test_doctest',
- 'test_doctest2',
- 'test_support'
-]
-
-# set of tests that we don't want to be executed when using regrtest
-NOTTESTS = set()
-
-def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
- """Return a list of all applicable test modules."""
- testdir = findtestdir(testdir)
- names = os.listdir(testdir)
- tests = []
- others = set(stdtests) | nottests
- for name in names:
- mod, ext = os.path.splitext(name)
- if mod[:5] == "test_" and ext in (".py", "") and mod not in others:
- tests.append(mod)
- return stdtests + sorted(tests)
-
-# We do not use a generator so multiple threads can call next().
-class MultiprocessTests(object):
-
- """A thread-safe iterator over tests for multiprocess mode."""
-
- def __init__(self, tests):
- self.interrupted = False
- self.lock = threading.Lock()
- self.tests = tests
-
- def __iter__(self):
- return self
-
- def __next__(self):
- with self.lock:
- if self.interrupted:
- raise StopIteration('tests interrupted')
- return next(self.tests)
-
-def replace_stdout():
- """Set stdout encoder error handler to backslashreplace (as stderr error
- handler) to avoid UnicodeEncodeError when printing a traceback"""
- import atexit
-
- stdout = sys.stdout
- sys.stdout = open(stdout.fileno(), 'w',
- encoding=stdout.encoding,
- errors="backslashreplace",
- closefd=False,
- newline='\n')
-
- def restore_stdout():
- sys.stdout.close()
- sys.stdout = stdout
- atexit.register(restore_stdout)
-
-def runtest(test, verbose, quiet,
- huntrleaks=False, use_resources=None,
- output_on_failure=False, failfast=False, match_tests=None,
- timeout=None, *, pgo=False):
- """Run a single test.
-
- test -- the name of the test
- verbose -- if true, print more messages
- quiet -- if true, don't print 'skipped' messages (probably redundant)
- huntrleaks -- run multiple times to test for leaks; requires a debug
- build; a triple corresponding to -R's three arguments
- use_resources -- list of extra resources to use
- output_on_failure -- if true, display test output on failure
- timeout -- dump the traceback and exit if a test takes more than
- timeout seconds
- failfast, match_tests -- See regrtest command-line flags for these.
- pgo -- if true, do not print unnecessary info when running the test
- for Profile Guided Optimization build
-
- Returns the tuple result, test_time, where result is one of the constants:
- INTERRUPTED KeyboardInterrupt when run under -j
- RESOURCE_DENIED test skipped because resource denied
- SKIPPED test skipped for some other reason
- ENV_CHANGED test failed because it changed the execution environment
- FAILED test failed
- PASSED test passed
- """
- if use_resources is not None:
- support.use_resources = use_resources
- use_timeout = (timeout is not None)
- if use_timeout:
- faulthandler.dump_traceback_later(timeout, exit=True)
- try:
- support.match_tests = match_tests
- if failfast:
- support.failfast = True
- if output_on_failure:
- support.verbose = True
-
- # Reuse the same instance to all calls to runtest(). Some
- # tests keep a reference to sys.stdout or sys.stderr
- # (eg. test_argparse).
- if runtest.stringio is None:
- stream = io.StringIO()
- runtest.stringio = stream
- else:
- stream = runtest.stringio
- stream.seek(0)
- stream.truncate()
-
- orig_stdout = sys.stdout
- orig_stderr = sys.stderr
- try:
- sys.stdout = stream
- sys.stderr = stream
- result = runtest_inner(test, verbose, quiet, huntrleaks,
- display_failure=False, pgo=pgo)
- if result[0] == FAILED and not pgo:
- output = stream.getvalue()
- orig_stderr.write(output)
- orig_stderr.flush()
- finally:
- sys.stdout = orig_stdout
- sys.stderr = orig_stderr
- else:
- support.verbose = verbose # Tell tests to be moderately quiet
- result = runtest_inner(test, verbose, quiet, huntrleaks,
- display_failure=not verbose, pgo=pgo)
- return result
- finally:
- if use_timeout:
- faulthandler.cancel_dump_traceback_later()
- cleanup_test_droppings(test, verbose)
-runtest.stringio = None
-
-# Unit tests are supposed to leave the execution environment unchanged
-# once they complete. But sometimes tests have bugs, especially when
-# tests fail, and the changes to environment go on to mess up other
-# tests. This can cause issues with buildbot stability, since tests
-# are run in random order and so problems may appear to come and go.
-# There are a few things we can save and restore to mitigate this, and
-# the following context manager handles this task.
-
-class saved_test_environment:
- """Save bits of the test environment and restore them at block exit.
-
- with saved_test_environment(testname, verbose, quiet):
- #stuff
-
- Unless quiet is True, a warning is printed to stderr if any of
- the saved items was changed by the test. The attribute 'changed'
- is initially False, but is set to True if a change is detected.
-
- If verbose is more than 1, the before and after state of changed
- items is also printed.
- """
-
- changed = False
-
- def __init__(self, testname, verbose=0, quiet=False, *, pgo=False):
- self.testname = testname
- self.verbose = verbose
- self.quiet = quiet
- self.pgo = pgo
-
- # To add things to save and restore, add a name XXX to the resources list
- # and add corresponding get_XXX/restore_XXX functions. get_XXX should
- # return the value to be saved and compared against a second call to the
- # get function when test execution completes. restore_XXX should accept
- # the saved value and restore the resource using it. It will be called if
- # and only if a change in the value is detected.
- #
- # Note: XXX will have any '.' replaced with '_' characters when determining
- # the corresponding method names.
-
- resources = ('sys.argv', 'cwd', 'sys.stdin', 'sys.stdout', 'sys.stderr',
- 'os.environ', 'sys.path', 'sys.path_hooks', '__import__',
- 'warnings.filters', 'asyncore.socket_map',
- 'logging._handlers', 'logging._handlerList', 'sys.gettrace',
- 'sys.warnoptions',
- # multiprocessing.process._cleanup() may release ref
- # to a thread, so check processes first.
- 'multiprocessing.process._dangling', 'threading._dangling',
- 'sysconfig._CONFIG_VARS', 'sysconfig._INSTALL_SCHEMES',
- 'files', 'locale', 'warnings.showwarning',
- 'shutil_archive_formats', 'shutil_unpack_formats',
- )
-
- def get_sys_argv(self):
- return id(sys.argv), sys.argv, sys.argv[:]
- def restore_sys_argv(self, saved_argv):
- sys.argv = saved_argv[1]
- sys.argv[:] = saved_argv[2]
-
- def get_cwd(self):
- return os.getcwd()
- def restore_cwd(self, saved_cwd):
- os.chdir(saved_cwd)
-
- def get_sys_stdout(self):
- return sys.stdout
- def restore_sys_stdout(self, saved_stdout):
- sys.stdout = saved_stdout
-
- def get_sys_stderr(self):
- return sys.stderr
- def restore_sys_stderr(self, saved_stderr):
- sys.stderr = saved_stderr
-
- def get_sys_stdin(self):
- return sys.stdin
- def restore_sys_stdin(self, saved_stdin):
- sys.stdin = saved_stdin
-
- def get_os_environ(self):
- return id(os.environ), os.environ, dict(os.environ)
- def restore_os_environ(self, saved_environ):
- os.environ = saved_environ[1]
- os.environ.clear()
- os.environ.update(saved_environ[2])
-
- def get_sys_path(self):
- return id(sys.path), sys.path, sys.path[:]
- def restore_sys_path(self, saved_path):
- sys.path = saved_path[1]
- sys.path[:] = saved_path[2]
-
- def get_sys_path_hooks(self):
- return id(sys.path_hooks), sys.path_hooks, sys.path_hooks[:]
- def restore_sys_path_hooks(self, saved_hooks):
- sys.path_hooks = saved_hooks[1]
- sys.path_hooks[:] = saved_hooks[2]
-
- def get_sys_gettrace(self):
- return sys.gettrace()
- def restore_sys_gettrace(self, trace_fxn):
- sys.settrace(trace_fxn)
-
- def get___import__(self):
- return builtins.__import__
- def restore___import__(self, import_):
- builtins.__import__ = import_
-
- def get_warnings_filters(self):
- return id(warnings.filters), warnings.filters, warnings.filters[:]
- def restore_warnings_filters(self, saved_filters):
- warnings.filters = saved_filters[1]
- warnings.filters[:] = saved_filters[2]
-
- def get_asyncore_socket_map(self):
- asyncore = sys.modules.get('asyncore')
- # XXX Making a copy keeps objects alive until __exit__ gets called.
- return asyncore and asyncore.socket_map.copy() or {}
- def restore_asyncore_socket_map(self, saved_map):
- asyncore = sys.modules.get('asyncore')
- if asyncore is not None:
- asyncore.close_all(ignore_all=True)
- asyncore.socket_map.update(saved_map)
-
- def get_shutil_archive_formats(self):
- # we could call get_archives_formats() but that only returns the
- # registry keys; we want to check the values too (the functions that
- # are registered)
- return shutil._ARCHIVE_FORMATS, shutil._ARCHIVE_FORMATS.copy()
- def restore_shutil_archive_formats(self, saved):
- shutil._ARCHIVE_FORMATS = saved[0]
- shutil._ARCHIVE_FORMATS.clear()
- shutil._ARCHIVE_FORMATS.update(saved[1])
-
- def get_shutil_unpack_formats(self):
- return shutil._UNPACK_FORMATS, shutil._UNPACK_FORMATS.copy()
- def restore_shutil_unpack_formats(self, saved):
- shutil._UNPACK_FORMATS = saved[0]
- shutil._UNPACK_FORMATS.clear()
- shutil._UNPACK_FORMATS.update(saved[1])
-
- def get_logging__handlers(self):
- # _handlers is a WeakValueDictionary
- return id(logging._handlers), logging._handlers, logging._handlers.copy()
- def restore_logging__handlers(self, saved_handlers):
- # Can't easily revert the logging state
- pass
-
- def get_logging__handlerList(self):
- # _handlerList is a list of weakrefs to handlers
- return id(logging._handlerList), logging._handlerList, logging._handlerList[:]
- def restore_logging__handlerList(self, saved_handlerList):
- # Can't easily revert the logging state
- pass
-
- def get_sys_warnoptions(self):
- return id(sys.warnoptions), sys.warnoptions, sys.warnoptions[:]
- def restore_sys_warnoptions(self, saved_options):
- sys.warnoptions = saved_options[1]
- sys.warnoptions[:] = saved_options[2]
-
- # Controlling dangling references to Thread objects can make it easier
- # to track reference leaks.
- def get_threading__dangling(self):
- if not threading:
- return None
- # This copies the weakrefs without making any strong reference
- return threading._dangling.copy()
- def restore_threading__dangling(self, saved):
- if not threading:
- return
- threading._dangling.clear()
- threading._dangling.update(saved)
-
- # Same for Process objects
- def get_multiprocessing_process__dangling(self):
- if not multiprocessing:
- return None
- # Unjoined process objects can survive after process exits
- multiprocessing.process._cleanup()
- # This copies the weakrefs without making any strong reference
- return multiprocessing.process._dangling.copy()
- def restore_multiprocessing_process__dangling(self, saved):
- if not multiprocessing:
- return
- multiprocessing.process._dangling.clear()
- multiprocessing.process._dangling.update(saved)
-
- def get_sysconfig__CONFIG_VARS(self):
- # make sure the dict is initialized
- sysconfig.get_config_var('prefix')
- return (id(sysconfig._CONFIG_VARS), sysconfig._CONFIG_VARS,
- dict(sysconfig._CONFIG_VARS))
- def restore_sysconfig__CONFIG_VARS(self, saved):
- sysconfig._CONFIG_VARS = saved[1]
- sysconfig._CONFIG_VARS.clear()
- sysconfig._CONFIG_VARS.update(saved[2])
-
- def get_sysconfig__INSTALL_SCHEMES(self):
- return (id(sysconfig._INSTALL_SCHEMES), sysconfig._INSTALL_SCHEMES,
- sysconfig._INSTALL_SCHEMES.copy())
- def restore_sysconfig__INSTALL_SCHEMES(self, saved):
- sysconfig._INSTALL_SCHEMES = saved[1]
- sysconfig._INSTALL_SCHEMES.clear()
- sysconfig._INSTALL_SCHEMES.update(saved[2])
-
- def get_files(self):
- return sorted(fn + ('/' if os.path.isdir(fn) else '')
- for fn in os.listdir())
- def restore_files(self, saved_value):
- fn = support.TESTFN
- if fn not in saved_value and (fn + '/') not in saved_value:
- if os.path.isfile(fn):
- support.unlink(fn)
- elif os.path.isdir(fn):
- support.rmtree(fn)
-
- _lc = [getattr(locale, lc) for lc in dir(locale)
- if lc.startswith('LC_')]
- def get_locale(self):
- pairings = []
- for lc in self._lc:
- try:
- pairings.append((lc, locale.setlocale(lc, None)))
- except (TypeError, ValueError):
- continue
- return pairings
- def restore_locale(self, saved):
- for lc, setting in saved:
- locale.setlocale(lc, setting)
-
- def get_warnings_showwarning(self):
- return warnings.showwarning
- def restore_warnings_showwarning(self, fxn):
- warnings.showwarning = fxn
-
- def resource_info(self):
- for name in self.resources:
- method_suffix = name.replace('.', '_')
- get_name = 'get_' + method_suffix
- restore_name = 'restore_' + method_suffix
- yield name, getattr(self, get_name), getattr(self, restore_name)
-
- def __enter__(self):
- self.saved_values = dict((name, get()) for name, get, restore
- in self.resource_info())
- return self
-
- def __exit__(self, exc_type, exc_val, exc_tb):
- saved_values = self.saved_values
- del self.saved_values
- for name, get, restore in self.resource_info():
- current = get()
- original = saved_values.pop(name)
- # Check for changes to the resource's value
- if current != original:
- self.changed = True
- restore(original)
- if not self.quiet and not self.pgo:
- print("Warning -- {} was modified by {}".format(
- name, self.testname),
- file=sys.stderr)
- if self.verbose > 1 and not self.pgo:
- print(" Before: {}\n After: {} ".format(
- original, current),
- file=sys.stderr)
- return False
-
-
-def runtest_inner(test, verbose, quiet,
- huntrleaks=False, display_failure=True, pgo=False):
- support.unload(test)
-
- test_time = 0.0
- refleak = False # True if the test leaked references.
- try:
- if test.startswith('test.'):
- abstest = test
- else:
- # Always import it from the test package
- abstest = 'test.' + test
- with saved_test_environment(test, verbose, quiet, pgo=pgo) as environment:
- start_time = time.time()
- the_module = importlib.import_module(abstest)
- # If the test has a test_main, that will run the appropriate
- # tests. If not, use normal unittest test loading.
- test_runner = getattr(the_module, "test_main", None)
- if test_runner is None:
- def test_runner():
- loader = unittest.TestLoader()
- tests = loader.loadTestsFromModule(the_module)
- for error in loader.errors:
- print(error, file=sys.stderr)
- if loader.errors:
- raise Exception("errors while loading tests")
- support.run_unittest(tests)
- test_runner()
- if huntrleaks:
- refleak = dash_R(the_module, test, test_runner, huntrleaks)
- test_time = time.time() - start_time
- except support.ResourceDenied as msg:
- if not quiet and not pgo:
- print(test, "skipped --", msg)
- sys.stdout.flush()
- return RESOURCE_DENIED, test_time
- except unittest.SkipTest as msg:
- if not quiet and not pgo:
- print(test, "skipped --", msg)
- sys.stdout.flush()
- return SKIPPED, test_time
- except KeyboardInterrupt:
- raise
- except support.TestFailed as msg:
- if not pgo:
- if display_failure:
- print("test", test, "failed --", msg, file=sys.stderr)
- else:
- print("test", test, "failed", file=sys.stderr)
- sys.stderr.flush()
- return FAILED, test_time
- except:
- msg = traceback.format_exc()
- if not pgo:
- print("test", test, "crashed --", msg, file=sys.stderr)
- sys.stderr.flush()
- return FAILED, test_time
- else:
- if refleak:
- return FAILED, test_time
- if environment.changed:
- return ENV_CHANGED, test_time
- return PASSED, test_time
-
-def cleanup_test_droppings(testname, verbose):
- import shutil
- import stat
- import gc
-
- # First kill any dangling references to open files etc.
- # This can also issue some ResourceWarnings which would otherwise get
- # triggered during the following test run, and possibly produce failures.
- gc.collect()
-
- # Try to clean up junk commonly left behind. While tests shouldn't leave
- # any files or directories behind, when a test fails that can be tedious
- # for it to arrange. The consequences can be especially nasty on Windows,
- # since if a test leaves a file open, it cannot be deleted by name (while
- # there's nothing we can do about that here either, we can display the
- # name of the offending test, which is a real help).
- for name in (support.TESTFN,
- "db_home",
- ):
- if not os.path.exists(name):
- continue
-
- if os.path.isdir(name):
- kind, nuker = "directory", shutil.rmtree
- elif os.path.isfile(name):
- kind, nuker = "file", os.unlink
- else:
- raise SystemError("os.path says %r exists but is neither "
- "directory nor file" % name)
-
- if verbose:
- print("%r left behind %s %r" % (testname, kind, name))
- try:
- # if we have chmod, fix possible permissions problems
- # that might prevent cleanup
- if (hasattr(os, 'chmod')):
- os.chmod(name, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
- nuker(name)
- except Exception as msg:
- print(("%r left behind %s %r and it couldn't be "
- "removed: %s" % (testname, kind, name, msg)), file=sys.stderr)
-
-def dash_R(the_module, test, indirect_test, huntrleaks):
- """Run a test multiple times, looking for reference leaks.
-
- Returns:
- False if the test didn't leak references; True if we detected refleaks.
- """
- # This code is hackish and inelegant, but it seems to do the job.
- import copyreg
- import collections.abc
-
- if not hasattr(sys, 'gettotalrefcount'):
- raise Exception("Tracking reference leaks requires a debug build "
- "of Python")
-
- # Save current values for dash_R_cleanup() to restore.
- fs = warnings.filters[:]
- ps = copyreg.dispatch_table.copy()
- pic = sys.path_importer_cache.copy()
- try:
- import zipimport
- except ImportError:
- zdc = None # Run unmodified on platforms without zipimport support
- else:
- zdc = zipimport._zip_directory_cache.copy()
- abcs = {}
- for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]:
- if not isabstract(abc):
- continue
- for obj in abc.__subclasses__() + [abc]:
- abcs[obj] = obj._abc_registry.copy()
-
- nwarmup, ntracked, fname = huntrleaks
- fname = os.path.join(support.SAVEDCWD, fname)
- repcount = nwarmup + ntracked
- rc_deltas = [0] * repcount
- alloc_deltas = [0] * repcount
-
- print("beginning", repcount, "repetitions", file=sys.stderr)
- print(("1234567890"*(repcount//10 + 1))[:repcount], file=sys.stderr)
- sys.stderr.flush()
- for i in range(repcount):
- indirect_test()
- alloc_after, rc_after = dash_R_cleanup(fs, ps, pic, zdc, abcs)
- sys.stderr.write('.')
- sys.stderr.flush()
- if i >= nwarmup:
- rc_deltas[i] = rc_after - rc_before
- alloc_deltas[i] = alloc_after - alloc_before
- alloc_before, rc_before = alloc_after, rc_after
- print(file=sys.stderr)
- # These checkers return False on success, True on failure
- def check_rc_deltas(deltas):
- return any(deltas)
- def check_alloc_deltas(deltas):
- # At least 1/3rd of 0s
- if 3 * deltas.count(0) < len(deltas):
- return True
- # Nothing else than 1s, 0s and -1s
- if not set(deltas) <= {1,0,-1}:
- return True
- return False
- failed = False
- for deltas, item_name, checker in [
- (rc_deltas, 'references', check_rc_deltas),
- (alloc_deltas, 'memory blocks', check_alloc_deltas)]:
- if checker(deltas):
- msg = '%s leaked %s %s, sum=%s' % (
- test, deltas[nwarmup:], item_name, sum(deltas))
- print(msg, file=sys.stderr)
- sys.stderr.flush()
- with open(fname, "a") as refrep:
- print(msg, file=refrep)
- refrep.flush()
- failed = True
- return failed
-
-def dash_R_cleanup(fs, ps, pic, zdc, abcs):
- import gc, copyreg
- import _strptime, linecache
- import urllib.parse, urllib.request, mimetypes, doctest
- import struct, filecmp, collections.abc
- from distutils.dir_util import _path_created
- from weakref import WeakSet
-
- # Clear the warnings registry, so they can be displayed again
- for mod in sys.modules.values():
- if hasattr(mod, '__warningregistry__'):
- del mod.__warningregistry__
-
- # Restore some original values.
- warnings.filters[:] = fs
- copyreg.dispatch_table.clear()
- copyreg.dispatch_table.update(ps)
- sys.path_importer_cache.clear()
- sys.path_importer_cache.update(pic)
- try:
- import zipimport
- except ImportError:
- pass # Run unmodified on platforms without zipimport support
- else:
- zipimport._zip_directory_cache.clear()
- zipimport._zip_directory_cache.update(zdc)
-
- # clear type cache
- sys._clear_type_cache()
-
- # Clear ABC registries, restoring previously saved ABC registries.
- for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]:
- if not isabstract(abc):
- continue
- for obj in abc.__subclasses__() + [abc]:
- obj._abc_registry = abcs.get(obj, WeakSet()).copy()
- obj._abc_cache.clear()
- obj._abc_negative_cache.clear()
-
- # Flush standard output, so that buffered data is sent to the OS and
- # associated Python objects are reclaimed.
- for stream in (sys.stdout, sys.stderr, sys.__stdout__, sys.__stderr__):
- if stream is not None:
- stream.flush()
-
- # Clear assorted module caches.
- _path_created.clear()
- re.purge()
- _strptime._regex_cache.clear()
- urllib.parse.clear_cache()
- urllib.request.urlcleanup()
- linecache.clearcache()
- mimetypes._default_mime_types()
- filecmp._cache.clear()
- struct._clearcache()
- doctest.master = None
- try:
- import ctypes
- except ImportError:
- # Don't worry about resetting the cache if ctypes is not supported
- pass
- else:
- ctypes._reset_cache()
-
- # Collect cyclic trash and read memory statistics immediately after.
- func1 = sys.getallocatedblocks
- func2 = sys.gettotalrefcount
- gc.collect()
- return func1(), func2()
-
-def warm_caches():
- # char cache
- s = bytes(range(256))
- for i in range(256):
- s[i:i+1]
- # unicode cache
- x = [chr(i) for i in range(256)]
- # int cache
- x = list(range(-5, 257))
-
-def findtestdir(path=None):
- return path or os.path.dirname(__file__) or os.curdir
-
-def removepy(names):
- if not names:
- return
- for idx, name in enumerate(names):
- basename, ext = os.path.splitext(name)
- if ext == '.py':
- names[idx] = basename
-
-def count(n, word):
- if n == 1:
- return "%d %s" % (n, word)
- else:
- return "%d %ss" % (n, word)
-
-def printlist(x, width=70, indent=4):
- """Print the elements of iterable x to stdout.
-
- Optional arg width (default 70) is the maximum line length.
- Optional arg indent (default 4) is the number of blanks with which to
- begin each line.
- """
-
- from textwrap import fill
- blanks = ' ' * indent
- # Print the sorted list: 'x' may be a '--random' list or a set()
- print(fill(' '.join(str(elt) for elt in sorted(x)), width,
- initial_indent=blanks, subsequent_indent=blanks))
-
-
-def main_in_temp_cwd():
- """Run main() in a temporary working directory."""
- if sysconfig.is_python_build():
- try:
- os.mkdir(TEMPDIR)
- except FileExistsError:
- pass
-
- # Define a writable temp dir that will be used as cwd while running
- # the tests. The name of the dir includes the pid to allow parallel
- # testing (see the -j option).
- test_cwd = 'test_python_{}'.format(os.getpid())
- test_cwd = os.path.join(TEMPDIR, test_cwd)
-
- # Run the tests in a context manager that temporarily changes the CWD to a
- # temporary and writable directory. If it's not possible to create or
- # change the CWD, the original CWD will be used. The original CWD is
- # available from support.SAVEDCWD.
- with support.temp_cwd(test_cwd, quiet=True):
- main()
-
+def _main():
+ global __file__
-if __name__ == '__main__':
# Remove regrtest.py's own directory from the module search path. Despite
# the elimination of implicit relative imports, this is still needed to
# ensure that submodules of the test package do not inappropriately appear
# as top-level modules even when people (or buildbots!) invoke regrtest.py
# directly instead of using the -m switch
mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
- i = len(sys.path)
+ i = len(sys.path) - 1
while i >= 0:
- i -= 1
if os.path.abspath(os.path.normpath(sys.path[i])) == mydir:
del sys.path[i]
+ else:
+ i -= 1
# findtestdir() gets the dirname out of __file__, so we have to make it
# absolute before changing the working directory.
@@ -1614,4 +43,8 @@
# sanity check
assert __file__ == os.path.abspath(sys.argv[0])
- main_in_temp_cwd()
+ main()
+
+
+if __name__ == '__main__':
+ _main()
diff --git a/Lib/test/seq_tests.py b/Lib/test/seq_tests.py
index 72f4845..1e7a6f6 100644
--- a/Lib/test/seq_tests.py
+++ b/Lib/test/seq_tests.py
@@ -318,7 +318,6 @@
self.assertEqual(id(s), id(s*1))
def test_bigrepeat(self):
- import sys
if sys.maxsize <= 2147483647:
x = self.type2test([0])
x *= 2**16
diff --git a/Lib/test/signalinterproctester.py b/Lib/test/signalinterproctester.py
new file mode 100644
index 0000000..d3ae170
--- /dev/null
+++ b/Lib/test/signalinterproctester.py
@@ -0,0 +1,84 @@
+import os
+import signal
+import subprocess
+import sys
+import time
+import unittest
+
+
+class SIGUSR1Exception(Exception):
+ pass
+
+
+class InterProcessSignalTests(unittest.TestCase):
+ def setUp(self):
+ self.got_signals = {'SIGHUP': 0, 'SIGUSR1': 0, 'SIGALRM': 0}
+
+ def sighup_handler(self, signum, frame):
+ self.got_signals['SIGHUP'] += 1
+
+ def sigusr1_handler(self, signum, frame):
+ self.got_signals['SIGUSR1'] += 1
+ raise SIGUSR1Exception
+
+ def wait_signal(self, child, signame, exc_class=None):
+ try:
+ if child is not None:
+ # This wait should be interrupted by exc_class
+ # (if set)
+ child.wait()
+
+ timeout = 10.0
+ deadline = time.monotonic() + timeout
+
+ while time.monotonic() < deadline:
+ if self.got_signals[signame]:
+ return
+ signal.pause()
+ except BaseException as exc:
+ if exc_class is not None and isinstance(exc, exc_class):
+ # got the expected exception
+ return
+ raise
+
+ self.fail('signal %s not received after %s seconds'
+ % (signame, timeout))
+
+ def subprocess_send_signal(self, pid, signame):
+ code = 'import os, signal; os.kill(%s, signal.%s)' % (pid, signame)
+ args = [sys.executable, '-I', '-c', code]
+ return subprocess.Popen(args)
+
+ def test_interprocess_signal(self):
+ # Install handlers. This function runs in a sub-process, so we
+ # don't worry about re-setting the default handlers.
+ signal.signal(signal.SIGHUP, self.sighup_handler)
+ signal.signal(signal.SIGUSR1, self.sigusr1_handler)
+ signal.signal(signal.SIGUSR2, signal.SIG_IGN)
+ signal.signal(signal.SIGALRM, signal.default_int_handler)
+
+ # Let the sub-processes know who to send signals to.
+ pid = str(os.getpid())
+
+ with self.subprocess_send_signal(pid, "SIGHUP") as child:
+ self.wait_signal(child, 'SIGHUP')
+ self.assertEqual(self.got_signals, {'SIGHUP': 1, 'SIGUSR1': 0,
+ 'SIGALRM': 0})
+
+ with self.subprocess_send_signal(pid, "SIGUSR1") as child:
+ self.wait_signal(child, 'SIGUSR1', SIGUSR1Exception)
+ self.assertEqual(self.got_signals, {'SIGHUP': 1, 'SIGUSR1': 1,
+ 'SIGALRM': 0})
+
+ with self.subprocess_send_signal(pid, "SIGUSR2") as child:
+ # Nothing should happen: SIGUSR2 is ignored
+ child.wait()
+
+ signal.alarm(1)
+ self.wait_signal(None, 'SIGALRM', KeyboardInterrupt)
+ self.assertEqual(self.got_signals, {'SIGHUP': 1, 'SIGUSR1': 1,
+ 'SIGALRM': 0})
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index c9e36fb..86ff734 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -26,6 +26,7 @@
import sysconfig
import tempfile
import time
+import types
import unittest
import urllib.error
import warnings
@@ -89,6 +90,7 @@
"bigmemtest", "bigaddrspacetest", "cpython_only", "get_attribute",
"requires_IEEE_754", "skip_unless_xattr", "requires_zlib",
"anticipate_failure", "load_package_tests", "detect_api_mismatch",
+ "check__all__",
# sys
"is_jython", "check_impl_detail",
# network
@@ -900,7 +902,7 @@
yield path
finally:
if dir_created:
- shutil.rmtree(path)
+ rmtree(path)
@contextlib.contextmanager
def change_cwd(path, quiet=False):
@@ -2074,6 +2076,11 @@
settings in sys.flags and sys.warnoptions."""
return subprocess._args_from_interpreter_flags()
+def optim_args_from_interpreter_flags():
+ """Return a list of command-line arguments reproducing the current
+ optimization settings in sys.flags."""
+ return subprocess._optim_args_from_interpreter_flags()
+
#============================================================
# Support for assertions about logging.
#============================================================
@@ -2225,6 +2232,65 @@
return missing_items
+def check__all__(test_case, module, name_of_module=None, extra=(),
+ blacklist=()):
+ """Assert that the __all__ variable of 'module' contains all public names.
+
+ The module's public names (its API) are detected automatically based on
+ whether they match the public name convention and were defined in
+ 'module'.
+
+ The 'name_of_module' argument can specify (as a string or tuple thereof)
+ what module(s) an API could be defined in in order to be detected as a
+ public API. One case for this is when 'module' imports part of its public
+ API from other modules, possibly a C backend (like 'csv' and its '_csv').
+
+ The 'extra' argument can be a set of names that wouldn't otherwise be
+ automatically detected as "public", like objects without a proper
+ '__module__' attriubute. If provided, it will be added to the
+ automatically detected ones.
+
+ The 'blacklist' argument can be a set of names that must not be treated
+ as part of the public API even though their names indicate otherwise.
+
+ Usage:
+ import bar
+ import foo
+ import unittest
+ from test import support
+
+ class MiscTestCase(unittest.TestCase):
+ def test__all__(self):
+ support.check__all__(self, foo)
+
+ class OtherTestCase(unittest.TestCase):
+ def test__all__(self):
+ extra = {'BAR_CONST', 'FOO_CONST'}
+ blacklist = {'baz'} # Undocumented name.
+ # bar imports part of its API from _bar.
+ support.check__all__(self, bar, ('bar', '_bar'),
+ extra=extra, blacklist=blacklist)
+
+ """
+
+ if name_of_module is None:
+ name_of_module = (module.__name__, )
+ elif isinstance(name_of_module, str):
+ name_of_module = (name_of_module, )
+
+ expected = set(extra)
+
+ for name in dir(module):
+ if name.startswith('_') or name in blacklist:
+ continue
+ obj = getattr(module, name)
+ if (getattr(obj, '__module__', None) in name_of_module or
+ (not hasattr(obj, '__module__') and
+ not isinstance(obj, types.ModuleType))):
+ expected.add(name)
+ test_case.assertCountEqual(module.__all__, expected)
+
+
class SuppressCrashReport:
"""Try to prevent a crash report from popping up.
diff --git a/Lib/test/test__locale.py b/Lib/test/test__locale.py
index 58f2f04..ab4e247 100644
--- a/Lib/test/test__locale.py
+++ b/Lib/test/test__locale.py
@@ -4,7 +4,6 @@
except ImportError:
nl_langinfo = None
-import codecs
import locale
import sys
import unittest
diff --git a/Lib/test/test__osx_support.py b/Lib/test/test__osx_support.py
index ac6325a..bcba8ca 100644
--- a/Lib/test/test__osx_support.py
+++ b/Lib/test/test__osx_support.py
@@ -4,7 +4,6 @@
import os
import platform
-import shutil
import stat
import sys
import unittest
diff --git a/Lib/test/test_aifc.py b/Lib/test/test_aifc.py
index ab51437..1bd1f89 100644
--- a/Lib/test/test_aifc.py
+++ b/Lib/test/test_aifc.py
@@ -2,7 +2,6 @@
import unittest
from test import audiotests
from audioop import byteswap
-import os
import io
import sys
import struct
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
index f9ee398..52c6247 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -4512,6 +4512,21 @@
string = "Namespace(bar='spam', foo=42)"
self.assertStringEqual(ns, string)
+ def test_namespace_starkwargs_notidentifier(self):
+ ns = argparse.Namespace(**{'"': 'quote'})
+ string = """Namespace(**{'"': 'quote'})"""
+ self.assertStringEqual(ns, string)
+
+ def test_namespace_kwargs_and_starkwargs_notidentifier(self):
+ ns = argparse.Namespace(a=1, **{'"': 'quote'})
+ string = """Namespace(a=1, **{'"': 'quote'})"""
+ self.assertStringEqual(ns, string)
+
+ def test_namespace_starkwargs_identifier(self):
+ ns = argparse.Namespace(**{'valid': True})
+ string = "Namespace(valid=True)"
+ self.assertStringEqual(ns, string)
+
def test_parser(self):
parser = argparse.ArgumentParser(prog='PROG')
string = (
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index 482526e..8fd54cc 100644
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -7,8 +7,6 @@
import weakref
import pickle
import operator
-import io
-import math
import struct
import sys
import warnings
@@ -318,8 +316,19 @@
d = pickle.dumps((itorig, orig), proto)
it, a = pickle.loads(d)
a.fromlist(data2)
- self.assertEqual(type(it), type(itorig))
- self.assertEqual(list(it), data2)
+ self.assertEqual(list(it), [])
+
+ def test_exhausted_iterator(self):
+ a = array.array(self.typecode, self.example)
+ self.assertEqual(list(a), list(self.example))
+ exhit = iter(a)
+ empit = iter(a)
+ for x in exhit: # exhaust the iterator
+ next(empit) # not exhausted
+ a.append(self.outside)
+ self.assertEqual(list(exhit), [])
+ self.assertEqual(list(empit), [self.outside])
+ self.assertEqual(list(a), list(self.example) + [self.outside])
def test_insert(self):
a = array.array(self.typecode, self.example)
@@ -1070,6 +1079,12 @@
a = array.array('B', b"")
self.assertRaises(BufferError, getbuffer_with_null_view, a)
+ def test_free_after_iterating(self):
+ support.check_free_after_iterating(self, iter, array.array,
+ (self.typecode,))
+ support.check_free_after_iterating(self, reversed, array.array,
+ (self.typecode,))
+
class StringTest(BaseTest):
def test_setitem(self):
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index d3e6d35..e032f6d 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -1,7 +1,8 @@
+import ast
+import dis
import os
import sys
import unittest
-import ast
import weakref
from test import support
@@ -238,7 +239,7 @@
ast_tree = compile(i, "?", kind, ast.PyCF_ONLY_AST)
self.assertEqual(to_tuple(ast_tree), o)
self._assertTrueorder(ast_tree, (0, 0))
- with self.subTest(action="compiling", input=i):
+ with self.subTest(action="compiling", input=i, kind=kind):
compile(ast_tree, "?", kind)
def test_slice(self):
@@ -547,6 +548,17 @@
compile(mod, 'test', 'exec')
self.assertIn("invalid integer value: None", str(cm.exception))
+ def test_level_as_none(self):
+ body = [ast.ImportFrom(module='time',
+ names=[ast.alias(name='sleep')],
+ level=None,
+ lineno=0, col_offset=0)]
+ mod = ast.Module(body)
+ code = compile(mod, 'test', 'exec')
+ ns = {}
+ exec(code, ns)
+ self.assertIn('sleep', ns)
+
class ASTValidatorTests(unittest.TestCase):
@@ -742,7 +754,7 @@
def test_importfrom(self):
imp = ast.ImportFrom(None, [ast.alias("x", None)], -42)
- self.stmt(imp, "level less than -1")
+ self.stmt(imp, "Negative ImportFrom level")
self.stmt(ast.ImportFrom(None, [], 0), "empty names on ImportFrom")
def test_global(self):
@@ -933,6 +945,125 @@
compile(mod, fn, "exec")
+class ConstantTests(unittest.TestCase):
+ """Tests on the ast.Constant node type."""
+
+ def compile_constant(self, value):
+ tree = ast.parse("x = 123")
+
+ node = tree.body[0].value
+ new_node = ast.Constant(value=value)
+ ast.copy_location(new_node, node)
+ tree.body[0].value = new_node
+
+ code = compile(tree, "<string>", "exec")
+
+ ns = {}
+ exec(code, ns)
+ return ns['x']
+
+ def test_validation(self):
+ with self.assertRaises(TypeError) as cm:
+ self.compile_constant([1, 2, 3])
+ self.assertEqual(str(cm.exception),
+ "got an invalid type in Constant: list")
+
+ def test_singletons(self):
+ for const in (None, False, True, Ellipsis, b'', frozenset()):
+ with self.subTest(const=const):
+ value = self.compile_constant(const)
+ self.assertIs(value, const)
+
+ def test_values(self):
+ nested_tuple = (1,)
+ nested_frozenset = frozenset({1})
+ for level in range(3):
+ nested_tuple = (nested_tuple, 2)
+ nested_frozenset = frozenset({nested_frozenset, 2})
+ values = (123, 123.0, 123j,
+ "unicode", b'bytes',
+ tuple("tuple"), frozenset("frozenset"),
+ nested_tuple, nested_frozenset)
+ for value in values:
+ with self.subTest(value=value):
+ result = self.compile_constant(value)
+ self.assertEqual(result, value)
+
+ def test_assign_to_constant(self):
+ tree = ast.parse("x = 1")
+
+ target = tree.body[0].targets[0]
+ new_target = ast.Constant(value=1)
+ ast.copy_location(new_target, target)
+ tree.body[0].targets[0] = new_target
+
+ with self.assertRaises(ValueError) as cm:
+ compile(tree, "string", "exec")
+ self.assertEqual(str(cm.exception),
+ "expression which can't be assigned "
+ "to in Store context")
+
+ def test_get_docstring(self):
+ tree = ast.parse("'docstring'\nx = 1")
+ self.assertEqual(ast.get_docstring(tree), 'docstring')
+
+ tree.body[0].value = ast.Constant(value='constant docstring')
+ self.assertEqual(ast.get_docstring(tree), 'constant docstring')
+
+ def get_load_const(self, tree):
+ # Compile to bytecode, disassemble and get parameter of LOAD_CONST
+ # instructions
+ co = compile(tree, '<string>', 'exec')
+ consts = []
+ for instr in dis.get_instructions(co):
+ if instr.opname == 'LOAD_CONST':
+ consts.append(instr.argval)
+ return consts
+
+ @support.cpython_only
+ def test_load_const(self):
+ consts = [None,
+ True, False,
+ 124,
+ 2.0,
+ 3j,
+ "unicode",
+ b'bytes',
+ (1, 2, 3)]
+
+ code = '\n'.join(['x={!r}'.format(const) for const in consts])
+ code += '\nx = ...'
+ consts.extend((Ellipsis, None))
+
+ tree = ast.parse(code)
+ self.assertEqual(self.get_load_const(tree),
+ consts)
+
+ # Replace expression nodes with constants
+ for assign, const in zip(tree.body, consts):
+ assert isinstance(assign, ast.Assign), ast.dump(assign)
+ new_node = ast.Constant(value=const)
+ ast.copy_location(new_node, assign.value)
+ assign.value = new_node
+
+ self.assertEqual(self.get_load_const(tree),
+ consts)
+
+ def test_literal_eval(self):
+ tree = ast.parse("1 + 2")
+ binop = tree.body[0].value
+
+ new_left = ast.Constant(value=10)
+ ast.copy_location(new_left, binop.left)
+ binop.left = new_left
+
+ new_right = ast.Constant(value=20)
+ ast.copy_location(new_right, binop.right)
+ binop.right = new_right
+
+ self.assertEqual(ast.literal_eval(binop), 30)
+
+
def main():
if __name__ != '__main__':
return
@@ -940,8 +1071,9 @@
for statements, kind in ((exec_tests, "exec"), (single_tests, "single"),
(eval_tests, "eval")):
print(kind+"_results = [")
- for s in statements:
- print(repr(to_tuple(compile(s, "?", kind, 0x400)))+",")
+ for statement in statements:
+ tree = ast.parse(statement, "?", kind)
+ print("%r," % (to_tuple(tree),))
print("]")
print("main()")
raise SystemExit
diff --git a/Lib/test/test_asynchat.py b/Lib/test/test_asynchat.py
index 3a33fc8..0eba76d 100644
--- a/Lib/test/test_asynchat.py
+++ b/Lib/test/test_asynchat.py
@@ -12,7 +12,6 @@
import sys
import time
import unittest
-import warnings
import unittest.mock
try:
import threading
@@ -297,37 +296,6 @@
self.assertEqual(asynchat.find_prefix_at_end("qwertydkjf", "\r\n"), 0)
-class TestFifo(unittest.TestCase):
- def test_basic(self):
- with self.assertWarns(DeprecationWarning) as cm:
- f = asynchat.fifo()
- self.assertEqual(str(cm.warning),
- "fifo class will be removed in Python 3.6")
- f.push(7)
- f.push(b'a')
- self.assertEqual(len(f), 2)
- self.assertEqual(f.first(), 7)
- self.assertEqual(f.pop(), (1, 7))
- self.assertEqual(len(f), 1)
- self.assertEqual(f.first(), b'a')
- self.assertEqual(f.is_empty(), False)
- self.assertEqual(f.pop(), (1, b'a'))
- self.assertEqual(len(f), 0)
- self.assertEqual(f.is_empty(), True)
- self.assertEqual(f.pop(), (0, None))
-
- def test_given_list(self):
- with self.assertWarns(DeprecationWarning) as cm:
- f = asynchat.fifo([b'x', 17, 3])
- self.assertEqual(str(cm.warning),
- "fifo class will be removed in Python 3.6")
- self.assertEqual(len(f), 3)
- self.assertEqual(f.pop(), (1, b'x'))
- self.assertEqual(f.pop(), (1, 17))
- self.assertEqual(f.pop(), (1, 3))
- self.assertEqual(f.pop(), (0, None))
-
-
class TestNotConnected(unittest.TestCase):
def test_disallow_negative_terminator(self):
# Issue #11259
diff --git a/Lib/test/test_bigmem.py b/Lib/test/test_bigmem.py
index 40ac9bf..6133bbc 100644
--- a/Lib/test/test_bigmem.py
+++ b/Lib/test/test_bigmem.py
@@ -14,7 +14,6 @@
import unittest
import operator
import sys
-import functools
# These tests all use one of the bigmemtest decorators to indicate how much
# memory they use and how much memory they need to be even meaningful. The
diff --git a/Lib/test/test_binascii.py b/Lib/test/test_binascii.py
index 8367afe..fbc933e4 100644
--- a/Lib/test/test_binascii.py
+++ b/Lib/test/test_binascii.py
@@ -159,11 +159,25 @@
# Then calculate the hexbin4 binary-to-ASCII translation
rle = binascii.rlecode_hqx(self.data)
a = binascii.b2a_hqx(self.type2test(rle))
+
b, _ = binascii.a2b_hqx(self.type2test(a))
res = binascii.rledecode_hqx(b)
-
self.assertEqual(res, self.rawdata)
+ def test_rle(self):
+ # test repetition with a repetition longer than the limit of 255
+ data = (b'a' * 100 + b'b' + b'c' * 300)
+
+ encoded = binascii.rlecode_hqx(data)
+ self.assertEqual(encoded,
+ (b'a\x90d' # 'a' * 100
+ b'b' # 'b'
+ b'c\x90\xff' # 'c' * 255
+ b'c\x90-')) # 'c' * 45
+
+ decoded = binascii.rledecode_hqx(encoded)
+ self.assertEqual(decoded, data)
+
def test_hex(self):
# test hexlification
s = b'{s\005\000\000\000worldi\002\000\000\000s\005\000\000\000helloi\001\000\000\0000'
@@ -262,6 +276,16 @@
# non-ASCII string
self.assertRaises(ValueError, a2b, "\x80")
+ def test_b2a_base64_newline(self):
+ # Issue #25357: test newline parameter
+ b = self.type2test(b'hello')
+ self.assertEqual(binascii.b2a_base64(b),
+ b'aGVsbG8=\n')
+ self.assertEqual(binascii.b2a_base64(b, newline=True),
+ b'aGVsbG8=\n')
+ self.assertEqual(binascii.b2a_base64(b, newline=False),
+ b'aGVsbG8=')
+
class ArrayBinASCIITest(BinASCIITest):
def type2test(self, s):
diff --git a/Lib/test/test_binhex.py b/Lib/test/test_binhex.py
index 9d4c85a..21f4463 100644
--- a/Lib/test/test_binhex.py
+++ b/Lib/test/test_binhex.py
@@ -4,7 +4,6 @@
Based on an original test by Roger E. Masse.
"""
import binhex
-import os
import unittest
from test import support
diff --git a/Lib/test/test_binop.py b/Lib/test/test_binop.py
index e9dbddc..fc8d30f 100644
--- a/Lib/test/test_binop.py
+++ b/Lib/test/test_binop.py
@@ -2,7 +2,7 @@
import unittest
from test import support
-from operator import eq, ne, lt, gt, le, ge
+from operator import eq, le
from abc import ABCMeta
def gcd(a, b):
diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py
index 2eef9fc..b83f2f1 100644
--- a/Lib/test/test_buffer.py
+++ b/Lib/test/test_buffer.py
@@ -16,7 +16,6 @@
from test import support
from itertools import permutations, product
from random import randrange, sample, choice
-from sysconfig import get_config_var
import warnings
import sys, array, io
from decimal import Decimal
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index 65c00d7..1cedd3a 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -300,6 +300,20 @@
self.assertRaises(ValueError, self.type2test.fromhex, '\x00')
self.assertRaises(ValueError, self.type2test.fromhex, '12 \x00 34')
+ for data, pos in (
+ # invalid first hexadecimal character
+ ('12 x4 56', 3),
+ # invalid second hexadecimal character
+ ('12 3x 56', 4),
+ # two invalid hexadecimal characters
+ ('12 xy 56', 3),
+ # test non-ASCII string
+ ('12 3\xff 56', 4),
+ ):
+ with self.assertRaises(ValueError) as cm:
+ self.type2test.fromhex(data)
+ self.assertIn('at position %s' % pos, str(cm.exception))
+
def test_hex(self):
self.assertRaises(TypeError, self.type2test.hex)
self.assertRaises(TypeError, self.type2test.hex, 1)
@@ -722,26 +736,107 @@
# Test PyBytes_FromFormat()
def test_from_format(self):
- test.support.import_module('ctypes')
- from ctypes import pythonapi, py_object, c_int, c_char_p
+ ctypes = test.support.import_module('ctypes')
+ _testcapi = test.support.import_module('_testcapi')
+ from ctypes import pythonapi, py_object
+ from ctypes import (
+ c_int, c_uint,
+ c_long, c_ulong,
+ c_size_t, c_ssize_t,
+ c_char_p)
+
PyBytes_FromFormat = pythonapi.PyBytes_FromFormat
PyBytes_FromFormat.restype = py_object
+ # basic tests
self.assertEqual(PyBytes_FromFormat(b'format'),
b'format')
+ self.assertEqual(PyBytes_FromFormat(b'Hello %s !', b'world'),
+ b'Hello world !')
+ # test formatters
+ self.assertEqual(PyBytes_FromFormat(b'c=%c', c_int(0)),
+ b'c=\0')
+ self.assertEqual(PyBytes_FromFormat(b'c=%c', c_int(ord('@'))),
+ b'c=@')
+ self.assertEqual(PyBytes_FromFormat(b'c=%c', c_int(255)),
+ b'c=\xff')
+ self.assertEqual(PyBytes_FromFormat(b'd=%d ld=%ld zd=%zd',
+ c_int(1), c_long(2),
+ c_size_t(3)),
+ b'd=1 ld=2 zd=3')
+ self.assertEqual(PyBytes_FromFormat(b'd=%d ld=%ld zd=%zd',
+ c_int(-1), c_long(-2),
+ c_size_t(-3)),
+ b'd=-1 ld=-2 zd=-3')
+ self.assertEqual(PyBytes_FromFormat(b'u=%u lu=%lu zu=%zu',
+ c_uint(123), c_ulong(456),
+ c_size_t(789)),
+ b'u=123 lu=456 zu=789')
+ self.assertEqual(PyBytes_FromFormat(b'i=%i', c_int(123)),
+ b'i=123')
+ self.assertEqual(PyBytes_FromFormat(b'i=%i', c_int(-123)),
+ b'i=-123')
+ self.assertEqual(PyBytes_FromFormat(b'x=%x', c_int(0xabc)),
+ b'x=abc')
+
+ sizeof_ptr = ctypes.sizeof(c_char_p)
+
+ if os.name == 'nt':
+ # Windows (MSCRT)
+ ptr_format = '0x%0{}X'.format(2 * sizeof_ptr)
+ def ptr_formatter(ptr):
+ return (ptr_format % ptr)
+ else:
+ # UNIX (glibc)
+ def ptr_formatter(ptr):
+ return '%#x' % ptr
+
+ ptr = 0xabcdef
+ self.assertEqual(PyBytes_FromFormat(b'ptr=%p', c_char_p(ptr)),
+ ('ptr=' + ptr_formatter(ptr)).encode('ascii'))
+ self.assertEqual(PyBytes_FromFormat(b's=%s', c_char_p(b'cstr')),
+ b's=cstr')
+
+ # test minimum and maximum integer values
+ size_max = c_size_t(-1).value
+ for formatstr, ctypes_type, value, py_formatter in (
+ (b'%d', c_int, _testcapi.INT_MIN, str),
+ (b'%d', c_int, _testcapi.INT_MAX, str),
+ (b'%ld', c_long, _testcapi.LONG_MIN, str),
+ (b'%ld', c_long, _testcapi.LONG_MAX, str),
+ (b'%lu', c_ulong, _testcapi.ULONG_MAX, str),
+ (b'%zd', c_ssize_t, _testcapi.PY_SSIZE_T_MIN, str),
+ (b'%zd', c_ssize_t, _testcapi.PY_SSIZE_T_MAX, str),
+ (b'%zu', c_size_t, size_max, str),
+ (b'%p', c_char_p, size_max, ptr_formatter),
+ ):
+ self.assertEqual(PyBytes_FromFormat(formatstr, ctypes_type(value)),
+ py_formatter(value).encode('ascii')),
+
+ # width and precision (width is currently ignored)
+ self.assertEqual(PyBytes_FromFormat(b'%5s', b'a'),
+ b'a')
+ self.assertEqual(PyBytes_FromFormat(b'%.3s', b'abcdef'),
+ b'abc')
+
+ # '%%' formatter
+ self.assertEqual(PyBytes_FromFormat(b'%%'),
+ b'%')
+ self.assertEqual(PyBytes_FromFormat(b'[%%]'),
+ b'[%]')
+ self.assertEqual(PyBytes_FromFormat(b'%%%c', c_int(ord('_'))),
+ b'%_')
+ self.assertEqual(PyBytes_FromFormat(b'%%s'),
+ b'%s')
+
+ # Invalid formats and partial formatting
self.assertEqual(PyBytes_FromFormat(b'%'), b'%')
- self.assertEqual(PyBytes_FromFormat(b'%%'), b'%')
- self.assertEqual(PyBytes_FromFormat(b'%%s'), b'%s')
- self.assertEqual(PyBytes_FromFormat(b'[%%]'), b'[%]')
- self.assertEqual(PyBytes_FromFormat(b'%%%c', c_int(ord('_'))), b'%_')
+ self.assertEqual(PyBytes_FromFormat(b'x=%i y=%', c_int(2), c_int(3)),
+ b'x=2 y=%')
- self.assertEqual(PyBytes_FromFormat(b'c:%c', c_int(255)),
- b'c:\xff')
- self.assertEqual(PyBytes_FromFormat(b's:%s', c_char_p(b'cstr')),
- b's:cstr')
-
- # Issue #19969
+ # Issue #19969: %c must raise OverflowError for values
+ # not in the range [0; 255]
self.assertRaises(OverflowError,
PyBytes_FromFormat, b'%c', c_int(-1))
self.assertRaises(OverflowError,
diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py
index 80ed632..6dad058 100644
--- a/Lib/test/test_calendar.py
+++ b/Lib/test/test_calendar.py
@@ -702,19 +702,19 @@
def assertFailure(self, *args):
rc, stdout, stderr = assert_python_failure('-m', 'calendar', *args)
- self.assertIn(b'Usage:', stderr)
+ self.assertIn(b'usage:', stderr)
self.assertEqual(rc, 2)
def test_help(self):
stdout = self.run_ok('-h')
- self.assertIn(b'Usage:', stdout)
+ self.assertIn(b'usage:', stdout)
self.assertIn(b'calendar.py', stdout)
self.assertIn(b'--help', stdout)
def test_illegal_arguments(self):
self.assertFailure('-z')
- #self.assertFailure('spam')
- #self.assertFailure('2004', 'spam')
+ self.assertFailure('spam')
+ self.assertFailure('2004', 'spam')
self.assertFailure('-t', 'html', '2004', '1')
def test_output_current_year(self):
@@ -815,5 +815,14 @@
b'href="custom.css" />', stdout)
+class MiscTestCase(unittest.TestCase):
+ def test__all__(self):
+ blacklist = {'mdays', 'January', 'February', 'EPOCH',
+ 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY',
+ 'SATURDAY', 'SUNDAY', 'different_locale', 'c',
+ 'prweek', 'week', 'format', 'formatstring', 'main'}
+ support.check__all__(self, calendar, blacklist=blacklist)
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py
index 1eadd22..6852381 100644
--- a/Lib/test/test_capi.py
+++ b/Lib/test/test_capi.py
@@ -4,8 +4,10 @@
import os
import pickle
import random
+import re
import subprocess
import sys
+import sysconfig
import textwrap
import time
import unittest
@@ -442,6 +444,7 @@
self.maxDiff = None
self.assertEqual(out.strip(), expected_output)
+
class SkipitemTest(unittest.TestCase):
def test_skipitem(self):
@@ -491,10 +494,10 @@
_testcapi.parse_tuple_and_keywords(tuple_1, dict_b,
format.encode("ascii"), keywords)
when_not_skipped = False
- except TypeError as e:
+ except SystemError as e:
s = "argument 1 (impossible<bad format char>)"
when_not_skipped = (str(e) == s)
- except RuntimeError as e:
+ except TypeError:
when_not_skipped = False
# test the format unit when skipped
@@ -503,7 +506,7 @@
_testcapi.parse_tuple_and_keywords(empty_tuple, dict_b,
optional_format.encode("ascii"), keywords)
when_skipped = False
- except RuntimeError as e:
+ except SystemError as e:
s = "impossible<bad format char>: '{}'".format(format)
when_skipped = (str(e) == s)
@@ -524,6 +527,32 @@
self.assertRaises(ValueError, _testcapi.parse_tuple_and_keywords,
(), {}, b'', [42])
+ def test_positional_only(self):
+ parse = _testcapi.parse_tuple_and_keywords
+
+ parse((1, 2, 3), {}, b'OOO', ['', '', 'a'])
+ parse((1, 2), {'a': 3}, b'OOO', ['', '', 'a'])
+ with self.assertRaisesRegex(TypeError,
+ 'Function takes at least 2 positional arguments \(1 given\)'):
+ parse((1,), {'a': 3}, b'OOO', ['', '', 'a'])
+ parse((1,), {}, b'O|OO', ['', '', 'a'])
+ with self.assertRaisesRegex(TypeError,
+ 'Function takes at least 1 positional arguments \(0 given\)'):
+ parse((), {}, b'O|OO', ['', '', 'a'])
+ parse((1, 2), {'a': 3}, b'OO$O', ['', '', 'a'])
+ with self.assertRaisesRegex(TypeError,
+ 'Function takes exactly 2 positional arguments \(1 given\)'):
+ parse((1,), {'a': 3}, b'OO$O', ['', '', 'a'])
+ parse((1,), {}, b'O|O$O', ['', '', 'a'])
+ with self.assertRaisesRegex(TypeError,
+ 'Function takes at least 1 positional arguments \(0 given\)'):
+ parse((), {}, b'O|O$O', ['', '', 'a'])
+ with self.assertRaisesRegex(SystemError, 'Empty parameter name after \$'):
+ parse((1,), {}, b'O|$OO', ['', '', 'a'])
+ with self.assertRaisesRegex(SystemError, 'Empty keyword'):
+ parse((1,), {}, b'O|OO', ['', 'a', ''])
+
+
@unittest.skipUnless(threading, 'Threading required for this test.')
class TestThreadState(unittest.TestCase):
@@ -548,6 +577,7 @@
t.start()
t.join()
+
class Test_testcapi(unittest.TestCase):
def test__testcapi(self):
for name in dir(_testcapi):
@@ -556,5 +586,84 @@
test = getattr(_testcapi, name)
test()
+
+class PyMemDebugTests(unittest.TestCase):
+ PYTHONMALLOC = 'debug'
+ # '0x04c06e0' or '04C06E0'
+ PTR_REGEX = r'(?:0x)?[0-9a-fA-F]+'
+
+ def check(self, code):
+ with support.SuppressCrashReport():
+ out = assert_python_failure('-c', code,
+ PYTHONMALLOC=self.PYTHONMALLOC)
+ stderr = out.err
+ return stderr.decode('ascii', 'replace')
+
+ def test_buffer_overflow(self):
+ out = self.check('import _testcapi; _testcapi.pymem_buffer_overflow()')
+ regex = (r"Debug memory block at address p={ptr}: API 'm'\n"
+ r" 16 bytes originally requested\n"
+ r" The [0-9] pad bytes at p-[0-9] are FORBIDDENBYTE, as expected.\n"
+ r" The [0-9] pad bytes at tail={ptr} are not all FORBIDDENBYTE \(0x[0-9a-f]{{2}}\):\n"
+ r" at tail\+0: 0x78 \*\*\* OUCH\n"
+ r" at tail\+1: 0xfb\n"
+ r" at tail\+2: 0xfb\n"
+ r" .*\n"
+ r" The block was made by call #[0-9]+ to debug malloc/realloc.\n"
+ r" Data at p: cb cb cb .*\n"
+ r"\n"
+ r"Fatal Python error: bad trailing pad byte")
+ regex = regex.format(ptr=self.PTR_REGEX)
+ regex = re.compile(regex, flags=re.DOTALL)
+ self.assertRegex(out, regex)
+
+ def test_api_misuse(self):
+ out = self.check('import _testcapi; _testcapi.pymem_api_misuse()')
+ regex = (r"Debug memory block at address p={ptr}: API 'm'\n"
+ r" 16 bytes originally requested\n"
+ r" The [0-9] pad bytes at p-[0-9] are FORBIDDENBYTE, as expected.\n"
+ r" The [0-9] pad bytes at tail={ptr} are FORBIDDENBYTE, as expected.\n"
+ r" The block was made by call #[0-9]+ to debug malloc/realloc.\n"
+ r" Data at p: cb cb cb .*\n"
+ r"\n"
+ r"Fatal Python error: bad ID: Allocated using API 'm', verified using API 'r'\n")
+ regex = regex.format(ptr=self.PTR_REGEX)
+ self.assertRegex(out, regex)
+
+ def check_malloc_without_gil(self, code):
+ out = self.check(code)
+ expected = ('Fatal Python error: Python memory allocator called '
+ 'without holding the GIL')
+ self.assertIn(expected, out)
+
+ def test_pymem_malloc_without_gil(self):
+ # Debug hooks must raise an error if PyMem_Malloc() is called
+ # without holding the GIL
+ code = 'import _testcapi; _testcapi.pymem_malloc_without_gil()'
+ self.check_malloc_without_gil(code)
+
+ def test_pyobject_malloc_without_gil(self):
+ # Debug hooks must raise an error if PyObject_Malloc() is called
+ # without holding the GIL
+ code = 'import _testcapi; _testcapi.pyobject_malloc_without_gil()'
+ self.check_malloc_without_gil(code)
+
+
+class PyMemMallocDebugTests(PyMemDebugTests):
+ PYTHONMALLOC = 'malloc_debug'
+
+
+@unittest.skipUnless(sysconfig.get_config_var('WITH_PYMALLOC') == 1,
+ 'need pymalloc')
+class PyMemPymallocDebugTests(PyMemDebugTests):
+ PYTHONMALLOC = 'pymalloc_debug'
+
+
+@unittest.skipUnless(Py_DEBUG, 'need Py_DEBUG')
+class PyMemDefaultTests(PyMemDebugTests):
+ # test default allocator of Python compiled in debug mode
+ PYTHONMALLOC = ''
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py
index ab9f6ab..1647849 100644
--- a/Lib/test/test_cgi.py
+++ b/Lib/test/test_cgi.py
@@ -7,6 +7,7 @@
import warnings
from collections import namedtuple
from io import StringIO, BytesIO
+from test import support
class HackedSysModule:
# The regression test will have real values in sys.argv, which
@@ -473,6 +474,11 @@
cgi.parse_header('form-data; name="files"; filename="fo\\"o;bar"'),
("form-data", {"name": "files", "filename": 'fo"o;bar'}))
+ def test_all(self):
+ blacklist = {"logfile", "logfp", "initlog", "dolog", "nolog",
+ "closelog", "log", "maxlen", "valid_boundary"}
+ support.check__all__(self, cgi, blacklist=blacklist)
+
BOUNDARY = "---------------------------721837373350705526688164684"
diff --git a/Lib/test/test_charmapcodec.py b/Lib/test/test_charmapcodec.py
index 4064aef..0d4594d 100644
--- a/Lib/test/test_charmapcodec.py
+++ b/Lib/test/test_charmapcodec.py
@@ -9,7 +9,7 @@
"""#"
-import test.support, unittest
+import unittest
import codecs
diff --git a/Lib/test/test_class.py b/Lib/test/test_class.py
index 4d554a3..e02a3cb 100644
--- a/Lib/test/test_class.py
+++ b/Lib/test/test_class.py
@@ -568,5 +568,15 @@
a = A(hash(A.f)^(-1))
hash(a.f)
+ def test_class_repr(self):
+ # We should get the address of the object
+ class A:
+ pass
+
+ result = repr(A)
+ self.assertRegex(result,
+ "<class 'test.test_class.ClassTests.test_class_repr.<locals>.A'"
+ " at 0x.+>")
+
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
index dce418b..8faa8e1 100644
--- a/Lib/test/test_cmd_line.py
+++ b/Lib/test/test_cmd_line.py
@@ -348,8 +348,9 @@
test.support.SuppressCrashReport().__enter__()
sys.stdout.write('x')
os.close(sys.stdout.fileno())"""
- rc, out, err = assert_python_ok('-c', code)
+ rc, out, err = assert_python_failure('-c', code)
self.assertEqual(b'', out)
+ self.assertEqual(120, rc)
self.assertRegex(err.decode('ascii', 'ignore'),
'Exception ignored in.*\nOSError: .*')
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py
index b2be9b1..e7c6351 100644
--- a/Lib/test/test_cmd_line_script.py
+++ b/Lib/test/test_cmd_line_script.py
@@ -127,7 +127,10 @@
print(printed_package)
print(printed_argv0)
print(printed_cwd)
- self.assertIn(printed_loader.encode('utf-8'), data)
+ expected = printed_loader.encode('utf-8')
+ idx = expected.find(b"at 0x")
+ expected = expected[:idx]
+ self.assertIn(expected, data)
self.assertIn(printed_file.encode('utf-8'), data)
self.assertIn(printed_package.encode('utf-8'), data)
self.assertIn(printed_argv0.encode('utf-8'), data)
@@ -138,9 +141,8 @@
expected_argv0, expected_path0,
expected_package, expected_loader,
*cmd_line_switches):
- if not __debug__:
- cmd_line_switches += ('-' + 'O' * sys.flags.optimize,)
- run_args = cmd_line_switches + (script_name,) + tuple(example_args)
+ run_args = [*support.optim_args_from_interpreter_flags(),
+ *cmd_line_switches, script_name, *example_args]
rc, out, err = assert_python_ok(*run_args, __isolated=False)
self._check_output(script_name, rc, out + err, expected_file,
expected_argv0, expected_path0,
@@ -159,6 +161,8 @@
def test_dash_c_loader(self):
rc, out, err = assert_python_ok("-c", "print(__loader__)")
expected = repr(importlib.machinery.BuiltinImporter).encode("utf-8")
+ idx = expected.find(b"at 0x")
+ expected = expected[:idx]
self.assertIn(expected, out)
def test_stdin_loader(self):
@@ -172,6 +176,8 @@
finally:
out = kill_python(p)
expected = repr(importlib.machinery.BuiltinImporter).encode("utf-8")
+ idx = expected.find(b"at 0x")
+ expected = expected[:idx]
self.assertIn(expected, out)
@contextlib.contextmanager
diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py
index ee1e28a..c8cdacf 100644
--- a/Lib/test/test_codeccallbacks.py
+++ b/Lib/test/test_codeccallbacks.py
@@ -4,7 +4,6 @@
import test.support
import unicodedata
import unittest
-import warnings
class PosReturn:
# this can be used for configurable callbacks
diff --git a/Lib/test/test_codecencodings_cn.py b/Lib/test/test_codecencodings_cn.py
index d0e3a15..3bdf7d0 100644
--- a/Lib/test/test_codecencodings_cn.py
+++ b/Lib/test/test_codecencodings_cn.py
@@ -3,7 +3,6 @@
# Codec encoding tests for PRC encodings.
#
-from test import support
from test import multibytecodec_support
import unittest
diff --git a/Lib/test/test_codecencodings_hk.py b/Lib/test/test_codecencodings_hk.py
index bb9be11..c5e2f99 100644
--- a/Lib/test/test_codecencodings_hk.py
+++ b/Lib/test/test_codecencodings_hk.py
@@ -3,7 +3,6 @@
# Codec encoding tests for HongKong encodings.
#
-from test import support
from test import multibytecodec_support
import unittest
diff --git a/Lib/test/test_codecencodings_iso2022.py b/Lib/test/test_codecencodings_iso2022.py
index 8a3ca70..00ea1c3 100644
--- a/Lib/test/test_codecencodings_iso2022.py
+++ b/Lib/test/test_codecencodings_iso2022.py
@@ -1,6 +1,5 @@
# Codec encoding tests for ISO 2022 encodings.
-from test import support
from test import multibytecodec_support
import unittest
diff --git a/Lib/test/test_codecencodings_jp.py b/Lib/test/test_codecencodings_jp.py
index 44b63a0..94378d1 100644
--- a/Lib/test/test_codecencodings_jp.py
+++ b/Lib/test/test_codecencodings_jp.py
@@ -3,7 +3,6 @@
# Codec encoding tests for Japanese encodings.
#
-from test import support
from test import multibytecodec_support
import unittest
diff --git a/Lib/test/test_codecencodings_kr.py b/Lib/test/test_codecencodings_kr.py
index b6a74fb..863d16b 100644
--- a/Lib/test/test_codecencodings_kr.py
+++ b/Lib/test/test_codecencodings_kr.py
@@ -3,7 +3,6 @@
# Codec encoding tests for ROK encodings.
#
-from test import support
from test import multibytecodec_support
import unittest
diff --git a/Lib/test/test_codecencodings_tw.py b/Lib/test/test_codecencodings_tw.py
index 9174296..bb1d133 100644
--- a/Lib/test/test_codecencodings_tw.py
+++ b/Lib/test/test_codecencodings_tw.py
@@ -3,7 +3,6 @@
# Codec encoding tests for ROC encodings.
#
-from test import support
from test import multibytecodec_support
import unittest
diff --git a/Lib/test/test_codecmaps_cn.py b/Lib/test/test_codecmaps_cn.py
index f1bd384..89e51c6 100644
--- a/Lib/test/test_codecmaps_cn.py
+++ b/Lib/test/test_codecmaps_cn.py
@@ -3,7 +3,6 @@
# Codec mapping tests for PRC encodings
#
-from test import support
from test import multibytecodec_support
import unittest
diff --git a/Lib/test/test_codecmaps_hk.py b/Lib/test/test_codecmaps_hk.py
index 4c0c415..7a48d24 100644
--- a/Lib/test/test_codecmaps_hk.py
+++ b/Lib/test/test_codecmaps_hk.py
@@ -3,7 +3,6 @@
# Codec mapping tests for HongKong encodings
#
-from test import support
from test import multibytecodec_support
import unittest
diff --git a/Lib/test/test_codecmaps_jp.py b/Lib/test/test_codecmaps_jp.py
index 5773823..fdfec80 100644
--- a/Lib/test/test_codecmaps_jp.py
+++ b/Lib/test/test_codecmaps_jp.py
@@ -3,7 +3,6 @@
# Codec mapping tests for Japanese encodings
#
-from test import support
from test import multibytecodec_support
import unittest
diff --git a/Lib/test/test_codecmaps_kr.py b/Lib/test/test_codecmaps_kr.py
index 6cb41c8..471cd74 100644
--- a/Lib/test/test_codecmaps_kr.py
+++ b/Lib/test/test_codecmaps_kr.py
@@ -3,7 +3,6 @@
# Codec mapping tests for ROK encodings
#
-from test import support
from test import multibytecodec_support
import unittest
diff --git a/Lib/test/test_codecmaps_tw.py b/Lib/test/test_codecmaps_tw.py
index 2ea44b5..145a97d 100644
--- a/Lib/test/test_codecmaps_tw.py
+++ b/Lib/test/test_codecmaps_tw.py
@@ -3,7 +3,6 @@
# Codec mapping tests for ROC encodings
#
-from test import support
from test import multibytecodec_support
import unittest
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 0479542..d875340 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -4,7 +4,6 @@
import locale
import sys
import unittest
-import warnings
import encodings
from test import support
@@ -27,6 +26,7 @@
self.assertEqual(coder(input), (expect, len(input)))
return check
+
class Queue(object):
"""
queue: write bytes at one end, read bytes from the other end
@@ -47,6 +47,7 @@
self._buffer = self._buffer[size:]
return s
+
class MixInCheckStateHandling:
def check_state_handling_decode(self, encoding, u, s):
for i in range(len(s)+1):
@@ -80,6 +81,7 @@
part2 = d.encode(u[i:], True)
self.assertEqual(s, part1+part2)
+
class ReadTest(MixInCheckStateHandling):
def check_partial(self, input, partialresults):
# get a StreamReader for the encoding and feed the bytestring version
@@ -358,6 +360,12 @@
self.assertEqual("[\uDC80]".encode(self.encoding, "replace"),
"[?]".encode(self.encoding))
+ # sequential surrogate characters
+ self.assertEqual("[\uD800\uDC80]".encode(self.encoding, "ignore"),
+ "[]".encode(self.encoding))
+ self.assertEqual("[\uD800\uDC80]".encode(self.encoding, "replace"),
+ "[??]".encode(self.encoding))
+
bom = "".encode(self.encoding)
for before, after in [("\U00010fff", "A"), ("[", "]"),
("A", "\U00010fff")]:
@@ -383,6 +391,7 @@
self.assertEqual(test_sequence.decode(self.encoding, "backslashreplace"),
before + backslashreplace + after)
+
class UTF32Test(ReadTest, unittest.TestCase):
encoding = "utf-32"
if sys.byteorder == 'little':
@@ -478,6 +487,7 @@
self.assertEqual('\U00010000' * 1024,
codecs.utf_32_decode(encoded_be)[0])
+
class UTF32LETest(ReadTest, unittest.TestCase):
encoding = "utf-32-le"
ill_formed_sequence = b"\x80\xdc\x00\x00"
@@ -523,6 +533,7 @@
self.assertEqual('\U00010000' * 1024,
codecs.utf_32_le_decode(encoded)[0])
+
class UTF32BETest(ReadTest, unittest.TestCase):
encoding = "utf-32-be"
ill_formed_sequence = b"\x00\x00\xdc\x80"
@@ -747,6 +758,7 @@
encoding = "utf-8"
ill_formed_sequence = b"\xed\xb2\x80"
ill_formed_sequence_replace = "\ufffd" * 3
+ BOM = b''
def test_partial(self):
self.check_partial(
@@ -775,27 +787,49 @@
self.check_state_handling_decode(self.encoding,
u, u.encode(self.encoding))
+ def test_decode_error(self):
+ for data, error_handler, expected in (
+ (b'[\x80\xff]', 'ignore', '[]'),
+ (b'[\x80\xff]', 'replace', '[\ufffd\ufffd]'),
+ (b'[\x80\xff]', 'surrogateescape', '[\udc80\udcff]'),
+ (b'[\x80\xff]', 'backslashreplace', '[\\x80\\xff]'),
+ ):
+ with self.subTest(data=data, error_handler=error_handler,
+ expected=expected):
+ self.assertEqual(data.decode(self.encoding, error_handler),
+ expected)
+
def test_lone_surrogates(self):
super().test_lone_surrogates()
# not sure if this is making sense for
# UTF-16 and UTF-32
- self.assertEqual("[\uDC80]".encode('utf-8', "surrogateescape"),
- b'[\x80]')
+ self.assertEqual("[\uDC80]".encode(self.encoding, "surrogateescape"),
+ self.BOM + b'[\x80]')
+
+ with self.assertRaises(UnicodeEncodeError) as cm:
+ "[\uDC80\uD800\uDFFF]".encode(self.encoding, "surrogateescape")
+ exc = cm.exception
+ self.assertEqual(exc.object[exc.start:exc.end], '\uD800\uDFFF')
def test_surrogatepass_handler(self):
- self.assertEqual("abc\ud800def".encode("utf-8", "surrogatepass"),
- b"abc\xed\xa0\x80def")
- self.assertEqual(b"abc\xed\xa0\x80def".decode("utf-8", "surrogatepass"),
+ self.assertEqual("abc\ud800def".encode(self.encoding, "surrogatepass"),
+ self.BOM + b"abc\xed\xa0\x80def")
+ self.assertEqual("\U00010fff\uD800".encode(self.encoding, "surrogatepass"),
+ self.BOM + b"\xf0\x90\xbf\xbf\xed\xa0\x80")
+ self.assertEqual("[\uD800\uDC80]".encode(self.encoding, "surrogatepass"),
+ self.BOM + b'[\xed\xa0\x80\xed\xb2\x80]')
+
+ self.assertEqual(b"abc\xed\xa0\x80def".decode(self.encoding, "surrogatepass"),
"abc\ud800def")
- self.assertEqual("\U00010fff\uD800".encode("utf-8", "surrogatepass"),
- b"\xf0\x90\xbf\xbf\xed\xa0\x80")
- self.assertEqual(b"\xf0\x90\xbf\xbf\xed\xa0\x80".decode("utf-8", "surrogatepass"),
+ self.assertEqual(b"\xf0\x90\xbf\xbf\xed\xa0\x80".decode(self.encoding, "surrogatepass"),
"\U00010fff\uD800")
+
self.assertTrue(codecs.lookup_error("surrogatepass"))
with self.assertRaises(UnicodeDecodeError):
- b"abc\xed\xa0".decode("utf-8", "surrogatepass")
+ b"abc\xed\xa0".decode(self.encoding, "surrogatepass")
with self.assertRaises(UnicodeDecodeError):
- b"abc\xed\xa0z".decode("utf-8", "surrogatepass")
+ b"abc\xed\xa0z".decode(self.encoding, "surrogatepass")
+
@unittest.skipUnless(sys.platform == 'win32',
'cp65001 is a Windows-only codec')
@@ -1059,6 +1093,7 @@
class UTF8SigTest(UTF8Test, unittest.TestCase):
encoding = "utf-8-sig"
+ BOM = codecs.BOM_UTF8
def test_partial(self):
self.check_partial(
@@ -1194,6 +1229,7 @@
self.assertEqual(decode(br"[\x0]\x0", "ignore"), (b"[]", 8))
self.assertEqual(decode(br"[\x0]\x0", "replace"), (b"[?]?", 8))
+
class RecodingTest(unittest.TestCase):
def test_recoding(self):
f = io.BytesIO()
@@ -1313,6 +1349,7 @@
if len(i)!=2:
print(repr(i))
+
class PunycodeTest(unittest.TestCase):
def test_encode(self):
for uni, puny in punycode_testcases:
@@ -1332,6 +1369,7 @@
puny = puny.decode("ascii").encode("ascii")
self.assertEqual(uni, puny.decode("punycode"))
+
class UnicodeInternalTest(unittest.TestCase):
@unittest.skipUnless(SIZEOF_WCHAR_T == 4, 'specific to 32-bit wchar_t')
def test_bug1251300(self):
@@ -1586,6 +1624,7 @@
except Exception as e:
raise support.TestFailed("Test 3.%d: %s" % (pos+1, str(e)))
+
class IDNACodecTest(unittest.TestCase):
def test_builtin_decode(self):
self.assertEqual(str(b"python.org", "idna"), "python.org")
@@ -1672,6 +1711,7 @@
self.assertRaises(Exception,
b"python.org".decode, "idna", errors)
+
class CodecsModuleTest(unittest.TestCase):
def test_decode(self):
@@ -1780,6 +1820,7 @@
self.assertRaises(UnicodeError,
codecs.decode, b'abc', 'undefined', errors)
+
class StreamReaderTest(unittest.TestCase):
def setUp(self):
@@ -1790,6 +1831,7 @@
f = self.reader(self.stream)
self.assertEqual(f.readlines(), ['\ud55c\n', '\uae00'])
+
class EncodedFileTest(unittest.TestCase):
def test_basic(self):
@@ -1920,6 +1962,7 @@
"unicode_internal"
]
+
class BasicUnicodeTest(unittest.TestCase, MixInCheckStateHandling):
def test_basics(self):
s = "abc123" # all codecs should be able to encode these
@@ -2082,6 +2125,7 @@
self.check_state_handling_decode(encoding, u, u.encode(encoding))
self.check_state_handling_encode(encoding, u, u.encode(encoding))
+
class CharmapTest(unittest.TestCase):
def test_decode_with_string_map(self):
self.assertEqual(
@@ -2332,6 +2376,7 @@
info.streamwriter, 'strict') as srw:
self.assertEqual(srw.read(), "\xfc")
+
class TypesTest(unittest.TestCase):
def test_decode_unicode(self):
# Most decoders don't accept unicode input
@@ -2622,6 +2667,7 @@
bytes_transform_encodings.append("bz2_codec")
transform_aliases["bz2_codec"] = ["bz2"]
+
class TransformCodecTest(unittest.TestCase):
def test_basics(self):
@@ -3099,5 +3145,81 @@
self.assertEqual(decoded, ('abc', 3))
+class ASCIITest(unittest.TestCase):
+ def test_encode(self):
+ self.assertEqual('abc123'.encode('ascii'), b'abc123')
+
+ def test_encode_error(self):
+ for data, error_handler, expected in (
+ ('[\x80\xff\u20ac]', 'ignore', b'[]'),
+ ('[\x80\xff\u20ac]', 'replace', b'[???]'),
+ ('[\x80\xff\u20ac]', 'xmlcharrefreplace', b'[€ÿ€]'),
+ ('[\x80\xff\u20ac\U000abcde]', 'backslashreplace',
+ b'[\\x80\\xff\\u20ac\\U000abcde]'),
+ ('[\udc80\udcff]', 'surrogateescape', b'[\x80\xff]'),
+ ):
+ with self.subTest(data=data, error_handler=error_handler,
+ expected=expected):
+ self.assertEqual(data.encode('ascii', error_handler),
+ expected)
+
+ def test_encode_surrogateescape_error(self):
+ with self.assertRaises(UnicodeEncodeError):
+ # the first character can be decoded, but not the second
+ '\udc80\xff'.encode('ascii', 'surrogateescape')
+
+ def test_decode(self):
+ self.assertEqual(b'abc'.decode('ascii'), 'abc')
+
+ def test_decode_error(self):
+ for data, error_handler, expected in (
+ (b'[\x80\xff]', 'ignore', '[]'),
+ (b'[\x80\xff]', 'replace', '[\ufffd\ufffd]'),
+ (b'[\x80\xff]', 'surrogateescape', '[\udc80\udcff]'),
+ (b'[\x80\xff]', 'backslashreplace', '[\\x80\\xff]'),
+ ):
+ with self.subTest(data=data, error_handler=error_handler,
+ expected=expected):
+ self.assertEqual(data.decode('ascii', error_handler),
+ expected)
+
+
+class Latin1Test(unittest.TestCase):
+ def test_encode(self):
+ for data, expected in (
+ ('abc', b'abc'),
+ ('\x80\xe9\xff', b'\x80\xe9\xff'),
+ ):
+ with self.subTest(data=data, expected=expected):
+ self.assertEqual(data.encode('latin1'), expected)
+
+ def test_encode_errors(self):
+ for data, error_handler, expected in (
+ ('[\u20ac\udc80]', 'ignore', b'[]'),
+ ('[\u20ac\udc80]', 'replace', b'[??]'),
+ ('[\u20ac\U000abcde]', 'backslashreplace',
+ b'[\\u20ac\\U000abcde]'),
+ ('[\u20ac\udc80]', 'xmlcharrefreplace', b'[€�]'),
+ ('[\udc80\udcff]', 'surrogateescape', b'[\x80\xff]'),
+ ):
+ with self.subTest(data=data, error_handler=error_handler,
+ expected=expected):
+ self.assertEqual(data.encode('latin1', error_handler),
+ expected)
+
+ def test_encode_surrogateescape_error(self):
+ with self.assertRaises(UnicodeEncodeError):
+ # the first character can be decoded, but not the second
+ '\udc80\u20ac'.encode('latin1', 'surrogateescape')
+
+ def test_decode(self):
+ for data, expected in (
+ (b'abc', 'abc'),
+ (b'[\x80\xff]', '[\x80\xff]'),
+ ):
+ with self.subTest(data=data, expected=expected):
+ self.assertEqual(data.decode('latin1'), expected)
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_codeop.py b/Lib/test/test_codeop.py
index 509bf5d..98da26f 100644
--- a/Lib/test/test_codeop.py
+++ b/Lib/test/test_codeop.py
@@ -282,7 +282,6 @@
ai("if (a == 1 and b = 2): pass")
ai("del 1")
- ai("del ()")
ai("del (1,)")
ai("del [1]")
ai("del '1'")
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index 4c32e09..3824a87 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -20,10 +20,10 @@
from collections import ChainMap
from collections import deque
from collections.abc import Awaitable, Coroutine, AsyncIterator, AsyncIterable
-from collections.abc import Hashable, Iterable, Iterator, Generator
+from collections.abc import Hashable, Iterable, Iterator, Generator, Reversible
from collections.abc import Sized, Container, Callable
from collections.abc import Set, MutableSet
-from collections.abc import Mapping, MutableMapping, KeysView, ItemsView
+from collections.abc import Mapping, MutableMapping, KeysView, ItemsView, ValuesView
from collections.abc import Sequence, MutableSequence
from collections.abc import ByteString
@@ -689,6 +689,31 @@
self.validate_abstract_methods(Iterable, '__iter__')
self.validate_isinstance(Iterable, '__iter__')
+ def test_Reversible(self):
+ # Check some non-reversibles
+ non_samples = [None, 42, 3.14, 1j, dict(), set(), frozenset()]
+ for x in non_samples:
+ self.assertNotIsInstance(x, Reversible)
+ self.assertFalse(issubclass(type(x), Reversible), repr(type(x)))
+ # Check some reversibles
+ samples = [tuple(), list()]
+ for x in samples:
+ self.assertIsInstance(x, Reversible)
+ self.assertTrue(issubclass(type(x), Reversible), repr(type(x)))
+ # Check also Mapping, MutableMapping, and Sequence
+ self.assertTrue(issubclass(Sequence, Reversible), repr(Sequence))
+ self.assertFalse(issubclass(Mapping, Reversible), repr(Mapping))
+ self.assertFalse(issubclass(MutableMapping, Reversible), repr(MutableMapping))
+ # Check direct subclassing
+ class R(Reversible):
+ def __iter__(self):
+ return iter(list())
+ def __reversed__(self):
+ return iter(list())
+ self.assertEqual(list(reversed(R())), [])
+ self.assertFalse(issubclass(float, R))
+ self.validate_abstract_methods(Reversible, '__reversed__', '__iter__')
+
def test_Iterator(self):
non_samples = [None, 42, 3.14, 1j, b"", "", (), [], {}, set()]
for x in non_samples:
@@ -842,14 +867,14 @@
self.validate_isinstance(Callable, '__call__')
def test_direct_subclassing(self):
- for B in Hashable, Iterable, Iterator, Sized, Container, Callable:
+ for B in Hashable, Iterable, Iterator, Reversible, Sized, Container, Callable:
class C(B):
pass
self.assertTrue(issubclass(C, B))
self.assertFalse(issubclass(int, C))
def test_registration(self):
- for B in Hashable, Iterable, Iterator, Sized, Container, Callable:
+ for B in Hashable, Iterable, Iterator, Reversible, Sized, Container, Callable:
class C:
__hash__ = None # Make sure it isn't hashable by default
self.assertFalse(issubclass(C, B), B.__name__)
@@ -1049,6 +1074,26 @@
self.assertFalse(ncs > cs)
self.assertTrue(ncs >= cs)
+ def test_issue26915(self):
+ # Container membership test should check identity first
+ class CustomEqualObject:
+ def __eq__(self, other):
+ return False
+ class CustomSequence(list):
+ def __contains__(self, value):
+ return Sequence.__contains__(self, value)
+
+ nan = float('nan')
+ obj = CustomEqualObject()
+ containers = [
+ CustomSequence([nan, obj]),
+ ItemsView({1: nan, 2: obj}),
+ ValuesView({1: nan, 2: obj})
+ ]
+ for container in containers:
+ for elem in container:
+ self.assertIn(elem, container)
+
def assertSameSet(self, s1, s2):
# coerce both to a real set then check equality
self.assertSetEqual(set(s1), set(s2))
diff --git a/Lib/test/test_compileall.py b/Lib/test/test_compileall.py
index 2ce8a61..9b424a7 100644
--- a/Lib/test/test_compileall.py
+++ b/Lib/test/test_compileall.py
@@ -1,6 +1,7 @@
import sys
import compileall
import importlib.util
+import test.test_importlib.util
import os
import pathlib
import py_compile
@@ -40,6 +41,11 @@
def tearDown(self):
shutil.rmtree(self.directory)
+ def add_bad_source_file(self):
+ self.bad_source_path = os.path.join(self.directory, '_test_bad.py')
+ with open(self.bad_source_path, 'w') as file:
+ file.write('x (\n')
+
def data(self):
with open(self.bc_path, 'rb') as file:
data = file.read(8)
@@ -78,15 +84,43 @@
os.unlink(fn)
except:
pass
- compileall.compile_file(self.source_path, force=False, quiet=True)
+ self.assertTrue(compileall.compile_file(self.source_path,
+ force=False, quiet=True))
self.assertTrue(os.path.isfile(self.bc_path) and
not os.path.isfile(self.bc_path2))
os.unlink(self.bc_path)
- compileall.compile_dir(self.directory, force=False, quiet=True)
+ self.assertTrue(compileall.compile_dir(self.directory, force=False,
+ quiet=True))
self.assertTrue(os.path.isfile(self.bc_path) and
os.path.isfile(self.bc_path2))
os.unlink(self.bc_path)
os.unlink(self.bc_path2)
+ # Test against bad files
+ self.add_bad_source_file()
+ self.assertFalse(compileall.compile_file(self.bad_source_path,
+ force=False, quiet=2))
+ self.assertFalse(compileall.compile_dir(self.directory,
+ force=False, quiet=2))
+
+ def test_compile_path(self):
+ # Exclude Lib/test/ which contains invalid Python files like
+ # Lib/test/badsyntax_pep3120.py
+ testdir = os.path.realpath(os.path.dirname(__file__))
+ if testdir in sys.path:
+ self.addCleanup(setattr, sys, 'path', sys.path)
+
+ sys.path = list(sys.path)
+ try:
+ sys.path.remove(testdir)
+ except ValueError:
+ pass
+
+ self.assertTrue(compileall.compile_path(quiet=2))
+
+ with test.test_importlib.util.import_state(path=[self.directory]):
+ self.add_bad_source_file()
+ self.assertFalse(compileall.compile_path(skip_curdir=False,
+ force=True, quiet=2))
def test_no_pycache_in_non_package(self):
# Bug 8563 reported that __pycache__ directories got created by
@@ -197,10 +231,9 @@
raise unittest.SkipTest('not all entries on sys.path are writable')
def _get_run_args(self, args):
- interp_args = ['-S']
- if sys.flags.optimize:
- interp_args.append({1 : '-O', 2 : '-OO'}[sys.flags.optimize])
- return interp_args + ['-m', 'compileall'] + list(args)
+ return [*support.optim_args_from_interpreter_flags(),
+ '-S', '-m', 'compileall',
+ *args]
def assertRunOK(self, *args, **env_vars):
rc, out, err = script_helper.assert_python_ok(
diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py
index 516403e..c04c804 100644
--- a/Lib/test/test_contextlib.py
+++ b/Lib/test/test_contextlib.py
@@ -12,6 +12,39 @@
threading = None
+class TestAbstractContextManager(unittest.TestCase):
+
+ def test_enter(self):
+ class DefaultEnter(AbstractContextManager):
+ def __exit__(self, *args):
+ super().__exit__(*args)
+
+ manager = DefaultEnter()
+ self.assertIs(manager.__enter__(), manager)
+
+ def test_exit_is_abstract(self):
+ class MissingExit(AbstractContextManager):
+ pass
+
+ with self.assertRaises(TypeError):
+ MissingExit()
+
+ def test_structural_subclassing(self):
+ class ManagerFromScratch:
+ def __enter__(self):
+ return self
+ def __exit__(self, exc_type, exc_value, traceback):
+ return None
+
+ self.assertTrue(issubclass(ManagerFromScratch, AbstractContextManager))
+
+ class DefaultEnter(AbstractContextManager):
+ def __exit__(self, *args):
+ super().__exit__(*args)
+
+ self.assertTrue(issubclass(DefaultEnter, AbstractContextManager))
+
+
class ContextManagerTestCase(unittest.TestCase):
def test_contextmanager_plain(self):
@@ -89,7 +122,7 @@
def woohoo():
yield
try:
- with self.assertWarnsRegex(PendingDeprecationWarning,
+ with self.assertWarnsRegex(DeprecationWarning,
"StopIteration"):
with woohoo():
raise stop_exc
diff --git a/Lib/test/test_copy.py b/Lib/test/test_copy.py
index 0e1f670..45a6920 100644
--- a/Lib/test/test_copy.py
+++ b/Lib/test/test_copy.py
@@ -98,7 +98,7 @@
tests = [None, ..., NotImplemented,
42, 2**100, 3.14, True, False, 1j,
"hello", "hello\u1234", f.__code__,
- b"world", bytes(range(256)), range(10),
+ b"world", bytes(range(256)), range(10), slice(1, 10, 2),
NewStyle, Classic, max, WithMetaclass]
for x in tests:
self.assertIs(copy.copy(x), x)
diff --git a/Lib/test/test_cprofile.py b/Lib/test/test_cprofile.py
index f18983f..53f8917 100644
--- a/Lib/test/test_cprofile.py
+++ b/Lib/test/test_cprofile.py
@@ -6,7 +6,7 @@
# rip off all interesting stuff from test_profile
import cProfile
from test.test_profile import ProfileTest, regenerate_expected_output
-from test.profilee import testfunc
+
class CProfileTest(ProfileTest):
profilerclass = cProfile.Profile
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py
index 77c315e..e97c9f3 100644
--- a/Lib/test/test_csv.py
+++ b/Lib/test/test_csv.py
@@ -2,9 +2,7 @@
# csv package unit tests
import copy
-import io
import sys
-import os
import unittest
from io import StringIO
from tempfile import TemporaryFile
@@ -426,17 +424,16 @@
self.assertRaises(TypeError, csv.reader, [], quoting = -1)
self.assertRaises(TypeError, csv.reader, [], quoting = 100)
- # See issue #22995
- ## def test_copy(self):
- ## for name in csv.list_dialects():
- ## dialect = csv.get_dialect(name)
- ## self.assertRaises(TypeError, copy.copy, dialect)
+ def test_copy(self):
+ for name in csv.list_dialects():
+ dialect = csv.get_dialect(name)
+ self.assertRaises(TypeError, copy.copy, dialect)
- ## def test_pickle(self):
- ## for name in csv.list_dialects():
- ## dialect = csv.get_dialect(name)
- ## for proto in range(pickle.HIGHEST_PROTOCOL + 1):
- ## self.assertRaises(TypeError, pickle.dumps, dialect, proto)
+ def test_pickle(self):
+ for name in csv.list_dialects():
+ dialect = csv.get_dialect(name)
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ self.assertRaises(TypeError, pickle.dumps, dialect, proto)
class TestCsvBase(unittest.TestCase):
def readerAssertEqual(self, input, expected_result):
@@ -1080,7 +1077,6 @@
"François Pinard"]
def test_unicode_read(self):
- import io
with TemporaryFile("w+", newline='', encoding="utf-8") as fileobj:
fileobj.write(",".join(self.names) + "\r\n")
fileobj.seek(0)
@@ -1089,7 +1085,6 @@
def test_unicode_write(self):
- import io
with TemporaryFile("w+", newline='', encoding="utf-8") as fileobj:
writer = csv.writer(fileobj)
writer.writerow(self.names)
@@ -1098,5 +1093,11 @@
self.assertEqual(fileobj.read(), expected)
+class MiscTestCase(unittest.TestCase):
+ def test__all__(self):
+ extra = {'__doc__', '__version__'}
+ support.check__all__(self, csv, ('csv', '_csv'), extra=extra)
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/test/test_dbm.py b/Lib/test/test_dbm.py
index 623d992..f0a428d 100644
--- a/Lib/test/test_dbm.py
+++ b/Lib/test/test_dbm.py
@@ -1,6 +1,5 @@
"""Test script for the dbm.open function based on testdumbdbm.py"""
-import os
import unittest
import glob
import test.support
diff --git a/Lib/test/test_dbm_gnu.py b/Lib/test/test_dbm_gnu.py
index a7808f5..304b332 100644
--- a/Lib/test/test_dbm_gnu.py
+++ b/Lib/test/test_dbm_gnu.py
@@ -2,7 +2,7 @@
gdbm = support.import_module("dbm.gnu") #skip if not supported
import unittest
import os
-from test.support import verbose, TESTFN, unlink
+from test.support import TESTFN, unlink
filename = TESTFN
diff --git a/Lib/test/test_dbm_ndbm.py b/Lib/test/test_dbm_ndbm.py
index 2291561..49f4426 100644
--- a/Lib/test/test_dbm_ndbm.py
+++ b/Lib/test/test_dbm_ndbm.py
@@ -1,8 +1,6 @@
from test import support
support.import_module("dbm.ndbm") #skip if not supported
import unittest
-import os
-import random
import dbm.ndbm
from dbm.ndbm import error
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index cde5d78..64e1cc6 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -2047,6 +2047,39 @@
d = Decimal( (1, (0, 2, 7, 1), 'F') )
self.assertEqual(d.as_tuple(), (1, (0,), 'F'))
+ def test_as_integer_ratio(self):
+ Decimal = self.decimal.Decimal
+
+ # exceptional cases
+ self.assertRaises(OverflowError,
+ Decimal.as_integer_ratio, Decimal('inf'))
+ self.assertRaises(OverflowError,
+ Decimal.as_integer_ratio, Decimal('-inf'))
+ self.assertRaises(ValueError,
+ Decimal.as_integer_ratio, Decimal('-nan'))
+ self.assertRaises(ValueError,
+ Decimal.as_integer_ratio, Decimal('snan123'))
+
+ for exp in range(-4, 2):
+ for coeff in range(1000):
+ for sign in '+', '-':
+ d = Decimal('%s%dE%d' % (sign, coeff, exp))
+ pq = d.as_integer_ratio()
+ p, q = pq
+
+ # check return type
+ self.assertIsInstance(pq, tuple)
+ self.assertIsInstance(p, int)
+ self.assertIsInstance(q, int)
+
+ # check normalization: q should be positive;
+ # p should be relatively prime to q.
+ self.assertGreater(q, 0)
+ self.assertEqual(math.gcd(p, q), 1)
+
+ # check that p/q actually gives the correct value
+ self.assertEqual(Decimal(p) / Decimal(q), d)
+
def test_subclassing(self):
# Different behaviours when subclassing Decimal
Decimal = self.decimal.Decimal
diff --git a/Lib/test/test_defaultdict.py b/Lib/test/test_defaultdict.py
index a90bc2b..5bb4e12 100644
--- a/Lib/test/test_defaultdict.py
+++ b/Lib/test/test_defaultdict.py
@@ -65,7 +65,7 @@
d2 = defaultdict(int)
self.assertEqual(d2.default_factory, int)
d2[12] = 42
- self.assertEqual(repr(d2), "defaultdict(<class 'int'>, {12: 42})")
+ self.assertRegex(repr(d2), r"defaultdict\(<class 'int' at 0x.+>, {12: 42}\)")
def foo(): return 43
d3 = defaultdict(foo)
self.assertTrue(d3.default_factory is foo)
diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py
index f525429..4fd0cc7 100644
--- a/Lib/test/test_deque.py
+++ b/Lib/test/test_deque.py
@@ -289,7 +289,7 @@
else:
self.assertEqual(d.index(element, start, stop), target)
- def test_insert_bug_24913(self):
+ def test_index_bug_24913(self):
d = deque('A' * 3)
with self.assertRaises(ValueError):
i = d.index("Hello world", 0, 4)
@@ -622,20 +622,22 @@
self.assertEqual(list(d), list(e))
def test_pickle(self):
- d = deque(range(200))
- for i in range(pickle.HIGHEST_PROTOCOL + 1):
- s = pickle.dumps(d, i)
- e = pickle.loads(s)
- self.assertNotEqual(id(d), id(e))
- self.assertEqual(list(d), list(e))
+ for d in deque(range(200)), deque(range(200), 100):
+ for i in range(pickle.HIGHEST_PROTOCOL + 1):
+ s = pickle.dumps(d, i)
+ e = pickle.loads(s)
+ self.assertNotEqual(id(e), id(d))
+ self.assertEqual(list(e), list(d))
+ self.assertEqual(e.maxlen, d.maxlen)
-## def test_pickle_recursive(self):
-## d = deque('abc')
-## d.append(d)
-## for i in range(pickle.HIGHEST_PROTOCOL + 1):
-## e = pickle.loads(pickle.dumps(d, i))
-## self.assertNotEqual(id(d), id(e))
-## self.assertEqual(id(e), id(e[-1]))
+ def test_pickle_recursive(self):
+ for d in deque('abc'), deque('abc', 3):
+ d.append(d)
+ for i in range(pickle.HIGHEST_PROTOCOL + 1):
+ e = pickle.loads(pickle.dumps(d, i))
+ self.assertNotEqual(id(e), id(d))
+ self.assertEqual(id(e[-1]), id(e))
+ self.assertEqual(e.maxlen, d.maxlen)
def test_iterator_pickle(self):
orig = deque(range(200))
@@ -696,6 +698,15 @@
self.assertNotEqual(id(d), id(e))
self.assertEqual(list(d), list(e))
+ for i in range(5):
+ for maxlen in range(-1, 6):
+ s = [random.random() for j in range(i)]
+ d = deque(s) if maxlen == -1 else deque(s, maxlen)
+ e = d.copy()
+ self.assertEqual(d, e)
+ self.assertEqual(d.maxlen, e.maxlen)
+ self.assertTrue(all(x is y for x, y in zip(d, e)))
+
def test_copy_method(self):
mut = [10]
d = deque([mut])
@@ -845,24 +856,26 @@
self.assertEqual(type(d), type(e))
self.assertEqual(list(d), list(e))
-## def test_pickle(self):
-## d = Deque('abc')
-## d.append(d)
-##
-## e = pickle.loads(pickle.dumps(d))
-## self.assertNotEqual(id(d), id(e))
-## self.assertEqual(type(d), type(e))
-## dd = d.pop()
-## ee = e.pop()
-## self.assertEqual(id(e), id(ee))
-## self.assertEqual(d, e)
-##
-## d.x = d
-## e = pickle.loads(pickle.dumps(d))
-## self.assertEqual(id(e), id(e.x))
-##
-## d = DequeWithBadIter('abc')
-## self.assertRaises(TypeError, pickle.dumps, d)
+ def test_pickle_recursive(self):
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ for d in Deque('abc'), Deque('abc', 3):
+ d.append(d)
+
+ e = pickle.loads(pickle.dumps(d, proto))
+ self.assertNotEqual(id(e), id(d))
+ self.assertEqual(type(e), type(d))
+ self.assertEqual(e.maxlen, d.maxlen)
+ dd = d.pop()
+ ee = e.pop()
+ self.assertEqual(id(ee), id(e))
+ self.assertEqual(e, d)
+
+ d.x = d
+ e = pickle.loads(pickle.dumps(d, proto))
+ self.assertEqual(id(e.x), id(e))
+
+ for d in DequeWithBadIter('abc'), DequeWithBadIter('abc', 2):
+ self.assertRaises(TypeError, pickle.dumps, d, proto)
def test_weakref(self):
d = deque('gallahad')
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index a130cec..954ef2d 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -4544,9 +4544,9 @@
pass
foo = Foo()
self.assertRegex(repr(foo.method), # access via instance
- r"<bound method .*Foo\.method of <class '.*Foo'>>")
+ r"<bound method .*Foo\.method of <class '.*Foo' at 0x.+>>")
self.assertRegex(repr(Foo.method), # access via the class
- r"<bound method .*Foo\.method of <class '.*Foo'>>")
+ r"<bound method .*Foo\.method of <class '.*Foo' at 0x.+>>")
class MyCallable:
@@ -4738,11 +4738,8 @@
return (args, kwargs)
obj = C3()
for proto in protocols:
- if proto >= 4:
+ if proto >= 2:
self._check_reduce(proto, obj, args, kwargs)
- elif proto >= 2:
- with self.assertRaises(ValueError):
- obj.__reduce_ex__(proto)
class C4:
def __getnewargs_ex__(self):
@@ -5061,10 +5058,6 @@
kwargs = getattr(cls, 'KWARGS', {})
obj = cls(*cls.ARGS, **kwargs)
proto = pickle_copier.proto
- if 2 <= proto < 4 and hasattr(cls, '__getnewargs_ex__'):
- with self.assertRaises(ValueError):
- pickle_copier.dumps(obj, proto)
- continue
objcopy = pickle_copier.copy(obj)
self._assert_is_copy(obj, objcopy)
# For test classes that supports this, make sure we didn't go
diff --git a/Lib/test/test_descrtut.py b/Lib/test/test_descrtut.py
index 506d1ab..80cfa41 100644
--- a/Lib/test/test_descrtut.py
+++ b/Lib/test/test_descrtut.py
@@ -37,16 +37,16 @@
Here's the new type at work:
>>> print(defaultdict) # show our type
- <class 'test.test_descrtut.defaultdict'>
+ <class 'test.test_descrtut.defaultdict' ...>
>>> print(type(defaultdict)) # its metatype
- <class 'type'>
+ <class 'type' ...>
>>> a = defaultdict(default=0.0) # create an instance
>>> print(a) # show the instance
{}
>>> print(type(a)) # show its type
- <class 'test.test_descrtut.defaultdict'>
+ <class 'test.test_descrtut.defaultdict' ...>
>>> print(a.__class__) # show its class
- <class 'test.test_descrtut.defaultdict'>
+ <class 'test.test_descrtut.defaultdict' ...>
>>> print(type(a) is a.__class__) # its type is its class
True
>>> a[1] = 3.25 # modify the instance
@@ -149,11 +149,11 @@
For instance of built-in types, x.__class__ is now the same as type(x):
>>> type([])
- <class 'list'>
+ <class 'list' ...>
>>> [].__class__
- <class 'list'>
+ <class 'list' ...>
>>> list
- <class 'list'>
+ <class 'list' ...>
>>> isinstance([], list)
True
>>> isinstance([], dict)
@@ -258,19 +258,19 @@
... print("classmethod", cls, y)
>>> C.foo(1)
- classmethod <class 'test.test_descrtut.C'> 1
+ classmethod <class 'test.test_descrtut.C' ...> 1
>>> c = C()
>>> c.foo(1)
- classmethod <class 'test.test_descrtut.C'> 1
+ classmethod <class 'test.test_descrtut.C' ...> 1
>>> class D(C):
... pass
>>> D.foo(1)
- classmethod <class 'test.test_descrtut.D'> 1
+ classmethod <class 'test.test_descrtut.D' ...> 1
>>> d = D()
>>> d.foo(1)
- classmethod <class 'test.test_descrtut.D'> 1
+ classmethod <class 'test.test_descrtut.D' ...> 1
This prints "classmethod __main__.D 1" both times; in other words, the
class passed as the first argument of foo() is the class involved in the
@@ -286,11 +286,11 @@
>>> E.foo(1)
E.foo() called
- classmethod <class 'test.test_descrtut.C'> 1
+ classmethod <class 'test.test_descrtut.C' ...> 1
>>> e = E()
>>> e.foo(1)
E.foo() called
- classmethod <class 'test.test_descrtut.C'> 1
+ classmethod <class 'test.test_descrtut.C' ...> 1
In this example, the call to C.foo() from E.foo() will see class C as its
first argument, not class E. This is to be expected, since the call
@@ -350,7 +350,7 @@
>>> del property # unmask the builtin
>>> property
- <class 'property'>
+ <class 'property' ...>
>>> class C(object):
... def __init__(self):
@@ -478,7 +478,8 @@
# business is used the name can change depending on how the test is
# invoked.
from test import support, test_descrtut
- support.run_doctest(test_descrtut, verbose)
+ import doctest
+ support.run_doctest(test_descrtut, verbose, optionflags=doctest.ELLIPSIS)
# This part isn't needed for regrtest, but for running the test directly.
if __name__ == "__main__":
diff --git a/Lib/test/test_devpoll.py b/Lib/test/test_devpoll.py
index 955618a..c133c81 100644
--- a/Lib/test/test_devpoll.py
+++ b/Lib/test/test_devpoll.py
@@ -5,9 +5,8 @@
import os
import random
import select
-import sys
import unittest
-from test.support import TESTFN, run_unittest, cpython_only
+from test.support import run_unittest, cpython_only
if not hasattr(select, 'devpoll') :
raise unittest.SkipTest('test works only on Solaris OS family')
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
index 6d68e76..6c47066 100644
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -1,10 +1,12 @@
-import unittest
-from test import support
-
-import collections, random, string
+import collections
import collections.abc
-import gc, weakref
+import gc
import pickle
+import random
+import string
+import unittest
+import weakref
+from test import support
class DictTest(unittest.TestCase):
@@ -969,5 +971,6 @@
class SubclassMappingTests(mapping_tests.BasicTestMappingProtocol):
type2test = Dict
+
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_dictcomps.py b/Lib/test/test_dictcomps.py
index 3c8b95c..0873071 100644
--- a/Lib/test/test_dictcomps.py
+++ b/Lib/test/test_dictcomps.py
@@ -1,7 +1,5 @@
import unittest
-from test import support
-
# For scope testing.
g = "Global variable"
diff --git a/Lib/test/test_dictviews.py b/Lib/test/test_dictviews.py
index ab23ca1..4c290ff 100644
--- a/Lib/test/test_dictviews.py
+++ b/Lib/test/test_dictviews.py
@@ -1,3 +1,4 @@
+import collections
import copy
import pickle
import unittest
@@ -219,6 +220,27 @@
self.assertRaises((TypeError, pickle.PicklingError),
pickle.dumps, d.items(), proto)
+ def test_abc_registry(self):
+ d = dict(a=1)
+
+ self.assertIsInstance(d.keys(), collections.KeysView)
+ self.assertIsInstance(d.keys(), collections.MappingView)
+ self.assertIsInstance(d.keys(), collections.Set)
+ self.assertIsInstance(d.keys(), collections.Sized)
+ self.assertIsInstance(d.keys(), collections.Iterable)
+ self.assertIsInstance(d.keys(), collections.Container)
+
+ self.assertIsInstance(d.values(), collections.ValuesView)
+ self.assertIsInstance(d.values(), collections.MappingView)
+ self.assertIsInstance(d.values(), collections.Sized)
+
+ self.assertIsInstance(d.items(), collections.ItemsView)
+ self.assertIsInstance(d.items(), collections.MappingView)
+ self.assertIsInstance(d.items(), collections.Set)
+ self.assertIsInstance(d.items(), collections.Sized)
+ self.assertIsInstance(d.items(), collections.Iterable)
+ self.assertIsInstance(d.items(), collections.Container)
+
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py
index 0fd1348..09e68ce 100644
--- a/Lib/test/test_dis.py
+++ b/Lib/test/test_dis.py
@@ -40,41 +40,41 @@
dis_c_instance_method = """\
%3d 0 LOAD_FAST 1 (x)
- 3 LOAD_CONST 1 (1)
- 6 COMPARE_OP 2 (==)
- 9 LOAD_FAST 0 (self)
- 12 STORE_ATTR 0 (x)
- 15 LOAD_CONST 0 (None)
- 18 RETURN_VALUE
+ 2 LOAD_CONST 1 (1)
+ 4 COMPARE_OP 2 (==)
+ 6 LOAD_FAST 0 (self)
+ 8 STORE_ATTR 0 (x)
+ 10 LOAD_CONST 0 (None)
+ 12 RETURN_VALUE
""" % (_C.__init__.__code__.co_firstlineno + 1,)
dis_c_instance_method_bytes = """\
0 LOAD_FAST 1 (1)
- 3 LOAD_CONST 1 (1)
- 6 COMPARE_OP 2 (==)
- 9 LOAD_FAST 0 (0)
- 12 STORE_ATTR 0 (0)
- 15 LOAD_CONST 0 (0)
- 18 RETURN_VALUE
+ 2 LOAD_CONST 1 (1)
+ 4 COMPARE_OP 2 (==)
+ 6 LOAD_FAST 0 (0)
+ 8 STORE_ATTR 0 (0)
+ 10 LOAD_CONST 0 (0)
+ 12 RETURN_VALUE
"""
dis_c_class_method = """\
%3d 0 LOAD_FAST 1 (x)
- 3 LOAD_CONST 1 (1)
- 6 COMPARE_OP 2 (==)
- 9 LOAD_FAST 0 (cls)
- 12 STORE_ATTR 0 (x)
- 15 LOAD_CONST 0 (None)
- 18 RETURN_VALUE
+ 2 LOAD_CONST 1 (1)
+ 4 COMPARE_OP 2 (==)
+ 6 LOAD_FAST 0 (cls)
+ 8 STORE_ATTR 0 (x)
+ 10 LOAD_CONST 0 (None)
+ 12 RETURN_VALUE
""" % (_C.cm.__code__.co_firstlineno + 2,)
dis_c_static_method = """\
%3d 0 LOAD_FAST 0 (x)
- 3 LOAD_CONST 1 (1)
- 6 COMPARE_OP 2 (==)
- 9 STORE_FAST 0 (x)
- 12 LOAD_CONST 0 (None)
- 15 RETURN_VALUE
+ 2 LOAD_CONST 1 (1)
+ 4 COMPARE_OP 2 (==)
+ 6 STORE_FAST 0 (x)
+ 8 LOAD_CONST 0 (None)
+ 10 RETURN_VALUE
""" % (_C.sm.__code__.co_firstlineno + 2,)
# Class disassembling info has an extra newline at end.
@@ -95,23 +95,23 @@
dis_f = """\
%3d 0 LOAD_GLOBAL 0 (print)
- 3 LOAD_FAST 0 (a)
- 6 CALL_FUNCTION 1 (1 positional, 0 keyword pair)
- 9 POP_TOP
+ 2 LOAD_FAST 0 (a)
+ 4 CALL_FUNCTION 1 (1 positional, 0 keyword pair)
+ 6 POP_TOP
-%3d 10 LOAD_CONST 1 (1)
- 13 RETURN_VALUE
+%3d 8 LOAD_CONST 1 (1)
+ 10 RETURN_VALUE
""" % (_f.__code__.co_firstlineno + 1,
_f.__code__.co_firstlineno + 2)
dis_f_co_code = """\
0 LOAD_GLOBAL 0 (0)
- 3 LOAD_FAST 0 (0)
- 6 CALL_FUNCTION 1 (1 positional, 0 keyword pair)
- 9 POP_TOP
- 10 LOAD_CONST 1 (1)
- 13 RETURN_VALUE
+ 2 LOAD_FAST 0 (0)
+ 4 CALL_FUNCTION 1 (1 positional, 0 keyword pair)
+ 6 POP_TOP
+ 8 LOAD_CONST 1 (1)
+ 10 RETURN_VALUE
"""
@@ -121,20 +121,20 @@
pass
dis_bug708901 = """\
-%3d 0 SETUP_LOOP 23 (to 26)
- 3 LOAD_GLOBAL 0 (range)
- 6 LOAD_CONST 1 (1)
+%3d 0 SETUP_LOOP 18 (to 20)
+ 2 LOAD_GLOBAL 0 (range)
+ 4 LOAD_CONST 1 (1)
-%3d 9 LOAD_CONST 2 (10)
- 12 CALL_FUNCTION 2 (2 positional, 0 keyword pair)
- 15 GET_ITER
- >> 16 FOR_ITER 6 (to 25)
- 19 STORE_FAST 0 (res)
+%3d 6 LOAD_CONST 2 (10)
+ 8 CALL_FUNCTION 2 (2 positional, 0 keyword pair)
+ 10 GET_ITER
+ >> 12 FOR_ITER 4 (to 18)
+ 14 STORE_FAST 0 (res)
-%3d 22 JUMP_ABSOLUTE 16
- >> 25 POP_BLOCK
- >> 26 LOAD_CONST 0 (None)
- 29 RETURN_VALUE
+%3d 16 JUMP_ABSOLUTE 12
+ >> 18 POP_BLOCK
+ >> 20 LOAD_CONST 0 (None)
+ 22 RETURN_VALUE
""" % (bug708901.__code__.co_firstlineno + 1,
bug708901.__code__.co_firstlineno + 2,
bug708901.__code__.co_firstlineno + 3)
@@ -147,22 +147,22 @@
dis_bug1333982 = """\
%3d 0 LOAD_CONST 1 (0)
- 3 POP_JUMP_IF_TRUE 35
- 6 LOAD_GLOBAL 0 (AssertionError)
- 9 LOAD_CONST 2 (<code object <listcomp> at 0x..., file "%s", line %d>)
- 12 LOAD_CONST 3 ('bug1333982.<locals>.<listcomp>')
- 15 MAKE_FUNCTION 0
- 18 LOAD_FAST 0 (x)
- 21 GET_ITER
+ 2 POP_JUMP_IF_TRUE 26
+ 4 LOAD_GLOBAL 0 (AssertionError)
+ 6 LOAD_CONST 2 (<code object <listcomp> at 0x..., file "%s", line %d>)
+ 8 LOAD_CONST 3 ('bug1333982.<locals>.<listcomp>')
+ 10 MAKE_FUNCTION 0
+ 12 LOAD_FAST 0 (x)
+ 14 GET_ITER
+ 16 CALL_FUNCTION 1 (1 positional, 0 keyword pair)
+
+%3d 18 LOAD_CONST 4 (1)
+ 20 BINARY_ADD
22 CALL_FUNCTION 1 (1 positional, 0 keyword pair)
+ 24 RAISE_VARARGS 1
-%3d 25 LOAD_CONST 4 (1)
- 28 BINARY_ADD
- 29 CALL_FUNCTION 1 (1 positional, 0 keyword pair)
- 32 RAISE_VARARGS 1
-
-%3d >> 35 LOAD_CONST 0 (None)
- 38 RETURN_VALUE
+%3d >> 26 LOAD_CONST 0 (None)
+ 28 RETURN_VALUE
""" % (bug1333982.__code__.co_firstlineno + 1,
__file__,
bug1333982.__code__.co_firstlineno + 1,
@@ -171,19 +171,19 @@
_BIG_LINENO_FORMAT = """\
%3d 0 LOAD_GLOBAL 0 (spam)
- 3 POP_TOP
+ 2 POP_TOP
4 LOAD_CONST 0 (None)
- 7 RETURN_VALUE
+ 6 RETURN_VALUE
"""
dis_module_expected_results = """\
Disassembly of f:
4 0 LOAD_CONST 0 (None)
- 3 RETURN_VALUE
+ 2 RETURN_VALUE
Disassembly of g:
5 0 LOAD_CONST 0 (None)
- 3 RETURN_VALUE
+ 2 RETURN_VALUE
"""
@@ -191,20 +191,20 @@
dis_expr_str = """\
1 0 LOAD_NAME 0 (x)
- 3 LOAD_CONST 0 (1)
- 6 BINARY_ADD
- 7 RETURN_VALUE
+ 2 LOAD_CONST 0 (1)
+ 4 BINARY_ADD
+ 6 RETURN_VALUE
"""
simple_stmt_str = "x = x + 1"
dis_simple_stmt_str = """\
1 0 LOAD_NAME 0 (x)
- 3 LOAD_CONST 0 (1)
- 6 BINARY_ADD
- 7 STORE_NAME 0 (x)
- 10 LOAD_CONST 1 (None)
- 13 RETURN_VALUE
+ 2 LOAD_CONST 0 (1)
+ 4 BINARY_ADD
+ 6 STORE_NAME 0 (x)
+ 8 LOAD_CONST 1 (None)
+ 10 RETURN_VALUE
"""
compound_stmt_str = """\
@@ -215,54 +215,54 @@
dis_compound_stmt_str = """\
1 0 LOAD_CONST 0 (0)
- 3 STORE_NAME 0 (x)
+ 2 STORE_NAME 0 (x)
- 2 6 SETUP_LOOP 14 (to 23)
+ 2 4 SETUP_LOOP 12 (to 18)
- 3 >> 9 LOAD_NAME 0 (x)
- 12 LOAD_CONST 1 (1)
- 15 INPLACE_ADD
- 16 STORE_NAME 0 (x)
- 19 JUMP_ABSOLUTE 9
- 22 POP_BLOCK
- >> 23 LOAD_CONST 2 (None)
- 26 RETURN_VALUE
+ 3 >> 6 LOAD_NAME 0 (x)
+ 8 LOAD_CONST 1 (1)
+ 10 INPLACE_ADD
+ 12 STORE_NAME 0 (x)
+ 14 JUMP_ABSOLUTE 6
+ 16 POP_BLOCK
+ >> 18 LOAD_CONST 2 (None)
+ 20 RETURN_VALUE
"""
dis_traceback = """\
-%3d 0 SETUP_EXCEPT 12 (to 15)
+%3d 0 SETUP_EXCEPT 12 (to 14)
-%3d 3 LOAD_CONST 1 (1)
- 6 LOAD_CONST 2 (0)
- --> 9 BINARY_TRUE_DIVIDE
- 10 POP_TOP
- 11 POP_BLOCK
- 12 JUMP_FORWARD 46 (to 61)
+%3d 2 LOAD_CONST 1 (1)
+ 4 LOAD_CONST 2 (0)
+ --> 6 BINARY_TRUE_DIVIDE
+ 8 POP_TOP
+ 10 POP_BLOCK
+ 12 JUMP_FORWARD 40 (to 54)
-%3d >> 15 DUP_TOP
+%3d >> 14 DUP_TOP
16 LOAD_GLOBAL 0 (Exception)
- 19 COMPARE_OP 10 (exception match)
- 22 POP_JUMP_IF_FALSE 60
- 25 POP_TOP
- 26 STORE_FAST 0 (e)
- 29 POP_TOP
- 30 SETUP_FINALLY 14 (to 47)
+ 18 COMPARE_OP 10 (exception match)
+ 20 POP_JUMP_IF_FALSE 52
+ 22 POP_TOP
+ 24 STORE_FAST 0 (e)
+ 26 POP_TOP
+ 28 SETUP_FINALLY 12 (to 42)
-%3d 33 LOAD_FAST 0 (e)
- 36 LOAD_ATTR 1 (__traceback__)
- 39 STORE_FAST 1 (tb)
- 42 POP_BLOCK
- 43 POP_EXCEPT
- 44 LOAD_CONST 0 (None)
- >> 47 LOAD_CONST 0 (None)
- 50 STORE_FAST 0 (e)
- 53 DELETE_FAST 0 (e)
- 56 END_FINALLY
- 57 JUMP_FORWARD 1 (to 61)
- >> 60 END_FINALLY
+%3d 30 LOAD_FAST 0 (e)
+ 32 LOAD_ATTR 1 (__traceback__)
+ 34 STORE_FAST 1 (tb)
+ 36 POP_BLOCK
+ 38 POP_EXCEPT
+ 40 LOAD_CONST 0 (None)
+ >> 42 LOAD_CONST 0 (None)
+ 44 STORE_FAST 0 (e)
+ 46 DELETE_FAST 0 (e)
+ 48 END_FINALLY
+ 50 JUMP_FORWARD 2 (to 54)
+ >> 52 END_FINALLY
-%3d >> 61 LOAD_FAST 1 (tb)
- 64 RETURN_VALUE
+%3d >> 54 LOAD_FAST 1 (tb)
+ 56 RETURN_VALUE
""" % (TRACEBACK_CODE.co_firstlineno + 1,
TRACEBACK_CODE.co_firstlineno + 2,
TRACEBACK_CODE.co_firstlineno + 3,
@@ -649,171 +649,169 @@
Instruction = dis.Instruction
expected_opinfo_outer = [
- Instruction(opname='LOAD_CONST', opcode=100, arg=1, argval=3, argrepr='3', offset=0, starts_line=2, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=2, argval=4, argrepr='4', offset=3, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CLOSURE', opcode=135, arg=0, argval='a', argrepr='a', offset=6, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CLOSURE', opcode=135, arg=1, argval='b', argrepr='b', offset=9, starts_line=None, is_jump_target=False),
- Instruction(opname='BUILD_TUPLE', opcode=102, arg=2, argval=2, argrepr='', offset=12, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=3, argval=code_object_f, argrepr=repr(code_object_f), offset=15, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=4, argval='outer.<locals>.f', argrepr="'outer.<locals>.f'", offset=18, starts_line=None, is_jump_target=False),
- Instruction(opname='MAKE_CLOSURE', opcode=134, arg=2, argval=2, argrepr='', offset=21, starts_line=None, is_jump_target=False),
- Instruction(opname='STORE_FAST', opcode=125, arg=2, argval='f', argrepr='f', offset=24, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_GLOBAL', opcode=116, arg=0, argval='print', argrepr='print', offset=27, starts_line=7, is_jump_target=False),
- Instruction(opname='LOAD_DEREF', opcode=136, arg=0, argval='a', argrepr='a', offset=30, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_DEREF', opcode=136, arg=1, argval='b', argrepr='b', offset=33, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=5, argval='', argrepr="''", offset=36, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=6, argval=1, argrepr='1', offset=39, starts_line=None, is_jump_target=False),
- Instruction(opname='BUILD_LIST', opcode=103, arg=0, argval=0, argrepr='', offset=42, starts_line=None, is_jump_target=False),
- Instruction(opname='BUILD_MAP', opcode=105, arg=0, argval=0, argrepr='', offset=45, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=7, argval='Hello world!', argrepr="'Hello world!'", offset=48, starts_line=None, is_jump_target=False),
- Instruction(opname='CALL_FUNCTION', opcode=131, arg=7, argval=7, argrepr='7 positional, 0 keyword pair', offset=51, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=54, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_FAST', opcode=124, arg=2, argval='f', argrepr='f', offset=55, starts_line=8, is_jump_target=False),
- Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=58, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=8, argval=(3, 4), argrepr='(3, 4)', offset=0, starts_line=2, is_jump_target=False),
+ Instruction(opname='LOAD_CLOSURE', opcode=135, arg=0, argval='a', argrepr='a', offset=2, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CLOSURE', opcode=135, arg=1, argval='b', argrepr='b', offset=4, starts_line=None, is_jump_target=False),
+ Instruction(opname='BUILD_TUPLE', opcode=102, arg=2, argval=2, argrepr='', offset=6, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=3, argval=code_object_f, argrepr=repr(code_object_f), offset=8, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=4, argval='outer.<locals>.f', argrepr="'outer.<locals>.f'", offset=10, starts_line=None, is_jump_target=False),
+ Instruction(opname='MAKE_FUNCTION', opcode=132, arg=9, argval=9, argrepr='', offset=12, starts_line=None, is_jump_target=False),
+ Instruction(opname='STORE_FAST', opcode=125, arg=2, argval='f', argrepr='f', offset=14, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_GLOBAL', opcode=116, arg=0, argval='print', argrepr='print', offset=16, starts_line=7, is_jump_target=False),
+ Instruction(opname='LOAD_DEREF', opcode=136, arg=0, argval='a', argrepr='a', offset=18, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_DEREF', opcode=136, arg=1, argval='b', argrepr='b', offset=20, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=5, argval='', argrepr="''", offset=22, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=6, argval=1, argrepr='1', offset=24, starts_line=None, is_jump_target=False),
+ Instruction(opname='BUILD_LIST', opcode=103, arg=0, argval=0, argrepr='', offset=26, starts_line=None, is_jump_target=False),
+ Instruction(opname='BUILD_MAP', opcode=105, arg=0, argval=0, argrepr='', offset=28, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=7, argval='Hello world!', argrepr="'Hello world!'", offset=30, starts_line=None, is_jump_target=False),
+ Instruction(opname='CALL_FUNCTION', opcode=131, arg=7, argval=7, argrepr='7 positional, 0 keyword pair', offset=32, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=34, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_FAST', opcode=124, arg=2, argval='f', argrepr='f', offset=36, starts_line=8, is_jump_target=False),
+ Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=38, starts_line=None, is_jump_target=False),
]
expected_opinfo_f = [
- Instruction(opname='LOAD_CONST', opcode=100, arg=1, argval=5, argrepr='5', offset=0, starts_line=3, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=2, argval=6, argrepr='6', offset=3, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CLOSURE', opcode=135, arg=2, argval='a', argrepr='a', offset=6, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CLOSURE', opcode=135, arg=3, argval='b', argrepr='b', offset=9, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CLOSURE', opcode=135, arg=0, argval='c', argrepr='c', offset=12, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CLOSURE', opcode=135, arg=1, argval='d', argrepr='d', offset=15, starts_line=None, is_jump_target=False),
- Instruction(opname='BUILD_TUPLE', opcode=102, arg=4, argval=4, argrepr='', offset=18, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=3, argval=code_object_inner, argrepr=repr(code_object_inner), offset=21, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=4, argval='outer.<locals>.f.<locals>.inner', argrepr="'outer.<locals>.f.<locals>.inner'", offset=24, starts_line=None, is_jump_target=False),
- Instruction(opname='MAKE_CLOSURE', opcode=134, arg=2, argval=2, argrepr='', offset=27, starts_line=None, is_jump_target=False),
- Instruction(opname='STORE_FAST', opcode=125, arg=2, argval='inner', argrepr='inner', offset=30, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_GLOBAL', opcode=116, arg=0, argval='print', argrepr='print', offset=33, starts_line=5, is_jump_target=False),
- Instruction(opname='LOAD_DEREF', opcode=136, arg=2, argval='a', argrepr='a', offset=36, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_DEREF', opcode=136, arg=3, argval='b', argrepr='b', offset=39, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_DEREF', opcode=136, arg=0, argval='c', argrepr='c', offset=42, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_DEREF', opcode=136, arg=1, argval='d', argrepr='d', offset=45, starts_line=None, is_jump_target=False),
- Instruction(opname='CALL_FUNCTION', opcode=131, arg=4, argval=4, argrepr='4 positional, 0 keyword pair', offset=48, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=51, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_FAST', opcode=124, arg=2, argval='inner', argrepr='inner', offset=52, starts_line=6, is_jump_target=False),
- Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=55, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=5, argval=(5, 6), argrepr='(5, 6)', offset=0, starts_line=3, is_jump_target=False),
+ Instruction(opname='LOAD_CLOSURE', opcode=135, arg=2, argval='a', argrepr='a', offset=2, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CLOSURE', opcode=135, arg=3, argval='b', argrepr='b', offset=4, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CLOSURE', opcode=135, arg=0, argval='c', argrepr='c', offset=6, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CLOSURE', opcode=135, arg=1, argval='d', argrepr='d', offset=8, starts_line=None, is_jump_target=False),
+ Instruction(opname='BUILD_TUPLE', opcode=102, arg=4, argval=4, argrepr='', offset=10, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=3, argval=code_object_inner, argrepr=repr(code_object_inner), offset=12, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=4, argval='outer.<locals>.f.<locals>.inner', argrepr="'outer.<locals>.f.<locals>.inner'", offset=14, starts_line=None, is_jump_target=False),
+ Instruction(opname='MAKE_FUNCTION', opcode=132, arg=9, argval=9, argrepr='', offset=16, starts_line=None, is_jump_target=False),
+ Instruction(opname='STORE_FAST', opcode=125, arg=2, argval='inner', argrepr='inner', offset=18, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_GLOBAL', opcode=116, arg=0, argval='print', argrepr='print', offset=20, starts_line=5, is_jump_target=False),
+ Instruction(opname='LOAD_DEREF', opcode=136, arg=2, argval='a', argrepr='a', offset=22, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_DEREF', opcode=136, arg=3, argval='b', argrepr='b', offset=24, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_DEREF', opcode=136, arg=0, argval='c', argrepr='c', offset=26, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_DEREF', opcode=136, arg=1, argval='d', argrepr='d', offset=28, starts_line=None, is_jump_target=False),
+ Instruction(opname='CALL_FUNCTION', opcode=131, arg=4, argval=4, argrepr='4 positional, 0 keyword pair', offset=30, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=32, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_FAST', opcode=124, arg=2, argval='inner', argrepr='inner', offset=34, starts_line=6, is_jump_target=False),
+ Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=36, starts_line=None, is_jump_target=False),
]
expected_opinfo_inner = [
Instruction(opname='LOAD_GLOBAL', opcode=116, arg=0, argval='print', argrepr='print', offset=0, starts_line=4, is_jump_target=False),
- Instruction(opname='LOAD_DEREF', opcode=136, arg=0, argval='a', argrepr='a', offset=3, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_DEREF', opcode=136, arg=1, argval='b', argrepr='b', offset=6, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_DEREF', opcode=136, arg=2, argval='c', argrepr='c', offset=9, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_DEREF', opcode=136, arg=3, argval='d', argrepr='d', offset=12, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='e', argrepr='e', offset=15, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_FAST', opcode=124, arg=1, argval='f', argrepr='f', offset=18, starts_line=None, is_jump_target=False),
- Instruction(opname='CALL_FUNCTION', opcode=131, arg=6, argval=6, argrepr='6 positional, 0 keyword pair', offset=21, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=24, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=25, starts_line=None, is_jump_target=False),
- Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=28, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_DEREF', opcode=136, arg=0, argval='a', argrepr='a', offset=2, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_DEREF', opcode=136, arg=1, argval='b', argrepr='b', offset=4, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_DEREF', opcode=136, arg=2, argval='c', argrepr='c', offset=6, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_DEREF', opcode=136, arg=3, argval='d', argrepr='d', offset=8, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='e', argrepr='e', offset=10, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_FAST', opcode=124, arg=1, argval='f', argrepr='f', offset=12, starts_line=None, is_jump_target=False),
+ Instruction(opname='CALL_FUNCTION', opcode=131, arg=6, argval=6, argrepr='6 positional, 0 keyword pair', offset=14, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=16, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=18, starts_line=None, is_jump_target=False),
+ Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=20, starts_line=None, is_jump_target=False),
]
expected_opinfo_jumpy = [
- Instruction(opname='SETUP_LOOP', opcode=120, arg=68, argval=71, argrepr='to 71', offset=0, starts_line=3, is_jump_target=False),
- Instruction(opname='LOAD_GLOBAL', opcode=116, arg=0, argval='range', argrepr='range', offset=3, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=1, argval=10, argrepr='10', offset=6, starts_line=None, is_jump_target=False),
- Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='1 positional, 0 keyword pair', offset=9, starts_line=None, is_jump_target=False),
- Instruction(opname='GET_ITER', opcode=68, arg=None, argval=None, argrepr='', offset=12, starts_line=None, is_jump_target=False),
- Instruction(opname='FOR_ITER', opcode=93, arg=44, argval=60, argrepr='to 60', offset=13, starts_line=None, is_jump_target=True),
- Instruction(opname='STORE_FAST', opcode=125, arg=0, argval='i', argrepr='i', offset=16, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=19, starts_line=4, is_jump_target=False),
- Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=22, starts_line=None, is_jump_target=False),
- Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='1 positional, 0 keyword pair', offset=25, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=28, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=29, starts_line=5, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=2, argval=4, argrepr='4', offset=32, starts_line=None, is_jump_target=False),
- Instruction(opname='COMPARE_OP', opcode=107, arg=0, argval='<', argrepr='<', offset=35, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=44, argval=44, argrepr='', offset=38, starts_line=None, is_jump_target=False),
- Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=13, argval=13, argrepr='', offset=41, starts_line=6, is_jump_target=False),
- Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=44, starts_line=7, is_jump_target=True),
- Instruction(opname='LOAD_CONST', opcode=100, arg=3, argval=6, argrepr='6', offset=47, starts_line=None, is_jump_target=False),
- Instruction(opname='COMPARE_OP', opcode=107, arg=4, argval='>', argrepr='>', offset=50, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=13, argval=13, argrepr='', offset=53, starts_line=None, is_jump_target=False),
- Instruction(opname='BREAK_LOOP', opcode=80, arg=None, argval=None, argrepr='', offset=56, starts_line=8, is_jump_target=False),
- Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=13, argval=13, argrepr='', offset=57, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_BLOCK', opcode=87, arg=None, argval=None, argrepr='', offset=60, starts_line=None, is_jump_target=True),
- Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=61, starts_line=10, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=4, argval='I can haz else clause?', argrepr="'I can haz else clause?'", offset=64, starts_line=None, is_jump_target=False),
- Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='1 positional, 0 keyword pair', offset=67, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=70, starts_line=None, is_jump_target=False),
- Instruction(opname='SETUP_LOOP', opcode=120, arg=68, argval=142, argrepr='to 142', offset=71, starts_line=11, is_jump_target=True),
- Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=74, starts_line=None, is_jump_target=True),
- Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=131, argval=131, argrepr='', offset=77, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=80, starts_line=12, is_jump_target=False),
- Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=83, starts_line=None, is_jump_target=False),
- Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='1 positional, 0 keyword pair', offset=86, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=89, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=90, starts_line=13, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=5, argval=1, argrepr='1', offset=93, starts_line=None, is_jump_target=False),
- Instruction(opname='INPLACE_SUBTRACT', opcode=56, arg=None, argval=None, argrepr='', offset=96, starts_line=None, is_jump_target=False),
- Instruction(opname='STORE_FAST', opcode=125, arg=0, argval='i', argrepr='i', offset=97, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=100, starts_line=14, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=3, argval=6, argrepr='6', offset=103, starts_line=None, is_jump_target=False),
- Instruction(opname='COMPARE_OP', opcode=107, arg=4, argval='>', argrepr='>', offset=106, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=115, argval=115, argrepr='', offset=109, starts_line=None, is_jump_target=False),
- Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=74, argval=74, argrepr='', offset=112, starts_line=15, is_jump_target=False),
- Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=115, starts_line=16, is_jump_target=True),
- Instruction(opname='LOAD_CONST', opcode=100, arg=2, argval=4, argrepr='4', offset=118, starts_line=None, is_jump_target=False),
- Instruction(opname='COMPARE_OP', opcode=107, arg=0, argval='<', argrepr='<', offset=121, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=74, argval=74, argrepr='', offset=124, starts_line=None, is_jump_target=False),
- Instruction(opname='BREAK_LOOP', opcode=80, arg=None, argval=None, argrepr='', offset=127, starts_line=17, is_jump_target=False),
- Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=74, argval=74, argrepr='', offset=128, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_BLOCK', opcode=87, arg=None, argval=None, argrepr='', offset=131, starts_line=None, is_jump_target=True),
- Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=132, starts_line=19, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=6, argval='Who let lolcatz into this test suite?', argrepr="'Who let lolcatz into this test suite?'", offset=135, starts_line=None, is_jump_target=False),
- Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='1 positional, 0 keyword pair', offset=138, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=141, starts_line=None, is_jump_target=False),
- Instruction(opname='SETUP_FINALLY', opcode=122, arg=73, argval=218, argrepr='to 218', offset=142, starts_line=20, is_jump_target=True),
- Instruction(opname='SETUP_EXCEPT', opcode=121, arg=12, argval=160, argrepr='to 160', offset=145, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=5, argval=1, argrepr='1', offset=148, starts_line=21, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=7, argval=0, argrepr='0', offset=151, starts_line=None, is_jump_target=False),
- Instruction(opname='BINARY_TRUE_DIVIDE', opcode=27, arg=None, argval=None, argrepr='', offset=154, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=155, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_BLOCK', opcode=87, arg=None, argval=None, argrepr='', offset=156, starts_line=None, is_jump_target=False),
- Instruction(opname='JUMP_FORWARD', opcode=110, arg=28, argval=188, argrepr='to 188', offset=157, starts_line=None, is_jump_target=False),
- Instruction(opname='DUP_TOP', opcode=4, arg=None, argval=None, argrepr='', offset=160, starts_line=22, is_jump_target=True),
- Instruction(opname='LOAD_GLOBAL', opcode=116, arg=2, argval='ZeroDivisionError', argrepr='ZeroDivisionError', offset=161, starts_line=None, is_jump_target=False),
- Instruction(opname='COMPARE_OP', opcode=107, arg=10, argval='exception match', argrepr='exception match', offset=164, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=187, argval=187, argrepr='', offset=167, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=170, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=171, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=172, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=173, starts_line=23, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=8, argval='Here we go, here we go, here we go...', argrepr="'Here we go, here we go, here we go...'", offset=176, starts_line=None, is_jump_target=False),
- Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='1 positional, 0 keyword pair', offset=179, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=182, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_EXCEPT', opcode=89, arg=None, argval=None, argrepr='', offset=183, starts_line=None, is_jump_target=False),
- Instruction(opname='JUMP_FORWARD', opcode=110, arg=27, argval=214, argrepr='to 214', offset=184, starts_line=None, is_jump_target=False),
- Instruction(opname='END_FINALLY', opcode=88, arg=None, argval=None, argrepr='', offset=187, starts_line=None, is_jump_target=True),
- Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=188, starts_line=25, is_jump_target=True),
- Instruction(opname='SETUP_WITH', opcode=143, arg=17, argval=211, argrepr='to 211', offset=191, starts_line=None, is_jump_target=False),
- Instruction(opname='STORE_FAST', opcode=125, arg=1, argval='dodgy', argrepr='dodgy', offset=194, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=197, starts_line=26, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=9, argval='Never reach this', argrepr="'Never reach this'", offset=200, starts_line=None, is_jump_target=False),
- Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='1 positional, 0 keyword pair', offset=203, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=206, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_BLOCK', opcode=87, arg=None, argval=None, argrepr='', offset=207, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=208, starts_line=None, is_jump_target=False),
- Instruction(opname='WITH_CLEANUP_START', opcode=81, arg=None, argval=None, argrepr='', offset=211, starts_line=None, is_jump_target=True),
- Instruction(opname='WITH_CLEANUP_FINISH', opcode=82, arg=None, argval=None, argrepr='', offset=212, starts_line=None, is_jump_target=False),
- Instruction(opname='END_FINALLY', opcode=88, arg=None, argval=None, argrepr='', offset=213, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_BLOCK', opcode=87, arg=None, argval=None, argrepr='', offset=214, starts_line=None, is_jump_target=True),
- Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=215, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=218, starts_line=28, is_jump_target=True),
- Instruction(opname='LOAD_CONST', opcode=100, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=221, starts_line=None, is_jump_target=False),
- Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='1 positional, 0 keyword pair', offset=224, starts_line=None, is_jump_target=False),
- Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=227, starts_line=None, is_jump_target=False),
- Instruction(opname='END_FINALLY', opcode=88, arg=None, argval=None, argrepr='', offset=228, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=229, starts_line=None, is_jump_target=False),
- Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=232, starts_line=None, is_jump_target=False),
+ Instruction(opname='SETUP_LOOP', opcode=120, arg=52, argval=54, argrepr='to 54', offset=0, starts_line=3, is_jump_target=False),
+ Instruction(opname='LOAD_GLOBAL', opcode=116, arg=0, argval='range', argrepr='range', offset=2, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=1, argval=10, argrepr='10', offset=4, starts_line=None, is_jump_target=False),
+ Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='1 positional, 0 keyword pair', offset=6, starts_line=None, is_jump_target=False),
+ Instruction(opname='GET_ITER', opcode=68, arg=None, argval=None, argrepr='', offset=8, starts_line=None, is_jump_target=False),
+ Instruction(opname='FOR_ITER', opcode=93, arg=32, argval=44, argrepr='to 44', offset=10, starts_line=None, is_jump_target=True),
+ Instruction(opname='STORE_FAST', opcode=125, arg=0, argval='i', argrepr='i', offset=12, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=14, starts_line=4, is_jump_target=False),
+ Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=16, starts_line=None, is_jump_target=False),
+ Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='1 positional, 0 keyword pair', offset=18, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=20, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=22, starts_line=5, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=2, argval=4, argrepr='4', offset=24, starts_line=None, is_jump_target=False),
+ Instruction(opname='COMPARE_OP', opcode=107, arg=0, argval='<', argrepr='<', offset=26, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=32, argval=32, argrepr='', offset=28, starts_line=None, is_jump_target=False),
+ Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=10, argval=10, argrepr='', offset=30, starts_line=6, is_jump_target=False),
+ Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=32, starts_line=7, is_jump_target=True),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=3, argval=6, argrepr='6', offset=34, starts_line=None, is_jump_target=False),
+ Instruction(opname='COMPARE_OP', opcode=107, arg=4, argval='>', argrepr='>', offset=36, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=10, argval=10, argrepr='', offset=38, starts_line=None, is_jump_target=False),
+ Instruction(opname='BREAK_LOOP', opcode=80, arg=None, argval=None, argrepr='', offset=40, starts_line=8, is_jump_target=False),
+ Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=10, argval=10, argrepr='', offset=42, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_BLOCK', opcode=87, arg=None, argval=None, argrepr='', offset=44, starts_line=None, is_jump_target=True),
+ Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=46, starts_line=10, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=4, argval='I can haz else clause?', argrepr="'I can haz else clause?'", offset=48, starts_line=None, is_jump_target=False),
+ Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='1 positional, 0 keyword pair', offset=50, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=52, starts_line=None, is_jump_target=False),
+ Instruction(opname='SETUP_LOOP', opcode=120, arg=52, argval=108, argrepr='to 108', offset=54, starts_line=11, is_jump_target=True),
+ Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=56, starts_line=None, is_jump_target=True),
+ Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=98, argval=98, argrepr='', offset=58, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=60, starts_line=12, is_jump_target=False),
+ Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=62, starts_line=None, is_jump_target=False),
+ Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='1 positional, 0 keyword pair', offset=64, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=66, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=68, starts_line=13, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=5, argval=1, argrepr='1', offset=70, starts_line=None, is_jump_target=False),
+ Instruction(opname='INPLACE_SUBTRACT', opcode=56, arg=None, argval=None, argrepr='', offset=72, starts_line=None, is_jump_target=False),
+ Instruction(opname='STORE_FAST', opcode=125, arg=0, argval='i', argrepr='i', offset=74, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=76, starts_line=14, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=3, argval=6, argrepr='6', offset=78, starts_line=None, is_jump_target=False),
+ Instruction(opname='COMPARE_OP', opcode=107, arg=4, argval='>', argrepr='>', offset=80, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=86, argval=86, argrepr='', offset=82, starts_line=None, is_jump_target=False),
+ Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=56, argval=56, argrepr='', offset=84, starts_line=15, is_jump_target=False),
+ Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=86, starts_line=16, is_jump_target=True),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=2, argval=4, argrepr='4', offset=88, starts_line=None, is_jump_target=False),
+ Instruction(opname='COMPARE_OP', opcode=107, arg=0, argval='<', argrepr='<', offset=90, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=56, argval=56, argrepr='', offset=92, starts_line=None, is_jump_target=False),
+ Instruction(opname='BREAK_LOOP', opcode=80, arg=None, argval=None, argrepr='', offset=94, starts_line=17, is_jump_target=False),
+ Instruction(opname='JUMP_ABSOLUTE', opcode=113, arg=56, argval=56, argrepr='', offset=96, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_BLOCK', opcode=87, arg=None, argval=None, argrepr='', offset=98, starts_line=None, is_jump_target=True),
+ Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=100, starts_line=19, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=6, argval='Who let lolcatz into this test suite?', argrepr="'Who let lolcatz into this test suite?'", offset=102, starts_line=None, is_jump_target=False),
+ Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='1 positional, 0 keyword pair', offset=104, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=106, starts_line=None, is_jump_target=False),
+ Instruction(opname='SETUP_FINALLY', opcode=122, arg=70, argval=180, argrepr='to 180', offset=108, starts_line=20, is_jump_target=True),
+ Instruction(opname='SETUP_EXCEPT', opcode=121, arg=12, argval=124, argrepr='to 124', offset=110, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=5, argval=1, argrepr='1', offset=112, starts_line=21, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=7, argval=0, argrepr='0', offset=114, starts_line=None, is_jump_target=False),
+ Instruction(opname='BINARY_TRUE_DIVIDE', opcode=27, arg=None, argval=None, argrepr='', offset=116, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=118, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_BLOCK', opcode=87, arg=None, argval=None, argrepr='', offset=120, starts_line=None, is_jump_target=False),
+ Instruction(opname='JUMP_FORWARD', opcode=110, arg=28, argval=152, argrepr='to 152', offset=122, starts_line=None, is_jump_target=False),
+ Instruction(opname='DUP_TOP', opcode=4, arg=None, argval=None, argrepr='', offset=124, starts_line=22, is_jump_target=True),
+ Instruction(opname='LOAD_GLOBAL', opcode=116, arg=2, argval='ZeroDivisionError', argrepr='ZeroDivisionError', offset=126, starts_line=None, is_jump_target=False),
+ Instruction(opname='COMPARE_OP', opcode=107, arg=10, argval='exception match', argrepr='exception match', offset=128, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_JUMP_IF_FALSE', opcode=114, arg=150, argval=150, argrepr='', offset=130, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=132, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=134, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=136, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=138, starts_line=23, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=8, argval='Here we go, here we go, here we go...', argrepr="'Here we go, here we go, here we go...'", offset=140, starts_line=None, is_jump_target=False),
+ Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='1 positional, 0 keyword pair', offset=142, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=144, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_EXCEPT', opcode=89, arg=None, argval=None, argrepr='', offset=146, starts_line=None, is_jump_target=False),
+ Instruction(opname='JUMP_FORWARD', opcode=110, arg=26, argval=176, argrepr='to 176', offset=148, starts_line=None, is_jump_target=False),
+ Instruction(opname='END_FINALLY', opcode=88, arg=None, argval=None, argrepr='', offset=150, starts_line=None, is_jump_target=True),
+ Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='i', argrepr='i', offset=152, starts_line=25, is_jump_target=True),
+ Instruction(opname='SETUP_WITH', opcode=143, arg=14, argval=170, argrepr='to 170', offset=154, starts_line=None, is_jump_target=False),
+ Instruction(opname='STORE_FAST', opcode=125, arg=1, argval='dodgy', argrepr='dodgy', offset=156, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=158, starts_line=26, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=9, argval='Never reach this', argrepr="'Never reach this'", offset=160, starts_line=None, is_jump_target=False),
+ Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='1 positional, 0 keyword pair', offset=162, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=164, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_BLOCK', opcode=87, arg=None, argval=None, argrepr='', offset=166, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=168, starts_line=None, is_jump_target=False),
+ Instruction(opname='WITH_CLEANUP_START', opcode=81, arg=None, argval=None, argrepr='', offset=170, starts_line=None, is_jump_target=True),
+ Instruction(opname='WITH_CLEANUP_FINISH', opcode=82, arg=None, argval=None, argrepr='', offset=172, starts_line=None, is_jump_target=False),
+ Instruction(opname='END_FINALLY', opcode=88, arg=None, argval=None, argrepr='', offset=174, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_BLOCK', opcode=87, arg=None, argval=None, argrepr='', offset=176, starts_line=None, is_jump_target=True),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=178, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_GLOBAL', opcode=116, arg=1, argval='print', argrepr='print', offset=180, starts_line=28, is_jump_target=True),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=182, starts_line=None, is_jump_target=False),
+ Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='1 positional, 0 keyword pair', offset=184, starts_line=None, is_jump_target=False),
+ Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=186, starts_line=None, is_jump_target=False),
+ Instruction(opname='END_FINALLY', opcode=88, arg=None, argval=None, argrepr='', offset=188, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=190, starts_line=None, is_jump_target=False),
+ Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=192, starts_line=None, is_jump_target=False),
]
# One last piece of inspect fodder to check the default line number handling
def simple(): pass
expected_opinfo_simple = [
Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=0, starts_line=simple.__code__.co_firstlineno, is_jump_target=False),
- Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=3, starts_line=None, is_jump_target=False)
+ Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=2, starts_line=None, is_jump_target=False)
]
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index 33163b9..b416cbb 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -1876,7 +1876,6 @@
To demonstrate this, we'll create a fake standard input that
captures our debugger input:
- >>> import tempfile
>>> real_stdin = sys.stdin
>>> sys.stdin = _FakeInput([
... 'print(x)', # print data defined by the example
@@ -1917,7 +1916,7 @@
... finally:
... sys.stdin = real_stdin
--Return--
- > <doctest test.test_doctest.test_pdb_set_trace[8]>(3)calls_set_trace()->None
+ > <doctest test.test_doctest.test_pdb_set_trace[7]>(3)calls_set_trace()->None
-> import pdb; pdb.set_trace()
(Pdb) print(y)
2
@@ -2339,7 +2338,7 @@
`__file__` global, which is set to the name of the file
containing the tests:
- >>> suite = doctest.DocFileSuite('test_doctest3.txt')
+ >>> suite = doctest.DocFileSuite('test_doctest3.txt', optionflags=doctest.ELLIPSIS)
>>> suite.run(unittest.TestResult())
<unittest.result.TestResult run=1 errors=0 failures=0>
@@ -2798,7 +2797,6 @@
... _ = f.write(" 'abc def'\n")
... _ = f.write("\n")
... _ = f.write(' \"\"\"\n')
- ... import shutil
... rc1, out1, err1 = script_helper.assert_python_failure(
... '-m', 'doctest', fn, fn2)
... rc2, out2, err2 = script_helper.assert_python_ok(
@@ -2942,12 +2940,11 @@
def test_main():
# Check the doctest cases in doctest itself:
ret = support.run_doctest(doctest, verbosity=True)
+
# Check the doctest cases defined here:
from test import test_doctest
support.run_doctest(test_doctest, verbosity=True)
-import sys, re, io
-
def test_coverage(coverdir):
trace = support.import_module('trace')
tracer = trace.Trace(ignoredirs=[sys.base_prefix, sys.base_exec_prefix,],
diff --git a/Lib/test/test_doctest3.txt b/Lib/test/test_doctest3.txt
index dd8557e..380ea76 100644
--- a/Lib/test/test_doctest3.txt
+++ b/Lib/test/test_doctest3.txt
@@ -2,4 +2,4 @@
Here we check that `__file__` is provided:
>>> type(__file__)
- <class 'str'>
+ <class 'str' ...>
diff --git a/Lib/test/test_dynamic.py b/Lib/test/test_dynamic.py
index 5080ec9..3ae090f 100644
--- a/Lib/test/test_dynamic.py
+++ b/Lib/test/test_dynamic.py
@@ -1,7 +1,6 @@
# Test the most dynamic corner cases of Python's runtime semantics.
import builtins
-import contextlib
import unittest
from test.support import swap_item, swap_attr
diff --git a/Lib/test/test_eintr.py b/Lib/test/test_eintr.py
index aabad83..25f86d3 100644
--- a/Lib/test/test_eintr.py
+++ b/Lib/test/test_eintr.py
@@ -1,7 +1,5 @@
import os
import signal
-import subprocess
-import sys
import unittest
from test import support
@@ -16,14 +14,8 @@
# Run the tester in a sub-process, to make sure there is only one
# thread (for reliable signal delivery).
tester = support.findfile("eintr_tester.py", subdir="eintrdata")
-
- if support.verbose:
- args = [sys.executable, tester]
- with subprocess.Popen(args) as proc:
- exitcode = proc.wait()
- self.assertEqual(exitcode, 0)
- else:
- script_helper.assert_python_ok(tester)
+ # use -u to try to get the full output if the test hangs or crash
+ script_helper.assert_python_ok("-u", tester)
if __name__ == "__main__":
diff --git a/Lib/test/test_email/__init__.py b/Lib/test/test_email/__init__.py
index d2f7d31..1600159 100644
--- a/Lib/test/test_email/__init__.py
+++ b/Lib/test/test_email/__init__.py
@@ -1,5 +1,4 @@
import os
-import sys
import unittest
import collections
import email
diff --git a/Lib/test/test_email/test_asian_codecs.py b/Lib/test/test_email/test_asian_codecs.py
index f9cd7d9..1e0caee 100644
--- a/Lib/test/test_email/test_asian_codecs.py
+++ b/Lib/test/test_email/test_asian_codecs.py
@@ -3,7 +3,6 @@
# email package unit tests for (optional) Asian codecs
import unittest
-from test.support import run_unittest
from test.test_email import TestEmailBase
from email.charset import Charset
diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py
index 894b800..af3fb85 100644
--- a/Lib/test/test_email/test_email.py
+++ b/Lib/test/test_email/test_email.py
@@ -3421,7 +3421,6 @@
class TestFeedParsers(TestEmailBase):
def parse(self, chunks):
- from email.feedparser import FeedParser
feedparser = FeedParser()
for chunk in chunks:
feedparser.feed(chunk)
diff --git a/Lib/test/test_email/test_headerregistry.py b/Lib/test/test_email/test_headerregistry.py
index 55ecdea..af836dc 100644
--- a/Lib/test/test_email/test_headerregistry.py
+++ b/Lib/test/test_email/test_headerregistry.py
@@ -1,7 +1,6 @@
import datetime
import textwrap
import unittest
-import types
from email import errors
from email import policy
from email.message import Message
diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py
index e970a26..b1a5855 100644
--- a/Lib/test/test_enum.py
+++ b/Lib/test/test_enum.py
@@ -6,6 +6,7 @@
from enum import Enum, IntEnum, EnumMeta, unique
from io import StringIO
from pickle import dumps, loads, PicklingError, HIGHEST_PROTOCOL
+from test import support
# for pickle tests
try:
@@ -283,6 +284,28 @@
class Wrong(Enum):
_any_name_ = 9
+ def test_bool(self):
+ # plain Enum members are always True
+ class Logic(Enum):
+ true = True
+ false = False
+ self.assertTrue(Logic.true)
+ self.assertTrue(Logic.false)
+ # unless overridden
+ class RealLogic(Enum):
+ true = True
+ false = False
+ def __bool__(self):
+ return bool(self._value_)
+ self.assertTrue(RealLogic.true)
+ self.assertFalse(RealLogic.false)
+ # mixed Enums depend on mixed-in type
+ class IntLogic(int, Enum):
+ true = 1
+ false = 0
+ self.assertTrue(IntLogic.true)
+ self.assertFalse(IntLogic.false)
+
def test_contains(self):
Season = self.Season
self.assertIn(Season.AUTUMN, Season)
@@ -1739,5 +1762,47 @@
if failed:
self.fail("result does not equal expected, see print above")
+
+class MiscTestCase(unittest.TestCase):
+ def test__all__(self):
+ support.check__all__(self, enum)
+
+
+# These are unordered here on purpose to ensure that declaration order
+# makes no difference.
+CONVERT_TEST_NAME_D = 5
+CONVERT_TEST_NAME_C = 5
+CONVERT_TEST_NAME_B = 5
+CONVERT_TEST_NAME_A = 5 # This one should sort first.
+CONVERT_TEST_NAME_E = 5
+CONVERT_TEST_NAME_F = 5
+
+class TestIntEnumConvert(unittest.TestCase):
+ def test_convert_value_lookup_priority(self):
+ test_type = enum.IntEnum._convert(
+ 'UnittestConvert', 'test.test_enum',
+ filter=lambda x: x.startswith('CONVERT_TEST_'))
+ # We don't want the reverse lookup value to vary when there are
+ # multiple possible names for a given value. It should always
+ # report the first lexigraphical name in that case.
+ self.assertEqual(test_type(5).name, 'CONVERT_TEST_NAME_A')
+
+ def test_convert(self):
+ test_type = enum.IntEnum._convert(
+ 'UnittestConvert', 'test.test_enum',
+ filter=lambda x: x.startswith('CONVERT_TEST_'))
+ # Ensure that test_type has all of the desired names and values.
+ self.assertEqual(test_type.CONVERT_TEST_NAME_F,
+ test_type.CONVERT_TEST_NAME_A)
+ self.assertEqual(test_type.CONVERT_TEST_NAME_B, 5)
+ self.assertEqual(test_type.CONVERT_TEST_NAME_C, 5)
+ self.assertEqual(test_type.CONVERT_TEST_NAME_D, 5)
+ self.assertEqual(test_type.CONVERT_TEST_NAME_E, 5)
+ # Ensure that test_type only picked up names matching the filter.
+ self.assertEqual([name for name in dir(test_type)
+ if name[0:2] not in ('CO', '__')],
+ [], msg='Names other than CONVERT_TEST_* found.')
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/test/test_epoll.py b/Lib/test/test_epoll.py
index a7359e9..a7aff8a 100644
--- a/Lib/test/test_epoll.py
+++ b/Lib/test/test_epoll.py
@@ -28,7 +28,6 @@
import time
import unittest
-from test import support
if not hasattr(select, "epoll"):
raise unittest.SkipTest("test works only on Linux 2.6")
diff --git a/Lib/test/test_faulthandler.py b/Lib/test/test_faulthandler.py
index 1562eec..fc2d6d7 100644
--- a/Lib/test/test_faulthandler.py
+++ b/Lib/test/test_faulthandler.py
@@ -23,6 +23,7 @@
_testcapi = None
TIMEOUT = 0.5
+MS_WINDOWS = (os.name == 'nt')
def expected_traceback(lineno1, lineno2, header, min_count=1):
regex = header
@@ -58,8 +59,9 @@
pass_fds.append(fd)
with support.SuppressCrashReport():
process = script_helper.spawn_python('-c', code, pass_fds=pass_fds)
- stdout, stderr = process.communicate()
- exitcode = process.wait()
+ with process:
+ stdout, stderr = process.communicate()
+ exitcode = process.wait()
output = support.strip_python_stderr(stdout)
output = output.decode('ascii', 'backslashreplace')
if filename:
@@ -73,14 +75,11 @@
with open(fd, "rb", closefd=False) as fp:
output = fp.read()
output = output.decode('ascii', 'backslashreplace')
- output = re.sub('Current thread 0x[0-9a-f]+',
- 'Current thread XXX',
- output)
return output.splitlines(), exitcode
- def check_fatal_error(self, code, line_number, name_regex,
- filename=None, all_threads=True, other_regex=None,
- fd=None):
+ def check_error(self, code, line_number, fatal_error, *,
+ filename=None, all_threads=True, other_regex=None,
+ fd=None, know_current_thread=True):
"""
Check that the fault handler for fatal errors is enabled and check the
traceback from the child process output.
@@ -88,19 +87,22 @@
Raise an error if the output doesn't match the expected format.
"""
if all_threads:
- header = 'Current thread XXX (most recent call first)'
+ if know_current_thread:
+ header = 'Current thread 0x[0-9a-f]+'
+ else:
+ header = 'Thread 0x[0-9a-f]+'
else:
- header = 'Stack (most recent call first)'
+ header = 'Stack'
regex = """
- ^Fatal Python error: {name}
+ ^{fatal_error}
- {header}:
+ {header} \(most recent call first\):
File "<string>", line {lineno} in <module>
"""
regex = dedent(regex.format(
lineno=line_number,
- name=name_regex,
- header=re.escape(header))).strip()
+ fatal_error=fatal_error,
+ header=header)).strip()
if other_regex:
regex += '|' + other_regex
output, exitcode = self.get_output(code, filename=filename, fd=fd)
@@ -108,17 +110,36 @@
self.assertRegex(output, regex)
self.assertNotEqual(exitcode, 0)
+ def check_fatal_error(self, code, line_number, name_regex, **kw):
+ fatal_error = 'Fatal Python error: %s' % name_regex
+ self.check_error(code, line_number, fatal_error, **kw)
+
+ def check_windows_exception(self, code, line_number, name_regex, **kw):
+ fatal_error = 'Windows fatal exception: %s' % name_regex
+ self.check_error(code, line_number, fatal_error, **kw)
+
@unittest.skipIf(sys.platform.startswith('aix'),
"the first page of memory is a mapped read-only on AIX")
def test_read_null(self):
- self.check_fatal_error("""
- import faulthandler
- faulthandler.enable()
- faulthandler._read_null()
- """,
- 3,
- # Issue #12700: Read NULL raises SIGILL on Mac OS X Lion
- '(?:Segmentation fault|Bus error|Illegal instruction)')
+ if not MS_WINDOWS:
+ self.check_fatal_error("""
+ import faulthandler
+ faulthandler.enable()
+ faulthandler._read_null()
+ """,
+ 3,
+ # Issue #12700: Read NULL raises SIGILL on Mac OS X Lion
+ '(?:Segmentation fault'
+ '|Bus error'
+ '|Illegal instruction)')
+ else:
+ self.check_windows_exception("""
+ import faulthandler
+ faulthandler.enable()
+ faulthandler._read_null()
+ """,
+ 3,
+ 'access violation')
def test_sigsegv(self):
self.check_fatal_error("""
@@ -129,6 +150,17 @@
3,
'Segmentation fault')
+ @unittest.skipIf(not HAVE_THREADS, 'need threads')
+ def test_fatal_error_c_thread(self):
+ self.check_fatal_error("""
+ import faulthandler
+ faulthandler.enable()
+ faulthandler._fatal_error_c_thread()
+ """,
+ 3,
+ 'in new thread',
+ know_current_thread=False)
+
def test_sigabrt(self):
self.check_fatal_error("""
import faulthandler
@@ -465,7 +497,7 @@
File ".*threading.py", line [0-9]+ in _bootstrap_inner
File ".*threading.py", line [0-9]+ in _bootstrap
- Current thread XXX \(most recent call first\):
+ Current thread 0x[0-9a-f]+ \(most recent call first\):
File "<string>", line {lineno} in dump
File "<string>", line 28 in <module>$
"""
@@ -637,7 +669,7 @@
trace = '\n'.join(trace)
if not unregister:
if all_threads:
- regex = 'Current thread XXX \(most recent call first\):\n'
+ regex = 'Current thread 0x[0-9a-f]+ \(most recent call first\):\n'
else:
regex = 'Stack \(most recent call first\):\n'
regex = expected_traceback(14, 32, regex)
@@ -696,6 +728,22 @@
with self.check_stderr_none():
faulthandler.register(signal.SIGUSR1)
+ @unittest.skipUnless(MS_WINDOWS, 'specific to Windows')
+ def test_raise_exception(self):
+ for exc, name in (
+ ('EXCEPTION_ACCESS_VIOLATION', 'access violation'),
+ ('EXCEPTION_INT_DIVIDE_BY_ZERO', 'int divide by zero'),
+ ('EXCEPTION_STACK_OVERFLOW', 'stack overflow'),
+ ):
+ self.check_windows_exception(f"""
+ import faulthandler
+ faulthandler.enable()
+ faulthandler._raise_exception(faulthandler._{exc})
+ """,
+ 3,
+ name)
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py
index 4e392b7..65be30f 100644
--- a/Lib/test/test_file.py
+++ b/Lib/test/test_file.py
@@ -7,7 +7,7 @@
import io
import _pyio as pyio
-from test.support import TESTFN, run_unittest
+from test.support import TESTFN
from collections import UserList
class AutoFileTests:
@@ -139,7 +139,7 @@
def testModeStrings(self):
# check invalid mode strings
- for mode in ("", "aU", "wU+"):
+ for mode in ("", "aU", "wU+", "U+", "+U", "rU+"):
try:
f = self.open(TESTFN, mode)
except ValueError:
diff --git a/Lib/test/test_fileinput.py b/Lib/test/test_fileinput.py
index 784bc92..565633f 100644
--- a/Lib/test/test_fileinput.py
+++ b/Lib/test/test_fileinput.py
@@ -22,8 +22,9 @@
from io import BytesIO, StringIO
from fileinput import FileInput, hook_encoded
-from test.support import verbose, TESTFN, run_unittest, check_warnings
+from test.support import verbose, TESTFN, check_warnings
from test.support import unlink as safe_unlink
+from test import support
from unittest import mock
@@ -92,7 +93,11 @@
t2 = writeTmp(2, ["Line %s of file 2\n" % (i+1) for i in range(10)])
t3 = writeTmp(3, ["Line %s of file 3\n" % (i+1) for i in range(5)])
t4 = writeTmp(4, ["Line %s of file 4\n" % (i+1) for i in range(1)])
- self.buffer_size_test(t1, t2, t3, t4, bs, round)
+ if bs:
+ with self.assertWarns(DeprecationWarning):
+ self.buffer_size_test(t1, t2, t3, t4, bs, round)
+ else:
+ self.buffer_size_test(t1, t2, t3, t4, bs, round)
finally:
remove_tempfiles(t1, t2, t3, t4)
@@ -940,7 +945,8 @@
def test(self):
encoding = object()
- result = fileinput.hook_encoded(encoding)
+ errors = object()
+ result = fileinput.hook_encoded(encoding, errors=errors)
fake_open = InvocationRecorder()
original_open = builtins.open
@@ -958,8 +964,26 @@
self.assertIs(args[0], filename)
self.assertIs(args[1], mode)
self.assertIs(kwargs.pop('encoding'), encoding)
+ self.assertIs(kwargs.pop('errors'), errors)
self.assertFalse(kwargs)
+ def test_errors(self):
+ with open(TESTFN, 'wb') as f:
+ f.write(b'\x80abc')
+ self.addCleanup(safe_unlink, TESTFN)
+
+ def check(errors, expected_lines):
+ with FileInput(files=TESTFN, mode='r',
+ openhook=hook_encoded('utf-8', errors=errors)) as fi:
+ lines = list(fi)
+ self.assertEqual(lines, expected_lines)
+
+ check('ignore', ['abc'])
+ with self.assertRaises(UnicodeDecodeError):
+ check('strict', ['abc'])
+ check('replace', ['\ufffdabc'])
+ check('backslashreplace', ['\\x80abc'])
+
def test_modes(self):
with open(TESTFN, 'wb') as f:
# UTF-7 is a convenient, seldom used encoding
@@ -981,5 +1005,11 @@
check('rb', ['A\n', 'B\r\n', 'C\r', 'D\u20ac'])
+class MiscTest(unittest.TestCase):
+
+ def test_all(self):
+ support.check__all__(self, fileinput)
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py
index cb1f6db..68b212e 100644
--- a/Lib/test/test_float.py
+++ b/Lib/test/test_float.py
@@ -1,6 +1,5 @@
import fractions
-import math
import operator
import os
import random
@@ -162,11 +161,12 @@
def __float__(self):
return float(str(self)) + 1
- self.assertAlmostEqual(float(Foo1()), 42.)
- self.assertAlmostEqual(float(Foo2()), 42.)
- self.assertAlmostEqual(float(Foo3(21)), 42.)
+ self.assertEqual(float(Foo1()), 42.)
+ self.assertEqual(float(Foo2()), 42.)
+ with self.assertWarns(DeprecationWarning):
+ self.assertEqual(float(Foo3(21)), 42.)
self.assertRaises(TypeError, float, Foo4(42))
- self.assertAlmostEqual(float(FooStr('8')), 9.)
+ self.assertEqual(float(FooStr('8')), 9.)
class Foo5:
def __float__(self):
@@ -177,10 +177,14 @@
class F:
def __float__(self):
return OtherFloatSubclass(42.)
- self.assertAlmostEqual(float(F()), 42.)
- self.assertIs(type(float(F())), OtherFloatSubclass)
- self.assertAlmostEqual(FloatSubclass(F()), 42.)
- self.assertIs(type(FloatSubclass(F())), FloatSubclass)
+ with self.assertWarns(DeprecationWarning):
+ self.assertEqual(float(F()), 42.)
+ with self.assertWarns(DeprecationWarning):
+ self.assertIs(type(float(F())), float)
+ with self.assertWarns(DeprecationWarning):
+ self.assertEqual(FloatSubclass(F()), 42.)
+ with self.assertWarns(DeprecationWarning):
+ self.assertIs(type(FloatSubclass(F())), FloatSubclass)
def test_is_integer(self):
self.assertFalse((1.1).is_integer())
diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py
index 9b13632..8afd5b8 100644
--- a/Lib/test/test_format.py
+++ b/Lib/test/test_format.py
@@ -274,7 +274,7 @@
test_exc('%d', '1', TypeError, "%d format: a number is required, not str")
test_exc('%x', '1', TypeError, "%x format: an integer is required, not str")
test_exc('%x', 3.14, TypeError, "%x format: an integer is required, not float")
- test_exc('%g', '1', TypeError, "a float is required")
+ test_exc('%g', '1', TypeError, "must be real number, not str")
test_exc('no format', '1', TypeError,
"not all arguments converted during string formatting")
test_exc('%c', -1, OverflowError, "%c arg not in range(0x110000)")
@@ -300,6 +300,8 @@
testcommon(b"%c", 7, b"\x07")
testcommon(b"%c", b"Z", b"Z")
testcommon(b"%c", bytearray(b"Z"), b"Z")
+ testcommon(b"%5c", 65, b" A")
+ testcommon(b"%-5c", 65, b"A ")
# %b will insert a series of bytes, either from a type that supports
# the Py_buffer protocol, or something that has a __bytes__ method
class FakeBytes(object):
diff --git a/Lib/test/test_fractions.py b/Lib/test/test_fractions.py
index 1699852..73d2dd3 100644
--- a/Lib/test/test_fractions.py
+++ b/Lib/test/test_fractions.py
@@ -263,13 +263,13 @@
nan = inf - inf
# bug 16469: error types should be consistent with float -> int
self.assertRaisesMessage(
- OverflowError, "Cannot convert inf to Fraction.",
+ OverflowError, "cannot convert Infinity to integer ratio",
F.from_float, inf)
self.assertRaisesMessage(
- OverflowError, "Cannot convert -inf to Fraction.",
+ OverflowError, "cannot convert Infinity to integer ratio",
F.from_float, -inf)
self.assertRaisesMessage(
- ValueError, "Cannot convert nan to Fraction.",
+ ValueError, "cannot convert NaN to integer ratio",
F.from_float, nan)
def testFromDecimal(self):
@@ -284,16 +284,16 @@
# bug 16469: error types should be consistent with decimal -> int
self.assertRaisesMessage(
- OverflowError, "Cannot convert Infinity to Fraction.",
+ OverflowError, "cannot convert Infinity to integer ratio",
F.from_decimal, Decimal("inf"))
self.assertRaisesMessage(
- OverflowError, "Cannot convert -Infinity to Fraction.",
+ OverflowError, "cannot convert Infinity to integer ratio",
F.from_decimal, Decimal("-inf"))
self.assertRaisesMessage(
- ValueError, "Cannot convert NaN to Fraction.",
+ ValueError, "cannot convert NaN to integer ratio",
F.from_decimal, Decimal("nan"))
self.assertRaisesMessage(
- ValueError, "Cannot convert sNaN to Fraction.",
+ ValueError, "cannot convert NaN to integer ratio",
F.from_decimal, Decimal("snan"))
def testLimitDenominator(self):
diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py
new file mode 100644
index 0000000..a82dedf
--- /dev/null
+++ b/Lib/test/test_fstring.py
@@ -0,0 +1,745 @@
+import ast
+import types
+import decimal
+import unittest
+
+a_global = 'global variable'
+
+# You could argue that I'm too strict in looking for specific error
+# values with assertRaisesRegex, but without it it's way too easy to
+# make a syntax error in the test strings. Especially with all of the
+# triple quotes, raw strings, backslashes, etc. I think it's a
+# worthwhile tradeoff. When I switched to this method, I found many
+# examples where I wasn't testing what I thought I was.
+
+class TestCase(unittest.TestCase):
+ def assertAllRaise(self, exception_type, regex, error_strings):
+ for str in error_strings:
+ with self.subTest(str=str):
+ with self.assertRaisesRegex(exception_type, regex):
+ eval(str)
+
+ def test__format__lookup(self):
+ # Make sure __format__ is looked up on the type, not the instance.
+ class X:
+ def __format__(self, spec):
+ return 'class'
+
+ x = X()
+
+ # Add a bound __format__ method to the 'y' instance, but not
+ # the 'x' instance.
+ y = X()
+ y.__format__ = types.MethodType(lambda self, spec: 'instance', y)
+
+ self.assertEqual(f'{y}', format(y))
+ self.assertEqual(f'{y}', 'class')
+ self.assertEqual(format(x), format(y))
+
+ # __format__ is not called this way, but still make sure it
+ # returns what we expect (so we can make sure we're bypassing
+ # it).
+ self.assertEqual(x.__format__(''), 'class')
+ self.assertEqual(y.__format__(''), 'instance')
+
+ # This is how __format__ is actually called.
+ self.assertEqual(type(x).__format__(x, ''), 'class')
+ self.assertEqual(type(y).__format__(y, ''), 'class')
+
+ def test_ast(self):
+ # Inspired by http://bugs.python.org/issue24975
+ class X:
+ def __init__(self):
+ self.called = False
+ def __call__(self):
+ self.called = True
+ return 4
+ x = X()
+ expr = """
+a = 10
+f'{a * x()}'"""
+ t = ast.parse(expr)
+ c = compile(t, '', 'exec')
+
+ # Make sure x was not called.
+ self.assertFalse(x.called)
+
+ # Actually run the code.
+ exec(c)
+
+ # Make sure x was called.
+ self.assertTrue(x.called)
+
+ def test_literal_eval(self):
+ # With no expressions, an f-string is okay.
+ self.assertEqual(ast.literal_eval("f'x'"), 'x')
+ self.assertEqual(ast.literal_eval("f'x' 'y'"), 'xy')
+
+ # But this should raise an error.
+ with self.assertRaisesRegex(ValueError, 'malformed node or string'):
+ ast.literal_eval("f'x{3}'")
+
+ # As should this, which uses a different ast node
+ with self.assertRaisesRegex(ValueError, 'malformed node or string'):
+ ast.literal_eval("f'{3}'")
+
+ def test_ast_compile_time_concat(self):
+ x = ['']
+
+ expr = """x[0] = 'foo' f'{3}'"""
+ t = ast.parse(expr)
+ c = compile(t, '', 'exec')
+ exec(c)
+ self.assertEqual(x[0], 'foo3')
+
+ def test_literal(self):
+ self.assertEqual(f'', '')
+ self.assertEqual(f'a', 'a')
+ self.assertEqual(f' ', ' ')
+ self.assertEqual(f'\N{GREEK CAPITAL LETTER DELTA}',
+ '\N{GREEK CAPITAL LETTER DELTA}')
+ self.assertEqual(f'\N{GREEK CAPITAL LETTER DELTA}',
+ '\u0394')
+ self.assertEqual(f'\N{True}', '\u22a8')
+ self.assertEqual(rf'\N{True}', r'\NTrue')
+
+ def test_escape_order(self):
+ # note that hex(ord('{')) == 0x7b, so this
+ # string becomes f'a{4*10}b'
+ self.assertEqual(f'a\u007b4*10}b', 'a40b')
+ self.assertEqual(f'a\x7b4*10}b', 'a40b')
+ self.assertEqual(f'a\x7b4*10\N{RIGHT CURLY BRACKET}b', 'a40b')
+ self.assertEqual(f'{"a"!\N{LATIN SMALL LETTER R}}', "'a'")
+ self.assertEqual(f'{10\x3a02X}', '0A')
+ self.assertEqual(f'{10:02\N{LATIN CAPITAL LETTER X}}', '0A')
+
+ self.assertAllRaise(SyntaxError, "f-string: single '}' is not allowed",
+ [r"""f'a{\u007b4*10}b'""", # mis-matched brackets
+ ])
+ self.assertAllRaise(SyntaxError, 'unexpected character after line continuation character',
+ [r"""f'{"a"\!r}'""",
+ r"""f'{a\!r}'""",
+ ])
+
+ def test_unterminated_string(self):
+ self.assertAllRaise(SyntaxError, 'f-string: unterminated string',
+ [r"""f'{"x'""",
+ r"""f'{"x}'""",
+ r"""f'{("x'""",
+ r"""f'{("x}'""",
+ ])
+
+ def test_mismatched_parens(self):
+ self.assertAllRaise(SyntaxError, 'f-string: mismatched',
+ ["f'{((}'",
+ ])
+
+ def test_double_braces(self):
+ self.assertEqual(f'{{', '{')
+ self.assertEqual(f'a{{', 'a{')
+ self.assertEqual(f'{{b', '{b')
+ self.assertEqual(f'a{{b', 'a{b')
+ self.assertEqual(f'}}', '}')
+ self.assertEqual(f'a}}', 'a}')
+ self.assertEqual(f'}}b', '}b')
+ self.assertEqual(f'a}}b', 'a}b')
+
+ self.assertEqual(f'{{{10}', '{10')
+ self.assertEqual(f'}}{10}', '}10')
+ self.assertEqual(f'}}{{{10}', '}{10')
+ self.assertEqual(f'}}a{{{10}', '}a{10')
+
+ self.assertEqual(f'{10}{{', '10{')
+ self.assertEqual(f'{10}}}', '10}')
+ self.assertEqual(f'{10}}}{{', '10}{')
+ self.assertEqual(f'{10}}}a{{' '}', '10}a{}')
+
+ # Inside of strings, don't interpret doubled brackets.
+ self.assertEqual(f'{"{{}}"}', '{{}}')
+
+ self.assertAllRaise(TypeError, 'unhashable type',
+ ["f'{ {{}} }'", # dict in a set
+ ])
+
+ def test_compile_time_concat(self):
+ x = 'def'
+ self.assertEqual('abc' f'## {x}ghi', 'abc## defghi')
+ self.assertEqual('abc' f'{x}' 'ghi', 'abcdefghi')
+ self.assertEqual('abc' f'{x}' 'gh' f'i{x:4}', 'abcdefghidef ')
+ self.assertEqual('{x}' f'{x}', '{x}def')
+ self.assertEqual('{x' f'{x}', '{xdef')
+ self.assertEqual('{x}' f'{x}', '{x}def')
+ self.assertEqual('{{x}}' f'{x}', '{{x}}def')
+ self.assertEqual('{{x' f'{x}', '{{xdef')
+ self.assertEqual('x}}' f'{x}', 'x}}def')
+ self.assertEqual(f'{x}' 'x}}', 'defx}}')
+ self.assertEqual(f'{x}' '', 'def')
+ self.assertEqual('' f'{x}' '', 'def')
+ self.assertEqual('' f'{x}', 'def')
+ self.assertEqual(f'{x}' '2', 'def2')
+ self.assertEqual('1' f'{x}' '2', '1def2')
+ self.assertEqual('1' f'{x}', '1def')
+ self.assertEqual(f'{x}' f'-{x}', 'def-def')
+ self.assertEqual('' f'', '')
+ self.assertEqual('' f'' '', '')
+ self.assertEqual('' f'' '' f'', '')
+ self.assertEqual(f'', '')
+ self.assertEqual(f'' '', '')
+ self.assertEqual(f'' '' f'', '')
+ self.assertEqual(f'' '' f'' '', '')
+
+ self.assertAllRaise(SyntaxError, "f-string: expecting '}'",
+ ["f'{3' f'}'", # can't concat to get a valid f-string
+ ])
+
+ def test_comments(self):
+ # These aren't comments, since they're in strings.
+ d = {'#': 'hash'}
+ self.assertEqual(f'{"#"}', '#')
+ self.assertEqual(f'{d["#"]}', 'hash')
+
+ self.assertAllRaise(SyntaxError, "f-string cannot include '#'",
+ ["f'{1#}'", # error because the expression becomes "(1#)"
+ "f'{3(#)}'",
+ ])
+
+ def test_many_expressions(self):
+ # Create a string with many expressions in it. Note that
+ # because we have a space in here as a literal, we're actually
+ # going to use twice as many ast nodes: one for each literal
+ # plus one for each expression.
+ def build_fstr(n, extra=''):
+ return "f'" + ('{x} ' * n) + extra + "'"
+
+ x = 'X'
+ width = 1
+
+ # Test around 256.
+ for i in range(250, 260):
+ self.assertEqual(eval(build_fstr(i)), (x+' ')*i)
+
+ # Test concatenating 2 largs fstrings.
+ self.assertEqual(eval(build_fstr(255)*256), (x+' ')*(255*256))
+
+ s = build_fstr(253, '{x:{width}} ')
+ self.assertEqual(eval(s), (x+' ')*254)
+
+ # Test lots of expressions and constants, concatenated.
+ s = "f'{1}' 'x' 'y'" * 1024
+ self.assertEqual(eval(s), '1xy' * 1024)
+
+ def test_format_specifier_expressions(self):
+ width = 10
+ precision = 4
+ value = decimal.Decimal('12.34567')
+ self.assertEqual(f'result: {value:{width}.{precision}}', 'result: 12.35')
+ self.assertEqual(f'result: {value:{width!r}.{precision}}', 'result: 12.35')
+ self.assertEqual(f'result: {value:{width:0}.{precision:1}}', 'result: 12.35')
+ self.assertEqual(f'result: {value:{1}{0:0}.{precision:1}}', 'result: 12.35')
+ self.assertEqual(f'result: {value:{ 1}{ 0:0}.{ precision:1}}', 'result: 12.35')
+ self.assertEqual(f'{10:#{1}0x}', ' 0xa')
+ self.assertEqual(f'{10:{"#"}1{0}{"x"}}', ' 0xa')
+ self.assertEqual(f'{-10:-{"#"}1{0}x}', ' -0xa')
+ self.assertEqual(f'{-10:{"-"}#{1}0{"x"}}', ' -0xa')
+ self.assertEqual(f'{10:#{3 != {4:5} and width}x}', ' 0xa')
+
+ self.assertAllRaise(SyntaxError, "f-string: expecting '}'",
+ ["""f'{"s"!r{":10"}}'""",
+
+ # This looks like a nested format spec.
+ ])
+
+ self.assertAllRaise(SyntaxError, "invalid syntax",
+ [# Invalid sytax inside a nested spec.
+ "f'{4:{/5}}'",
+ ])
+
+ self.assertAllRaise(SyntaxError, "f-string: expressions nested too deeply",
+ [# Can't nest format specifiers.
+ "f'result: {value:{width:{0}}.{precision:1}}'",
+ ])
+
+ self.assertAllRaise(SyntaxError, 'f-string: invalid conversion character',
+ [# No expansion inside conversion or for
+ # the : or ! itself.
+ """f'{"s"!{"r"}}'""",
+ ])
+
+ def test_side_effect_order(self):
+ class X:
+ def __init__(self):
+ self.i = 0
+ def __format__(self, spec):
+ self.i += 1
+ return str(self.i)
+
+ x = X()
+ self.assertEqual(f'{x} {x}', '1 2')
+
+ def test_missing_expression(self):
+ self.assertAllRaise(SyntaxError, 'f-string: empty expression not allowed',
+ ["f'{}'",
+ "f'{ }'"
+ "f' {} '",
+ "f'{!r}'",
+ "f'{ !r}'",
+ "f'{10:{ }}'",
+ "f' { } '",
+ r"f'{\n}'",
+ r"f'{\n \n}'",
+
+ # Catch the empty expression before the
+ # invalid conversion.
+ "f'{!x}'",
+ "f'{ !xr}'",
+ "f'{!x:}'",
+ "f'{!x:a}'",
+ "f'{ !xr:}'",
+ "f'{ !xr:a}'",
+
+ "f'{!}'",
+ "f'{:}'",
+
+ # We find the empty expression before the
+ # missing closing brace.
+ "f'{!'",
+ "f'{!s:'",
+ "f'{:'",
+ "f'{:x'",
+ ])
+
+ def test_parens_in_expressions(self):
+ self.assertEqual(f'{3,}', '(3,)')
+
+ # Add these because when an expression is evaluated, parens
+ # are added around it. But we shouldn't go from an invalid
+ # expression to a valid one. The added parens are just
+ # supposed to allow whitespace (including newlines).
+ self.assertAllRaise(SyntaxError, 'invalid syntax',
+ ["f'{,}'",
+ "f'{,}'", # this is (,), which is an error
+ ])
+
+ self.assertAllRaise(SyntaxError, "f-string: expecting '}'",
+ ["f'{3)+(4}'",
+ ])
+
+ self.assertAllRaise(SyntaxError, 'EOL while scanning string literal',
+ ["f'{\n}'",
+ ])
+
+ def test_newlines_in_expressions(self):
+ self.assertEqual(f'{0}', '0')
+ self.assertEqual(f'{0\n}', '0')
+ self.assertEqual(f'{0\r}', '0')
+ self.assertEqual(f'{\n0\n}', '0')
+ self.assertEqual(f'{\r0\r}', '0')
+ self.assertEqual(f'{\n0\r}', '0')
+ self.assertEqual(f'{\n0}', '0')
+ self.assertEqual(f'{3+\n4}', '7')
+ self.assertEqual(f'{3+\\\n4}', '7')
+ self.assertEqual(rf'''{3+
+4}''', '7')
+ self.assertEqual(f'''{3+\
+4}''', '7')
+
+ self.assertAllRaise(SyntaxError, 'f-string: empty expression not allowed',
+ [r"f'{\n}'",
+ ])
+
+ def test_lambda(self):
+ x = 5
+ self.assertEqual(f'{(lambda y:x*y)("8")!r}', "'88888'")
+ self.assertEqual(f'{(lambda y:x*y)("8")!r:10}', "'88888' ")
+ self.assertEqual(f'{(lambda y:x*y)("8"):10}', "88888 ")
+
+ # lambda doesn't work without parens, because the colon
+ # makes the parser think it's a format_spec
+ self.assertAllRaise(SyntaxError, 'unexpected EOF while parsing',
+ ["f'{lambda x:x}'",
+ ])
+
+ def test_yield(self):
+ # Not terribly useful, but make sure the yield turns
+ # a function into a generator
+ def fn(y):
+ f'y:{yield y*2}'
+
+ g = fn(4)
+ self.assertEqual(next(g), 8)
+
+ def test_yield_send(self):
+ def fn(x):
+ yield f'x:{yield (lambda i: x * i)}'
+
+ g = fn(10)
+ the_lambda = next(g)
+ self.assertEqual(the_lambda(4), 40)
+ self.assertEqual(g.send('string'), 'x:string')
+
+ def test_expressions_with_triple_quoted_strings(self):
+ self.assertEqual(f"{'''x'''}", 'x')
+ self.assertEqual(f"{'''eric's'''}", "eric's")
+ self.assertEqual(f'{"""eric\'s"""}', "eric's")
+ self.assertEqual(f"{'''eric\"s'''}", 'eric"s')
+ self.assertEqual(f'{"""eric"s"""}', 'eric"s')
+
+ # Test concatenation within an expression
+ self.assertEqual(f'{"x" """eric"s""" "y"}', 'xeric"sy')
+ self.assertEqual(f'{"x" """eric"s"""}', 'xeric"s')
+ self.assertEqual(f'{"""eric"s""" "y"}', 'eric"sy')
+ self.assertEqual(f'{"""x""" """eric"s""" "y"}', 'xeric"sy')
+ self.assertEqual(f'{"""x""" """eric"s""" """y"""}', 'xeric"sy')
+ self.assertEqual(f'{r"""x""" """eric"s""" """y"""}', 'xeric"sy')
+
+ def test_multiple_vars(self):
+ x = 98
+ y = 'abc'
+ self.assertEqual(f'{x}{y}', '98abc')
+
+ self.assertEqual(f'X{x}{y}', 'X98abc')
+ self.assertEqual(f'{x}X{y}', '98Xabc')
+ self.assertEqual(f'{x}{y}X', '98abcX')
+
+ self.assertEqual(f'X{x}Y{y}', 'X98Yabc')
+ self.assertEqual(f'X{x}{y}Y', 'X98abcY')
+ self.assertEqual(f'{x}X{y}Y', '98XabcY')
+
+ self.assertEqual(f'X{x}Y{y}Z', 'X98YabcZ')
+
+ def test_closure(self):
+ def outer(x):
+ def inner():
+ return f'x:{x}'
+ return inner
+
+ self.assertEqual(outer('987')(), 'x:987')
+ self.assertEqual(outer(7)(), 'x:7')
+
+ def test_arguments(self):
+ y = 2
+ def f(x, width):
+ return f'x={x*y:{width}}'
+
+ self.assertEqual(f('foo', 10), 'x=foofoo ')
+ x = 'bar'
+ self.assertEqual(f(10, 10), 'x= 20')
+
+ def test_locals(self):
+ value = 123
+ self.assertEqual(f'v:{value}', 'v:123')
+
+ def test_missing_variable(self):
+ with self.assertRaises(NameError):
+ f'v:{value}'
+
+ def test_missing_format_spec(self):
+ class O:
+ def __format__(self, spec):
+ if not spec:
+ return '*'
+ return spec
+
+ self.assertEqual(f'{O():x}', 'x')
+ self.assertEqual(f'{O()}', '*')
+ self.assertEqual(f'{O():}', '*')
+
+ self.assertEqual(f'{3:}', '3')
+ self.assertEqual(f'{3!s:}', '3')
+
+ def test_global(self):
+ self.assertEqual(f'g:{a_global}', 'g:global variable')
+ self.assertEqual(f'g:{a_global!r}', "g:'global variable'")
+
+ a_local = 'local variable'
+ self.assertEqual(f'g:{a_global} l:{a_local}',
+ 'g:global variable l:local variable')
+ self.assertEqual(f'g:{a_global!r}',
+ "g:'global variable'")
+ self.assertEqual(f'g:{a_global} l:{a_local!r}',
+ "g:global variable l:'local variable'")
+
+ self.assertIn("module 'unittest' from", f'{unittest}')
+
+ def test_shadowed_global(self):
+ a_global = 'really a local'
+ self.assertEqual(f'g:{a_global}', 'g:really a local')
+ self.assertEqual(f'g:{a_global!r}', "g:'really a local'")
+
+ a_local = 'local variable'
+ self.assertEqual(f'g:{a_global} l:{a_local}',
+ 'g:really a local l:local variable')
+ self.assertEqual(f'g:{a_global!r}',
+ "g:'really a local'")
+ self.assertEqual(f'g:{a_global} l:{a_local!r}',
+ "g:really a local l:'local variable'")
+
+ def test_call(self):
+ def foo(x):
+ return 'x=' + str(x)
+
+ self.assertEqual(f'{foo(10)}', 'x=10')
+
+ def test_nested_fstrings(self):
+ y = 5
+ self.assertEqual(f'{f"{0}"*3}', '000')
+ self.assertEqual(f'{f"{y}"*3}', '555')
+ self.assertEqual(f'{f"{\'x\'}"*3}', 'xxx')
+
+ self.assertEqual(f"{r'x' f'{\"s\"}'}", 'xs')
+ self.assertEqual(f"{r'x'rf'{\"s\"}'}", 'xs')
+
+ def test_invalid_string_prefixes(self):
+ self.assertAllRaise(SyntaxError, 'unexpected EOF while parsing',
+ ["fu''",
+ "uf''",
+ "Fu''",
+ "fU''",
+ "Uf''",
+ "uF''",
+ "ufr''",
+ "urf''",
+ "fur''",
+ "fru''",
+ "rfu''",
+ "ruf''",
+ "FUR''",
+ "Fur''",
+ ])
+
+ def test_leading_trailing_spaces(self):
+ self.assertEqual(f'{ 3}', '3')
+ self.assertEqual(f'{ 3}', '3')
+ self.assertEqual(f'{\t3}', '3')
+ self.assertEqual(f'{\t\t3}', '3')
+ self.assertEqual(f'{3 }', '3')
+ self.assertEqual(f'{3 }', '3')
+ self.assertEqual(f'{3\t}', '3')
+ self.assertEqual(f'{3\t\t}', '3')
+
+ self.assertEqual(f'expr={ {x: y for x, y in [(1, 2), ]}}',
+ 'expr={1: 2}')
+ self.assertEqual(f'expr={ {x: y for x, y in [(1, 2), ]} }',
+ 'expr={1: 2}')
+
+ def test_character_name(self):
+ self.assertEqual(f'{4}\N{GREEK CAPITAL LETTER DELTA}{3}',
+ '4\N{GREEK CAPITAL LETTER DELTA}3')
+ self.assertEqual(f'{{}}\N{GREEK CAPITAL LETTER DELTA}{3}',
+ '{}\N{GREEK CAPITAL LETTER DELTA}3')
+
+ def test_not_equal(self):
+ # There's a special test for this because there's a special
+ # case in the f-string parser to look for != as not ending an
+ # expression. Normally it would, while looking for !s or !r.
+
+ self.assertEqual(f'{3!=4}', 'True')
+ self.assertEqual(f'{3!=4:}', 'True')
+ self.assertEqual(f'{3!=4!s}', 'True')
+ self.assertEqual(f'{3!=4!s:.3}', 'Tru')
+
+ def test_conversions(self):
+ self.assertEqual(f'{3.14:10.10}', ' 3.14')
+ self.assertEqual(f'{3.14!s:10.10}', '3.14 ')
+ self.assertEqual(f'{3.14!r:10.10}', '3.14 ')
+ self.assertEqual(f'{3.14!a:10.10}', '3.14 ')
+
+ self.assertEqual(f'{"a"}', 'a')
+ self.assertEqual(f'{"a"!r}', "'a'")
+ self.assertEqual(f'{"a"!a}', "'a'")
+
+ # Not a conversion.
+ self.assertEqual(f'{"a!r"}', "a!r")
+
+ # Not a conversion, but show that ! is allowed in a format spec.
+ self.assertEqual(f'{3.14:!<10.10}', '3.14!!!!!!')
+
+ self.assertEqual(f'{"\N{GREEK CAPITAL LETTER DELTA}"}', '\u0394')
+ self.assertEqual(f'{"\N{GREEK CAPITAL LETTER DELTA}"!r}', "'\u0394'")
+ self.assertEqual(f'{"\N{GREEK CAPITAL LETTER DELTA}"!a}', "'\\u0394'")
+
+ self.assertAllRaise(SyntaxError, 'f-string: invalid conversion character',
+ ["f'{3!g}'",
+ "f'{3!A}'",
+ "f'{3!A}'",
+ "f'{3!A}'",
+ "f'{3!!}'",
+ "f'{3!:}'",
+ "f'{3!\N{GREEK CAPITAL LETTER DELTA}}'",
+ "f'{3! s}'", # no space before conversion char
+ "f'{x!\\x00:.<10}'",
+ ])
+
+ self.assertAllRaise(SyntaxError, "f-string: expecting '}'",
+ ["f'{x!s{y}}'",
+ "f'{3!ss}'",
+ "f'{3!ss:}'",
+ "f'{3!ss:s}'",
+ ])
+
+ def test_assignment(self):
+ self.assertAllRaise(SyntaxError, 'invalid syntax',
+ ["f'' = 3",
+ "f'{0}' = x",
+ "f'{x}' = x",
+ ])
+
+ def test_del(self):
+ self.assertAllRaise(SyntaxError, 'invalid syntax',
+ ["del f''",
+ "del '' f''",
+ ])
+
+ def test_mismatched_braces(self):
+ self.assertAllRaise(SyntaxError, "f-string: single '}' is not allowed",
+ ["f'{{}'",
+ "f'{{}}}'",
+ "f'}'",
+ "f'x}'",
+ "f'x}x'",
+
+ # Can't have { or } in a format spec.
+ "f'{3:}>10}'",
+ r"f'{3:\\}>10}'",
+ "f'{3:}}>10}'",
+ ])
+
+ self.assertAllRaise(SyntaxError, "f-string: expecting '}'",
+ ["f'{3:{{>10}'",
+ "f'{3'",
+ "f'{3!'",
+ "f'{3:'",
+ "f'{3!s'",
+ "f'{3!s:'",
+ "f'{3!s:3'",
+ "f'x{'",
+ "f'x{x'",
+ "f'{3:s'",
+ "f'{{{'",
+ "f'{{}}{'",
+ "f'{'",
+ ])
+
+ self.assertAllRaise(SyntaxError, 'invalid syntax',
+ [r"f'{3:\\{>10}'",
+ ])
+
+ # But these are just normal strings.
+ self.assertEqual(f'{"{"}', '{')
+ self.assertEqual(f'{"}"}', '}')
+ self.assertEqual(f'{3:{"}"}>10}', '}}}}}}}}}3')
+ self.assertEqual(f'{2:{"{"}>10}', '{{{{{{{{{2')
+
+ def test_if_conditional(self):
+ # There's special logic in compile.c to test if the
+ # conditional for an if (and while) are constants. Exercise
+ # that code.
+
+ def test_fstring(x, expected):
+ flag = 0
+ if f'{x}':
+ flag = 1
+ else:
+ flag = 2
+ self.assertEqual(flag, expected)
+
+ def test_concat_empty(x, expected):
+ flag = 0
+ if '' f'{x}':
+ flag = 1
+ else:
+ flag = 2
+ self.assertEqual(flag, expected)
+
+ def test_concat_non_empty(x, expected):
+ flag = 0
+ if ' ' f'{x}':
+ flag = 1
+ else:
+ flag = 2
+ self.assertEqual(flag, expected)
+
+ test_fstring('', 2)
+ test_fstring(' ', 1)
+
+ test_concat_empty('', 2)
+ test_concat_empty(' ', 1)
+
+ test_concat_non_empty('', 1)
+ test_concat_non_empty(' ', 1)
+
+ def test_empty_format_specifier(self):
+ x = 'test'
+ self.assertEqual(f'{x}', 'test')
+ self.assertEqual(f'{x:}', 'test')
+ self.assertEqual(f'{x!s:}', 'test')
+ self.assertEqual(f'{x!r:}', "'test'")
+
+ def test_str_format_differences(self):
+ d = {'a': 'string',
+ 0: 'integer',
+ }
+ a = 0
+ self.assertEqual(f'{d[0]}', 'integer')
+ self.assertEqual(f'{d["a"]}', 'string')
+ self.assertEqual(f'{d[a]}', 'integer')
+ self.assertEqual('{d[a]}'.format(d=d), 'string')
+ self.assertEqual('{d[0]}'.format(d=d), 'integer')
+
+ def test_invalid_expressions(self):
+ self.assertAllRaise(SyntaxError, 'invalid syntax',
+ [r"f'{a[4)}'",
+ r"f'{a(4]}'",
+ ])
+
+ def test_errors(self):
+ # see issue 26287
+ self.assertAllRaise(TypeError, 'non-empty',
+ [r"f'{(lambda: 0):x}'",
+ r"f'{(0,):x}'",
+ ])
+ self.assertAllRaise(ValueError, 'Unknown format code',
+ [r"f'{1000:j}'",
+ r"f'{1000:j}'",
+ ])
+
+ def test_loop(self):
+ for i in range(1000):
+ self.assertEqual(f'i:{i}', 'i:' + str(i))
+
+ def test_dict(self):
+ d = {'"': 'dquote',
+ "'": 'squote',
+ 'foo': 'bar',
+ }
+ self.assertEqual(f'{d["\'"]}', 'squote')
+ self.assertEqual(f"{d['\"']}", 'dquote')
+
+ self.assertEqual(f'''{d["'"]}''', 'squote')
+ self.assertEqual(f"""{d['"']}""", 'dquote')
+
+ self.assertEqual(f'{d["foo"]}', 'bar')
+ self.assertEqual(f"{d['foo']}", 'bar')
+ self.assertEqual(f'{d[\'foo\']}', 'bar')
+ self.assertEqual(f"{d[\"foo\"]}", 'bar')
+
+ def test_escaped_quotes(self):
+ d = {'"': 'a',
+ "'": 'b'}
+
+ self.assertEqual(fr"{d['\"']}", 'a')
+ self.assertEqual(fr'{d["\'"]}', 'b')
+ self.assertEqual(fr"{'\"'}", '"')
+ self.assertEqual(fr'{"\'"}', "'")
+ self.assertEqual(f'{"\\"3"}', '"3')
+
+ self.assertAllRaise(SyntaxError, 'f-string: unterminated string',
+ [r'''f'{"""\\}' ''', # Backslash at end of expression
+ ])
+ self.assertAllRaise(SyntaxError, 'unexpected character after line continuation',
+ [r"rf'{3\}'",
+ ])
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py
index aef66da..9d8de21 100644
--- a/Lib/test/test_ftplib.py
+++ b/Lib/test/test_ftplib.py
@@ -1049,10 +1049,19 @@
ftp.close()
+class MiscTestCase(TestCase):
+ def test__all__(self):
+ blacklist = {'MSG_OOB', 'FTP_PORT', 'MAXLINE', 'CRLF', 'B_CRLF',
+ 'Error', 'parse150', 'parse227', 'parse229', 'parse257',
+ 'print_line', 'ftpcp', 'test'}
+ support.check__all__(self, ftplib, blacklist=blacklist)
+
+
def test_main():
tests = [TestFTPClass, TestTimeouts,
TestIPv6Environment,
- TestTLS_FTPClassMixin, TestTLS_FTPClass]
+ TestTLS_FTPClassMixin, TestTLS_FTPClass,
+ MiscTestCase]
thread_info = support.threading_setup()
try:
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index ab51a35..e2ab654 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -1577,7 +1577,7 @@
m = mro(D, bases)
self.assertEqual(m, [D, c.MutableSequence, c.Sequence,
c.defaultdict, dict, c.MutableMapping,
- c.Mapping, c.Sized, c.Iterable, c.Container,
+ c.Mapping, c.Sized, c.Reversible, c.Iterable, c.Container,
object])
# Container and Callable are registered on different base classes and
@@ -1758,13 +1758,10 @@
c.Container.register(P)
with self.assertRaises(RuntimeError) as re_one:
g(p)
- self.assertIn(
- str(re_one.exception),
- (("Ambiguous dispatch: <class 'collections.abc.Container'> "
- "or <class 'collections.abc.Iterable'>"),
- ("Ambiguous dispatch: <class 'collections.abc.Iterable'> "
- "or <class 'collections.abc.Container'>")),
- )
+ self.assertIn("Ambiguous dispatch:", str(re_one.exception))
+ self.assertIn("<class 'collections.abc.Container'", str(re_one.exception))
+ self.assertIn("<class 'collections.abc.Iterable'", str(re_one.exception))
+
class Q(c.Sized):
def __len__(self):
return 0
@@ -1790,13 +1787,10 @@
# perspective.
with self.assertRaises(RuntimeError) as re_two:
h(c.defaultdict(lambda: 0))
- self.assertIn(
- str(re_two.exception),
- (("Ambiguous dispatch: <class 'collections.abc.Container'> "
- "or <class 'collections.abc.Sized'>"),
- ("Ambiguous dispatch: <class 'collections.abc.Sized'> "
- "or <class 'collections.abc.Container'>")),
- )
+ self.assertIn("Ambiguous dispatch:", str(re_two.exception))
+ self.assertIn("<class 'collections.abc.Container'", str(re_two.exception))
+ self.assertIn("<class 'collections.abc.Sized'", str(re_two.exception))
+
class R(c.defaultdict):
pass
c.MutableSequence.register(R)
@@ -1830,13 +1824,10 @@
# There is no preference for registered versus inferred ABCs.
with self.assertRaises(RuntimeError) as re_three:
h(u)
- self.assertIn(
- str(re_three.exception),
- (("Ambiguous dispatch: <class 'collections.abc.Container'> "
- "or <class 'collections.abc.Sized'>"),
- ("Ambiguous dispatch: <class 'collections.abc.Sized'> "
- "or <class 'collections.abc.Container'>")),
- )
+ self.assertIn("Ambiguous dispatch:", str(re_three.exception))
+ self.assertIn("<class 'collections.abc.Container'", str(re_three.exception))
+ self.assertIn("<class 'collections.abc.Sized'", str(re_three.exception))
+
class V(c.Sized, S):
def __len__(self):
return 0
diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py
index 1f0867d..872ca62 100644
--- a/Lib/test/test_gc.py
+++ b/Lib/test/test_gc.py
@@ -682,7 +682,6 @@
# Create a reference cycle through the __main__ module and check
# it gets collected at interpreter shutdown.
code = """if 1:
- import weakref
class C:
def __del__(self):
print('__del__ called')
@@ -696,7 +695,6 @@
# Same as above, but with a non-__main__ module.
with temp_dir() as script_dir:
module = """if 1:
- import weakref
class C:
def __del__(self):
print('__del__ called')
diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py
index cd7d292..730b628 100644
--- a/Lib/test/test_gdb.py
+++ b/Lib/test/test_gdb.py
@@ -5,7 +5,6 @@
import os
import re
-import pprint
import subprocess
import sys
import sysconfig
@@ -176,6 +175,7 @@
args = ['--eval-command=%s' % cmd for cmd in commands]
args += ["--args",
sys.executable]
+ args.extend(subprocess._args_from_interpreter_flags())
if not import_site:
# -S suppresses the default 'import site'
@@ -291,7 +291,9 @@
'Verify the pretty-printing of dictionaries'
self.assertGdbRepr({})
self.assertGdbRepr({'foo': 'bar'}, "{'foo': 'bar'}")
- self.assertGdbRepr({'foo': 'bar', 'douglas': 42}, "{'douglas': 42, 'foo': 'bar'}")
+ # PYTHONHASHSEED is need to get the exact item order
+ if not sys.flags.ignore_environment:
+ self.assertGdbRepr({'foo': 'bar', 'douglas': 42}, "{'douglas': 42, 'foo': 'bar'}")
def test_lists(self):
'Verify the pretty-printing of lists'
@@ -354,9 +356,12 @@
'Verify the pretty-printing of sets'
if (gdb_major_version, gdb_minor_version) < (7, 3):
self.skipTest("pretty-printing of sets needs gdb 7.3 or later")
- self.assertGdbRepr(set(), 'set()')
- self.assertGdbRepr(set(['a', 'b']), "{'a', 'b'}")
- self.assertGdbRepr(set([4, 5, 6]), "{4, 5, 6}")
+ self.assertGdbRepr(set(), "set()")
+ self.assertGdbRepr(set(['a']), "{'a'}")
+ # PYTHONHASHSEED is need to get the exact frozenset item order
+ if not sys.flags.ignore_environment:
+ self.assertGdbRepr(set(['a', 'b']), "{'a', 'b'}")
+ self.assertGdbRepr(set([4, 5, 6]), "{4, 5, 6}")
# Ensure that we handle sets containing the "dummy" key value,
# which happens on deletion:
@@ -369,9 +374,12 @@
'Verify the pretty-printing of frozensets'
if (gdb_major_version, gdb_minor_version) < (7, 3):
self.skipTest("pretty-printing of frozensets needs gdb 7.3 or later")
- self.assertGdbRepr(frozenset(), 'frozenset()')
- self.assertGdbRepr(frozenset(['a', 'b']), "frozenset({'a', 'b'})")
- self.assertGdbRepr(frozenset([4, 5, 6]), "frozenset({4, 5, 6})")
+ self.assertGdbRepr(frozenset(), "frozenset()")
+ self.assertGdbRepr(frozenset(['a']), "frozenset({'a'})")
+ # PYTHONHASHSEED is need to get the exact frozenset item order
+ if not sys.flags.ignore_environment:
+ self.assertGdbRepr(frozenset(['a', 'b']), "frozenset({'a', 'b'})")
+ self.assertGdbRepr(frozenset([4, 5, 6]), "frozenset({4, 5, 6})")
def test_exceptions(self):
# Test a RuntimeError
@@ -500,6 +508,10 @@
def test_builtins_help(self):
'Ensure that the new-style class _Helper in site.py can be handled'
+
+ if sys.flags.no_site:
+ self.skipTest("need site module, but -S option was used")
+
# (this was the issue causing tracebacks in
# http://bugs.python.org/issue8032#msg100537 )
gdb_repr, gdb_output = self.get_gdb_repr('id(__builtins__.help)', import_site=True)
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index 3f82462..c193301 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -245,11 +245,11 @@
yield
with self.assertRaises(StopIteration), \
- self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"):
+ self.assertWarnsRegex(DeprecationWarning, "StopIteration"):
next(gen())
- with self.assertRaisesRegex(PendingDeprecationWarning,
+ with self.assertRaisesRegex(DeprecationWarning,
"generator .* raised StopIteration"), \
warnings.catch_warnings():
@@ -268,7 +268,7 @@
g = f()
self.assertEqual(next(g), 1)
- with self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"):
+ with self.assertWarnsRegex(DeprecationWarning, "StopIteration"):
with self.assertRaises(StopIteration):
next(g)
@@ -671,10 +671,10 @@
... yield 1
...
>>> type(g)
-<class 'function'>
+<class 'function' ...>
>>> i = g()
>>> type(i)
-<class 'generator'>
+<class 'generator' ...>
>>> [s for s in dir(i) if not s.startswith('_')]
['close', 'gi_code', 'gi_frame', 'gi_running', 'gi_yieldfrom', 'send', 'throw']
>>> from test.support import HAVE_DOCSTRINGS
@@ -691,7 +691,7 @@
>>> i.gi_running
0
>>> type(i.gi_frame)
-<class 'frame'>
+<class 'frame' ...>
>>> i.gi_running = 42
Traceback (most recent call last):
...
@@ -1066,27 +1066,27 @@
>>> def f():
... yield
>>> type(f())
-<class 'generator'>
+<class 'generator' ...>
>>> def f():
... if 0:
... yield
>>> type(f())
-<class 'generator'>
+<class 'generator' ...>
>>> def f():
... if 0:
... yield 1
>>> type(f())
-<class 'generator'>
+<class 'generator' ...>
>>> def f():
... if "":
... yield None
>>> type(f())
-<class 'generator'>
+<class 'generator' ...>
>>> def f():
... return
@@ -1110,7 +1110,7 @@
... x = 1
... return
>>> type(f())
-<class 'generator'>
+<class 'generator' ...>
>>> def f():
... if 0:
@@ -1118,7 +1118,7 @@
... yield 1
...
>>> type(f())
-<class 'NoneType'>
+<class 'NoneType' ...>
>>> def f():
... if 0:
@@ -1128,7 +1128,7 @@
... def f(self):
... yield 2
>>> type(f())
-<class 'NoneType'>
+<class 'NoneType' ...>
>>> def f():
... if 0:
@@ -1136,7 +1136,7 @@
... if 0:
... yield 2
>>> type(f())
-<class 'generator'>
+<class 'generator' ...>
This one caused a crash (see SF bug 567538):
@@ -1791,7 +1791,7 @@
>>> def f(): list(i for i in [(yield 26)])
>>> type(f())
-<class 'generator'>
+<class 'generator' ...>
A yield expression with augmented assignment.
@@ -2047,25 +2047,25 @@
>>> def f(): x += yield
>>> type(f())
-<class 'generator'>
+<class 'generator' ...>
>>> def f(): x = yield
>>> type(f())
-<class 'generator'>
+<class 'generator' ...>
>>> def f(): lambda x=(yield): 1
>>> type(f())
-<class 'generator'>
+<class 'generator' ...>
>>> def f(): x=(i for i in (yield) if (yield))
>>> type(f())
-<class 'generator'>
+<class 'generator' ...>
>>> def f(d): d[(yield "a")] = d[(yield "b")] = 27
>>> data = [1,2]
>>> g = f(data)
>>> type(g)
-<class 'generator'>
+<class 'generator' ...>
>>> g.send(None)
'a'
>>> data
@@ -2174,8 +2174,9 @@
# so this works as expected in both ways of running regrtest.
def test_main(verbose=None):
from test import support, test_generators
+ import doctest
support.run_unittest(__name__)
- support.run_doctest(test_generators, verbose)
+ support.run_doctest(test_generators, verbose, optionflags=doctest.ELLIPSIS)
# This part isn't needed for regrtest, but for running the test directly.
if __name__ == "__main__":
diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py
index 86fc2de..9c28a68 100644
--- a/Lib/test/test_genericpath.py
+++ b/Lib/test/test_genericpath.py
@@ -10,11 +10,9 @@
from test import support
-def safe_rmdir(dirname):
- try:
- os.rmdir(dirname)
- except OSError:
- pass
+def create_file(filename, data=b'foo'):
+ with open(filename, 'xb', 0) as fp:
+ fp.write(data)
class GenericTest:
@@ -97,52 +95,47 @@
self.assertNotEqual(s1[n:n+1], s2[n:n+1])
def test_getsize(self):
- f = open(support.TESTFN, "wb")
- try:
- f.write(b"foo")
- f.close()
- self.assertEqual(self.pathmodule.getsize(support.TESTFN), 3)
- finally:
- if not f.closed:
- f.close()
- support.unlink(support.TESTFN)
+ filename = support.TESTFN
+ self.addCleanup(support.unlink, filename)
- def test_time(self):
- f = open(support.TESTFN, "wb")
- try:
- f.write(b"foo")
- f.close()
- f = open(support.TESTFN, "ab")
+ create_file(filename, b'Hello')
+ self.assertEqual(self.pathmodule.getsize(filename), 5)
+ os.remove(filename)
+
+ create_file(filename, b'Hello World!')
+ self.assertEqual(self.pathmodule.getsize(filename), 12)
+
+ def test_filetime(self):
+ filename = support.TESTFN
+ self.addCleanup(support.unlink, filename)
+
+ create_file(filename, b'foo')
+
+ with open(filename, "ab", 0) as f:
f.write(b"bar")
- f.close()
- f = open(support.TESTFN, "rb")
- d = f.read()
- f.close()
- self.assertEqual(d, b"foobar")
- self.assertLessEqual(
- self.pathmodule.getctime(support.TESTFN),
- self.pathmodule.getmtime(support.TESTFN)
- )
- finally:
- if not f.closed:
- f.close()
- support.unlink(support.TESTFN)
+ with open(filename, "rb", 0) as f:
+ data = f.read()
+ self.assertEqual(data, b"foobar")
+
+ self.assertLessEqual(
+ self.pathmodule.getctime(filename),
+ self.pathmodule.getmtime(filename)
+ )
def test_exists(self):
- self.assertIs(self.pathmodule.exists(support.TESTFN), False)
- f = open(support.TESTFN, "wb")
- try:
+ filename = support.TESTFN
+ self.addCleanup(support.unlink, filename)
+
+ self.assertIs(self.pathmodule.exists(filename), False)
+
+ with open(filename, "xb") as f:
f.write(b"foo")
- f.close()
- self.assertIs(self.pathmodule.exists(support.TESTFN), True)
- if not self.pathmodule == genericpath:
- self.assertIs(self.pathmodule.lexists(support.TESTFN),
- True)
- finally:
- if not f.close():
- f.close()
- support.unlink(support.TESTFN)
+
+ self.assertIs(self.pathmodule.exists(filename), True)
+
+ if not self.pathmodule == genericpath:
+ self.assertIs(self.pathmodule.lexists(filename), True)
@unittest.skipUnless(hasattr(os, "pipe"), "requires os.pipe()")
def test_exists_fd(self):
@@ -154,53 +147,66 @@
os.close(w)
self.assertFalse(self.pathmodule.exists(r))
- def test_isdir(self):
- self.assertIs(self.pathmodule.isdir(support.TESTFN), False)
- f = open(support.TESTFN, "wb")
- try:
- f.write(b"foo")
- f.close()
- self.assertIs(self.pathmodule.isdir(support.TESTFN), False)
- os.remove(support.TESTFN)
- os.mkdir(support.TESTFN)
- self.assertIs(self.pathmodule.isdir(support.TESTFN), True)
- os.rmdir(support.TESTFN)
- finally:
- if not f.close():
- f.close()
- support.unlink(support.TESTFN)
- safe_rmdir(support.TESTFN)
+ def test_isdir_file(self):
+ filename = support.TESTFN
+ self.addCleanup(support.unlink, filename)
+ self.assertIs(self.pathmodule.isdir(filename), False)
- def test_isfile(self):
- self.assertIs(self.pathmodule.isfile(support.TESTFN), False)
- f = open(support.TESTFN, "wb")
- try:
- f.write(b"foo")
- f.close()
- self.assertIs(self.pathmodule.isfile(support.TESTFN), True)
- os.remove(support.TESTFN)
- os.mkdir(support.TESTFN)
- self.assertIs(self.pathmodule.isfile(support.TESTFN), False)
- os.rmdir(support.TESTFN)
- finally:
- if not f.close():
- f.close()
- support.unlink(support.TESTFN)
- safe_rmdir(support.TESTFN)
+ create_file(filename)
+ self.assertIs(self.pathmodule.isdir(filename), False)
- @staticmethod
- def _create_file(filename):
- with open(filename, 'wb') as f:
- f.write(b'foo')
+ def test_isdir_dir(self):
+ filename = support.TESTFN
+ self.addCleanup(support.rmdir, filename)
+ self.assertIs(self.pathmodule.isdir(filename), False)
+
+ os.mkdir(filename)
+ self.assertIs(self.pathmodule.isdir(filename), True)
+
+ def test_isfile_file(self):
+ filename = support.TESTFN
+ self.addCleanup(support.unlink, filename)
+ self.assertIs(self.pathmodule.isfile(filename), False)
+
+ create_file(filename)
+ self.assertIs(self.pathmodule.isfile(filename), True)
+
+ def test_isfile_dir(self):
+ filename = support.TESTFN
+ self.addCleanup(support.rmdir, filename)
+ self.assertIs(self.pathmodule.isfile(filename), False)
+
+ os.mkdir(filename)
+ self.assertIs(self.pathmodule.isfile(filename), False)
def test_samefile(self):
- try:
- test_fn = support.TESTFN + "1"
- self._create_file(test_fn)
- self.assertTrue(self.pathmodule.samefile(test_fn, test_fn))
- self.assertRaises(TypeError, self.pathmodule.samefile)
- finally:
- os.remove(test_fn)
+ file1 = support.TESTFN
+ file2 = support.TESTFN + "2"
+ self.addCleanup(support.unlink, file1)
+ self.addCleanup(support.unlink, file2)
+
+ create_file(file1)
+ self.assertTrue(self.pathmodule.samefile(file1, file1))
+
+ create_file(file2)
+ self.assertFalse(self.pathmodule.samefile(file1, file2))
+
+ self.assertRaises(TypeError, self.pathmodule.samefile)
+
+ def _test_samefile_on_link_func(self, func):
+ test_fn1 = support.TESTFN
+ test_fn2 = support.TESTFN + "2"
+ self.addCleanup(support.unlink, test_fn1)
+ self.addCleanup(support.unlink, test_fn2)
+
+ create_file(test_fn1)
+
+ func(test_fn1, test_fn2)
+ self.assertTrue(self.pathmodule.samefile(test_fn1, test_fn2))
+ os.remove(test_fn2)
+
+ create_file(test_fn2)
+ self.assertFalse(self.pathmodule.samefile(test_fn1, test_fn2))
@support.skip_unless_symlink
def test_samefile_on_symlink(self):
@@ -209,31 +215,37 @@
def test_samefile_on_link(self):
self._test_samefile_on_link_func(os.link)
- def _test_samefile_on_link_func(self, func):
- try:
- test_fn1 = support.TESTFN + "1"
- test_fn2 = support.TESTFN + "2"
- self._create_file(test_fn1)
-
- func(test_fn1, test_fn2)
- self.assertTrue(self.pathmodule.samefile(test_fn1, test_fn2))
- os.remove(test_fn2)
-
- self._create_file(test_fn2)
- self.assertFalse(self.pathmodule.samefile(test_fn1, test_fn2))
- finally:
- os.remove(test_fn1)
- os.remove(test_fn2)
-
def test_samestat(self):
- try:
- test_fn = support.TESTFN + "1"
- self._create_file(test_fn)
- test_fns = [test_fn]*2
- stats = map(os.stat, test_fns)
- self.assertTrue(self.pathmodule.samestat(*stats))
- finally:
- os.remove(test_fn)
+ test_fn1 = support.TESTFN
+ test_fn2 = support.TESTFN + "2"
+ self.addCleanup(support.unlink, test_fn1)
+ self.addCleanup(support.unlink, test_fn2)
+
+ create_file(test_fn1)
+ stat1 = os.stat(test_fn1)
+ self.assertTrue(self.pathmodule.samestat(stat1, os.stat(test_fn1)))
+
+ create_file(test_fn2)
+ stat2 = os.stat(test_fn2)
+ self.assertFalse(self.pathmodule.samestat(stat1, stat2))
+
+ self.assertRaises(TypeError, self.pathmodule.samestat)
+
+ def _test_samestat_on_link_func(self, func):
+ test_fn1 = support.TESTFN + "1"
+ test_fn2 = support.TESTFN + "2"
+ self.addCleanup(support.unlink, test_fn1)
+ self.addCleanup(support.unlink, test_fn2)
+
+ create_file(test_fn1)
+ func(test_fn1, test_fn2)
+ self.assertTrue(self.pathmodule.samestat(os.stat(test_fn1),
+ os.stat(test_fn2)))
+ os.remove(test_fn2)
+
+ create_file(test_fn2)
+ self.assertFalse(self.pathmodule.samestat(os.stat(test_fn1),
+ os.stat(test_fn2)))
@support.skip_unless_symlink
def test_samestat_on_symlink(self):
@@ -242,31 +254,17 @@
def test_samestat_on_link(self):
self._test_samestat_on_link_func(os.link)
- def _test_samestat_on_link_func(self, func):
- try:
- test_fn1 = support.TESTFN + "1"
- test_fn2 = support.TESTFN + "2"
- self._create_file(test_fn1)
- test_fns = (test_fn1, test_fn2)
- func(*test_fns)
- stats = map(os.stat, test_fns)
- self.assertTrue(self.pathmodule.samestat(*stats))
- os.remove(test_fn2)
-
- self._create_file(test_fn2)
- stats = map(os.stat, test_fns)
- self.assertFalse(self.pathmodule.samestat(*stats))
-
- self.assertRaises(TypeError, self.pathmodule.samestat)
- finally:
- os.remove(test_fn1)
- os.remove(test_fn2)
-
def test_sameopenfile(self):
- fname = support.TESTFN + "1"
- with open(fname, "wb") as a, open(fname, "wb") as b:
- self.assertTrue(self.pathmodule.sameopenfile(
- a.fileno(), b.fileno()))
+ filename = support.TESTFN
+ self.addCleanup(support.unlink, filename)
+ create_file(filename)
+
+ with open(filename, "rb", 0) as fp1:
+ fd1 = fp1.fileno()
+ with open(filename, "rb", 0) as fp2:
+ fd2 = fp2.fileno()
+ self.assertTrue(self.pathmodule.sameopenfile(fd1, fd2))
+
class TestGenericTest(GenericTest, unittest.TestCase):
# Issue 16852: GenericTest can't inherit from unittest.TestCase
diff --git a/Lib/test/test_genexps.py b/Lib/test/test_genexps.py
index fb531d6..c5e10dd 100644
--- a/Lib/test/test_genexps.py
+++ b/Lib/test/test_genexps.py
@@ -27,7 +27,7 @@
>>> g = (i*i for i in range(4))
>>> type(g)
- <class 'generator'>
+ <class 'generator' ...>
>>> list(g)
[0, 1, 4, 9]
@@ -269,7 +269,8 @@
def test_main(verbose=None):
from test import support
from test import test_genexps
- support.run_doctest(test_genexps, verbose)
+ import doctest
+ support.run_doctest(test_genexps, verbose, optionflags=doctest.ELLIPSIS)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
diff --git a/Lib/test/test_getargs2.py b/Lib/test/test_getargs2.py
index 984aac7..16e163a 100644
--- a/Lib/test/test_getargs2.py
+++ b/Lib/test/test_getargs2.py
@@ -365,7 +365,8 @@
self.assertEqual(getargs_f(FloatSubclass(7.5)), 7.5)
self.assertEqual(getargs_f(FloatSubclass2(7.5)), 7.5)
self.assertRaises(TypeError, getargs_f, BadFloat())
- self.assertEqual(getargs_f(BadFloat2()), 4.25)
+ with self.assertWarns(DeprecationWarning):
+ self.assertEqual(getargs_f(BadFloat2()), 4.25)
self.assertEqual(getargs_f(BadFloat3(7.5)), 7.5)
for x in (FLT_MIN, -FLT_MIN, FLT_MAX, -FLT_MAX, INF, -INF):
@@ -390,7 +391,8 @@
self.assertEqual(getargs_d(FloatSubclass(7.5)), 7.5)
self.assertEqual(getargs_d(FloatSubclass2(7.5)), 7.5)
self.assertRaises(TypeError, getargs_d, BadFloat())
- self.assertEqual(getargs_d(BadFloat2()), 4.25)
+ with self.assertWarns(DeprecationWarning):
+ self.assertEqual(getargs_d(BadFloat2()), 4.25)
self.assertEqual(getargs_d(BadFloat3(7.5)), 7.5)
for x in (DBL_MIN, -DBL_MIN, DBL_MAX, -DBL_MAX, INF, -INF):
@@ -474,7 +476,7 @@
ret = get_args(*TupleSubclass([1, 2]))
self.assertEqual(ret, (1, 2))
- self.assertIsInstance(ret, tuple)
+ self.assertIs(type(ret), tuple)
ret = get_args()
self.assertIn(ret, ((), None))
@@ -512,7 +514,7 @@
ret = get_kwargs(**DictSubclass({'a': 1, 'b': 2}))
self.assertEqual(ret, {'a': 1, 'b': 2})
- self.assertIsInstance(ret, dict)
+ self.assertIs(type(ret), dict)
ret = get_kwargs()
self.assertIn(ret, ({}, None))
@@ -656,6 +658,39 @@
getargs_keyword_only(1, 2, **{'\uDC80': 10})
+class PositionalOnlyAndKeywords_TestCase(unittest.TestCase):
+ from _testcapi import getargs_positional_only_and_keywords as getargs
+
+ def test_positional_args(self):
+ # using all possible positional args
+ self.assertEqual(self.getargs(1, 2, 3), (1, 2, 3))
+
+ def test_mixed_args(self):
+ # positional and keyword args
+ self.assertEqual(self.getargs(1, 2, keyword=3), (1, 2, 3))
+
+ def test_optional_args(self):
+ # missing optional args
+ self.assertEqual(self.getargs(1, 2), (1, 2, -1))
+ self.assertEqual(self.getargs(1, keyword=3), (1, -1, 3))
+
+ def test_required_args(self):
+ self.assertEqual(self.getargs(1), (1, -1, -1))
+ # required positional arg missing
+ with self.assertRaisesRegex(TypeError,
+ "Function takes at least 1 positional arguments \(0 given\)"):
+ self.getargs()
+
+ with self.assertRaisesRegex(TypeError,
+ "Function takes at least 1 positional arguments \(0 given\)"):
+ self.getargs(keyword=3)
+
+ def test_empty_keyword(self):
+ with self.assertRaisesRegex(TypeError,
+ "'' is an invalid keyword argument for this function"):
+ self.getargs(1, 2, **{'': 666})
+
+
class Bytes_TestCase(unittest.TestCase):
def test_c(self):
from _testcapi import getargs_c
@@ -822,10 +857,10 @@
self.assertEqual(getargs_es_hash('abc\xe9', 'latin1', buf), b'abc\xe9')
self.assertEqual(buf, bytearray(b'abc\xe9\x00'))
buf = bytearray(b'x'*4)
- self.assertRaises(TypeError, getargs_es_hash, 'abc\xe9', 'latin1', buf)
+ self.assertRaises(ValueError, getargs_es_hash, 'abc\xe9', 'latin1', buf)
self.assertEqual(buf, bytearray(b'x'*4))
buf = bytearray()
- self.assertRaises(TypeError, getargs_es_hash, 'abc\xe9', 'latin1', buf)
+ self.assertRaises(ValueError, getargs_es_hash, 'abc\xe9', 'latin1', buf)
def test_et_hash(self):
from _testcapi import getargs_et_hash
@@ -848,10 +883,10 @@
self.assertEqual(getargs_et_hash('abc\xe9', 'latin1', buf), b'abc\xe9')
self.assertEqual(buf, bytearray(b'abc\xe9\x00'))
buf = bytearray(b'x'*4)
- self.assertRaises(TypeError, getargs_et_hash, 'abc\xe9', 'latin1', buf)
+ self.assertRaises(ValueError, getargs_et_hash, 'abc\xe9', 'latin1', buf)
self.assertEqual(buf, bytearray(b'x'*4))
buf = bytearray()
- self.assertRaises(TypeError, getargs_et_hash, 'abc\xe9', 'latin1', buf)
+ self.assertRaises(ValueError, getargs_et_hash, 'abc\xe9', 'latin1', buf)
def test_u(self):
from _testcapi import getargs_u
diff --git a/Lib/test/test_gettext.py b/Lib/test/test_gettext.py
index de610c7..d345baa 100644
--- a/Lib/test/test_gettext.py
+++ b/Lib/test/test_gettext.py
@@ -1,6 +1,5 @@
import os
import base64
-import shutil
import gettext
import unittest
@@ -440,6 +439,12 @@
self.assertEqual(t.__class__, DummyGNUTranslations)
+class MiscTestCase(unittest.TestCase):
+ def test__all__(self):
+ blacklist = {'c2py', 'ENOENT'}
+ support.check__all__(self, gettext, blacklist=blacklist)
+
+
def test_main():
support.run_unittest(__name__)
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 154e3b6..bfe5225 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -295,6 +295,10 @@
pos2key2dict(1,2,k2=100,tokwarg1=100,tokwarg2=200)
pos2key2dict(1,2,tokwarg1=100,tokwarg2=200, k2=100)
+ self.assertRaises(SyntaxError, eval, "def f(*): pass")
+ self.assertRaises(SyntaxError, eval, "def f(*,): pass")
+ self.assertRaises(SyntaxError, eval, "def f(*, **kwds): pass")
+
# keyword arguments after *arglist
def f(*args, **kwargs):
return args, kwargs
@@ -341,7 +345,7 @@
def f(x) -> list: pass
self.assertEqual(f.__annotations__, {'return': list})
- # test MAKE_CLOSURE with a variety of oparg's
+ # test closures with a variety of opargs
closure = 1
def f(): return closure
def f(x=1): return closure
@@ -352,6 +356,23 @@
check_syntax_error(self, "f(*g(1=2))")
check_syntax_error(self, "f(**g(1=2))")
+ # Check trailing commas are permitted in funcdef argument list
+ def f(a,): pass
+ def f(*args,): pass
+ def f(**kwds,): pass
+ def f(a, *args,): pass
+ def f(a, **kwds,): pass
+ def f(*args, b,): pass
+ def f(*, b,): pass
+ def f(*args, **kwds,): pass
+ def f(a, *args, b,): pass
+ def f(a, *, b,): pass
+ def f(a, *args, **kwds,): pass
+ def f(*args, b, **kwds,): pass
+ def f(*, b, **kwds,): pass
+ def f(a, *args, b, **kwds,): pass
+ def f(a, *, b, **kwds,): pass
+
def test_lambdef(self):
### lambdef: 'lambda' [varargslist] ':' test
l1 = lambda : 0
@@ -370,6 +391,23 @@
self.assertEqual(l6(1,2), 1+2+20)
self.assertEqual(l6(1,2,k=10), 1+2+10)
+ # check that trailing commas are permitted
+ l10 = lambda a,: 0
+ l11 = lambda *args,: 0
+ l12 = lambda **kwds,: 0
+ l13 = lambda a, *args,: 0
+ l14 = lambda a, **kwds,: 0
+ l15 = lambda *args, b,: 0
+ l16 = lambda *, b,: 0
+ l17 = lambda *args, **kwds,: 0
+ l18 = lambda a, *args, b,: 0
+ l19 = lambda a, *, b,: 0
+ l20 = lambda a, *args, **kwds,: 0
+ l21 = lambda *args, b, **kwds,: 0
+ l22 = lambda *, b, **kwds,: 0
+ l23 = lambda a, *args, b, **kwds,: 0
+ l24 = lambda a, *, b, **kwds,: 0
+
### stmt: simple_stmt | compound_stmt
# Tested below
diff --git a/Lib/test/test_grp.py b/Lib/test/test_grp.py
index 272b086..69095a3 100644
--- a/Lib/test/test_grp.py
+++ b/Lib/test/test_grp.py
@@ -92,5 +92,15 @@
self.assertRaises(KeyError, grp.getgrgid, fakegid)
+ def test_noninteger_gid(self):
+ entries = grp.getgrall()
+ if not entries:
+ self.skipTest('no groups')
+ # Choose an existent gid.
+ gid = entries[0][2]
+ self.assertWarns(DeprecationWarning, grp.getgrgid, float(gid))
+ self.assertWarns(DeprecationWarning, grp.getgrgid, str(gid))
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_heapq.py b/Lib/test/test_heapq.py
index b7e8259..2f8c648 100644
--- a/Lib/test/test_heapq.py
+++ b/Lib/test/test_heapq.py
@@ -1,6 +1,5 @@
"""Unittests for heapq."""
-import sys
import random
import unittest
diff --git a/Lib/test/test_hmac.py b/Lib/test/test_hmac.py
index 98826b5..067e13f 100644
--- a/Lib/test/test_hmac.py
+++ b/Lib/test/test_hmac.py
@@ -3,7 +3,6 @@
import hashlib
import unittest
import warnings
-from test import support
def ignore_warning(func):
diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py
index 11420b2..a7f53d3 100644
--- a/Lib/test/test_htmlparser.py
+++ b/Lib/test/test_htmlparser.py
@@ -3,7 +3,6 @@
import html.parser
import pprint
import unittest
-from test import support
class EventCollector(html.parser.HTMLParser):
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
index 72e6e08..7f4b0f9 100644
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -18,6 +18,7 @@
import html
import http.client
import tempfile
+import time
from io import BytesIO
import unittest
@@ -388,7 +389,7 @@
quotedname = urllib.parse.quote(filename, errors='surrogatepass')
self.assertIn(('href="%s"' % quotedname)
.encode(enc, 'surrogateescape'), body)
- self.assertIn(('>%s<' % html.escape(filename))
+ self.assertIn(('>%s<' % html.escape(filename, quote=False))
.encode(enc, 'surrogateescape'), body)
response = self.request(self.base_url + '/' + quotedname)
self.check_status_and_reason(response, HTTPStatus.OK,
@@ -466,6 +467,27 @@
self.assertEqual(response.getheader("Location"),
self.tempdir_name + "/?hi=1")
+ def test_html_escape_filename(self):
+ filename = '<test&>.txt'
+ fullpath = os.path.join(self.tempdir, filename)
+
+ try:
+ open(fullpath, 'w').close()
+ except OSError:
+ raise unittest.SkipTest('Can not create file %s on current file '
+ 'system' % filename)
+
+ try:
+ response = self.request(self.base_url + '/')
+ body = self.check_status_and_reason(response, HTTPStatus.OK)
+ enc = response.headers.get_content_charset()
+ finally:
+ os.unlink(fullpath) # avoid affecting test_undecodable_filename
+
+ self.assertIsNotNone(enc)
+ html_text = '>%s<' % html.escape(filename, quote=False)
+ self.assertIn(html_text.encode(enc), body)
+
cgi_file1 = """\
#!%s
@@ -916,7 +938,7 @@
# Issue #6791: same for headers
result = self.send_typical_request(
b'GET / HTTP/1.1\r\nX-Foo: bar' + b'r' * 65537 + b'\r\n\r\n')
- self.assertEqual(result[0], b'HTTP/1.1 400 Line too long\r\n')
+ self.assertEqual(result[0], b'HTTP/1.1 431 Line too long\r\n')
self.assertFalse(self.handler.get_called)
self.assertEqual(self.handler.requestline, 'GET / HTTP/1.1')
@@ -927,6 +949,13 @@
self.assertFalse(self.handler.get_called)
self.assertEqual(self.handler.requestline, 'GET / HTTP/1.1')
+ def test_html_escape_on_error(self):
+ result = self.send_typical_request(
+ b'<script>alert("hello")</script> / HTTP/1.1')
+ result = b''.join(result)
+ text = '<script>alert("hello")</script>'
+ self.assertIn(html.escape(text, quote=False).encode('ascii'), result)
+
def test_close_connection(self):
# handle_one_request() should be repeatedly called until
# it sets close_connection
@@ -942,6 +971,19 @@
self.handler.handle()
self.assertRaises(StopIteration, next, close_values)
+ def test_date_time_string(self):
+ now = time.time()
+ # this is the old code that formats the timestamp
+ year, month, day, hh, mm, ss, wd, y, z = time.gmtime(now)
+ expected = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (
+ self.handler.weekdayname[wd],
+ day,
+ self.handler.monthname[month],
+ year, hh, mm, ss
+ )
+ self.assertEqual(self.handler.date_time_string(timestamp=now), expected)
+
+
class SimpleHTTPRequestHandlerTestCase(unittest.TestCase):
""" Test url parsing """
def setUp(self):
diff --git a/Lib/test/test_idle.py b/Lib/test/test_idle.py
index 141e89e..ad88e24 100644
--- a/Lib/test/test_idle.py
+++ b/Lib/test/test_idle.py
@@ -1,16 +1,21 @@
import unittest
-from test import support
from test.support import import_module
-# Skip test if _thread or _tkinter wasn't built or idlelib was deleted.
+# Skip test if _thread or _tkinter wasn't built, or idlelib is missing,
+# or if tcl/tk version before 8.5, which is needed for ttk widgets.
+
import_module('threading') # imported by PyShell, imports _thread
tk = import_module('tkinter') # imports _tkinter
-idletest = import_module('idlelib.idle_test')
+if tk.TkVersion < 8.5:
+ raise unittest.SkipTest("IDLE requires tk 8.5 or later.")
+tk.NoDefaultRoot()
+idlelib = import_module('idlelib')
+idlelib.testing = True # Avoid locale-changed test error
-# 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.)
-load_tests = idletest.load_tests
+# Without test_main present, test.libregrtest.runtest.runtest_inner
+# calls (line 173) unittest.TestLoader().loadTestsFromModule(module)
+# which calls load_tests() if it finds it. (Unittest.main does the same.)
+from idlelib.idle_test import load_tests
if __name__ == '__main__':
unittest.main(verbosity=2, exit=False)
diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py
index 07157f5..8e4990b 100644
--- a/Lib/test/test_imaplib.py
+++ b/Lib/test/test_imaplib.py
@@ -243,6 +243,55 @@
client.shutdown()
@reap_threads
+ def test_bracket_flags(self):
+
+ # This violates RFC 3501, which disallows ']' characters in tag names,
+ # but imaplib has allowed producing such tags forever, other programs
+ # also produce them (eg: OtherInbox's Organizer app as of 20140716),
+ # and Gmail, for example, accepts them and produces them. So we
+ # support them. See issue #21815.
+
+ class BracketFlagHandler(SimpleIMAPHandler):
+
+ def handle(self):
+ self.flags = ['Answered', 'Flagged', 'Deleted', 'Seen', 'Draft']
+ super().handle()
+
+ def cmd_AUTHENTICATE(self, tag, args):
+ self._send_textline('+')
+ self.server.response = yield
+ self._send_tagged(tag, 'OK', 'FAKEAUTH successful')
+
+ def cmd_SELECT(self, tag, args):
+ flag_msg = ' \\'.join(self.flags)
+ self._send_line(('* FLAGS (%s)' % flag_msg).encode('ascii'))
+ self._send_line(b'* 2 EXISTS')
+ self._send_line(b'* 0 RECENT')
+ msg = ('* OK [PERMANENTFLAGS %s \\*)] Flags permitted.'
+ % flag_msg)
+ self._send_line(msg.encode('ascii'))
+ self._send_tagged(tag, 'OK', '[READ-WRITE] SELECT completed.')
+
+ def cmd_STORE(self, tag, args):
+ new_flags = args[2].strip('(').strip(')').split()
+ self.flags.extend(new_flags)
+ flags_msg = '(FLAGS (%s))' % ' \\'.join(self.flags)
+ msg = '* %s FETCH %s' % (args[0], flags_msg)
+ self._send_line(msg.encode('ascii'))
+ self._send_tagged(tag, 'OK', 'STORE completed.')
+
+ with self.reaped_pair(BracketFlagHandler) as (server, client):
+ code, data = client.authenticate('MYAUTH', lambda x: b'fake')
+ self.assertEqual(code, 'OK')
+ self.assertEqual(server.response, b'ZmFrZQ==\r\n')
+ client.select('test')
+ typ, [data] = client.store(b'1', "+FLAGS", "[test]")
+ self.assertIn(b'[test]', data)
+ client.select('test')
+ typ, [data] = client.response('PERMANENTFLAGS')
+ self.assertIn(b'[test]', data)
+
+ @reap_threads
def test_issue5949(self):
class EOFHandler(socketserver.StreamRequestHandler):
diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py
index ee9ee1a..4ece365 100644
--- a/Lib/test/test_imp.py
+++ b/Lib/test/test_imp.py
@@ -6,13 +6,12 @@
import importlib.util
import os
import os.path
-import shutil
import sys
from test import support
import unittest
import warnings
with warnings.catch_warnings():
- warnings.simplefilter('ignore', PendingDeprecationWarning)
+ warnings.simplefilter('ignore', DeprecationWarning)
import imp
diff --git a/Lib/test/test_importlib/extension/test_case_sensitivity.py b/Lib/test/test_importlib/extension/test_case_sensitivity.py
index 706c3e4..b74e900 100644
--- a/Lib/test/test_importlib/extension/test_case_sensitivity.py
+++ b/Lib/test/test_importlib/extension/test_case_sensitivity.py
@@ -1,5 +1,4 @@
from importlib import _bootstrap_external
-import sys
from test import support
import unittest
@@ -8,8 +7,6 @@
machinery = util.import_importlib('importlib.machinery')
-# XXX find_spec tests
-
@unittest.skipIf(util.EXTENSIONS.filename is None, '_testcapi not available')
@util.case_insensitive_tests
class ExtensionModuleCaseSensitivityTest:
diff --git a/Lib/test/test_importlib/extension/test_finder.py b/Lib/test/test_importlib/extension/test_finder.py
index 71bf67f..c9b4a37 100644
--- a/Lib/test/test_importlib/extension/test_finder.py
+++ b/Lib/test/test_importlib/extension/test_finder.py
@@ -6,7 +6,6 @@
import unittest
import warnings
-# XXX find_spec tests
class FinderTests(abc.FinderTests):
diff --git a/Lib/test/test_importlib/extension/test_path_hook.py b/Lib/test/test_importlib/extension/test_path_hook.py
index 8f4b8bb..a4b5a64 100644
--- a/Lib/test/test_importlib/extension/test_path_hook.py
+++ b/Lib/test/test_importlib/extension/test_path_hook.py
@@ -2,8 +2,6 @@
machinery = util.import_importlib('importlib.machinery')
-import collections
-import sys
import unittest
diff --git a/Lib/test/test_importlib/frozen/test_loader.py b/Lib/test/test_importlib/frozen/test_loader.py
index 603c7d7..29ecff1 100644
--- a/Lib/test/test_importlib/frozen/test_loader.py
+++ b/Lib/test/test_importlib/frozen/test_loader.py
@@ -3,8 +3,6 @@
machinery = util.import_importlib('importlib.machinery')
-
-import sys
from test.support import captured_stdout
import types
import unittest
diff --git a/Lib/test/test_importlib/import_/test___package__.py b/Lib/test/test_importlib/import_/test___package__.py
index c7d3a2a..7f64548 100644
--- a/Lib/test/test_importlib/import_/test___package__.py
+++ b/Lib/test/test_importlib/import_/test___package__.py
@@ -5,6 +5,7 @@
"""
import unittest
+import warnings
from .. import util
@@ -33,31 +34,50 @@
"""
- def test_using___package__(self):
- # [__package__]
+ def import_module(self, globals_):
with self.mock_modules('pkg.__init__', 'pkg.fake') as importer:
with util.import_state(meta_path=[importer]):
self.__import__('pkg.fake')
module = self.__import__('',
- globals={'__package__': 'pkg.fake'},
- fromlist=['attr'], level=2)
+ globals=globals_,
+ fromlist=['attr'], level=2)
+ return module
+
+ def test_using___package__(self):
+ # [__package__]
+ module = self.import_module({'__package__': 'pkg.fake'})
self.assertEqual(module.__name__, 'pkg')
- def test_using___name__(self, package_as_None=False):
+ def test_using___name__(self):
# [__name__]
- globals_ = {'__name__': 'pkg.fake', '__path__': []}
- if package_as_None:
- globals_['__package__'] = None
- with self.mock_modules('pkg.__init__', 'pkg.fake') as importer:
- with util.import_state(meta_path=[importer]):
- self.__import__('pkg.fake')
- module = self.__import__('', globals= globals_,
- fromlist=['attr'], level=2)
- self.assertEqual(module.__name__, 'pkg')
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore")
+ module = self.import_module({'__name__': 'pkg.fake',
+ '__path__': []})
+ self.assertEqual(module.__name__, 'pkg')
+
+ def test_warn_when_using___name__(self):
+ with self.assertWarns(ImportWarning):
+ self.import_module({'__name__': 'pkg.fake', '__path__': []})
def test_None_as___package__(self):
# [None]
- self.test_using___name__(package_as_None=True)
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore")
+ module = self.import_module({
+ '__name__': 'pkg.fake', '__path__': [], '__package__': None })
+ self.assertEqual(module.__name__, 'pkg')
+
+ def test_spec_fallback(self):
+ # If __package__ isn't defined, fall back on __spec__.parent.
+ module = self.import_module({'__spec__': FakeSpec('pkg.fake')})
+ self.assertEqual(module.__name__, 'pkg')
+
+ def test_warn_when_package_and_spec_disagree(self):
+ # Raise an ImportWarning if __package__ != __spec__.parent.
+ with self.assertWarns(ImportWarning):
+ self.import_module({'__package__': 'pkg.fake',
+ '__spec__': FakeSpec('pkg.fakefake')})
def test_bad__package__(self):
globals = {'__package__': '<not real>'}
@@ -70,6 +90,11 @@
self.__import__('', globals, {}, ['relimport'], 1)
+class FakeSpec:
+ def __init__(self, parent):
+ self.parent = parent
+
+
class Using__package__PEP302(Using__package__):
mock_modules = util.mock_modules
diff --git a/Lib/test/test_importlib/import_/test_packages.py b/Lib/test/test_importlib/import_/test_packages.py
index 3755b84..2439604 100644
--- a/Lib/test/test_importlib/import_/test_packages.py
+++ b/Lib/test/test_importlib/import_/test_packages.py
@@ -1,7 +1,6 @@
from .. import util
import sys
import unittest
-import importlib
from test import support
diff --git a/Lib/test/test_importlib/import_/test_path.py b/Lib/test/test_importlib/import_/test_path.py
index b32a876..7aa26b0 100644
--- a/Lib/test/test_importlib/import_/test_path.py
+++ b/Lib/test/test_importlib/import_/test_path.py
@@ -16,11 +16,14 @@
"""Tests for PathFinder."""
+ find = None
+ check_found = None
+
def test_failure(self):
# Test None returned upon not finding a suitable loader.
module = '<test module>'
with util.import_state():
- self.assertIsNone(self.machinery.PathFinder.find_module(module))
+ self.assertIsNone(self.find(module))
def test_sys_path(self):
# Test that sys.path is used when 'path' is None.
@@ -30,8 +33,8 @@
importer = util.mock_spec(module)
with util.import_state(path_importer_cache={path: importer},
path=[path]):
- loader = self.machinery.PathFinder.find_module(module)
- self.assertIs(loader, importer)
+ found = self.find(module)
+ self.check_found(found, importer)
def test_path(self):
# Test that 'path' is used when set.
@@ -40,8 +43,8 @@
path = '<test path>'
importer = util.mock_spec(module)
with util.import_state(path_importer_cache={path: importer}):
- loader = self.machinery.PathFinder.find_module(module, [path])
- self.assertIs(loader, importer)
+ found = self.find(module, [path])
+ self.check_found(found, importer)
def test_empty_list(self):
# An empty list should not count as asking for sys.path.
@@ -50,7 +53,7 @@
importer = util.mock_spec(module)
with util.import_state(path_importer_cache={path: importer},
path=[path]):
- self.assertIsNone(self.machinery.PathFinder.find_module('module', []))
+ self.assertIsNone(self.find('module', []))
def test_path_hooks(self):
# Test that sys.path_hooks is used.
@@ -60,8 +63,8 @@
importer = util.mock_spec(module)
hook = 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)
+ found = self.find(module, [path])
+ self.check_found(found, importer)
self.assertIn(path, sys.path_importer_cache)
self.assertIs(sys.path_importer_cache[path], importer)
@@ -73,7 +76,7 @@
path=[path_entry]):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
- self.assertIsNone(self.machinery.PathFinder.find_module('os'))
+ self.assertIsNone(self.find('os'))
self.assertIsNone(sys.path_importer_cache[path_entry])
self.assertEqual(len(w), 1)
self.assertTrue(issubclass(w[-1].category, ImportWarning))
@@ -85,8 +88,8 @@
importer = util.mock_spec(module)
hook = 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)
+ found = self.find(module)
+ self.check_found(found, importer)
self.assertIn(os.getcwd(), sys.path_importer_cache)
def test_None_on_sys_path(self):
@@ -182,15 +185,50 @@
self.assertIsNone(self.machinery.PathFinder.find_spec('whatever'))
+class FindModuleTests(FinderTests):
+ def find(self, *args, **kwargs):
+ return self.machinery.PathFinder.find_module(*args, **kwargs)
+ def check_found(self, found, importer):
+ self.assertIs(found, importer)
-(Frozen_FinderTests,
- Source_FinderTests
- ) = util.test_both(FinderTests, importlib=importlib, machinery=machinery)
+(Frozen_FindModuleTests,
+ Source_FindModuleTests
+) = util.test_both(FindModuleTests, importlib=importlib, machinery=machinery)
+
+
+class FindSpecTests(FinderTests):
+ def find(self, *args, **kwargs):
+ return self.machinery.PathFinder.find_spec(*args, **kwargs)
+ def check_found(self, found, importer):
+ self.assertIs(found.loader, importer)
+
+
+(Frozen_FindSpecTests,
+ Source_FindSpecTests
+ ) = util.test_both(FindSpecTests, importlib=importlib, machinery=machinery)
class PathEntryFinderTests:
+ def test_finder_with_failing_find_spec(self):
+ # PathEntryFinder with find_module() defined should work.
+ # Issue #20763.
+ class Finder:
+ path_location = 'test_finder_with_find_module'
+ def __init__(self, path):
+ if path != self.path_location:
+ raise ImportError
+
+ @staticmethod
+ def find_module(fullname):
+ return None
+
+
+ with util.import_state(path=[Finder.path_location]+sys.path[:],
+ path_hooks=[Finder]):
+ self.machinery.PathFinder.find_spec('importlib')
+
def test_finder_with_failing_find_module(self):
# PathEntryFinder with find_module() defined should work.
# Issue #20763.
@@ -207,7 +245,7 @@
with util.import_state(path=[Finder.path_location]+sys.path[:],
path_hooks=[Finder]):
- self.machinery.PathFinder.find_spec('importlib')
+ self.machinery.PathFinder.find_module('importlib')
(Frozen_PEFTests,
diff --git a/Lib/test/test_importlib/import_/test_relative_imports.py b/Lib/test/test_importlib/import_/test_relative_imports.py
index 3bb819f..8a95a32 100644
--- a/Lib/test/test_importlib/import_/test_relative_imports.py
+++ b/Lib/test/test_importlib/import_/test_relative_imports.py
@@ -1,7 +1,8 @@
"""Test relative imports (PEP 328)."""
from .. import util
-import sys
import unittest
+import warnings
+
class RelativeImports:
@@ -65,9 +66,11 @@
uncache_names.append(name[:-len('.__init__')])
with util.mock_spec(*create) as importer:
with util.import_state(meta_path=[importer]):
- for global_ in globals_:
- with util.uncache(*uncache_names):
- callback(global_)
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore")
+ for global_ in globals_:
+ with util.uncache(*uncache_names):
+ callback(global_)
def test_module_from_module(self):
@@ -204,11 +207,18 @@
def test_relative_import_no_globals(self):
# No globals for a relative import is an error.
- with self.assertRaises(KeyError):
- self.__import__('sys', level=1)
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore")
+ with self.assertRaises(KeyError):
+ self.__import__('sys', level=1)
+
+ def test_relative_import_no_package(self):
+ with self.assertRaises(ImportError):
+ self.__import__('a', {'__package__': '', '__spec__': None},
+ level=1)
def test_relative_import_no_package_exists_absolute(self):
- with self.assertRaises(SystemError):
+ with self.assertRaises(ImportError):
self.__import__('sys', {'__package__': '', '__spec__': None},
level=1)
diff --git a/Lib/test/test_importlib/regrtest.py b/Lib/test/test_importlib/regrtest.py
deleted file mode 100644
index a5be11f..0000000
--- a/Lib/test/test_importlib/regrtest.py
+++ /dev/null
@@ -1,17 +0,0 @@
-"""Run Python's standard test suite using importlib.__import__.
-
-Tests known to fail because of assumptions that importlib (properly)
-invalidates are automatically skipped if the entire test suite is run.
-Otherwise all command-line options valid for test.regrtest are also valid for
-this script.
-
-"""
-import importlib
-import sys
-from test import regrtest
-
-if __name__ == '__main__':
- __builtins__.__import__ = importlib.__import__
- sys.path_importer_cache.clear()
-
- regrtest.main(quiet=True, verbose2=True)
diff --git a/Lib/test/test_importlib/source/test_case_sensitivity.py b/Lib/test/test_importlib/source/test_case_sensitivity.py
index c274b38..0d6c388 100644
--- a/Lib/test/test_importlib/source/test_case_sensitivity.py
+++ b/Lib/test/test_importlib/source/test_case_sensitivity.py
@@ -5,7 +5,6 @@
machinery = util.import_importlib('importlib.machinery')
import os
-import sys
from test import support as test_support
import unittest
diff --git a/Lib/test/test_importlib/source/test_file_loader.py b/Lib/test/test_importlib/source/test_file_loader.py
index 73f4c62..a151149 100644
--- a/Lib/test/test_importlib/source/test_file_loader.py
+++ b/Lib/test/test_importlib/source/test_file_loader.py
@@ -217,7 +217,7 @@
# PEP 302
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
- mod = loader.load_module('_temp') # XXX
+ mod = loader.load_module('_temp')
# Sanity checks.
self.assertEqual(mod.__cached__, compiled)
self.assertEqual(mod.x, 5)
@@ -245,12 +245,7 @@
class BadBytecodeTest:
def import_(self, file, module_name):
- loader = self.loader(module_name, file)
- with warnings.catch_warnings():
- warnings.simplefilter('ignore', DeprecationWarning)
- # XXX Change to use exec_module().
- module = loader.load_module(module_name)
- self.assertIn(module_name, sys.modules)
+ raise NotImplementedError
def manipulate_bytecode(self, name, mapping, manipulator, *,
del_source=False):
diff --git a/Lib/test/test_importlib/source/test_path_hook.py b/Lib/test/test_importlib/source/test_path_hook.py
index e6a2415..795d436 100644
--- a/Lib/test/test_importlib/source/test_path_hook.py
+++ b/Lib/test/test_importlib/source/test_path_hook.py
@@ -16,10 +16,19 @@
def test_success(self):
with util.create_modules('dummy') as mapping:
self.assertTrue(hasattr(self.path_hook()(mapping['.root']),
- 'find_module'))
+ 'find_spec'))
+
+ def test_success_legacy(self):
+ with util.create_modules('dummy') as mapping:
+ self.assertTrue(hasattr(self.path_hook()(mapping['.root']),
+ 'find_module'))
def test_empty_string(self):
# The empty string represents the cwd.
+ self.assertTrue(hasattr(self.path_hook()(''), 'find_spec'))
+
+ def test_empty_string_legacy(self):
+ # The empty string represents the cwd.
self.assertTrue(hasattr(self.path_hook()(''), 'find_module'))
diff --git a/Lib/test/test_importlib/source/test_source_encoding.py b/Lib/test/test_importlib/source/test_source_encoding.py
index 1e0771b..980855f 100644
--- a/Lib/test/test_importlib/source/test_source_encoding.py
+++ b/Lib/test/test_importlib/source/test_source_encoding.py
@@ -5,7 +5,6 @@
import codecs
import importlib.util
import re
-import sys
import types
# Because sys.path gets essentially blanked, need to have unicodedata already
# imported for the parser to use.
diff --git a/Lib/test/test_importlib/test_abc.py b/Lib/test/test_importlib/test_abc.py
index d4bf915..c862480 100644
--- a/Lib/test/test_importlib/test_abc.py
+++ b/Lib/test/test_importlib/test_abc.py
@@ -207,6 +207,10 @@
SPLIT = make_abc_subclasses(Loader)
+ def test_create_module(self):
+ spec = 'a spec'
+ self.assertIsNone(self.ins.create_module(spec))
+
def test_load_module(self):
with self.assertRaises(ImportError):
self.ins.load_module('something')
@@ -519,6 +523,12 @@
support.unload(self.module_name)
self.addCleanup(support.unload, self.module_name)
+ def load(self, loader):
+ spec = self.util.spec_from_loader(self.module_name, loader)
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', DeprecationWarning)
+ return self.init._bootstrap._load_unlocked(spec)
+
def mock_get_code(self):
return mock.patch.object(self.InspectLoaderSubclass, 'get_code')
@@ -528,9 +538,7 @@
mocked_get_code.side_effect = ImportError
with self.assertRaises(ImportError):
loader = self.InspectLoaderSubclass()
- with warnings.catch_warnings():
- warnings.simplefilter('ignore', DeprecationWarning)
- loader.load_module(self.module_name)
+ self.load(loader)
def test_get_code_None(self):
# If get_code() returns None, raise ImportError.
@@ -538,7 +546,7 @@
mocked_get_code.return_value = None
with self.assertRaises(ImportError):
loader = self.InspectLoaderSubclass()
- loader.load_module(self.module_name)
+ self.load(loader)
def test_module_returned(self):
# The loaded module should be returned.
@@ -546,14 +554,16 @@
with self.mock_get_code() as mocked_get_code:
mocked_get_code.return_value = code
loader = self.InspectLoaderSubclass()
- module = loader.load_module(self.module_name)
+ module = self.load(loader)
self.assertEqual(module, sys.modules[self.module_name])
(Frozen_ILLoadModuleTests,
Source_ILLoadModuleTests
) = test_util.test_both(InspectLoaderLoadModuleTests,
- InspectLoaderSubclass=SPLIT_IL)
+ InspectLoaderSubclass=SPLIT_IL,
+ init=init,
+ util=util)
##### ExecutionLoader concrete methods #########################################
diff --git a/Lib/test/test_importlib/test_api.py b/Lib/test/test_importlib/test_api.py
index 6bc3c56..b0a94aa 100644
--- a/Lib/test/test_importlib/test_api.py
+++ b/Lib/test/test_importlib/test_api.py
@@ -99,9 +99,7 @@
class FindLoaderTests:
- class FakeMetaFinder:
- @staticmethod
- def find_module(name, path=None): return name, path
+ FakeMetaFinder = None
def test_sys_modules(self):
# If a module with __loader__ is in sys.modules, then return it.
@@ -171,9 +169,30 @@
self.assertIsNone(self.init.find_loader('nevergoingtofindthismodule'))
-(Frozen_FindLoaderTests,
- Source_FindLoaderTests
- ) = test_util.test_both(FindLoaderTests, init=init)
+class FindLoaderPEP451Tests(FindLoaderTests):
+
+ class FakeMetaFinder:
+ @staticmethod
+ def find_spec(name, path=None, target=None):
+ return machinery['Source'].ModuleSpec(name, (name, path))
+
+
+(Frozen_FindLoaderPEP451Tests,
+ Source_FindLoaderPEP451Tests
+ ) = test_util.test_both(FindLoaderPEP451Tests, init=init)
+
+
+class FindLoaderPEP302Tests(FindLoaderTests):
+
+ class FakeMetaFinder:
+ @staticmethod
+ def find_module(name, path=None):
+ return name, path
+
+
+(Frozen_FindLoaderPEP302Tests,
+ Source_FindLoaderPEP302Tests
+ ) = test_util.test_both(FindLoaderPEP302Tests, init=init)
class ReloadTests:
diff --git a/Lib/test/test_importlib/test_lazy.py b/Lib/test/test_importlib/test_lazy.py
index cc383c2..ffd8dc6 100644
--- a/Lib/test/test_importlib/test_lazy.py
+++ b/Lib/test/test_importlib/test_lazy.py
@@ -66,6 +66,8 @@
spec = util.spec_from_loader(TestingImporter.module_name,
util.LazyLoader(loader))
module = spec.loader.create_module(spec)
+ if module is None:
+ module = types.ModuleType(TestingImporter.module_name)
module.__spec__ = spec
module.__loader__ = spec.loader
spec.loader.exec_module(module)
diff --git a/Lib/test/test_importlib/test_locks.py b/Lib/test/test_importlib/test_locks.py
index df0af12..b2aadff 100644
--- a/Lib/test/test_importlib/test_locks.py
+++ b/Lib/test/test_importlib/test_locks.py
@@ -3,7 +3,6 @@
init = test_util.import_importlib('importlib')
import sys
-import time
import unittest
import weakref
diff --git a/Lib/test/test_importlib/test_namespace_pkgs.py b/Lib/test/test_importlib/test_namespace_pkgs.py
index 6639612..e37d8a1 100644
--- a/Lib/test/test_importlib/test_namespace_pkgs.py
+++ b/Lib/test/test_importlib/test_namespace_pkgs.py
@@ -1,13 +1,10 @@
import contextlib
-import importlib.abc
-import importlib.machinery
+import importlib
import os
import sys
-import types
import unittest
from test.test_importlib import util
-from test.support import run_unittest
# needed tests:
#
@@ -71,6 +68,7 @@
# TODO: will we ever want to pass exc_info to __exit__?
self.ctx.__exit__(None, None, None)
+
class SingleNamespacePackage(NamespacePackageTest):
paths = ['portion1']
@@ -87,7 +85,7 @@
self.assertEqual(repr(foo), "<module 'foo' (namespace)>")
-class DynamicPatheNamespacePackage(NamespacePackageTest):
+class DynamicPathNamespacePackage(NamespacePackageTest):
paths = ['portion1']
def test_dynamic_path(self):
@@ -289,5 +287,35 @@
self.assertEqual(a_test.attr, 'in module')
+class ReloadTests(NamespacePackageTest):
+ paths = ['portion1']
+
+ def test_simple_package(self):
+ import foo.one
+ foo = importlib.reload(foo)
+ self.assertEqual(foo.one.attr, 'portion1 foo one')
+
+ def test_cant_import_other(self):
+ import foo
+ with self.assertRaises(ImportError):
+ import foo.two
+ foo = importlib.reload(foo)
+ with self.assertRaises(ImportError):
+ import foo.two
+
+ def test_dynamic_path(self):
+ import foo.one
+ with self.assertRaises(ImportError):
+ import foo.two
+
+ # Now modify sys.path and reload.
+ sys.path.append(os.path.join(self.root, 'portion2'))
+ foo = importlib.reload(foo)
+
+ # And make sure foo.two is now importable
+ import foo.two
+ self.assertEqual(foo.two.attr, 'portion2 foo two')
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_importlib/test_windows.py b/Lib/test/test_importlib/test_windows.py
index c893bcf..005b685 100644
--- a/Lib/test/test_importlib/test_windows.py
+++ b/Lib/test/test_importlib/test_windows.py
@@ -40,7 +40,7 @@
else:
root = machinery.WindowsRegistryFinder.REGISTRY_KEY
key = root.format(fullname=name,
- sys_version=sys.version[:3])
+ sys_version='%d.%d' % sys.version_info[:2])
try:
with temp_module(name, "a = 1") as location:
subkey = CreateKey(HKEY_CURRENT_USER, key)
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 671e05a..47244ae 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -30,6 +30,7 @@
from test.support.script_helper import assert_python_ok, assert_python_failure
from test import inspect_fodder as mod
from test import inspect_fodder2 as mod2
+from test import support
from test.test_import import _ready_to_import
@@ -38,7 +39,7 @@
# ismodule, isclass, ismethod, isfunction, istraceback, isframe, iscode,
# isbuiltin, isroutine, isgenerator, isgeneratorfunction, getmembers,
# getdoc, getfile, getmodule, getsourcefile, getcomments, getsource,
-# getclasstree, getargspec, getargvalues, formatargspec, formatargvalues,
+# getclasstree, getargvalues, formatargspec, formatargvalues,
# currentframe, stack, trace, isdatadescriptor
# NOTE: There are some additional tests relating to interaction with
@@ -400,7 +401,7 @@
self.assertEqual(normcase(inspect.getsourcefile(mod.spam)), modfile)
self.assertEqual(normcase(inspect.getsourcefile(git.abuse)), modfile)
fn = "_non_existing_filename_used_for_sourcefile_test.py"
- co = compile("None", fn, "exec")
+ co = compile("x=1", fn, "exec")
self.assertEqual(inspect.getsourcefile(co), None)
linecache.cache[co.co_filename] = (1, None, "None", co.co_filename)
try:
@@ -2902,6 +2903,10 @@
'is not a valid parameter name'):
inspect.Parameter('$', kind=inspect.Parameter.VAR_KEYWORD)
+ with self.assertRaisesRegex(ValueError,
+ 'is not a valid parameter name'):
+ inspect.Parameter('.a', kind=inspect.Parameter.VAR_KEYWORD)
+
with self.assertRaisesRegex(ValueError, 'cannot have default values'):
inspect.Parameter('a', default=42,
kind=inspect.Parameter.VAR_KEYWORD)
@@ -2985,6 +2990,17 @@
with self.assertRaisesRegex(TypeError, 'name must be a str'):
inspect.Parameter(None, kind=inspect.Parameter.POSITIONAL_ONLY)
+ @cpython_only
+ def test_signature_parameter_implicit(self):
+ with self.assertRaisesRegex(ValueError,
+ 'implicit arguments must be passed in as'):
+ inspect.Parameter('.0', kind=inspect.Parameter.POSITIONAL_ONLY)
+
+ param = inspect.Parameter(
+ '.0', kind=inspect.Parameter.POSITIONAL_OR_KEYWORD)
+ self.assertEqual(param.kind, inspect.Parameter.POSITIONAL_ONLY)
+ self.assertEqual(param.name, 'implicit0')
+
def test_signature_parameter_immutability(self):
p = inspect.Parameter('spam', kind=inspect.Parameter.KEYWORD_ONLY)
@@ -3233,6 +3249,17 @@
ba = sig.bind(args=1)
self.assertEqual(ba.arguments, {'kwargs': {'args': 1}})
+ @cpython_only
+ def test_signature_bind_implicit_arg(self):
+ # Issue #19611: getcallargs should work with set comprehensions
+ def make_set():
+ return {z * z for z in range(5)}
+ setcomp_code = make_set.__code__.co_consts[1]
+ setcomp_func = types.FunctionType(setcomp_code, {})
+
+ iterator = iter(range(5))
+ self.assertEqual(self.call(setcomp_func, iterator), {0, 1, 4, 9, 16})
+
class TestBoundArguments(unittest.TestCase):
def test_signature_bound_arguments_unhashable(self):
@@ -3543,14 +3570,14 @@
def test_details(self):
module = importlib.import_module('unittest')
- rc, out, err = assert_python_ok('-m', 'inspect',
+ args = support.optim_args_from_interpreter_flags()
+ rc, out, err = assert_python_ok(*args, '-m', 'inspect',
'unittest', '--details')
output = out.decode()
# Just a quick sanity check on the output
self.assertIn(module.__name__, output)
self.assertIn(module.__file__, output)
- if not sys.flags.optimize:
- self.assertIn(module.__cached__, output)
+ self.assertIn(module.__cached__, output)
self.assertEqual(err, b'')
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 000b525..0bfaba9 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -496,7 +496,11 @@
def test_open_handles_NUL_chars(self):
fn_with_NUL = 'foo\0bar'
self.assertRaises(ValueError, self.open, fn_with_NUL, 'w')
- self.assertRaises(ValueError, self.open, bytes(fn_with_NUL, 'ascii'), 'w')
+
+ bytes_fn = bytes(fn_with_NUL, 'ascii')
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
+ self.assertRaises(ValueError, self.open, bytes_fn, 'w')
def test_raw_file_io(self):
with self.open(support.TESTFN, "wb", buffering=0) as f:
@@ -856,6 +860,32 @@
self.assertEqual(getattr(stream, method)(buffer), 5)
self.assertEqual(bytes(buffer), b"12345")
+ def test_fspath_support(self):
+ class PathLike:
+ def __init__(self, path):
+ self.path = path
+
+ def __fspath__(self):
+ return self.path
+
+ def check_path_succeeds(path):
+ with self.open(path, "w") as f:
+ f.write("egg\n")
+
+ with self.open(path, "r") as f:
+ self.assertEqual(f.read(), "egg\n")
+
+ check_path_succeeds(PathLike(support.TESTFN))
+ check_path_succeeds(PathLike(support.TESTFN.encode('utf-8')))
+
+ bad_path = PathLike(TypeError)
+ with self.assertRaises(TypeError):
+ self.open(bad_path, 'w')
+
+ # ensure that refcounting is correct with some error conditions
+ with self.assertRaisesRegex(ValueError, 'read/write/append mode'):
+ self.open(PathLike(support.TESTFN), 'rwxa')
+
class CIOTest(IOTest):
@@ -3244,8 +3274,7 @@
class PyTextIOWrapperTest(TextIOWrapperTest):
io = pyio
- #shutdown_error = "LookupError: unknown encoding: ascii"
- shutdown_error = "TypeError: 'NoneType' object is not iterable"
+ shutdown_error = "LookupError: unknown encoding: ascii"
class IncrementalNewlineDecoderTest(unittest.TestCase):
diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py
index be62fad..6c08f80 100644
--- a/Lib/test/test_ipaddress.py
+++ b/Lib/test/test_ipaddress.py
@@ -1176,6 +1176,7 @@
self.assertEqual(str(self.ipv6_network[5]),
'2001:658:22a:cafe::5')
+ self.assertRaises(IndexError, self.ipv6_network.__getitem__, 1 << 64)
def testGetitem(self):
# http://code.google.com/p/ipaddr-py/issues/detail?id=15
diff --git a/Lib/test/test_iterlen.py b/Lib/test/test_iterlen.py
index 152f5fc..41c9752 100644
--- a/Lib/test/test_iterlen.py
+++ b/Lib/test/test_iterlen.py
@@ -42,7 +42,6 @@
"""
import unittest
-from test import support
from itertools import repeat
from collections import deque
from operator import length_hint
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
index f940852..945c58d 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -4,7 +4,6 @@
import weakref
from decimal import Decimal
from fractions import Fraction
-import sys
import operator
import random
import copy
@@ -613,6 +612,56 @@
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
self.pickletest(proto, cycle('abc'))
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ # test with partial consumed input iterable
+ it = iter('abcde')
+ c = cycle(it)
+ _ = [next(c) for i in range(2)] # consume 2 of 5 inputs
+ p = pickle.dumps(c, proto)
+ d = pickle.loads(p) # rebuild the cycle object
+ self.assertEqual(take(20, d), list('cdeabcdeabcdeabcdeab'))
+
+ # test with completely consumed input iterable
+ it = iter('abcde')
+ c = cycle(it)
+ _ = [next(c) for i in range(7)] # consume 7 of 5 inputs
+ p = pickle.dumps(c, proto)
+ d = pickle.loads(p) # rebuild the cycle object
+ self.assertEqual(take(20, d), list('cdeabcdeabcdeabcdeab'))
+
+ def test_cycle_setstate(self):
+ # Verify both modes for restoring state
+
+ # Mode 0 is efficient. It uses an incompletely consumed input
+ # iterator to build a cycle object and then passes in state with
+ # a list of previously consumed values. There is no data
+ # overlap between the two.
+ c = cycle('defg')
+ c.__setstate__((list('abc'), 0))
+ self.assertEqual(take(20, c), list('defgabcdefgabcdefgab'))
+
+ # Mode 1 is inefficient. It starts with a cycle object built
+ # from an iterator over the remaining elements in a partial
+ # cycle and then passes in state with all of the previously
+ # seen values (this overlaps values included in the iterator).
+ c = cycle('defg')
+ c.__setstate__((list('abcdefg'), 1))
+ self.assertEqual(take(20, c), list('defgabcdefgabcdefgab'))
+
+ # The first argument to setstate needs to be a tuple
+ with self.assertRaises(SystemError):
+ cycle('defg').__setstate__([list('abcdefg'), 0])
+
+ # The first argument in the setstate tuple must be a list
+ with self.assertRaises(TypeError):
+ c = cycle('defg')
+ c.__setstate__((dict.fromkeys('defg'), 0))
+ take(20, c)
+
+ # The first argument in the setstate tuple must be a list
+ with self.assertRaises(TypeError):
+ cycle('defg').__setstate__((list('abcdefg'), 'x'))
+
def test_groupby(self):
# Check whether it accepts arguments correctly
self.assertEqual([], list(groupby([])))
diff --git a/Lib/test/test_json/__init__.py b/Lib/test/test_json/__init__.py
index 0807e6f..bac370d 100644
--- a/Lib/test/test_json/__init__.py
+++ b/Lib/test/test_json/__init__.py
@@ -1,5 +1,4 @@
import os
-import sys
import json
import doctest
import unittest
diff --git a/Lib/test/test_json/test_fail.py b/Lib/test/test_json/test_fail.py
index 95ff5b8..7910521 100644
--- a/Lib/test/test_json/test_fail.py
+++ b/Lib/test/test_json/test_fail.py
@@ -1,5 +1,4 @@
from test.test_json import PyTest, CTest
-import re
# 2007-10-05
JSONDOCS = [
diff --git a/Lib/test/test_kqueue.py b/Lib/test/test_kqueue.py
index f822024..9f49886 100644
--- a/Lib/test/test_kqueue.py
+++ b/Lib/test/test_kqueue.py
@@ -5,7 +5,6 @@
import os
import select
import socket
-import sys
import time
import unittest
diff --git a/Lib/test/test_linecache.py b/Lib/test/test_linecache.py
index 47e2edd..375d9c4 100644
--- a/Lib/test/test_linecache.py
+++ b/Lib/test/test_linecache.py
@@ -3,6 +3,8 @@
import linecache
import unittest
import os.path
+import tempfile
+import tokenize
from test import support
@@ -10,8 +12,6 @@
NONEXISTENT_FILENAME = FILENAME + '.missing'
INVALID_NAME = '!@$)(!@#_1'
EMPTY = ''
-TESTS = 'inspect_fodder inspect_fodder2 mapping_tests'
-TESTS = TESTS.split()
TEST_PATH = os.path.dirname(__file__)
MODULES = "linecache abc".split()
MODULE_PATH = os.path.dirname(FILENAME)
@@ -37,6 +37,65 @@
return 3''' # No ending newline
+class TempFile:
+
+ def setUp(self):
+ super().setUp()
+ with tempfile.NamedTemporaryFile(delete=False) as fp:
+ self.file_name = fp.name
+ fp.write(self.file_byte_string)
+ self.addCleanup(support.unlink, self.file_name)
+
+
+class GetLineTestsGoodData(TempFile):
+ # file_list = ['list\n', 'of\n', 'good\n', 'strings\n']
+
+ def setUp(self):
+ self.file_byte_string = ''.join(self.file_list).encode('utf-8')
+ super().setUp()
+
+ def test_getline(self):
+ with tokenize.open(self.file_name) as fp:
+ for index, line in enumerate(fp):
+ if not line.endswith('\n'):
+ line += '\n'
+
+ cached_line = linecache.getline(self.file_name, index + 1)
+ self.assertEqual(line, cached_line)
+
+ def test_getlines(self):
+ lines = linecache.getlines(self.file_name)
+ self.assertEqual(lines, self.file_list)
+
+
+class GetLineTestsBadData(TempFile):
+ # file_byte_string = b'Bad data goes here'
+
+ def test_getline(self):
+ self.assertRaises((SyntaxError, UnicodeDecodeError),
+ linecache.getline, self.file_name, 1)
+
+ def test_getlines(self):
+ self.assertRaises((SyntaxError, UnicodeDecodeError),
+ linecache.getlines, self.file_name)
+
+
+class EmptyFile(GetLineTestsGoodData, unittest.TestCase):
+ file_list = []
+
+
+class SingleEmptyLine(GetLineTestsGoodData, unittest.TestCase):
+ file_list = ['\n']
+
+
+class GoodUnicode(GetLineTestsGoodData, unittest.TestCase):
+ file_list = ['á\n', 'b\n', 'abcdef\n', 'ááááá\n']
+
+
+class BadUnicode(GetLineTestsBadData, unittest.TestCase):
+ file_byte_string = b'\x80abc'
+
+
class LineCacheTests(unittest.TestCase):
def test_getline(self):
@@ -53,13 +112,6 @@
self.assertEqual(getline(EMPTY, 1), EMPTY)
self.assertEqual(getline(INVALID_NAME, 1), EMPTY)
- # Check whether lines correspond to those from file iteration
- for entry in TESTS:
- filename = os.path.join(TEST_PATH, entry) + '.py'
- with open(filename) as file:
- for index, line in enumerate(file):
- self.assertEqual(line, getline(filename, index + 1))
-
# Check module loading
for entry in MODULES:
filename = os.path.join(MODULE_PATH, entry) + '.py'
@@ -80,12 +132,13 @@
def test_clearcache(self):
cached = []
- for entry in TESTS:
- filename = os.path.join(TEST_PATH, entry) + '.py'
+ for entry in MODULES:
+ filename = os.path.join(MODULE_PATH, entry) + '.py'
cached.append(filename)
linecache.getline(filename, 1)
# Are all files cached?
+ self.assertNotEqual(cached, [])
cached_empty = [fn for fn in cached if fn not in linecache.cache]
self.assertEqual(cached_empty, [])
diff --git a/Lib/test/test_list.py b/Lib/test/test_list.py
index 8f82ab5..aee62dc 100644
--- a/Lib/test/test_list.py
+++ b/Lib/test/test_list.py
@@ -1,5 +1,5 @@
import sys
-from test import support, list_tests
+from test import list_tests
import pickle
import unittest
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index 84fd8b5..9e391dc 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -4160,6 +4160,17 @@
msg = 'Record not found in event log, went back %d records' % GO_BACK
self.assertTrue(found, msg=msg)
+
+class MiscTestCase(unittest.TestCase):
+ def test__all__(self):
+ blacklist = {'logThreads', 'logMultiprocessing',
+ 'logProcesses', 'currentframe',
+ 'PercentStyle', 'StrFormatStyle', 'StringTemplateStyle',
+ 'Filterer', 'PlaceHolder', 'Manager', 'RootLogger',
+ 'root'}
+ support.check__all__(self, logging, blacklist=blacklist)
+
+
# Set the locale to the platform-dependent default. I have no idea
# why the test does this, but in any case we save the current locale
# first and restore it at the end.
@@ -4176,7 +4187,8 @@
RotatingFileHandlerTest, LastResortTest, LogRecordTest,
ExceptionTest, SysLogHandlerTest, HTTPHandlerTest,
NTEventLogHandlerTest, TimedRotatingFileHandlerTest,
- UnixSocketHandlerTest, UnixDatagramHandlerTest, UnixSysLogHandlerTest)
+ UnixSocketHandlerTest, UnixDatagramHandlerTest, UnixSysLogHandlerTest,
+ MiscTestCase)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py
index b2d008b..f0dd074 100644
--- a/Lib/test/test_long.py
+++ b/Lib/test/test_long.py
@@ -689,6 +689,20 @@
self.assertRaises(OverflowError, int, float('-inf'))
self.assertRaises(ValueError, int, float('nan'))
+ def test_mod_division(self):
+ with self.assertRaises(ZeroDivisionError):
+ _ = 1 % 0
+
+ self.assertEqual(13 % 10, 3)
+ self.assertEqual(-13 % 10, 7)
+ self.assertEqual(13 % -10, -7)
+ self.assertEqual(-13 % -10, -3)
+
+ self.assertEqual(12 % 4, 0)
+ self.assertEqual(-12 % 4, 0)
+ self.assertEqual(12 % -4, 0)
+ self.assertEqual(-12 % -4, 0)
+
def test_true_division(self):
huge = 1 << 40000
mhuge = -huge
@@ -723,6 +737,25 @@
for zero in ["huge / 0", "mhuge / 0"]:
self.assertRaises(ZeroDivisionError, eval, zero, namespace)
+ def test_floordiv(self):
+ with self.assertRaises(ZeroDivisionError):
+ _ = 1 // 0
+
+ self.assertEqual(2 // 3, 0)
+ self.assertEqual(2 // -3, -1)
+ self.assertEqual(-2 // 3, -1)
+ self.assertEqual(-2 // -3, 0)
+
+ self.assertEqual(-11 // -3, 3)
+ self.assertEqual(-11 // 3, -4)
+ self.assertEqual(11 // -3, -4)
+ self.assertEqual(11 // 3, 3)
+
+ self.assertEqual(-12 // -3, 4)
+ self.assertEqual(-12 // 3, -4)
+ self.assertEqual(12 // -3, -4)
+ self.assertEqual(12 // 3, 4)
+
def check_truediv(self, a, b, skip_small=True):
"""Verify that the result of a/b is correctly rounded, by
comparing it with a pure Python implementation of correctly
diff --git a/Lib/test/test_macpath.py b/Lib/test/test_macpath.py
index 80bec7a..0698ff5 100644
--- a/Lib/test/test_macpath.py
+++ b/Lib/test/test_macpath.py
@@ -1,5 +1,5 @@
import macpath
-from test import support, test_genericpath
+from test import test_genericpath
import unittest
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index 0991f74..aeabdbb 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -7,17 +7,12 @@
import email.message
import re
import io
-import shutil
import tempfile
from test import support
import unittest
import textwrap
import mailbox
import glob
-try:
- import fcntl
-except ImportError:
- pass
class TestBase:
@@ -2273,12 +2268,18 @@
""")
+class MiscTestCase(unittest.TestCase):
+ def test__all__(self):
+ blacklist = {"linesep", "fcntl"}
+ support.check__all__(self, mailbox, blacklist=blacklist)
+
+
def test_main():
tests = (TestMailboxSuperclass, TestMaildir, TestMbox, TestMMDF, TestMH,
TestBabyl, TestMessage, TestMaildirMessage, TestMboxMessage,
TestMHMessage, TestBabylMessage, TestMMDFMessage,
TestMessageConversion, TestProxyFile, TestPartialFile,
- MaildirTestCase, TestFakeMailBox)
+ MaildirTestCase, TestFakeMailBox, MiscTestCase)
support.run_unittest(*tests)
support.reap_children()
diff --git a/Lib/test/test_mailcap.py b/Lib/test/test_mailcap.py
index 22b2fcc..623fadb 100644
--- a/Lib/test/test_mailcap.py
+++ b/Lib/test/test_mailcap.py
@@ -1,6 +1,5 @@
import mailcap
import os
-import shutil
import test.support
import unittest
diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py
index c7def9a..b378ffe 100644
--- a/Lib/test/test_marshal.py
+++ b/Lib/test/test_marshal.py
@@ -135,6 +135,13 @@
for constructor in (set, frozenset):
self.helper(constructor(self.d.keys()))
+ @support.cpython_only
+ def test_empty_frozenset_singleton(self):
+ # marshal.loads() must reuse the empty frozenset singleton
+ obj = frozenset()
+ obj2 = marshal.loads(marshal.dumps(obj))
+ self.assertIs(obj2, obj)
+
class BufferTestCase(unittest.TestCase, HelperMixin):
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index 6c7b99d..d0bc790 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -6,7 +6,6 @@
import unittest
import math
import os
-import platform
import sys
import struct
import sysconfig
diff --git a/Lib/test/test_metaclass.py b/Lib/test/test_metaclass.py
index e6fe20a..be683dd 100644
--- a/Lib/test/test_metaclass.py
+++ b/Lib/test/test_metaclass.py
@@ -78,7 +78,7 @@
>>> class C(object, metaclass=M, other="haha"):
... pass
...
- Prepare called: ('C', (<class 'object'>,)) {'other': 'haha'}
+ Prepare called: ('C', (<class 'object' ...>,)) {'other': 'haha'}
New called: {'other': 'haha'}
>>> C.__class__ is M
True
@@ -104,7 +104,7 @@
>>> kwds = {'metaclass': M, 'other': 'haha'}
>>> class C(*bases, **kwds): pass
...
- Prepare called: ('C', (<class 'object'>,)) {'other': 'haha'}
+ Prepare called: ('C', (<class 'object' ...>,)) {'other': 'haha'}
New called: {'other': 'haha'}
>>> C.__class__ is M
True
@@ -114,7 +114,7 @@
>>> kwds = {'other': 'haha'}
>>> class C(B, metaclass=M, *bases, **kwds): pass
...
- Prepare called: ('C', (<class 'test.test_metaclass.B'>, <class 'object'>)) {'other': 'haha'}
+ Prepare called: ('C', (<class 'test.test_metaclass.B' ...>, <class 'object' ...>)) {'other': 'haha'}
New called: {'other': 'haha'}
>>> C.__class__ is M
True
@@ -259,7 +259,8 @@
def test_main(verbose=False):
from test import support
from test import test_metaclass
- support.run_doctest(test_metaclass, verbose)
+ import doctest
+ support.run_doctest(test_metaclass, verbose, optionflags=doctest.ELLIPSIS)
if __name__ == "__main__":
test_main(verbose=True)
diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py
index 6856593..4e2c908 100644
--- a/Lib/test/test_mimetypes.py
+++ b/Lib/test/test_mimetypes.py
@@ -101,5 +101,11 @@
eq(self.db.guess_type("image.jpg"), ("image/jpeg", None))
eq(self.db.guess_type("image.png"), ("image/png", None))
+
+class MiscTestCase(unittest.TestCase):
+ def test__all__(self):
+ support.check__all__(self, mimetypes)
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py
index b365d84..bbb4070 100644
--- a/Lib/test/test_mmap.py
+++ b/Lib/test/test_mmap.py
@@ -713,6 +713,14 @@
gc_collect()
self.assertIs(wr(), None)
+ def test_write_returning_the_number_of_bytes_written(self):
+ mm = mmap.mmap(-1, 16)
+ self.assertEqual(mm.write(b""), 0)
+ self.assertEqual(mm.write(b"x"), 1)
+ self.assertEqual(mm.write(b"yz"), 2)
+ self.assertEqual(mm.write(b"python"), 6)
+
+
class LargeMmapTests(unittest.TestCase):
def setUp(self):
diff --git a/Lib/test/test_msilib.py b/Lib/test/test_msilib.py
index 8ef334f..f656f72 100644
--- a/Lib/test/test_msilib.py
+++ b/Lib/test/test_msilib.py
@@ -1,6 +1,5 @@
""" Test suite for the code in msilib """
import unittest
-import os
from test.support import import_module
msilib = import_module('msilib')
diff --git a/Lib/test/test_multibytecodec.py b/Lib/test/test_multibytecodec.py
index 8d7a213..01a1cd3 100644
--- a/Lib/test/test_multibytecodec.py
+++ b/Lib/test/test_multibytecodec.py
@@ -5,7 +5,7 @@
from test import support
from test.support import TESTFN
-import unittest, io, codecs, sys, os
+import unittest, io, codecs, sys
import _multibytecodec
ALL_CJKENCODINGS = [
diff --git a/Lib/test/test_multiprocessing_main_handling.py b/Lib/test/test_multiprocessing_main_handling.py
index 52273ea..2e15cd8 100644
--- a/Lib/test/test_multiprocessing_main_handling.py
+++ b/Lib/test/test_multiprocessing_main_handling.py
@@ -6,7 +6,6 @@
import importlib
import importlib.machinery
-import zipimport
import unittest
import sys
import os
@@ -15,7 +14,7 @@
from test.support.script_helper import (
make_pkg, make_script, make_zip_pkg, make_zip_script,
- assert_python_ok, assert_python_failure, spawn_python, kill_python)
+ assert_python_ok)
# Look up which start methods are available to test
import multiprocessing
diff --git a/Lib/test/test_nis.py b/Lib/test/test_nis.py
index 387a4e7..21074c6 100644
--- a/Lib/test/test_nis.py
+++ b/Lib/test/test_nis.py
@@ -1,6 +1,5 @@
from test import support
import unittest
-import sys
# Skip test if nis module does not exist.
nis = support.import_module('nis')
diff --git a/Lib/test/test_normalization.py b/Lib/test/test_normalization.py
index 30fa612..5b590e1 100644
--- a/Lib/test/test_normalization.py
+++ b/Lib/test/test_normalization.py
@@ -3,7 +3,6 @@
from http.client import HTTPException
import sys
-import os
from unicodedata import normalize, unidata_version
TESTDATAFILE = "NormalizationTest.txt"
diff --git a/Lib/test/test_operator.py b/Lib/test/test_operator.py
index b5ba976..6254091 100644
--- a/Lib/test/test_operator.py
+++ b/Lib/test/test_operator.py
@@ -120,63 +120,63 @@
operator = self.module
self.assertRaises(TypeError, operator.add)
self.assertRaises(TypeError, operator.add, None, None)
- self.assertTrue(operator.add(3, 4) == 7)
+ self.assertEqual(operator.add(3, 4), 7)
def test_bitwise_and(self):
operator = self.module
self.assertRaises(TypeError, operator.and_)
self.assertRaises(TypeError, operator.and_, None, None)
- self.assertTrue(operator.and_(0xf, 0xa) == 0xa)
+ self.assertEqual(operator.and_(0xf, 0xa), 0xa)
def test_concat(self):
operator = self.module
self.assertRaises(TypeError, operator.concat)
self.assertRaises(TypeError, operator.concat, None, None)
- self.assertTrue(operator.concat('py', 'thon') == 'python')
- self.assertTrue(operator.concat([1, 2], [3, 4]) == [1, 2, 3, 4])
- self.assertTrue(operator.concat(Seq1([5, 6]), Seq1([7])) == [5, 6, 7])
- self.assertTrue(operator.concat(Seq2([5, 6]), Seq2([7])) == [5, 6, 7])
+ self.assertEqual(operator.concat('py', 'thon'), 'python')
+ self.assertEqual(operator.concat([1, 2], [3, 4]), [1, 2, 3, 4])
+ self.assertEqual(operator.concat(Seq1([5, 6]), Seq1([7])), [5, 6, 7])
+ self.assertEqual(operator.concat(Seq2([5, 6]), Seq2([7])), [5, 6, 7])
self.assertRaises(TypeError, operator.concat, 13, 29)
def test_countOf(self):
operator = self.module
self.assertRaises(TypeError, operator.countOf)
self.assertRaises(TypeError, operator.countOf, None, None)
- self.assertTrue(operator.countOf([1, 2, 1, 3, 1, 4], 3) == 1)
- self.assertTrue(operator.countOf([1, 2, 1, 3, 1, 4], 5) == 0)
+ self.assertEqual(operator.countOf([1, 2, 1, 3, 1, 4], 3), 1)
+ self.assertEqual(operator.countOf([1, 2, 1, 3, 1, 4], 5), 0)
def test_delitem(self):
operator = self.module
a = [4, 3, 2, 1]
self.assertRaises(TypeError, operator.delitem, a)
self.assertRaises(TypeError, operator.delitem, a, None)
- self.assertTrue(operator.delitem(a, 1) is None)
- self.assertTrue(a == [4, 2, 1])
+ self.assertIsNone(operator.delitem(a, 1))
+ self.assertEqual(a, [4, 2, 1])
def test_floordiv(self):
operator = self.module
self.assertRaises(TypeError, operator.floordiv, 5)
self.assertRaises(TypeError, operator.floordiv, None, None)
- self.assertTrue(operator.floordiv(5, 2) == 2)
+ self.assertEqual(operator.floordiv(5, 2), 2)
def test_truediv(self):
operator = self.module
self.assertRaises(TypeError, operator.truediv, 5)
self.assertRaises(TypeError, operator.truediv, None, None)
- self.assertTrue(operator.truediv(5, 2) == 2.5)
+ self.assertEqual(operator.truediv(5, 2), 2.5)
def test_getitem(self):
operator = self.module
a = range(10)
self.assertRaises(TypeError, operator.getitem)
self.assertRaises(TypeError, operator.getitem, a, None)
- self.assertTrue(operator.getitem(a, 2) == 2)
+ self.assertEqual(operator.getitem(a, 2), 2)
def test_indexOf(self):
operator = self.module
self.assertRaises(TypeError, operator.indexOf)
self.assertRaises(TypeError, operator.indexOf, None, None)
- self.assertTrue(operator.indexOf([4, 3, 2, 1], 3) == 1)
+ self.assertEqual(operator.indexOf([4, 3, 2, 1], 3), 1)
self.assertRaises(ValueError, operator.indexOf, [4, 3, 2, 1], 0)
def test_invert(self):
@@ -189,21 +189,21 @@
operator = self.module
self.assertRaises(TypeError, operator.lshift)
self.assertRaises(TypeError, operator.lshift, None, 42)
- self.assertTrue(operator.lshift(5, 1) == 10)
- self.assertTrue(operator.lshift(5, 0) == 5)
+ self.assertEqual(operator.lshift(5, 1), 10)
+ self.assertEqual(operator.lshift(5, 0), 5)
self.assertRaises(ValueError, operator.lshift, 2, -1)
def test_mod(self):
operator = self.module
self.assertRaises(TypeError, operator.mod)
self.assertRaises(TypeError, operator.mod, None, 42)
- self.assertTrue(operator.mod(5, 2) == 1)
+ self.assertEqual(operator.mod(5, 2), 1)
def test_mul(self):
operator = self.module
self.assertRaises(TypeError, operator.mul)
self.assertRaises(TypeError, operator.mul, None, None)
- self.assertTrue(operator.mul(5, 2) == 10)
+ self.assertEqual(operator.mul(5, 2), 10)
def test_matmul(self):
operator = self.module
@@ -227,7 +227,7 @@
operator = self.module
self.assertRaises(TypeError, operator.or_)
self.assertRaises(TypeError, operator.or_, None, None)
- self.assertTrue(operator.or_(0xa, 0x5) == 0xf)
+ self.assertEqual(operator.or_(0xa, 0x5), 0xf)
def test_pos(self):
operator = self.module
@@ -250,8 +250,8 @@
operator = self.module
self.assertRaises(TypeError, operator.rshift)
self.assertRaises(TypeError, operator.rshift, None, 42)
- self.assertTrue(operator.rshift(5, 1) == 2)
- self.assertTrue(operator.rshift(5, 0) == 5)
+ self.assertEqual(operator.rshift(5, 1), 2)
+ self.assertEqual(operator.rshift(5, 0), 5)
self.assertRaises(ValueError, operator.rshift, 2, -1)
def test_contains(self):
@@ -266,15 +266,15 @@
a = list(range(3))
self.assertRaises(TypeError, operator.setitem, a)
self.assertRaises(TypeError, operator.setitem, a, None, None)
- self.assertTrue(operator.setitem(a, 0, 2) is None)
- self.assertTrue(a == [2, 1, 2])
+ self.assertIsNone(operator.setitem(a, 0, 2))
+ self.assertEqual(a, [2, 1, 2])
self.assertRaises(IndexError, operator.setitem, a, 4, 2)
def test_sub(self):
operator = self.module
self.assertRaises(TypeError, operator.sub)
self.assertRaises(TypeError, operator.sub, None, None)
- self.assertTrue(operator.sub(5, 2) == 3)
+ self.assertEqual(operator.sub(5, 2), 3)
def test_truth(self):
operator = self.module
@@ -292,7 +292,7 @@
operator = self.module
self.assertRaises(TypeError, operator.xor)
self.assertRaises(TypeError, operator.xor, None, None)
- self.assertTrue(operator.xor(0xb, 0xc) == 0x7)
+ self.assertEqual(operator.xor(0xb, 0xc), 0x7)
def test_is(self):
operator = self.module
diff --git a/Lib/test/test_optparse.py b/Lib/test/test_optparse.py
index 7621c24..91a0319 100644
--- a/Lib/test/test_optparse.py
+++ b/Lib/test/test_optparse.py
@@ -16,6 +16,7 @@
from test import support
+import optparse
from optparse import make_option, Option, \
TitledHelpFormatter, OptionParser, OptionGroup, \
SUPPRESS_USAGE, OptionError, OptionConflictError, \
@@ -1650,6 +1651,12 @@
"option -l: invalid integer value: '0x12x'")
+class MiscTestCase(unittest.TestCase):
+ def test__all__(self):
+ blacklist = {'check_builtin', 'AmbiguousOptionError', 'NO_DEFAULT'}
+ support.check__all__(self, optparse, blacklist=blacklist)
+
+
def test_main():
support.run_unittest(__name__)
diff --git a/Lib/test/test_ordered_dict.py b/Lib/test/test_ordered_dict.py
index 901d4b2..6fbc1b4 100644
--- a/Lib/test/test_ordered_dict.py
+++ b/Lib/test/test_ordered_dict.py
@@ -298,9 +298,11 @@
# do not save instance dictionary if not needed
pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)]
od = OrderedDict(pairs)
+ self.assertIsInstance(od.__dict__, dict)
self.assertIsNone(od.__reduce__()[2])
od.x = 10
- self.assertIsNotNone(od.__reduce__()[2])
+ self.assertEqual(od.__dict__['x'], 10)
+ self.assertEqual(od.__reduce__()[2], {'x': 10})
def test_pickle_recursive(self):
OrderedDict = self.OrderedDict
@@ -403,6 +405,14 @@
od = OrderedDict(**d)
self.assertGreater(sys.getsizeof(od), sys.getsizeof(d))
+ def test_views(self):
+ OrderedDict = self.OrderedDict
+ # See http://bugs.python.org/issue24286
+ s = 'the quick brown fox jumped over a lazy dog yesterday before dawn'.split()
+ od = OrderedDict.fromkeys(s)
+ self.assertEqual(od.keys(), dict(od).keys())
+ self.assertEqual(od.items(), dict(od).items())
+
def test_override_update(self):
OrderedDict = self.OrderedDict
# Verify that subclasses can override update() without breaking __init__()
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 874f9e4..4ade4aa 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -15,7 +15,6 @@
import mmap
import os
import pickle
-import platform
import re
import shutil
import signal
@@ -66,6 +65,7 @@
from test.support.script_helper import assert_python_ok
+
root_in_posix = False
if hasattr(os, 'geteuid'):
root_in_posix = (os.geteuid() == 0)
@@ -82,6 +82,28 @@
# Issue #14110: Some tests fail on FreeBSD if the user is in the wheel group.
HAVE_WHEEL_GROUP = sys.platform.startswith('freebsd') and os.getgid() == 0
+
+@contextlib.contextmanager
+def ignore_deprecation_warnings(msg_regex, quiet=False):
+ with support.check_warnings((msg_regex, DeprecationWarning), quiet=quiet):
+ yield
+
+
+@contextlib.contextmanager
+def bytes_filename_warn(expected):
+ msg = 'The Windows bytes API has been deprecated'
+ if os.name == 'nt':
+ with ignore_deprecation_warnings(msg, quiet=not expected):
+ yield
+ else:
+ yield
+
+
+def create_file(filename, content=b'content'):
+ with open(filename, "xb", 0) as fp:
+ fp.write(content)
+
+
# Tests creating TESTFN
class FileTests(unittest.TestCase):
def setUp(self):
@@ -140,9 +162,8 @@
"needs INT_MAX < PY_SSIZE_T_MAX")
@support.bigmemtest(size=INT_MAX + 10, memuse=1, dry_run=False)
def test_large_read(self, size):
- with open(support.TESTFN, "wb") as fp:
- fp.write(b'test')
self.addCleanup(support.unlink, support.TESTFN)
+ create_file(support.TESTFN, b'test')
# Issue #21932: Make sure that os.read() does not raise an
# OverflowError for size larger than INT_MAX
@@ -199,11 +220,12 @@
def test_replace(self):
TESTFN2 = support.TESTFN + ".2"
- with open(support.TESTFN, 'w') as f:
- f.write("1")
- with open(TESTFN2, 'w') as f:
- f.write("2")
- self.addCleanup(os.unlink, TESTFN2)
+ self.addCleanup(support.unlink, support.TESTFN)
+ self.addCleanup(support.unlink, TESTFN2)
+
+ create_file(support.TESTFN, b"1")
+ create_file(TESTFN2, b"2")
+
os.replace(support.TESTFN, TESTFN2)
self.assertRaises(FileNotFoundError, os.stat, support.TESTFN)
with open(TESTFN2, 'r') as f:
@@ -226,15 +248,9 @@
# Test attributes on return values from os.*stat* family.
class StatAttributeTests(unittest.TestCase):
def setUp(self):
- os.mkdir(support.TESTFN)
- self.fname = os.path.join(support.TESTFN, "f1")
- f = open(self.fname, 'wb')
- f.write(b"ABC")
- f.close()
-
- def tearDown(self):
- os.unlink(self.fname)
- os.rmdir(support.TESTFN)
+ self.fname = support.TESTFN
+ self.addCleanup(support.unlink, self.fname)
+ create_file(self.fname, b"ABC")
@unittest.skipUnless(hasattr(os, 'stat'), 'test needs os.stat()')
def check_stat_attributes(self, fname):
@@ -310,8 +326,7 @@
fname = self.fname.encode(sys.getfilesystemencoding())
except UnicodeEncodeError:
self.skipTest("cannot encode %a for the filesystem" % self.fname)
- with warnings.catch_warnings():
- warnings.simplefilter("ignore", DeprecationWarning)
+ with bytes_filename_warn(True):
self.check_stat_attributes(fname)
def test_stat_result_pickle(self):
@@ -426,7 +441,11 @@
0)
# test directory st_file_attributes (FILE_ATTRIBUTE_DIRECTORY set)
- result = os.stat(support.TESTFN)
+ dirname = support.TESTFN + "dir"
+ os.mkdir(dirname)
+ self.addCleanup(os.rmdir, dirname)
+
+ result = os.stat(dirname)
self.check_file_attributes(result)
self.assertEqual(
result.st_file_attributes & stat.FILE_ATTRIBUTE_DIRECTORY,
@@ -440,19 +459,14 @@
self.addCleanup(support.rmtree, self.dirname)
os.mkdir(self.dirname)
- with open(self.fname, 'wb') as fp:
- fp.write(b"ABC")
+ create_file(self.fname)
def restore_float_times(state):
- with warnings.catch_warnings():
- warnings.simplefilter("ignore", DeprecationWarning)
-
+ with ignore_deprecation_warnings('stat_float_times'):
os.stat_float_times(state)
# ensure that st_atime and st_mtime are float
- with warnings.catch_warnings():
- warnings.simplefilter("ignore", DeprecationWarning)
-
+ with ignore_deprecation_warnings('stat_float_times'):
old_float_times = os.stat_float_times(-1)
self.addCleanup(restore_float_times, old_float_times)
@@ -544,7 +558,7 @@
"fd support for utime required for this test.")
def test_utime_fd(self):
def set_time(filename, ns):
- with open(filename, 'wb') as fp:
+ with open(filename, 'wb', 0) as fp:
# use a file descriptor to test futimens(timespec)
# or futimes(timeval)
os.utime(fp.fileno(), ns=ns)
@@ -798,6 +812,7 @@
def setUp(self):
join = os.path.join
+ self.addCleanup(support.rmtree, support.TESTFN)
# Build:
# TESTFN/
@@ -830,9 +845,8 @@
os.makedirs(t2_path)
for path in tmp1_path, tmp2_path, tmp3_path, tmp4_path:
- f = open(path, "w")
- f.write("I'm " + path + " and proud of it. Blame test_os.\n")
- f.close()
+ with open(path, "x") as f:
+ f.write("I'm " + path + " and proud of it. Blame test_os.\n")
if support.can_symlink():
os.symlink(os.path.abspath(t2_path), self.link_path)
@@ -878,7 +892,7 @@
# Walk bottom-up.
all = list(self.walk(self.walk_path, topdown=False))
- self.assertEqual(len(all), 4)
+ self.assertEqual(len(all), 4, all)
# We can't know which order SUB1 and SUB2 will appear in.
# Not flipped: SUB11, SUB1, SUB2, TESTFN
# flipped: SUB2, SUB11, SUB1, TESTFN
@@ -908,22 +922,6 @@
else:
self.fail("Didn't follow symlink with followlinks=True")
- def tearDown(self):
- # Tear everything down. This is a decent use for bottom-up on
- # Windows, which doesn't have a recursive delete command. The
- # (not so) subtlety is that rmdir will fail unless the dir's
- # kids are removed first, so bottom up is essential.
- for root, dirs, files in os.walk(support.TESTFN, topdown=False):
- for name in files:
- os.remove(os.path.join(root, name))
- for name in dirs:
- dirname = os.path.join(root, name)
- if not os.path.islink(dirname):
- os.rmdir(dirname)
- else:
- os.remove(dirname)
- os.rmdir(support.TESTFN)
-
def test_walk_bad_dir(self):
# Walk top-down.
errors = []
@@ -1006,27 +1004,13 @@
self.addCleanup(os.close, newfd)
self.assertEqual(newfd, minfd)
- def tearDown(self):
- # cleanup
- for root, dirs, files, rootfd in os.fwalk(support.TESTFN, topdown=False):
- for name in files:
- os.unlink(name, dir_fd=rootfd)
- for name in dirs:
- st = os.stat(name, dir_fd=rootfd, follow_symlinks=False)
- if stat.S_ISDIR(st.st_mode):
- os.rmdir(name, dir_fd=rootfd)
- else:
- os.unlink(name, dir_fd=rootfd)
- os.rmdir(support.TESTFN)
-
class BytesWalkTests(WalkTests):
"""Tests for os.walk() with bytes."""
def setUp(self):
super().setUp()
self.stack = contextlib.ExitStack()
if os.name == 'nt':
- self.stack.enter_context(warnings.catch_warnings())
- warnings.simplefilter("ignore", DeprecationWarning)
+ self.stack.enter_context(bytes_filename_warn(False))
def tearDown(self):
self.stack.close()
@@ -1203,8 +1187,7 @@
os.mkdir(dira)
dirb = os.path.join(dira, 'dirb')
os.mkdir(dirb)
- with open(os.path.join(dira, 'file.txt'), 'w') as f:
- f.write('text')
+ create_file(os.path.join(dira, 'file.txt'))
os.removedirs(dirb)
self.assertFalse(os.path.exists(dirb))
self.assertTrue(os.path.exists(dira))
@@ -1215,8 +1198,7 @@
os.mkdir(dira)
dirb = os.path.join(dira, 'dirb')
os.mkdir(dirb)
- with open(os.path.join(dirb, 'file.txt'), 'w') as f:
- f.write('text')
+ create_file(os.path.join(dirb, 'file.txt'))
with self.assertRaises(OSError):
os.removedirs(dirb)
self.assertTrue(os.path.exists(dirb))
@@ -1226,7 +1208,7 @@
class DevNullTests(unittest.TestCase):
def test_devnull(self):
- with open(os.devnull, 'wb') as f:
+ with open(os.devnull, 'wb', 0) as f:
f.write(b'hello')
f.close()
with open(os.devnull, 'rb') as f:
@@ -1313,9 +1295,9 @@
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)
+ self.addCleanup(support.unlink, support.TESTFN)
+ create_file(support.TESTFN, b"x" * 256)
+
code = """if 1:
import os
import sys
@@ -1444,6 +1426,18 @@
@unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
class Win32ErrorTests(unittest.TestCase):
+ def setUp(self):
+ try:
+ os.stat(support.TESTFN)
+ except FileNotFoundError:
+ exists = False
+ except OSError as exc:
+ exists = True
+ self.fail("file %s must not exist; os.stat failed with %s"
+ % (support.TESTFN, exc))
+ else:
+ self.fail("file %s must not exist" % support.TESTFN)
+
def test_rename(self):
self.assertRaises(OSError, os.rename, support.TESTFN, support.TESTFN+".bak")
@@ -1454,12 +1448,10 @@
self.assertRaises(OSError, os.chdir, support.TESTFN)
def test_mkdir(self):
- f = open(support.TESTFN, "w")
- try:
+ self.addCleanup(support.unlink, support.TESTFN)
+
+ with open(support.TESTFN, "x") as f:
self.assertRaises(OSError, os.mkdir, support.TESTFN)
- finally:
- f.close()
- os.unlink(support.TESTFN)
def test_utime(self):
self.assertRaises(OSError, os.utime, support.TESTFN, None)
@@ -1467,6 +1459,7 @@
def test_chmod(self):
self.assertRaises(OSError, os.chmod, support.TESTFN, 0)
+
class TestInvalidFD(unittest.TestCase):
singles = ["fchdir", "dup", "fdopen", "fdatasync", "fstat",
"fstatvfs", "fsync", "tcgetpgrp", "ttyname"]
@@ -1578,11 +1571,9 @@
os.unlink(file)
def _test_link(self, file1, file2):
- with open(file1, "w") as f1:
- f1.write("test")
+ create_file(file1)
- with warnings.catch_warnings():
- warnings.simplefilter("ignore", DeprecationWarning)
+ with bytes_filename_warn(False):
os.link(file1, file2)
with open(file1, "r") as f1, open(file2, "r") as f2:
self.assertTrue(os.path.sameopenfile(f1.fileno(), f2.fileno()))
@@ -1874,10 +1865,12 @@
self.assertEqual(
sorted(os.listdir(support.TESTFN)),
self.created_paths)
+
# bytes
- self.assertEqual(
- sorted(os.listdir(os.fsencode(support.TESTFN))),
- [os.fsencode(path) for path in self.created_paths])
+ with bytes_filename_warn(False):
+ self.assertEqual(
+ sorted(os.listdir(os.fsencode(support.TESTFN))),
+ [os.fsencode(path) for path in self.created_paths])
def test_listdir_extended_path(self):
"""Test when the path starts with '\\\\?\\'."""
@@ -1887,11 +1880,13 @@
self.assertEqual(
sorted(os.listdir(path)),
self.created_paths)
+
# bytes
- path = b'\\\\?\\' + os.fsencode(os.path.abspath(support.TESTFN))
- self.assertEqual(
- sorted(os.listdir(path)),
- [os.fsencode(path) for path in self.created_paths])
+ with bytes_filename_warn(False):
+ path = b'\\\\?\\' + os.fsencode(os.path.abspath(support.TESTFN))
+ self.assertEqual(
+ sorted(os.listdir(path)),
+ [os.fsencode(path) for path in self.created_paths])
@unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
@@ -1966,51 +1961,45 @@
self.assertNotEqual(os.lstat(link), os.stat(link))
bytes_link = os.fsencode(link)
- with warnings.catch_warnings():
- warnings.simplefilter("ignore", DeprecationWarning)
+ with bytes_filename_warn(True):
self.assertEqual(os.stat(bytes_link), os.stat(target))
+ with bytes_filename_warn(True):
self.assertNotEqual(os.lstat(bytes_link), os.stat(bytes_link))
def test_12084(self):
level1 = os.path.abspath(support.TESTFN)
level2 = os.path.join(level1, "level2")
level3 = os.path.join(level2, "level3")
+ self.addCleanup(support.rmtree, level1)
+
+ os.mkdir(level1)
+ os.mkdir(level2)
+ os.mkdir(level3)
+
+ file1 = os.path.abspath(os.path.join(level1, "file1"))
+ create_file(file1)
+
+ orig_dir = os.getcwd()
try:
- os.mkdir(level1)
- os.mkdir(level2)
- os.mkdir(level3)
+ os.chdir(level2)
+ link = os.path.join(level2, "link")
+ os.symlink(os.path.relpath(file1), "link")
+ self.assertIn("link", os.listdir(os.getcwd()))
- file1 = os.path.abspath(os.path.join(level1, "file1"))
+ # Check os.stat calls from the same dir as the link
+ self.assertEqual(os.stat(file1), os.stat("link"))
- with open(file1, "w") as f:
- f.write("file1")
+ # Check os.stat calls from a dir below the link
+ os.chdir(level1)
+ self.assertEqual(os.stat(file1),
+ os.stat(os.path.relpath(link)))
- orig_dir = os.getcwd()
- try:
- os.chdir(level2)
- link = os.path.join(level2, "link")
- os.symlink(os.path.relpath(file1), "link")
- self.assertIn("link", os.listdir(os.getcwd()))
-
- # Check os.stat calls from the same dir as the link
- self.assertEqual(os.stat(file1), os.stat("link"))
-
- # Check os.stat calls from a dir below the link
- os.chdir(level1)
- self.assertEqual(os.stat(file1),
- os.stat(os.path.relpath(link)))
-
- # Check os.stat calls from a dir above the link
- os.chdir(level3)
- self.assertEqual(os.stat(file1),
- os.stat(os.path.relpath(link)))
- finally:
- os.chdir(orig_dir)
- except OSError as err:
- self.fail(err)
+ # Check os.stat calls from a dir above the link
+ os.chdir(level3)
+ self.assertEqual(os.stat(file1),
+ os.stat(os.path.relpath(link)))
finally:
- os.remove(file1)
- shutil.rmtree(level1)
+ os.chdir(orig_dir)
@unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
@@ -2146,8 +2135,8 @@
try:
new_prio = os.getpriority(os.PRIO_PROCESS, os.getpid())
if base >= 19 and new_prio <= 19:
- raise unittest.SkipTest(
- "unable to reliably test setpriority at current nice level of %s" % base)
+ raise unittest.SkipTest("unable to reliably test setpriority "
+ "at current nice level of %s" % base)
else:
self.assertEqual(new_prio, base + 1)
finally:
@@ -2257,8 +2246,7 @@
@classmethod
def setUpClass(cls):
cls.key = support.threading_setup()
- with open(support.TESTFN, "wb") as f:
- f.write(cls.DATA)
+ create_file(support.TESTFN, cls.DATA)
@classmethod
def tearDownClass(cls):
@@ -2408,10 +2396,11 @@
def test_trailers(self):
TESTFN2 = support.TESTFN + "2"
file_data = b"abcdef"
- with open(TESTFN2, 'wb') as f:
- f.write(file_data)
- with open(TESTFN2, 'rb')as f:
- self.addCleanup(os.remove, TESTFN2)
+
+ self.addCleanup(support.unlink, TESTFN2)
+ create_file(TESTFN2, file_data)
+
+ with open(TESTFN2, 'rb') as f:
os.sendfile(self.sockno, f.fileno(), 0, len(file_data),
trailers=[b"1234"])
self.client.close()
@@ -2434,35 +2423,37 @@
def supports_extended_attributes():
if not hasattr(os, "setxattr"):
return False
+
try:
- with open(support.TESTFN, "wb") as fp:
+ with open(support.TESTFN, "xb", 0) as fp:
try:
os.setxattr(fp.fileno(), b"user.test", b"")
except OSError:
return False
finally:
support.unlink(support.TESTFN)
- # Kernels < 2.6.39 don't respect setxattr flags.
- kernel_version = platform.release()
- m = re.match("2.6.(\d{1,2})", kernel_version)
- return m is None or int(m.group(1)) >= 39
+
+ return True
@unittest.skipUnless(supports_extended_attributes(),
"no non-broken extended attribute support")
+# Kernels < 2.6.39 don't respect setxattr flags.
+@support.requires_linux_version(2, 6, 39)
class ExtendedAttributeTests(unittest.TestCase):
- def tearDown(self):
- support.unlink(support.TESTFN)
-
def _check_xattrs_str(self, s, getxattr, setxattr, removexattr, listxattr, **kwargs):
fn = support.TESTFN
- open(fn, "wb").close()
+ self.addCleanup(support.unlink, fn)
+ create_file(fn)
+
with self.assertRaises(OSError) as cm:
getxattr(fn, s("user.test"), **kwargs)
self.assertEqual(cm.exception.errno, errno.ENODATA)
+
init_xattr = listxattr(fn)
self.assertIsInstance(init_xattr, list)
+
setxattr(fn, s("user.test"), b"", **kwargs)
xattr = set(init_xattr)
xattr.add("user.test")
@@ -2470,19 +2461,24 @@
self.assertEqual(getxattr(fn, b"user.test", **kwargs), b"")
setxattr(fn, s("user.test"), b"hello", os.XATTR_REPLACE, **kwargs)
self.assertEqual(getxattr(fn, b"user.test", **kwargs), b"hello")
+
with self.assertRaises(OSError) as cm:
setxattr(fn, s("user.test"), b"bye", os.XATTR_CREATE, **kwargs)
self.assertEqual(cm.exception.errno, errno.EEXIST)
+
with self.assertRaises(OSError) as cm:
setxattr(fn, s("user.test2"), b"bye", os.XATTR_REPLACE, **kwargs)
self.assertEqual(cm.exception.errno, errno.ENODATA)
+
setxattr(fn, s("user.test2"), b"foo", os.XATTR_CREATE, **kwargs)
xattr.add("user.test2")
self.assertEqual(set(listxattr(fn)), xattr)
removexattr(fn, s("user.test"), **kwargs)
+
with self.assertRaises(OSError) as cm:
getxattr(fn, s("user.test"), **kwargs)
self.assertEqual(cm.exception.errno, errno.ENODATA)
+
xattr.remove("user.test")
self.assertEqual(set(listxattr(fn)), xattr)
self.assertEqual(getxattr(fn, s("user.test2"), **kwargs), b"foo")
@@ -2495,11 +2491,11 @@
self.assertEqual(set(listxattr(fn)), set(init_xattr) | set(many))
def _check_xattrs(self, *args, **kwargs):
- def make_bytes(s):
- return bytes(s, "ascii")
self._check_xattrs_str(str, *args, **kwargs)
support.unlink(support.TESTFN)
- self._check_xattrs_str(make_bytes, *args, **kwargs)
+
+ self._check_xattrs_str(os.fsencode, *args, **kwargs)
+ support.unlink(support.TESTFN)
def test_simple(self):
self._check_xattrs(os.getxattr, os.setxattr, os.removexattr,
@@ -2514,10 +2510,10 @@
with open(path, "rb") as fp:
return os.getxattr(fp.fileno(), *args)
def setxattr(path, *args):
- with open(path, "wb") as fp:
+ with open(path, "wb", 0) as fp:
os.setxattr(fp.fileno(), *args)
def removexattr(path, *args):
- with open(path, "wb") as fp:
+ with open(path, "wb", 0) as fp:
os.removexattr(fp.fileno(), *args)
def listxattr(path, *args):
with open(path, "rb") as fp:
@@ -2530,36 +2526,39 @@
def test_deprecated(self):
import nt
filename = os.fsencode(support.TESTFN)
- with warnings.catch_warnings():
- warnings.simplefilter("error", DeprecationWarning)
- for func, *args in (
- (nt._getfullpathname, filename),
- (nt._isdir, filename),
- (os.access, filename, os.R_OK),
- (os.chdir, filename),
- (os.chmod, filename, 0o777),
- (os.getcwdb,),
- (os.link, filename, filename),
- (os.listdir, filename),
- (os.lstat, filename),
- (os.mkdir, filename),
- (os.open, filename, os.O_RDONLY),
- (os.rename, filename, filename),
- (os.rmdir, filename),
- (os.startfile, filename),
- (os.stat, filename),
- (os.unlink, filename),
- (os.utime, filename),
- ):
- self.assertRaises(DeprecationWarning, func, *args)
+ for func, *args in (
+ (nt._getfullpathname, filename),
+ (nt._isdir, filename),
+ (os.access, filename, os.R_OK),
+ (os.chdir, filename),
+ (os.chmod, filename, 0o777),
+ (os.getcwdb,),
+ (os.link, filename, filename),
+ (os.listdir, filename),
+ (os.lstat, filename),
+ (os.mkdir, filename),
+ (os.open, filename, os.O_RDONLY),
+ (os.rename, filename, filename),
+ (os.rmdir, filename),
+ (os.startfile, filename),
+ (os.stat, filename),
+ (os.unlink, filename),
+ (os.utime, filename),
+ ):
+ with bytes_filename_warn(True):
+ try:
+ func(*args)
+ except OSError:
+ # ignore OSError, we only care about DeprecationWarning
+ pass
@support.skip_unless_symlink
def test_symlink(self):
+ self.addCleanup(support.unlink, support.TESTFN)
+
filename = os.fsencode(support.TESTFN)
- with warnings.catch_warnings():
- warnings.simplefilter("error", DeprecationWarning)
- self.assertRaises(DeprecationWarning,
- os.symlink, filename, filename)
+ with bytes_filename_warn(True):
+ os.symlink(filename, filename)
@unittest.skipUnless(hasattr(os, 'get_terminal_size'), "requires os.get_terminal_size")
@@ -2697,7 +2696,8 @@
for filenames, func, *func_args in funcs:
for name in filenames:
try:
- func(name, *func_args)
+ with bytes_filename_warn(False):
+ func(name, *func_args)
except OSError as err:
self.assertIs(err.filename, name)
else:
@@ -2820,15 +2820,18 @@
class TestScandir(unittest.TestCase):
+ check_no_resource_warning = support.check_no_resource_warning
+
def setUp(self):
self.path = os.path.realpath(support.TESTFN)
+ self.bytes_path = os.fsencode(self.path)
self.addCleanup(support.rmtree, self.path)
os.mkdir(self.path)
def create_file(self, name="file.txt"):
- filename = os.path.join(self.path, name)
- with open(filename, "wb") as fp:
- fp.write(b'python')
+ path = self.bytes_path if isinstance(name, bytes) else self.path
+ filename = os.path.join(path, name)
+ create_file(filename, b'python')
return filename
def get_entries(self, names):
@@ -2851,6 +2854,7 @@
self.assertEqual(stat1, stat2)
def check_entry(self, entry, name, is_dir, is_file, is_symlink):
+ self.assertIsInstance(entry, os.DirEntry)
self.assertEqual(entry.name, name)
self.assertEqual(entry.path, os.path.join(self.path, name))
self.assertEqual(entry.inode(),
@@ -2916,15 +2920,16 @@
self.check_entry(entry, 'symlink_file.txt', False, True, True)
def get_entry(self, name):
- entries = list(os.scandir(self.path))
+ path = self.bytes_path if isinstance(name, bytes) else self.path
+ entries = list(os.scandir(path))
self.assertEqual(len(entries), 1)
entry = entries[0]
self.assertEqual(entry.name, name)
return entry
- def create_file_entry(self):
- filename = self.create_file()
+ def create_file_entry(self, name='file.txt'):
+ filename = self.create_file(name=name)
return self.get_entry(os.path.basename(filename))
def test_current_directory(self):
@@ -2945,6 +2950,19 @@
entry = self.create_file_entry()
self.assertEqual(repr(entry), "<DirEntry 'file.txt'>")
+ def test_fspath_protocol(self):
+ entry = self.create_file_entry()
+ self.assertEqual(os.fspath(entry), os.path.join(self.path, 'file.txt'))
+
+ @unittest.skipIf(os.name == "nt", "test requires bytes path support")
+ def test_fspath_protocol_bytes(self):
+ bytes_filename = os.fsencode('bytesfile.txt')
+ bytes_entry = self.create_file_entry(name=bytes_filename)
+ fspath = os.fspath(bytes_entry)
+ self.assertIsInstance(fspath, bytes)
+ self.assertEqual(fspath,
+ os.path.join(os.fsencode(self.path),bytes_filename))
+
def test_removed_dir(self):
path = os.path.join(self.path, 'dir')
@@ -3010,7 +3028,8 @@
def test_bytes(self):
if os.name == "nt":
# On Windows, os.scandir(bytes) must raise an exception
- self.assertRaises(TypeError, os.scandir, b'.')
+ with bytes_filename_warn(True):
+ self.assertRaises(TypeError, os.scandir, b'.')
return
self.create_file("file.txt")
@@ -3042,6 +3061,112 @@
for obj in [1234, 1.234, {}, []]:
self.assertRaises(TypeError, os.scandir, obj)
+ def test_close(self):
+ self.create_file("file.txt")
+ self.create_file("file2.txt")
+ iterator = os.scandir(self.path)
+ next(iterator)
+ iterator.close()
+ # multiple closes
+ iterator.close()
+ with self.check_no_resource_warning():
+ del iterator
+
+ def test_context_manager(self):
+ self.create_file("file.txt")
+ self.create_file("file2.txt")
+ with os.scandir(self.path) as iterator:
+ next(iterator)
+ with self.check_no_resource_warning():
+ del iterator
+
+ def test_context_manager_close(self):
+ self.create_file("file.txt")
+ self.create_file("file2.txt")
+ with os.scandir(self.path) as iterator:
+ next(iterator)
+ iterator.close()
+
+ def test_context_manager_exception(self):
+ self.create_file("file.txt")
+ self.create_file("file2.txt")
+ with self.assertRaises(ZeroDivisionError):
+ with os.scandir(self.path) as iterator:
+ next(iterator)
+ 1/0
+ with self.check_no_resource_warning():
+ del iterator
+
+ def test_resource_warning(self):
+ self.create_file("file.txt")
+ self.create_file("file2.txt")
+ iterator = os.scandir(self.path)
+ next(iterator)
+ with self.assertWarns(ResourceWarning):
+ del iterator
+ support.gc_collect()
+ # exhausted iterator
+ iterator = os.scandir(self.path)
+ list(iterator)
+ with self.check_no_resource_warning():
+ del iterator
+
+
+class TestPEP519(unittest.TestCase):
+
+ # Abstracted so it can be overridden to test pure Python implementation
+ # if a C version is provided.
+ fspath = staticmethod(os.fspath)
+
+ class PathLike:
+ def __init__(self, path=''):
+ self.path = path
+ def __fspath__(self):
+ return self.path
+
+ def test_return_bytes(self):
+ for b in b'hello', b'goodbye', b'some/path/and/file':
+ self.assertEqual(b, self.fspath(b))
+
+ def test_return_string(self):
+ for s in 'hello', 'goodbye', 'some/path/and/file':
+ self.assertEqual(s, self.fspath(s))
+
+ def test_fsencode_fsdecode(self):
+ for p in "path/like/object", b"path/like/object":
+ pathlike = self.PathLike(p)
+
+ self.assertEqual(p, self.fspath(pathlike))
+ self.assertEqual(b"path/like/object", os.fsencode(pathlike))
+ self.assertEqual("path/like/object", os.fsdecode(pathlike))
+
+ def test_pathlike(self):
+ self.assertEqual('#feelthegil', self.fspath(self.PathLike('#feelthegil')))
+ self.assertTrue(issubclass(self.PathLike, os.PathLike))
+ self.assertTrue(isinstance(self.PathLike(), os.PathLike))
+
+ with self.assertRaises(TypeError):
+ self.fspath(self.PathLike(42))
+
+ def test_garbage_in_exception_out(self):
+ vapor = type('blah', (), {})
+ for o in int, type, os, vapor():
+ self.assertRaises(TypeError, self.fspath, o)
+
+ def test_argument_required(self):
+ with self.assertRaises(TypeError):
+ self.fspath()
+
+
+# Only test if the C version is provided, otherwise TestPEP519 already tested
+# the pure Python implementation.
+if hasattr(os, "_fspath"):
+ class TestPEP519PurePython(TestPEP519):
+
+ """Explicitly test the pure Python implementation of os.fspath()."""
+
+ fspath = staticmethod(os._fspath)
+
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py
index ab6577f..1e7d331 100644
--- a/Lib/test/test_parser.py
+++ b/Lib/test/test_parser.py
@@ -1,6 +1,5 @@
import parser
import unittest
-import sys
import operator
import struct
from test import support
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
index fa96d9f..2f2ba3c 100644
--- a/Lib/test/test_pathlib.py
+++ b/Lib/test/test_pathlib.py
@@ -190,13 +190,18 @@
P = self.cls
p = P('a')
self.assertIsInstance(p, P)
+ class PathLike:
+ def __fspath__(self):
+ return "a/b/c"
P('a', 'b', 'c')
P('/a', 'b', 'c')
P('a/b/c')
P('/a/b/c')
+ P(PathLike())
self.assertEqual(P(P('a')), P('a'))
self.assertEqual(P(P('a'), 'b'), P('a/b'))
self.assertEqual(P(P('a'), P('b')), P('a/b'))
+ self.assertEqual(P(P('a'), P('b'), P('c')), P(PathLike()))
def _check_str_subclass(self, *args):
# Issue #21127: it should be possible to construct a PurePath object
@@ -384,6 +389,12 @@
parts = p.parts
self.assertEqual(parts, (sep, 'a', 'b'))
+ def test_fspath_common(self):
+ P = self.cls
+ p = P('a/b')
+ self._check_str(p.__fspath__(), ('a/b',))
+ self._check_str(os.fspath(p), ('a/b',))
+
def test_equivalences(self):
for k, tuples in self.equivalences.items():
canon = k.replace('/', self.sep)
@@ -1474,13 +1485,13 @@
self.assertEqual(set(p.glob("dirA/../file*")), { P(BASE, "dirA/../fileA") })
self.assertEqual(set(p.glob("../xyzzy")), set())
- def _check_resolve_relative(self, p, expected):
+
+ def _check_resolve(self, p, expected):
q = p.resolve()
self.assertEqual(q, expected)
- def _check_resolve_absolute(self, p, expected):
- q = p.resolve()
- self.assertEqual(q, expected)
+ # this can be used to check both relative and absolute resolutions
+ _check_resolve_relative = _check_resolve_absolute = _check_resolve
@with_symlinks
def test_resolve_common(self):
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index 45ba5a9..a63ccd8 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -558,7 +558,6 @@
def pdb_invoke(method, arg):
"""Run pdb.method(arg)."""
- import pdb
getattr(pdb.Pdb(nosigint=True), method)(arg)
diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py
index 41e5091..b033640 100644
--- a/Lib/test/test_peepholer.py
+++ b/Lib/test/test_peepholer.py
@@ -1,9 +1,8 @@
import dis
import re
import sys
-from io import StringIO
+import textwrap
import unittest
-from math import copysign
from test.bytecode_helper import BytecodeTestCase
@@ -30,22 +29,25 @@
def test_global_as_constant(self):
# LOAD_GLOBAL None/True/False --> LOAD_CONST None/True/False
- def f(x):
- None
- None
+ def f():
+ x = None
+ x = None
return x
- def g(x):
- True
+ def g():
+ x = True
return x
- def h(x):
- False
+ def h():
+ x = False
return x
+
for func, elem in ((f, None), (g, True), (h, False)):
self.assertNotInBytecode(func, 'LOAD_GLOBAL')
self.assertInBytecode(func, 'LOAD_CONST', elem)
+
def f():
'Adding a docstring made this test fail in Py2.5.0'
return None
+
self.assertNotInBytecode(f, 'LOAD_GLOBAL')
self.assertInBytecode(f, 'LOAD_CONST', None)
diff --git a/Lib/test/test_pep3151.py b/Lib/test/test_pep3151.py
index 7b0d465..8649596 100644
--- a/Lib/test/test_pep3151.py
+++ b/Lib/test/test_pep3151.py
@@ -2,7 +2,6 @@
import os
import select
import socket
-import sys
import unittest
import errno
from errno import EEXIST
diff --git a/Lib/test/test_pep352.py b/Lib/test/test_pep352.py
index 7c98c46..27d514f 100644
--- a/Lib/test/test_pep352.py
+++ b/Lib/test/test_pep352.py
@@ -1,6 +1,5 @@
import unittest
import builtins
-import warnings
import os
from platform import system as platform_system
diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py
index ee7a667..e2ba1ad 100644
--- a/Lib/test/test_pickle.py
+++ b/Lib/test/test_pickle.py
@@ -33,8 +33,6 @@
unpickler = pickle._Unpickler
bad_stack_errors = (IndexError,)
- bad_mark_errors = (IndexError, pickle.UnpicklingError,
- TypeError, AttributeError, EOFError)
truncated_errors = (pickle.UnpicklingError, EOFError,
AttributeError, ValueError,
struct.error, IndexError, ImportError)
@@ -69,8 +67,6 @@
pickler = pickle._Pickler
unpickler = pickle._Unpickler
bad_stack_errors = (pickle.UnpicklingError, IndexError)
- bad_mark_errors = (pickle.UnpicklingError, IndexError,
- TypeError, AttributeError, EOFError)
truncated_errors = (pickle.UnpicklingError, EOFError,
AttributeError, ValueError,
struct.error, IndexError, ImportError)
@@ -132,7 +128,6 @@
class CUnpicklerTests(PyUnpicklerTests):
unpickler = _pickle.Unpickler
bad_stack_errors = (pickle.UnpicklingError,)
- bad_mark_errors = (EOFError,)
truncated_errors = (pickle.UnpicklingError, EOFError,
AttributeError, ValueError)
diff --git a/Lib/test/test_pickletools.py b/Lib/test/test_pickletools.py
index bbe6875..86bebfa 100644
--- a/Lib/test/test_pickletools.py
+++ b/Lib/test/test_pickletools.py
@@ -1,9 +1,9 @@
-import struct
import pickle
import pickletools
from test import support
from test.pickletester import AbstractPickleTests
from test.pickletester import AbstractPickleModuleTests
+import unittest
class OptimizedPickleTests(AbstractPickleTests, AbstractPickleModuleTests):
@@ -59,8 +59,40 @@
self.assertNotIn(pickle.BINPUT, pickled2)
+class MiscTestCase(unittest.TestCase):
+ def test__all__(self):
+ blacklist = {'bytes_types',
+ 'UP_TO_NEWLINE', 'TAKEN_FROM_ARGUMENT1',
+ 'TAKEN_FROM_ARGUMENT4', 'TAKEN_FROM_ARGUMENT4U',
+ 'TAKEN_FROM_ARGUMENT8U', 'ArgumentDescriptor',
+ 'read_uint1', 'read_uint2', 'read_int4', 'read_uint4',
+ 'read_uint8', 'read_stringnl', 'read_stringnl_noescape',
+ 'read_stringnl_noescape_pair', 'read_string1',
+ 'read_string4', 'read_bytes1', 'read_bytes4',
+ 'read_bytes8', 'read_unicodestringnl',
+ 'read_unicodestring1', 'read_unicodestring4',
+ 'read_unicodestring8', 'read_decimalnl_short',
+ 'read_decimalnl_long', 'read_floatnl', 'read_float8',
+ 'read_long1', 'read_long4',
+ 'uint1', 'uint2', 'int4', 'uint4', 'uint8', 'stringnl',
+ 'stringnl_noescape', 'stringnl_noescape_pair', 'string1',
+ 'string4', 'bytes1', 'bytes4', 'bytes8',
+ 'unicodestringnl', 'unicodestring1', 'unicodestring4',
+ 'unicodestring8', 'decimalnl_short', 'decimalnl_long',
+ 'floatnl', 'float8', 'long1', 'long4',
+ 'StackObject',
+ 'pyint', 'pylong', 'pyinteger_or_bool', 'pybool', 'pyfloat',
+ 'pybytes_or_str', 'pystring', 'pybytes', 'pyunicode',
+ 'pynone', 'pytuple', 'pylist', 'pydict', 'pyset',
+ 'pyfrozenset', 'anyobject', 'markobject', 'stackslice',
+ 'OpcodeInfo', 'opcodes', 'code2op',
+ }
+ support.check__all__(self, pickletools, blacklist=blacklist)
+
+
def test_main():
support.run_unittest(OptimizedPickleTests)
+ support.run_unittest(MiscTestCase)
support.run_doctest(pickletools)
diff --git a/Lib/test/test_pipes.py b/Lib/test/test_pipes.py
index 6a7b45f..ad01d08 100644
--- a/Lib/test/test_pipes.py
+++ b/Lib/test/test_pipes.py
@@ -2,6 +2,7 @@
import os
import string
import unittest
+import shutil
from test.support import TESTFN, run_unittest, unlink, reap_children
if os.name != 'posix':
@@ -18,6 +19,8 @@
unlink(f)
def testSimplePipe1(self):
+ if shutil.which('tr') is None:
+ self.skipTest('tr is not available')
t = pipes.Template()
t.append(s_command, pipes.STDIN_STDOUT)
f = t.open(TESTFN, 'w')
@@ -27,6 +30,8 @@
self.assertEqual(f.read(), 'HELLO WORLD #1')
def testSimplePipe2(self):
+ if shutil.which('tr') is None:
+ self.skipTest('tr is not available')
with open(TESTFN, 'w') as f:
f.write('hello world #2')
t = pipes.Template()
@@ -36,6 +41,8 @@
self.assertEqual(f.read(), 'HELLO WORLD #2')
def testSimplePipe3(self):
+ if shutil.which('tr') is None:
+ self.skipTest('tr is not available')
with open(TESTFN, 'w') as f:
f.write('hello world #2')
t = pipes.Template()
diff --git a/Lib/test/test_plistlib.py b/Lib/test/test_plistlib.py
index 16114f9..60ff918 100644
--- a/Lib/test/test_plistlib.py
+++ b/Lib/test/test_plistlib.py
@@ -7,7 +7,6 @@
import codecs
import binascii
import collections
-import struct
from test import support
from io import BytesIO
@@ -527,8 +526,14 @@
self.assertEqual(cur, in_data)
+class MiscTestCase(unittest.TestCase):
+ def test__all__(self):
+ blacklist = {"PlistFormat", "PLISTHEADER"}
+ support.check__all__(self, plistlib, blacklist=blacklist)
+
+
def test_main():
- support.run_unittest(TestPlistlib, TestPlistlibDeprecated)
+ support.run_unittest(TestPlistlib, TestPlistlibDeprecated, MiscTestCase)
if __name__ == '__main__':
diff --git a/Lib/test/test_poplib.py b/Lib/test/test_poplib.py
index bceeb93..7b9606d 100644
--- a/Lib/test/test_poplib.py
+++ b/Lib/test/test_poplib.py
@@ -8,7 +8,6 @@
import asynchat
import socket
import os
-import time
import errno
from unittest import TestCase, skipUnless
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 2a59c38..6a1c829 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -11,7 +11,6 @@
import os
import platform
import pwd
-import shutil
import stat
import tempfile
import unittest
@@ -411,7 +410,7 @@
self.assertTrue(posix.stat(bytearray(os.fsencode(support.TESTFN))))
self.assertRaisesRegex(TypeError,
- 'can\'t specify None for path argument',
+ 'should be string, bytes or integer, not',
posix.stat, None)
self.assertRaisesRegex(TypeError,
'should be string, bytes or integer, not',
@@ -863,9 +862,9 @@
self.assertEqual(s1, s2)
s2 = posix.stat(support.TESTFN, dir_fd=None)
self.assertEqual(s1, s2)
- self.assertRaisesRegex(TypeError, 'should be integer, not',
+ self.assertRaisesRegex(TypeError, 'should be integer or None, not',
posix.stat, support.TESTFN, dir_fd=posix.getcwd())
- self.assertRaisesRegex(TypeError, 'should be integer, not',
+ self.assertRaisesRegex(TypeError, 'should be integer or None, not',
posix.stat, support.TESTFN, dir_fd=float(f))
self.assertRaises(OverflowError,
posix.stat, support.TESTFN, dir_fd=10**20)
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py
index acf1102..4ff445d 100644
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -1,7 +1,5 @@
-import itertools
import os
import posixpath
-import sys
import unittest
import warnings
from posixpath import realpath, abspath, dirname, basename
diff --git a/Lib/test/test_pow.py b/Lib/test/test_pow.py
index 6feac40..ce99fe6 100644
--- a/Lib/test/test_pow.py
+++ b/Lib/test/test_pow.py
@@ -1,4 +1,4 @@
-import test.support, unittest
+import unittest
class PowTest(unittest.TestCase):
diff --git a/Lib/test/test_pprint.py b/Lib/test/test_pprint.py
index 7ebc298..2283923 100644
--- a/Lib/test/test_pprint.py
+++ b/Lib/test/test_pprint.py
@@ -848,12 +848,11 @@
def test_default_dict(self):
d = collections.defaultdict(int)
- self.assertEqual(pprint.pformat(d, width=1), "defaultdict(<class 'int'>, {})")
+ self.assertRegex(pprint.pformat(d, width=1), r"defaultdict\(<class 'int' at 0x.+>, {}\)")
words = 'the quick brown fox jumped over a lazy dog'.split()
d = collections.defaultdict(int, zip(words, itertools.count()))
- self.assertEqual(pprint.pformat(d),
-"""\
-defaultdict(<class 'int'>,
+ self.assertRegex(pprint.pformat(d),
+r"""defaultdict\(<class 'int' at 0x.+>,
{'a': 6,
'brown': 2,
'dog': 8,
@@ -862,7 +861,7 @@
'lazy': 7,
'over': 5,
'quick': 1,
- 'the': 0})""")
+ 'the': 0}\)""")
def test_counter(self):
d = collections.Counter()
diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py
index ef5e99e..15f88e4 100644
--- a/Lib/test/test_pty.py
+++ b/Lib/test/test_pty.py
@@ -277,7 +277,6 @@
socketpair = self._socketpair()
masters = [s.fileno() for s in socketpair]
- os.close(masters[1])
socketpair[1].close()
os.close(write_to_stdin_fd)
diff --git a/Lib/test/test_pulldom.py b/Lib/test/test_pulldom.py
index 1932c6b..3d89e3a 100644
--- a/Lib/test/test_pulldom.py
+++ b/Lib/test/test_pulldom.py
@@ -1,6 +1,5 @@
import io
import unittest
-import sys
import xml.sax
from xml.sax.xmlreader import AttributesImpl
diff --git a/Lib/test/test_pyclbr.py b/Lib/test/test_pyclbr.py
index 6ffbbbd..06c10c1 100644
--- a/Lib/test/test_pyclbr.py
+++ b/Lib/test/test_pyclbr.py
@@ -156,7 +156,7 @@
# These were once about the 10 longest modules
cm('random', ignore=('Random',)) # from _random import Random as CoreGenerator
cm('cgi', ignore=('log',)) # set with = in module
- cm('pickle')
+ cm('pickle', ignore=('partial',))
cm('aifc', ignore=('openfp', '_aifc_params')) # set with = in module
cm('sre_parse', ignore=('dump', 'groups')) # from sre_constants import *; property
cm('pdb')
diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py
index aee979b..889ce59 100644
--- a/Lib/test/test_pydoc.py
+++ b/Lib/test/test_pydoc.py
@@ -855,6 +855,22 @@
self.assertEqual(self._get_summary_line(t.wrap),
"wrap(text) method of textwrap.TextWrapper instance")
+ def test_field_order_for_named_tuples(self):
+ Person = namedtuple('Person', ['nickname', 'firstname', 'agegroup'])
+ s = pydoc.render_doc(Person)
+ self.assertLess(s.index('nickname'), s.index('firstname'))
+ self.assertLess(s.index('firstname'), s.index('agegroup'))
+
+ class NonIterableFields:
+ _fields = None
+
+ class NonHashableFields:
+ _fields = [[]]
+
+ # Make sure these doesn't fail
+ pydoc.render_doc(NonIterableFields)
+ pydoc.render_doc(NonHashableFields)
+
@requires_docstrings
def test_bound_builtin_method(self):
s = StringIO()
diff --git a/Lib/test/test_quopri.py b/Lib/test/test_quopri.py
index 7cac013..715544c 100644
--- a/Lib/test/test_quopri.py
+++ b/Lib/test/test_quopri.py
@@ -1,6 +1,6 @@
import unittest
-import sys, os, io, subprocess
+import sys, io, subprocess
import quopri
diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py
index 106c732..e03b570 100644
--- a/Lib/test/test_range.py
+++ b/Lib/test/test_range.py
@@ -1,6 +1,6 @@
# Python test set -- built-in functions
-import test.support, unittest
+import unittest
import sys
import pickle
import itertools
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 7a74141..24a0604 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -124,7 +124,7 @@
(chr(9)+chr(10)+chr(11)+chr(13)+chr(12)+chr(7)+chr(8)))
for c in 'cdehijklmopqsuwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ':
with self.subTest(c):
- with self.assertWarns(DeprecationWarning):
+ with self.assertRaises(re.error):
self.assertEqual(re.sub('a', '\\' + c, 'a'), '\\' + c)
self.assertEqual(re.sub('^\s*', 'X', 'test'), 'Xtest')
@@ -414,19 +414,33 @@
self.assertEqual(pat.match('bc').groups(), ('b', None, 'b', 'c'))
self.assertEqual(pat.match('bc').groups(""), ('b', "", 'b', 'c'))
- # A single group
- m = re.match('(a)', 'a')
- self.assertEqual(m.group(0), 'a')
- self.assertEqual(m.group(0), 'a')
- self.assertEqual(m.group(1), 'a')
- self.assertEqual(m.group(1, 1), ('a', 'a'))
-
pat = re.compile('(?:(?P<a1>a)|(?P<b2>b))(?P<c3>c)?')
self.assertEqual(pat.match('a').group(1, 2, 3), ('a', None, None))
self.assertEqual(pat.match('b').group('a1', 'b2', 'c3'),
(None, 'b', None))
self.assertEqual(pat.match('ac').group(1, 'b2', 3), ('a', None, 'c'))
+ def test_group(self):
+ class Index:
+ def __init__(self, value):
+ self.value = value
+ def __index__(self):
+ return self.value
+ # A single group
+ m = re.match('(a)(b)', 'ab')
+ self.assertEqual(m.group(), 'ab')
+ self.assertEqual(m.group(0), 'ab')
+ self.assertEqual(m.group(1), 'a')
+ self.assertEqual(m.group(Index(1)), 'a')
+ self.assertRaises(IndexError, m.group, -1)
+ self.assertRaises(IndexError, m.group, 3)
+ self.assertRaises(IndexError, m.group, 1<<1000)
+ self.assertRaises(IndexError, m.group, Index(1<<1000))
+ self.assertRaises(IndexError, m.group, 'x')
+ # Multiple groups
+ self.assertEqual(m.group(2, 1), ('b', 'a'))
+ self.assertEqual(m.group(Index(2), Index(1)), ('b', 'a'))
+
def test_re_fullmatch(self):
# Issue 16203: Proposal: add re.fullmatch() method.
self.assertEqual(re.fullmatch(r"a", "a").span(), (0, 1))
@@ -633,14 +647,10 @@
re.purge() # for warnings
for c in 'ceghijklmopqyzCEFGHIJKLMNOPQRTVXY':
with self.subTest(c):
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(re.fullmatch('\\%c' % c, c).group(), c)
- self.assertIsNone(re.match('\\%c' % c, 'a'))
+ self.assertRaises(re.error, re.compile, '\\%c' % c)
for c in 'ceghijklmopqyzABCEFGHIJKLMNOPQRTVXYZ':
with self.subTest(c):
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(re.fullmatch('[\\%c]' % c, c).group(), c)
- self.assertIsNone(re.match('[\\%c]' % c, 'a'))
+ self.assertRaises(re.error, re.compile, '[\\%c]' % c)
def test_string_boundaries(self):
# See http://bugs.python.org/issue10713
@@ -993,10 +1003,8 @@
self.assertTrue(re.match((r"\x%02x" % i).encode(), bytes([i])))
self.assertTrue(re.match((r"\x%02x0" % i).encode(), bytes([i])+b"0"))
self.assertTrue(re.match((r"\x%02xz" % i).encode(), bytes([i])+b"z"))
- with self.assertWarns(DeprecationWarning):
- self.assertTrue(re.match(br"\u1234", b'u1234'))
- with self.assertWarns(DeprecationWarning):
- self.assertTrue(re.match(br"\U00012345", b'U00012345'))
+ self.assertRaises(re.error, re.compile, br"\u1234")
+ self.assertRaises(re.error, re.compile, br"\U00012345")
self.assertTrue(re.match(br"\0", b"\000"))
self.assertTrue(re.match(br"\08", b"\0008"))
self.assertTrue(re.match(br"\01", b"\001"))
@@ -1018,10 +1026,8 @@
self.assertTrue(re.match((r"[\x%02x]" % i).encode(), bytes([i])))
self.assertTrue(re.match((r"[\x%02x0]" % i).encode(), bytes([i])))
self.assertTrue(re.match((r"[\x%02xz]" % i).encode(), bytes([i])))
- with self.assertWarns(DeprecationWarning):
- self.assertTrue(re.match(br"[\u1234]", b'u'))
- with self.assertWarns(DeprecationWarning):
- self.assertTrue(re.match(br"[\U00012345]", b'U'))
+ self.assertRaises(re.error, re.compile, br"[\u1234]")
+ self.assertRaises(re.error, re.compile, br"[\U00012345]")
self.checkPatternError(br"[\567]",
r'octal escape value \567 outside of '
r'range 0-0o377', 1)
@@ -1363,12 +1369,12 @@
if bletter:
self.assertIsNone(pat.match(bletter))
# Incompatibilities
- self.assertWarns(DeprecationWarning, re.compile, '', re.LOCALE)
- self.assertWarns(DeprecationWarning, re.compile, '(?L)')
- self.assertWarns(DeprecationWarning, re.compile, b'', re.LOCALE | re.ASCII)
- self.assertWarns(DeprecationWarning, re.compile, b'(?L)', re.ASCII)
- self.assertWarns(DeprecationWarning, re.compile, b'(?a)', re.LOCALE)
- self.assertWarns(DeprecationWarning, re.compile, b'(?aL)')
+ self.assertRaises(ValueError, re.compile, '', re.LOCALE)
+ self.assertRaises(ValueError, re.compile, '(?L)')
+ self.assertRaises(ValueError, re.compile, b'', re.LOCALE | re.ASCII)
+ self.assertRaises(ValueError, re.compile, b'(?L)', re.ASCII)
+ self.assertRaises(ValueError, re.compile, b'(?a)', re.LOCALE)
+ self.assertRaises(ValueError, re.compile, b'(?aL)')
def test_bug_6509(self):
# Replacement strings of both types must parse properly.
@@ -1419,13 +1425,6 @@
# Test behaviour when not given a string or pattern as parameter
self.assertRaises(TypeError, re.compile, 0)
- def test_bug_13899(self):
- # Issue #13899: re pattern r"[\A]" should work like "A" but matches
- # nothing. Ditto B and Z.
- with self.assertWarns(DeprecationWarning):
- self.assertEqual(re.findall(r'[\A\B\b\C\Z]', 'AB\bCZ'),
- ['A', 'B', '\b', 'C', 'Z'])
-
@bigmemtest(size=_2G, memuse=1)
def test_large_search(self, size):
# Issue #10182: indices were 32-bit-truncated.
diff --git a/Lib/test/test_readline.py b/Lib/test/test_readline.py
index 8c2ad85..9c895a1 100644
--- a/Lib/test/test_readline.py
+++ b/Lib/test/test_readline.py
@@ -121,6 +121,21 @@
TERM='xterm-256color')
self.assertEqual(stdout, b'')
+ auto_history_script = """\
+import readline
+readline.set_auto_history({})
+input()
+print("History length:", readline.get_current_history_length())
+"""
+
+ def test_auto_history_enabled(self):
+ output = run_pty(self.auto_history_script.format(True))
+ self.assertIn(b"History length: 1\r\n", output)
+
+ def test_auto_history_disabled(self):
+ output = run_pty(self.auto_history_script.format(False))
+ self.assertIn(b"History length: 0\r\n", output)
+
def test_nonascii(self):
try:
readline.add_history("\xEB\xEF")
diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
index a398a4f..c11408d 100644
--- a/Lib/test/test_regrtest.py
+++ b/Lib/test/test_regrtest.py
@@ -1,21 +1,48 @@
"""
Tests of regrtest.py.
+
+Note: test_regrtest cannot be run twice in parallel.
"""
-import argparse
+import contextlib
import faulthandler
-import getopt
+import io
import os.path
+import platform
+import re
+import subprocess
+import sys
+import sysconfig
+import tempfile
+import textwrap
import unittest
-from test import regrtest, support
+from test import libregrtest
+from test import support
+
+
+Py_DEBUG = hasattr(sys, 'getobjects')
+ROOT_DIR = os.path.join(os.path.dirname(__file__), '..', '..')
+ROOT_DIR = os.path.abspath(os.path.normpath(ROOT_DIR))
+
+TEST_INTERRUPTED = textwrap.dedent("""
+ from signal import SIGINT
+ try:
+ from _testcapi import raise_signal
+ raise_signal(SIGINT)
+ except ImportError:
+ import os
+ os.kill(os.getpid(), SIGINT)
+ """)
+
class ParseArgsTestCase(unittest.TestCase):
-
- """Test regrtest's argument parsing."""
+ """
+ Test regrtest's argument parsing, function _parse_args().
+ """
def checkError(self, args, msg):
with support.captured_stderr() as err, self.assertRaises(SystemExit):
- regrtest._parse_args(args)
+ libregrtest._parse_args(args)
self.assertIn(msg, err.getvalue())
def test_help(self):
@@ -23,82 +50,82 @@
with self.subTest(opt=opt):
with support.captured_stdout() as out, \
self.assertRaises(SystemExit):
- regrtest._parse_args([opt])
+ libregrtest._parse_args([opt])
self.assertIn('Run Python regression tests.', out.getvalue())
@unittest.skipUnless(hasattr(faulthandler, 'dump_traceback_later'),
"faulthandler.dump_traceback_later() required")
def test_timeout(self):
- ns = regrtest._parse_args(['--timeout', '4.2'])
+ ns = libregrtest._parse_args(['--timeout', '4.2'])
self.assertEqual(ns.timeout, 4.2)
self.checkError(['--timeout'], 'expected one argument')
self.checkError(['--timeout', 'foo'], 'invalid float value')
def test_wait(self):
- ns = regrtest._parse_args(['--wait'])
+ ns = libregrtest._parse_args(['--wait'])
self.assertTrue(ns.wait)
def test_slaveargs(self):
- ns = regrtest._parse_args(['--slaveargs', '[[], {}]'])
+ ns = libregrtest._parse_args(['--slaveargs', '[[], {}]'])
self.assertEqual(ns.slaveargs, '[[], {}]')
self.checkError(['--slaveargs'], 'expected one argument')
def test_start(self):
for opt in '-S', '--start':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt, 'foo'])
+ ns = libregrtest._parse_args([opt, 'foo'])
self.assertEqual(ns.start, 'foo')
self.checkError([opt], 'expected one argument')
def test_verbose(self):
- ns = regrtest._parse_args(['-v'])
+ ns = libregrtest._parse_args(['-v'])
self.assertEqual(ns.verbose, 1)
- ns = regrtest._parse_args(['-vvv'])
+ ns = libregrtest._parse_args(['-vvv'])
self.assertEqual(ns.verbose, 3)
- ns = regrtest._parse_args(['--verbose'])
+ ns = libregrtest._parse_args(['--verbose'])
self.assertEqual(ns.verbose, 1)
- ns = regrtest._parse_args(['--verbose'] * 3)
+ ns = libregrtest._parse_args(['--verbose'] * 3)
self.assertEqual(ns.verbose, 3)
- ns = regrtest._parse_args([])
+ ns = libregrtest._parse_args([])
self.assertEqual(ns.verbose, 0)
def test_verbose2(self):
for opt in '-w', '--verbose2':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt])
+ ns = libregrtest._parse_args([opt])
self.assertTrue(ns.verbose2)
def test_verbose3(self):
for opt in '-W', '--verbose3':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt])
+ ns = libregrtest._parse_args([opt])
self.assertTrue(ns.verbose3)
def test_quiet(self):
for opt in '-q', '--quiet':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt])
+ ns = libregrtest._parse_args([opt])
self.assertTrue(ns.quiet)
self.assertEqual(ns.verbose, 0)
def test_slow(self):
for opt in '-o', '--slow':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt])
+ ns = libregrtest._parse_args([opt])
self.assertTrue(ns.print_slow)
def test_header(self):
- ns = regrtest._parse_args(['--header'])
+ ns = libregrtest._parse_args(['--header'])
self.assertTrue(ns.header)
def test_randomize(self):
for opt in '-r', '--randomize':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt])
+ ns = libregrtest._parse_args([opt])
self.assertTrue(ns.randomize)
def test_randseed(self):
- ns = regrtest._parse_args(['--randseed', '12345'])
+ ns = libregrtest._parse_args(['--randseed', '12345'])
self.assertEqual(ns.random_seed, 12345)
self.assertTrue(ns.randomize)
self.checkError(['--randseed'], 'expected one argument')
@@ -107,7 +134,7 @@
def test_fromfile(self):
for opt in '-f', '--fromfile':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt, 'foo'])
+ ns = libregrtest._parse_args([opt, 'foo'])
self.assertEqual(ns.fromfile, 'foo')
self.checkError([opt], 'expected one argument')
self.checkError([opt, 'foo', '-s'], "don't go together")
@@ -115,42 +142,42 @@
def test_exclude(self):
for opt in '-x', '--exclude':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt])
+ ns = libregrtest._parse_args([opt])
self.assertTrue(ns.exclude)
def test_single(self):
for opt in '-s', '--single':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt])
+ ns = libregrtest._parse_args([opt])
self.assertTrue(ns.single)
self.checkError([opt, '-f', 'foo'], "don't go together")
def test_match(self):
for opt in '-m', '--match':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt, 'pattern'])
+ ns = libregrtest._parse_args([opt, 'pattern'])
self.assertEqual(ns.match_tests, 'pattern')
self.checkError([opt], 'expected one argument')
def test_failfast(self):
for opt in '-G', '--failfast':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt, '-v'])
+ ns = libregrtest._parse_args([opt, '-v'])
self.assertTrue(ns.failfast)
- ns = regrtest._parse_args([opt, '-W'])
+ ns = libregrtest._parse_args([opt, '-W'])
self.assertTrue(ns.failfast)
self.checkError([opt], '-G/--failfast needs either -v or -W')
def test_use(self):
for opt in '-u', '--use':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt, 'gui,network'])
+ ns = libregrtest._parse_args([opt, 'gui,network'])
self.assertEqual(ns.use_resources, ['gui', 'network'])
- ns = regrtest._parse_args([opt, 'gui,none,network'])
+ ns = libregrtest._parse_args([opt, 'gui,none,network'])
self.assertEqual(ns.use_resources, ['network'])
- expected = list(regrtest.RESOURCE_NAMES)
+ expected = list(libregrtest.RESOURCE_NAMES)
expected.remove('gui')
- ns = regrtest._parse_args([opt, 'all,-gui'])
+ ns = libregrtest._parse_args([opt, 'all,-gui'])
self.assertEqual(ns.use_resources, expected)
self.checkError([opt], 'expected one argument')
self.checkError([opt, 'foo'], 'invalid resource')
@@ -158,31 +185,31 @@
def test_memlimit(self):
for opt in '-M', '--memlimit':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt, '4G'])
+ ns = libregrtest._parse_args([opt, '4G'])
self.assertEqual(ns.memlimit, '4G')
self.checkError([opt], 'expected one argument')
def test_testdir(self):
- ns = regrtest._parse_args(['--testdir', 'foo'])
+ ns = libregrtest._parse_args(['--testdir', 'foo'])
self.assertEqual(ns.testdir, os.path.join(support.SAVEDCWD, 'foo'))
self.checkError(['--testdir'], 'expected one argument')
def test_runleaks(self):
for opt in '-L', '--runleaks':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt])
+ ns = libregrtest._parse_args([opt])
self.assertTrue(ns.runleaks)
def test_huntrleaks(self):
for opt in '-R', '--huntrleaks':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt, ':'])
+ ns = libregrtest._parse_args([opt, ':'])
self.assertEqual(ns.huntrleaks, (5, 4, 'reflog.txt'))
- ns = regrtest._parse_args([opt, '6:'])
+ ns = libregrtest._parse_args([opt, '6:'])
self.assertEqual(ns.huntrleaks, (6, 4, 'reflog.txt'))
- ns = regrtest._parse_args([opt, ':3'])
+ ns = libregrtest._parse_args([opt, ':3'])
self.assertEqual(ns.huntrleaks, (5, 3, 'reflog.txt'))
- ns = regrtest._parse_args([opt, '6:3:leaks.log'])
+ ns = libregrtest._parse_args([opt, '6:3:leaks.log'])
self.assertEqual(ns.huntrleaks, (6, 3, 'leaks.log'))
self.checkError([opt], 'expected one argument')
self.checkError([opt, '6'],
@@ -193,24 +220,23 @@
def test_multiprocess(self):
for opt in '-j', '--multiprocess':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt, '2'])
+ ns = libregrtest._parse_args([opt, '2'])
self.assertEqual(ns.use_mp, 2)
self.checkError([opt], 'expected one argument')
self.checkError([opt, 'foo'], 'invalid int value')
self.checkError([opt, '2', '-T'], "don't go together")
self.checkError([opt, '2', '-l'], "don't go together")
- self.checkError([opt, '2', '-M', '4G'], "don't go together")
def test_coverage(self):
for opt in '-T', '--coverage':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt])
+ ns = libregrtest._parse_args([opt])
self.assertTrue(ns.trace)
def test_coverdir(self):
for opt in '-D', '--coverdir':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt, 'foo'])
+ ns = libregrtest._parse_args([opt, 'foo'])
self.assertEqual(ns.coverdir,
os.path.join(support.SAVEDCWD, 'foo'))
self.checkError([opt], 'expected one argument')
@@ -218,13 +244,13 @@
def test_nocoverdir(self):
for opt in '-N', '--nocoverdir':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt])
+ ns = libregrtest._parse_args([opt])
self.assertIsNone(ns.coverdir)
def test_threshold(self):
for opt in '-t', '--threshold':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt, '1000'])
+ ns = libregrtest._parse_args([opt, '1000'])
self.assertEqual(ns.threshold, 1000)
self.checkError([opt], 'expected one argument')
self.checkError([opt, 'foo'], 'invalid int value')
@@ -232,13 +258,16 @@
def test_nowindows(self):
for opt in '-n', '--nowindows':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt])
+ with contextlib.redirect_stderr(io.StringIO()) as stderr:
+ ns = libregrtest._parse_args([opt])
self.assertTrue(ns.nowindows)
+ err = stderr.getvalue()
+ self.assertIn('the --nowindows (-n) option is deprecated', err)
def test_forever(self):
for opt in '-F', '--forever':
with self.subTest(opt=opt):
- ns = regrtest._parse_args([opt])
+ ns = libregrtest._parse_args([opt])
self.assertTrue(ns.forever)
@@ -246,30 +275,503 @@
self.checkError(['--xxx'], 'usage:')
def test_long_option__partial(self):
- ns = regrtest._parse_args(['--qui'])
+ ns = libregrtest._parse_args(['--qui'])
self.assertTrue(ns.quiet)
self.assertEqual(ns.verbose, 0)
def test_two_options(self):
- ns = regrtest._parse_args(['--quiet', '--exclude'])
+ ns = libregrtest._parse_args(['--quiet', '--exclude'])
self.assertTrue(ns.quiet)
self.assertEqual(ns.verbose, 0)
self.assertTrue(ns.exclude)
def test_option_with_empty_string_value(self):
- ns = regrtest._parse_args(['--start', ''])
+ ns = libregrtest._parse_args(['--start', ''])
self.assertEqual(ns.start, '')
def test_arg(self):
- ns = regrtest._parse_args(['foo'])
+ ns = libregrtest._parse_args(['foo'])
self.assertEqual(ns.args, ['foo'])
def test_option_and_arg(self):
- ns = regrtest._parse_args(['--quiet', 'foo'])
+ ns = libregrtest._parse_args(['--quiet', 'foo'])
self.assertTrue(ns.quiet)
self.assertEqual(ns.verbose, 0)
self.assertEqual(ns.args, ['foo'])
+class BaseTestCase(unittest.TestCase):
+ TEST_UNIQUE_ID = 1
+ TESTNAME_PREFIX = 'test_regrtest_'
+ TESTNAME_REGEX = r'test_[a-zA-Z0-9_]+'
+
+ def setUp(self):
+ self.testdir = os.path.realpath(os.path.dirname(__file__))
+
+ self.tmptestdir = tempfile.mkdtemp()
+ self.addCleanup(support.rmtree, self.tmptestdir)
+
+ def create_test(self, name=None, code=''):
+ if not name:
+ name = 'noop%s' % BaseTestCase.TEST_UNIQUE_ID
+ BaseTestCase.TEST_UNIQUE_ID += 1
+
+ # test_regrtest cannot be run twice in parallel because
+ # of setUp() and create_test()
+ name = self.TESTNAME_PREFIX + name
+ path = os.path.join(self.tmptestdir, name + '.py')
+
+ self.addCleanup(support.unlink, path)
+ # Use 'x' mode to ensure that we do not override existing tests
+ try:
+ with open(path, 'x', encoding='utf-8') as fp:
+ fp.write(code)
+ except PermissionError as exc:
+ if not sysconfig.is_python_build():
+ self.skipTest("cannot write %s: %s" % (path, exc))
+ raise
+ return name
+
+ def regex_search(self, regex, output):
+ match = re.search(regex, output, re.MULTILINE)
+ if not match:
+ self.fail("%r not found in %r" % (regex, output))
+ return match
+
+ def check_line(self, output, regex):
+ regex = re.compile(r'^' + regex, re.MULTILINE)
+ self.assertRegex(output, regex)
+
+ def parse_executed_tests(self, output):
+ regex = (r'^[0-9]+:[0-9]+:[0-9]+ \[ *[0-9]+(?:/ *[0-9]+)?\] (%s)'
+ % self.TESTNAME_REGEX)
+ parser = re.finditer(regex, output, re.MULTILINE)
+ return list(match.group(1) for match in parser)
+
+ def check_executed_tests(self, output, tests, skipped=(), failed=(),
+ omitted=(), randomize=False):
+ if isinstance(tests, str):
+ tests = [tests]
+ if isinstance(skipped, str):
+ skipped = [skipped]
+ if isinstance(failed, str):
+ failed = [failed]
+ if isinstance(omitted, str):
+ omitted = [omitted]
+ ntest = len(tests)
+ nskipped = len(skipped)
+ nfailed = len(failed)
+ nomitted = len(omitted)
+
+ executed = self.parse_executed_tests(output)
+ if randomize:
+ self.assertEqual(set(executed), set(tests), output)
+ else:
+ self.assertEqual(executed, tests, output)
+
+ def plural(count):
+ return 's' if count != 1 else ''
+
+ def list_regex(line_format, tests):
+ count = len(tests)
+ names = ' '.join(sorted(tests))
+ regex = line_format % (count, plural(count))
+ regex = r'%s:\n %s$' % (regex, names)
+ return regex
+
+ if skipped:
+ regex = list_regex('%s test%s skipped', skipped)
+ self.check_line(output, regex)
+
+ if failed:
+ regex = list_regex('%s test%s failed', failed)
+ self.check_line(output, regex)
+
+ if omitted:
+ regex = list_regex('%s test%s omitted', omitted)
+ self.check_line(output, regex)
+
+ good = ntest - nskipped - nfailed - nomitted
+ if good:
+ regex = r'%s test%s OK\.$' % (good, plural(good))
+ if not skipped and not failed and good > 1:
+ regex = 'All %s' % regex
+ self.check_line(output, regex)
+
+ def parse_random_seed(self, output):
+ match = self.regex_search(r'Using random seed ([0-9]+)', output)
+ randseed = int(match.group(1))
+ self.assertTrue(0 <= randseed <= 10000000, randseed)
+ return randseed
+
+ def run_command(self, args, input=None, exitcode=0, **kw):
+ if not input:
+ input = ''
+ if 'stderr' not in kw:
+ kw['stderr'] = subprocess.PIPE
+ proc = subprocess.run(args,
+ universal_newlines=True,
+ input=input,
+ stdout=subprocess.PIPE,
+ **kw)
+ if proc.returncode != exitcode:
+ msg = ("Command %s failed with exit code %s\n"
+ "\n"
+ "stdout:\n"
+ "---\n"
+ "%s\n"
+ "---\n"
+ % (str(args), proc.returncode, proc.stdout))
+ if proc.stderr:
+ msg += ("\n"
+ "stderr:\n"
+ "---\n"
+ "%s"
+ "---\n"
+ % proc.stderr)
+ self.fail(msg)
+ return proc
+
+
+ def run_python(self, args, **kw):
+ args = [sys.executable, '-X', 'faulthandler', '-I', *args]
+ proc = self.run_command(args, **kw)
+ return proc.stdout
+
+
+class ProgramsTestCase(BaseTestCase):
+ """
+ Test various ways to run the Python test suite. Use options close
+ to options used on the buildbot.
+ """
+
+ NTEST = 4
+
+ def setUp(self):
+ super().setUp()
+
+ # Create NTEST tests doing nothing
+ self.tests = [self.create_test() for index in range(self.NTEST)]
+
+ self.python_args = ['-Wd', '-E', '-bb']
+ self.regrtest_args = ['-uall', '-rwW',
+ '--testdir=%s' % self.tmptestdir]
+ if hasattr(faulthandler, 'dump_traceback_later'):
+ self.regrtest_args.extend(('--timeout', '3600', '-j4'))
+ if sys.platform == 'win32':
+ self.regrtest_args.append('-n')
+
+ def check_output(self, output):
+ self.parse_random_seed(output)
+ self.check_executed_tests(output, self.tests, randomize=True)
+
+ def run_tests(self, args):
+ output = self.run_python(args)
+ self.check_output(output)
+
+ def test_script_regrtest(self):
+ # Lib/test/regrtest.py
+ script = os.path.join(self.testdir, 'regrtest.py')
+
+ args = [*self.python_args, script, *self.regrtest_args, *self.tests]
+ self.run_tests(args)
+
+ def test_module_test(self):
+ # -m test
+ args = [*self.python_args, '-m', 'test',
+ *self.regrtest_args, *self.tests]
+ self.run_tests(args)
+
+ def test_module_regrtest(self):
+ # -m test.regrtest
+ args = [*self.python_args, '-m', 'test.regrtest',
+ *self.regrtest_args, *self.tests]
+ self.run_tests(args)
+
+ def test_module_autotest(self):
+ # -m test.autotest
+ args = [*self.python_args, '-m', 'test.autotest',
+ *self.regrtest_args, *self.tests]
+ self.run_tests(args)
+
+ def test_module_from_test_autotest(self):
+ # from test import autotest
+ code = 'from test import autotest'
+ args = [*self.python_args, '-c', code,
+ *self.regrtest_args, *self.tests]
+ self.run_tests(args)
+
+ def test_script_autotest(self):
+ # Lib/test/autotest.py
+ script = os.path.join(self.testdir, 'autotest.py')
+ args = [*self.python_args, script, *self.regrtest_args, *self.tests]
+ self.run_tests(args)
+
+ @unittest.skipUnless(sysconfig.is_python_build(),
+ 'run_tests.py script is not installed')
+ def test_tools_script_run_tests(self):
+ # Tools/scripts/run_tests.py
+ script = os.path.join(ROOT_DIR, 'Tools', 'scripts', 'run_tests.py')
+ args = [script, *self.regrtest_args, *self.tests]
+ self.run_tests(args)
+
+ def run_batch(self, *args):
+ proc = self.run_command(args)
+ self.check_output(proc.stdout)
+
+ @unittest.skipUnless(sysconfig.is_python_build(),
+ 'test.bat script is not installed')
+ @unittest.skipUnless(sys.platform == 'win32', 'Windows only')
+ def test_tools_buildbot_test(self):
+ # Tools\buildbot\test.bat
+ script = os.path.join(ROOT_DIR, 'Tools', 'buildbot', 'test.bat')
+ test_args = ['--testdir=%s' % self.tmptestdir]
+ if platform.architecture()[0] == '64bit':
+ test_args.append('-x64') # 64-bit build
+ if not Py_DEBUG:
+ test_args.append('+d') # Release build, use python.exe
+ self.run_batch(script, *test_args, *self.tests)
+
+ @unittest.skipUnless(sys.platform == 'win32', 'Windows only')
+ def test_pcbuild_rt(self):
+ # PCbuild\rt.bat
+ script = os.path.join(ROOT_DIR, r'PCbuild\rt.bat')
+ rt_args = ["-q"] # Quick, don't run tests twice
+ if platform.architecture()[0] == '64bit':
+ rt_args.append('-x64') # 64-bit build
+ if Py_DEBUG:
+ rt_args.append('-d') # Debug build, use python_d.exe
+ self.run_batch(script, *rt_args, *self.regrtest_args, *self.tests)
+
+
+class ArgsTestCase(BaseTestCase):
+ """
+ Test arguments of the Python test suite.
+ """
+
+ def run_tests(self, *testargs, **kw):
+ cmdargs = ['-m', 'test', '--testdir=%s' % self.tmptestdir, *testargs]
+ return self.run_python(cmdargs, **kw)
+
+ def test_failing_test(self):
+ # test a failing test
+ code = textwrap.dedent("""
+ import unittest
+
+ class FailingTest(unittest.TestCase):
+ def test_failing(self):
+ self.fail("bug")
+ """)
+ test_ok = self.create_test('ok')
+ test_failing = self.create_test('failing', code=code)
+ tests = [test_ok, test_failing]
+
+ output = self.run_tests(*tests, exitcode=1)
+ self.check_executed_tests(output, tests, failed=test_failing)
+
+ def test_resources(self):
+ # test -u command line option
+ tests = {}
+ for resource in ('audio', 'network'):
+ code = 'from test import support\nsupport.requires(%r)' % resource
+ tests[resource] = self.create_test(resource, code)
+ test_names = sorted(tests.values())
+
+ # -u all: 2 resources enabled
+ output = self.run_tests('-u', 'all', *test_names)
+ self.check_executed_tests(output, test_names)
+
+ # -u audio: 1 resource enabled
+ output = self.run_tests('-uaudio', *test_names)
+ self.check_executed_tests(output, test_names,
+ skipped=tests['network'])
+
+ # no option: 0 resources enabled
+ output = self.run_tests(*test_names)
+ self.check_executed_tests(output, test_names,
+ skipped=test_names)
+
+ def test_random(self):
+ # test -r and --randseed command line option
+ code = textwrap.dedent("""
+ import random
+ print("TESTRANDOM: %s" % random.randint(1, 1000))
+ """)
+ test = self.create_test('random', code)
+
+ # first run to get the output with the random seed
+ output = self.run_tests('-r', test)
+ randseed = self.parse_random_seed(output)
+ match = self.regex_search(r'TESTRANDOM: ([0-9]+)', output)
+ test_random = int(match.group(1))
+
+ # try to reproduce with the random seed
+ output = self.run_tests('-r', '--randseed=%s' % randseed, test)
+ randseed2 = self.parse_random_seed(output)
+ self.assertEqual(randseed2, randseed)
+
+ match = self.regex_search(r'TESTRANDOM: ([0-9]+)', output)
+ test_random2 = int(match.group(1))
+ self.assertEqual(test_random2, test_random)
+
+ def test_fromfile(self):
+ # test --fromfile
+ tests = [self.create_test() for index in range(5)]
+
+ # Write the list of files using a format similar to regrtest output:
+ # [1/2] test_1
+ # [2/2] test_2
+ filename = support.TESTFN
+ self.addCleanup(support.unlink, filename)
+
+ # test format '0:00:00 [2/7] test_opcodes -- test_grammar took 0 sec'
+ with open(filename, "w") as fp:
+ previous = None
+ for index, name in enumerate(tests, 1):
+ line = ("00:00:%02i [%s/%s] %s"
+ % (index, index, len(tests), name))
+ if previous:
+ line += " -- %s took 0 sec" % previous
+ print(line, file=fp)
+ previous = name
+
+ output = self.run_tests('--fromfile', filename)
+ self.check_executed_tests(output, tests)
+
+ # test format '[2/7] test_opcodes'
+ with open(filename, "w") as fp:
+ for index, name in enumerate(tests, 1):
+ print("[%s/%s] %s" % (index, len(tests), name), file=fp)
+
+ output = self.run_tests('--fromfile', filename)
+ self.check_executed_tests(output, tests)
+
+ # test format 'test_opcodes'
+ with open(filename, "w") as fp:
+ for name in tests:
+ print(name, file=fp)
+
+ output = self.run_tests('--fromfile', filename)
+ self.check_executed_tests(output, tests)
+
+ def test_interrupted(self):
+ code = TEST_INTERRUPTED
+ test = self.create_test('sigint', code=code)
+ output = self.run_tests(test, exitcode=1)
+ self.check_executed_tests(output, test, omitted=test)
+
+ def test_slow(self):
+ # test --slow
+ tests = [self.create_test() for index in range(3)]
+ output = self.run_tests("--slow", *tests)
+ self.check_executed_tests(output, tests)
+ regex = ('10 slowest tests:\n'
+ '(?:%s: [0-9]+\.[0-9]+s\n){%s}'
+ % (self.TESTNAME_REGEX, len(tests)))
+ self.check_line(output, regex)
+
+ def test_slow_interrupted(self):
+ # Issue #25373: test --slow with an interrupted test
+ code = TEST_INTERRUPTED
+ test = self.create_test("sigint", code=code)
+
+ for multiprocessing in (False, True):
+ if multiprocessing:
+ args = ("--slow", "-j2", test)
+ else:
+ args = ("--slow", test)
+ output = self.run_tests(*args, exitcode=1)
+ self.check_executed_tests(output, test, omitted=test)
+ regex = ('10 slowest tests:\n')
+ self.check_line(output, regex)
+ self.check_line(output, 'Test suite interrupted by signal SIGINT.')
+
+ def test_coverage(self):
+ # test --coverage
+ test = self.create_test('coverage')
+ output = self.run_tests("--coverage", test)
+ self.check_executed_tests(output, [test])
+ regex = ('lines +cov% +module +\(path\)\n'
+ '(?: *[0-9]+ *[0-9]{1,2}% *[^ ]+ +\([^)]+\)+)+')
+ self.check_line(output, regex)
+
+ def test_wait(self):
+ # test --wait
+ test = self.create_test('wait')
+ output = self.run_tests("--wait", test, input='key')
+ self.check_line(output, 'Press any key to continue')
+
+ def test_forever(self):
+ # test --forever
+ code = textwrap.dedent("""
+ import builtins
+ import unittest
+
+ class ForeverTester(unittest.TestCase):
+ def test_run(self):
+ # Store the state in the builtins module, because the test
+ # module is reload at each run
+ if 'RUN' in builtins.__dict__:
+ builtins.__dict__['RUN'] += 1
+ if builtins.__dict__['RUN'] >= 3:
+ self.fail("fail at the 3rd runs")
+ else:
+ builtins.__dict__['RUN'] = 1
+ """)
+ test = self.create_test('forever', code=code)
+ output = self.run_tests('--forever', test, exitcode=1)
+ self.check_executed_tests(output, [test]*3, failed=test)
+
+ @unittest.skipUnless(Py_DEBUG, 'need a debug build')
+ def test_huntrleaks_fd_leak(self):
+ # test --huntrleaks for file descriptor leak
+ code = textwrap.dedent("""
+ import os
+ import unittest
+
+ # Issue #25306: Disable popups and logs to stderr on assertion
+ # failures in MSCRT
+ try:
+ import msvcrt
+ msvcrt.CrtSetReportMode
+ except (ImportError, AttributeError):
+ # no Windows, o release build
+ pass
+ else:
+ for m in [msvcrt.CRT_WARN, msvcrt.CRT_ERROR, msvcrt.CRT_ASSERT]:
+ msvcrt.CrtSetReportMode(m, 0)
+
+ class FDLeakTest(unittest.TestCase):
+ def test_leak(self):
+ fd = os.open(__file__, os.O_RDONLY)
+ # bug: never cloes the file descriptor
+ """)
+ test = self.create_test('huntrleaks', code=code)
+
+ filename = 'reflog.txt'
+ self.addCleanup(support.unlink, filename)
+ output = self.run_tests('--huntrleaks', '3:3:', test,
+ exitcode=1,
+ stderr=subprocess.STDOUT)
+ self.check_executed_tests(output, [test], failed=test)
+
+ line = 'beginning 6 repetitions\n123456\n......\n'
+ self.check_line(output, re.escape(line))
+
+ line2 = '%s leaked [1, 1, 1] file descriptors, sum=3\n' % test
+ self.check_line(output, re.escape(line2))
+
+ with open(filename) as fp:
+ reflog = fp.read()
+ self.assertEqual(reflog, line2)
+
+ def test_list_tests(self):
+ # test --list-tests
+ tests = [self.create_test() for i in range(5)]
+ output = self.run_tests('--list-tests', *tests)
+ self.assertEqual(output.rstrip().splitlines(),
+ tests)
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/test/test_reprlib.py b/Lib/test/test_reprlib.py
index 4bf9194..2ecea02 100644
--- a/Lib/test/test_reprlib.py
+++ b/Lib/test/test_reprlib.py
@@ -292,8 +292,8 @@
''')
importlib.invalidate_caches()
from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import foo
- eq(repr(foo.foo),
- "<class '%s.foo'>" % foo.__name__)
+ self.assertRegex(repr(foo.foo),
+ r"<class '%s.foo' at 0x.+>" % foo.__name__)
@unittest.skip('need a suitable object')
def test_object(self):
@@ -310,7 +310,7 @@
importlib.invalidate_caches()
from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import bar
# Module name may be prefixed with "test.", depending on how run.
- self.assertEqual(repr(bar.bar), "<class '%s.bar'>" % bar.__name__)
+ self.assertRegex(repr(bar.bar), r"<class '%s.bar' at 0x.+>" % bar.__name__)
def test_instance(self):
self._check_path_limitations('baz')
diff --git a/Lib/test/test_richcmp.py b/Lib/test/test_richcmp.py
index 1582caa..58729a9 100644
--- a/Lib/test/test_richcmp.py
+++ b/Lib/test/test_richcmp.py
@@ -253,6 +253,31 @@
self.assertTrue(a != b)
self.assertTrue(a < b)
+ def test_exception_message(self):
+ class Spam:
+ pass
+
+ tests = [
+ (lambda: 42 < None, r"'<' .* of 'int' and 'NoneType'"),
+ (lambda: None < 42, r"'<' .* of 'NoneType' and 'int'"),
+ (lambda: 42 > None, r"'>' .* of 'int' and 'NoneType'"),
+ (lambda: "foo" < None, r"'<' .* of 'str' and 'NoneType'"),
+ (lambda: "foo" >= 666, r"'>=' .* of 'str' and 'int'"),
+ (lambda: 42 <= None, r"'<=' .* of 'int' and 'NoneType'"),
+ (lambda: 42 >= None, r"'>=' .* of 'int' and 'NoneType'"),
+ (lambda: 42 < [], r"'<' .* of 'int' and 'list'"),
+ (lambda: () > [], r"'>' .* of 'tuple' and 'list'"),
+ (lambda: None >= None, r"'>=' .* of 'NoneType' and 'NoneType'"),
+ (lambda: Spam() < 42, r"'<' .* of 'Spam' and 'int'"),
+ (lambda: 42 < Spam(), r"'<' .* of 'int' and 'Spam'"),
+ (lambda: Spam() <= Spam(), r"'<=' .* of 'Spam' and 'Spam'"),
+ ]
+ for i, test in enumerate(tests):
+ with self.subTest(test=i):
+ with self.assertRaisesRegex(TypeError, test[1]):
+ test[0]()
+
+
class DictTest(unittest.TestCase):
def test_dicts(self):
diff --git a/Lib/test/test_rlcompleter.py b/Lib/test/test_rlcompleter.py
index 853e773..0dc1080 100644
--- a/Lib/test/test_rlcompleter.py
+++ b/Lib/test/test_rlcompleter.py
@@ -1,11 +1,12 @@
import unittest
-import unittest.mock
+from unittest.mock import patch
import builtins
import rlcompleter
class CompleteMe:
""" Trivial class used in testing rlcompleter.Completer. """
spam = 1
+ _ham = 2
class TestRlcompleter(unittest.TestCase):
@@ -52,18 +53,32 @@
['str.{}('.format(x) for x in dir(str)
if x.startswith('s')])
self.assertEqual(self.stdcompleter.attr_matches('tuple.foospamegg'), [])
+ expected = sorted({'None.%s%s' % (x, '(' if x != '__doc__' else '')
+ for x in dir(None)})
+ self.assertEqual(self.stdcompleter.attr_matches('None.'), expected)
+ self.assertEqual(self.stdcompleter.attr_matches('None._'), expected)
+ self.assertEqual(self.stdcompleter.attr_matches('None.__'), expected)
# test with a customized namespace
self.assertEqual(self.completer.attr_matches('CompleteMe.sp'),
['CompleteMe.spam'])
self.assertEqual(self.completer.attr_matches('Completeme.egg'), [])
+ self.assertEqual(self.completer.attr_matches('CompleteMe.'),
+ ['CompleteMe.mro(', 'CompleteMe.spam'])
+ self.assertEqual(self.completer.attr_matches('CompleteMe._'),
+ ['CompleteMe._ham'])
+ matches = self.completer.attr_matches('CompleteMe.__')
+ for x in matches:
+ self.assertTrue(x.startswith('CompleteMe.__'), x)
+ self.assertIn('CompleteMe.__name__', matches)
+ self.assertIn('CompleteMe.__new__(', matches)
- CompleteMe.me = CompleteMe
- self.assertEqual(self.completer.attr_matches('CompleteMe.me.me.sp'),
- ['CompleteMe.me.me.spam'])
- self.assertEqual(self.completer.attr_matches('egg.s'),
- ['egg.{}('.format(x) for x in dir(str)
- if x.startswith('s')])
+ with patch.object(CompleteMe, "me", CompleteMe, create=True):
+ self.assertEqual(self.completer.attr_matches('CompleteMe.me.me.sp'),
+ ['CompleteMe.me.me.spam'])
+ self.assertEqual(self.completer.attr_matches('egg.s'),
+ ['egg.{}('.format(x) for x in dir(str)
+ if x.startswith('s')])
def test_excessive_getattr(self):
# Ensure getattr() is invoked no more than once per attribute
@@ -78,14 +93,27 @@
self.assertEqual(completer.complete('f.b', 0), 'f.bar')
self.assertEqual(f.calls, 1)
+ def test_uncreated_attr(self):
+ # Attributes like properties and slots should be completed even when
+ # they haven't been created on an instance
+ class Foo:
+ __slots__ = ("bar",)
+ completer = rlcompleter.Completer(dict(f=Foo()))
+ self.assertEqual(completer.complete('f.', 0), 'f.bar')
+
@unittest.mock.patch('rlcompleter._readline_available', False)
def test_complete(self):
completer = rlcompleter.Completer()
self.assertEqual(completer.complete('', 0), '\t')
- self.assertEqual(completer.complete('a', 0), 'and')
- self.assertEqual(completer.complete('a', 1), 'as')
- self.assertEqual(completer.complete('as', 2), 'assert')
- self.assertEqual(completer.complete('an', 0), 'and')
+ self.assertEqual(completer.complete('a', 0), 'and ')
+ self.assertEqual(completer.complete('a', 1), 'as ')
+ self.assertEqual(completer.complete('as', 2), 'assert ')
+ self.assertEqual(completer.complete('an', 0), 'and ')
+ self.assertEqual(completer.complete('pa', 0), 'pass')
+ self.assertEqual(completer.complete('Fa', 0), 'False')
+ self.assertEqual(completer.complete('el', 0), 'elif ')
+ self.assertEqual(completer.complete('el', 1), 'else')
+ self.assertEqual(completer.complete('tr', 0), 'try:')
def test_duplicate_globals(self):
namespace = {
@@ -98,9 +126,10 @@
completer = rlcompleter.Completer(namespace)
self.assertEqual(completer.complete('False', 0), 'False')
self.assertIsNone(completer.complete('False', 1)) # No duplicates
- self.assertEqual(completer.complete('assert', 0), 'assert')
+ # Space or colon added due to being a reserved keyword
+ self.assertEqual(completer.complete('assert', 0), 'assert ')
self.assertIsNone(completer.complete('assert', 1))
- self.assertEqual(completer.complete('try', 0), 'try')
+ self.assertEqual(completer.complete('try', 0), 'try:')
self.assertIsNone(completer.complete('try', 1))
# No opening bracket "(" because we overrode the built-in class
self.assertEqual(completer.complete('memoryview', 0), 'memoryview')
diff --git a/Lib/test/test_robotparser.py b/Lib/test/test_robotparser.py
index d01266f..76f4f7c 100644
--- a/Lib/test/test_robotparser.py
+++ b/Lib/test/test_robotparser.py
@@ -1,8 +1,7 @@
import io
import unittest
import urllib.robotparser
-from urllib.error import URLError, HTTPError
-from urllib.request import urlopen
+from collections import namedtuple
from test import support
from http.server import BaseHTTPRequestHandler, HTTPServer
try:
@@ -12,7 +11,8 @@
class RobotTestCase(unittest.TestCase):
- def __init__(self, index=None, parser=None, url=None, good=None, agent=None):
+ def __init__(self, index=None, parser=None, url=None, good=None,
+ agent=None, request_rate=None, crawl_delay=None):
# workaround to make unittest discovery work (see #17066)
if not isinstance(index, int):
return
@@ -25,6 +25,8 @@
self.url = url
self.good = good
self.agent = agent
+ self.request_rate = request_rate
+ self.crawl_delay = crawl_delay
def runTest(self):
if isinstance(self.url, tuple):
@@ -34,6 +36,18 @@
agent = self.agent
if self.good:
self.assertTrue(self.parser.can_fetch(agent, url))
+ self.assertEqual(self.parser.crawl_delay(agent), self.crawl_delay)
+ # if we have actual values for request rate
+ if self.request_rate and self.parser.request_rate(agent):
+ self.assertEqual(
+ self.parser.request_rate(agent).requests,
+ self.request_rate.requests
+ )
+ self.assertEqual(
+ self.parser.request_rate(agent).seconds,
+ self.request_rate.seconds
+ )
+ self.assertEqual(self.parser.request_rate(agent), self.request_rate)
else:
self.assertFalse(self.parser.can_fetch(agent, url))
@@ -43,15 +57,17 @@
tests = unittest.TestSuite()
def RobotTest(index, robots_txt, good_urls, bad_urls,
- agent="test_robotparser"):
+ request_rate, crawl_delay, agent="test_robotparser"):
lines = io.StringIO(robots_txt).readlines()
parser = urllib.robotparser.RobotFileParser()
parser.parse(lines)
for url in good_urls:
- tests.addTest(RobotTestCase(index, parser, url, 1, agent))
+ tests.addTest(RobotTestCase(index, parser, url, 1, agent,
+ request_rate, crawl_delay))
for url in bad_urls:
- tests.addTest(RobotTestCase(index, parser, url, 0, agent))
+ tests.addTest(RobotTestCase(index, parser, url, 0, agent,
+ request_rate, crawl_delay))
# Examples from http://www.robotstxt.org/wc/norobots.html (fetched 2002)
@@ -65,14 +81,18 @@
good = ['/','/test.html']
bad = ['/cyberworld/map/index.html','/tmp/xxx','/foo.html']
+request_rate = None
+crawl_delay = None
-RobotTest(1, doc, good, bad)
+RobotTest(1, doc, good, bad, request_rate, crawl_delay)
# 2.
doc = """
# robots.txt for http://www.example.com/
User-agent: *
+Crawl-delay: 1
+Request-rate: 3/15
Disallow: /cyberworld/map/ # This is an infinite virtual URL space
# Cybermapper knows where to go.
@@ -83,8 +103,10 @@
good = ['/','/test.html',('cybermapper','/cyberworld/map/index.html')]
bad = ['/cyberworld/map/index.html']
+request_rate = None # The parameters should be equal to None since they
+crawl_delay = None # don't apply to the cybermapper user agent
-RobotTest(2, doc, good, bad)
+RobotTest(2, doc, good, bad, request_rate, crawl_delay)
# 3.
doc = """
@@ -95,14 +117,18 @@
good = []
bad = ['/cyberworld/map/index.html','/','/tmp/']
+request_rate = None
+crawl_delay = None
-RobotTest(3, doc, good, bad)
+RobotTest(3, doc, good, bad, request_rate, crawl_delay)
# Examples from http://www.robotstxt.org/wc/norobots-rfc.html (fetched 2002)
# 4.
doc = """
User-agent: figtree
+Crawl-delay: 3
+Request-rate: 9/30
Disallow: /tmp
Disallow: /a%3cd.html
Disallow: /a%2fb.html
@@ -115,8 +141,17 @@
'/~joe/index.html'
]
-RobotTest(4, doc, good, bad, 'figtree')
-RobotTest(5, doc, good, bad, 'FigTree Robot libwww-perl/5.04')
+request_rate = namedtuple('req_rate', 'requests seconds')
+request_rate.requests = 9
+request_rate.seconds = 30
+crawl_delay = 3
+request_rate_bad = None # not actually tested, but we still need to parse it
+crawl_delay_bad = None # in order to accommodate the input parameters
+
+
+RobotTest(4, doc, good, bad, request_rate, crawl_delay, 'figtree' )
+RobotTest(5, doc, good, bad, request_rate_bad, crawl_delay_bad,
+ 'FigTree Robot libwww-perl/5.04')
# 6.
doc = """
@@ -125,14 +160,18 @@
Disallow: /a%3Cd.html
Disallow: /a/b.html
Disallow: /%7ejoe/index.html
+Crawl-delay: 3
+Request-rate: 9/banana
"""
good = ['/tmp',] # XFAIL: '/a%2fb.html'
bad = ['/tmp/','/tmp/a.html',
'/a%3cd.html','/a%3Cd.html',"/a/b.html",
'/%7Ejoe/index.html']
+crawl_delay = 3
+request_rate = None # since request rate has invalid syntax, return None
-RobotTest(6, doc, good, bad)
+RobotTest(6, doc, good, bad, None, None)
# From bug report #523041
@@ -140,12 +179,16 @@
doc = """
User-Agent: *
Disallow: /.
+Crawl-delay: pears
"""
good = ['/foo.html']
-bad = [] # Bug report says "/" should be denied, but that is not in the RFC
+bad = [] # bug report says "/" should be denied, but that is not in the RFC
-RobotTest(7, doc, good, bad)
+crawl_delay = None # since crawl delay has invalid syntax, return None
+request_rate = None
+
+RobotTest(7, doc, good, bad, crawl_delay, request_rate)
# From Google: http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=40364
@@ -154,12 +197,15 @@
User-agent: Googlebot
Allow: /folder1/myfile.html
Disallow: /folder1/
+Request-rate: whale/banana
"""
good = ['/folder1/myfile.html']
bad = ['/folder1/anotherfile.html']
+crawl_delay = None
+request_rate = None # invalid syntax, return none
-RobotTest(8, doc, good, bad, agent="Googlebot")
+RobotTest(8, doc, good, bad, crawl_delay, request_rate, agent="Googlebot")
# 9. This file is incorrect because "Googlebot" is a substring of
# "Googlebot-Mobile", so test 10 works just like test 9.
@@ -174,12 +220,12 @@
good = []
bad = ['/something.jpg']
-RobotTest(9, doc, good, bad, agent="Googlebot")
+RobotTest(9, doc, good, bad, None, None, agent="Googlebot")
good = []
bad = ['/something.jpg']
-RobotTest(10, doc, good, bad, agent="Googlebot-Mobile")
+RobotTest(10, doc, good, bad, None, None, agent="Googlebot-Mobile")
# 11. Get the order correct.
doc = """
@@ -193,12 +239,12 @@
good = []
bad = ['/something.jpg']
-RobotTest(11, doc, good, bad, agent="Googlebot")
+RobotTest(11, doc, good, bad, None, None, agent="Googlebot")
good = ['/something.jpg']
bad = []
-RobotTest(12, doc, good, bad, agent="Googlebot-Mobile")
+RobotTest(12, doc, good, bad, None, None, agent="Googlebot-Mobile")
# 13. Google also got the order wrong in #8. You need to specify the
@@ -212,7 +258,7 @@
good = ['/folder1/myfile.html']
bad = ['/folder1/anotherfile.html']
-RobotTest(13, doc, good, bad, agent="googlebot")
+RobotTest(13, doc, good, bad, None, None, agent="googlebot")
# 14. For issue #6325 (query string support)
@@ -224,7 +270,7 @@
good = ['/some/path']
bad = ['/some/path?name=value']
-RobotTest(14, doc, good, bad)
+RobotTest(14, doc, good, bad, None, None)
# 15. For issue #4108 (obey first * entry)
doc = """
@@ -238,7 +284,7 @@
good = ['/another/path']
bad = ['/some/path']
-RobotTest(15, doc, good, bad)
+RobotTest(15, doc, good, bad, None, None)
# 16. Empty query (issue #17403). Normalizing the url first.
doc = """
@@ -250,7 +296,7 @@
good = ['/some/path?']
bad = ['/another/path?']
-RobotTest(16, doc, good, bad)
+RobotTest(16, doc, good, bad, None, None)
class RobotHandler(BaseHTTPRequestHandler):
diff --git a/Lib/test/test_sched.py b/Lib/test/test_sched.py
index fe8e785..f86f599 100644
--- a/Lib/test/test_sched.py
+++ b/Lib/test/test_sched.py
@@ -2,7 +2,6 @@
import sched
import time
import unittest
-from test import support
try:
import threading
except ImportError:
diff --git a/Lib/test/test_secrets.py b/Lib/test/test_secrets.py
new file mode 100644
index 0000000..4c65cf0
--- /dev/null
+++ b/Lib/test/test_secrets.py
@@ -0,0 +1,123 @@
+"""Test the secrets module.
+
+As most of the functions in secrets are thin wrappers around functions
+defined elsewhere, we don't need to test them exhaustively.
+"""
+
+
+import secrets
+import unittest
+import string
+
+
+# === Unit tests ===
+
+class Compare_Digest_Tests(unittest.TestCase):
+ """Test secrets.compare_digest function."""
+
+ def test_equal(self):
+ # Test compare_digest functionality with equal (byte/text) strings.
+ for s in ("a", "bcd", "xyz123"):
+ a = s*100
+ b = s*100
+ self.assertTrue(secrets.compare_digest(a, b))
+ self.assertTrue(secrets.compare_digest(a.encode('utf-8'), b.encode('utf-8')))
+
+ def test_unequal(self):
+ # Test compare_digest functionality with unequal (byte/text) strings.
+ self.assertFalse(secrets.compare_digest("abc", "abcd"))
+ self.assertFalse(secrets.compare_digest(b"abc", b"abcd"))
+ for s in ("x", "mn", "a1b2c3"):
+ a = s*100 + "q"
+ b = s*100 + "k"
+ self.assertFalse(secrets.compare_digest(a, b))
+ self.assertFalse(secrets.compare_digest(a.encode('utf-8'), b.encode('utf-8')))
+
+ def test_bad_types(self):
+ # Test that compare_digest raises with mixed types.
+ a = 'abcde'
+ b = a.encode('utf-8')
+ assert isinstance(a, str)
+ assert isinstance(b, bytes)
+ self.assertRaises(TypeError, secrets.compare_digest, a, b)
+ self.assertRaises(TypeError, secrets.compare_digest, b, a)
+
+ def test_bool(self):
+ # Test that compare_digest returns a bool.
+ self.assertIsInstance(secrets.compare_digest("abc", "abc"), bool)
+ self.assertIsInstance(secrets.compare_digest("abc", "xyz"), bool)
+
+
+class Random_Tests(unittest.TestCase):
+ """Test wrappers around SystemRandom methods."""
+
+ def test_randbits(self):
+ # Test randbits.
+ errmsg = "randbits(%d) returned %d"
+ for numbits in (3, 12, 30):
+ for i in range(6):
+ n = secrets.randbits(numbits)
+ self.assertTrue(0 <= n < 2**numbits, errmsg % (numbits, n))
+
+ def test_choice(self):
+ # Test choice.
+ items = [1, 2, 4, 8, 16, 32, 64]
+ for i in range(10):
+ self.assertTrue(secrets.choice(items) in items)
+
+ def test_randbelow(self):
+ # Test randbelow.
+ for i in range(2, 10):
+ self.assertIn(secrets.randbelow(i), range(i))
+ self.assertRaises(ValueError, secrets.randbelow, 0)
+
+
+class Token_Tests(unittest.TestCase):
+ """Test token functions."""
+
+ def test_token_defaults(self):
+ # Test that token_* functions handle default size correctly.
+ for func in (secrets.token_bytes, secrets.token_hex,
+ secrets.token_urlsafe):
+ with self.subTest(func=func):
+ name = func.__name__
+ try:
+ func()
+ except TypeError:
+ self.fail("%s cannot be called with no argument" % name)
+ try:
+ func(None)
+ except TypeError:
+ self.fail("%s cannot be called with None" % name)
+ size = secrets.DEFAULT_ENTROPY
+ self.assertEqual(len(secrets.token_bytes(None)), size)
+ self.assertEqual(len(secrets.token_hex(None)), 2*size)
+
+ def test_token_bytes(self):
+ # Test token_bytes.
+ for n in (1, 8, 17, 100):
+ with self.subTest(n=n):
+ self.assertIsInstance(secrets.token_bytes(n), bytes)
+ self.assertEqual(len(secrets.token_bytes(n)), n)
+
+ def test_token_hex(self):
+ # Test token_hex.
+ for n in (1, 12, 25, 90):
+ with self.subTest(n=n):
+ s = secrets.token_hex(n)
+ self.assertIsInstance(s, str)
+ self.assertEqual(len(s), 2*n)
+ self.assertTrue(all(c in string.hexdigits for c in s))
+
+ def test_token_urlsafe(self):
+ # Test token_urlsafe.
+ legal = string.ascii_letters + string.digits + '-_'
+ for n in (1, 11, 28, 76):
+ with self.subTest(n=n):
+ s = secrets.token_urlsafe(n)
+ self.assertIsInstance(s, str)
+ self.assertTrue(all(c in legal for c in s))
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py
index 1a49edf..49abfb3 100644
--- a/Lib/test/test_set.py
+++ b/Lib/test/test_set.py
@@ -6,10 +6,11 @@
import copy
import pickle
from random import randrange, shuffle
-import sys
import warnings
import collections
import collections.abc
+import itertools
+import string
class PassThru(Exception):
pass
@@ -714,6 +715,28 @@
addhashvalue(hash(frozenset([e for e, m in elemmasks if m&i])))
self.assertEqual(len(hashvalues), 2**n)
+ def letter_range(n):
+ return string.ascii_letters[:n]
+
+ def zf_range(n):
+ # https://en.wikipedia.org/wiki/Set-theoretic_definition_of_natural_numbers
+ nums = [frozenset()]
+ for i in range(n-1):
+ num = frozenset(nums)
+ nums.append(num)
+ return nums[:n]
+
+ def powerset(s):
+ for i in range(len(s)+1):
+ yield from map(frozenset, itertools.combinations(s, i))
+
+ for n in range(18):
+ t = 2 ** n
+ mask = t - 1
+ for nums in (range, letter_range, zf_range):
+ u = len({h & mask for h in map(hash, powerset(nums(n)))})
+ self.assertGreater(4*u, t)
+
class FrozenSetSubclass(frozenset):
pass
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
index 1b80ff0..ab42ed7 100644
--- a/Lib/test/test_signal.py
+++ b/Lib/test/test_signal.py
@@ -22,29 +22,6 @@
_testcapi = None
-class HandlerBCalled(Exception):
- pass
-
-
-def exit_subprocess():
- """Use os._exit(0) to exit the current subprocess.
-
- Otherwise, the test catches the SystemExit and continues executing
- in parallel with the original test, so you wind up with an
- exponential number of tests running concurrently.
- """
- os._exit(0)
-
-
-def ignoring_eintr(__func, *args, **kwargs):
- try:
- return __func(*args, **kwargs)
- except OSError as e:
- if e.errno != errno.EINTR:
- raise
- return None
-
-
class GenericTests(unittest.TestCase):
@unittest.skipIf(threading is None, "test needs threading module")
@@ -63,145 +40,6 @@
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
-class InterProcessSignalTests(unittest.TestCase):
- MAX_DURATION = 20 # Entire test should last at most 20 sec.
-
- def setUp(self):
- self.using_gc = gc.isenabled()
- gc.disable()
-
- def tearDown(self):
- if self.using_gc:
- gc.enable()
-
- def format_frame(self, frame, limit=None):
- return ''.join(traceback.format_stack(frame, limit=limit))
-
- def handlerA(self, signum, frame):
- self.a_called = True
-
- def handlerB(self, signum, frame):
- self.b_called = True
- raise HandlerBCalled(signum, self.format_frame(frame))
-
- def wait(self, child):
- """Wait for child to finish, ignoring EINTR."""
- while True:
- try:
- child.wait()
- return
- except OSError as e:
- if e.errno != errno.EINTR:
- raise
-
- def run_test(self):
- # Install handlers. This function runs in a sub-process, so we
- # don't worry about re-setting the default handlers.
- signal.signal(signal.SIGHUP, self.handlerA)
- signal.signal(signal.SIGUSR1, self.handlerB)
- signal.signal(signal.SIGUSR2, signal.SIG_IGN)
- signal.signal(signal.SIGALRM, signal.default_int_handler)
-
- # Variables the signals will modify:
- self.a_called = False
- self.b_called = False
-
- # Let the sub-processes know who to send signals to.
- pid = os.getpid()
-
- child = ignoring_eintr(subprocess.Popen, ['kill', '-HUP', str(pid)])
- if child:
- self.wait(child)
- if not self.a_called:
- time.sleep(1) # Give the signal time to be delivered.
- self.assertTrue(self.a_called)
- self.assertFalse(self.b_called)
- self.a_called = False
-
- # Make sure the signal isn't delivered while the previous
- # Popen object is being destroyed, because __del__ swallows
- # exceptions.
- del child
- try:
- child = subprocess.Popen(['kill', '-USR1', str(pid)])
- # This wait should be interrupted by the signal's exception.
- self.wait(child)
- time.sleep(1) # Give the signal time to be delivered.
- self.fail('HandlerBCalled exception not raised')
- except HandlerBCalled:
- self.assertTrue(self.b_called)
- self.assertFalse(self.a_called)
-
- child = ignoring_eintr(subprocess.Popen, ['kill', '-USR2', str(pid)])
- if child:
- self.wait(child) # Nothing should happen.
-
- try:
- signal.alarm(1)
- # The race condition in pause doesn't matter in this case,
- # since alarm is going to raise a KeyboardException, which
- # will skip the call.
- signal.pause()
- # But if another signal arrives before the alarm, pause
- # may return early.
- time.sleep(1)
- except KeyboardInterrupt:
- pass
- except:
- self.fail("Some other exception woke us from pause: %s" %
- traceback.format_exc())
- else:
- self.fail("pause returned of its own accord, and the signal"
- " didn't arrive after another second.")
-
- # Issue 3864, unknown if this affects earlier versions of freebsd also
- @unittest.skipIf(sys.platform=='freebsd6',
- 'inter process signals not reliable (do not mix well with threading) '
- 'on freebsd6')
- def test_main(self):
- # This function spawns a child process to insulate the main
- # test-running process from all the signals. It then
- # communicates with that child process over a pipe and
- # re-raises information about any exceptions the child
- # raises. The real work happens in self.run_test().
- os_done_r, os_done_w = os.pipe()
- with closing(os.fdopen(os_done_r, 'rb')) as done_r, \
- closing(os.fdopen(os_done_w, 'wb')) as done_w:
- child = os.fork()
- if child == 0:
- # In the child process; run the test and report results
- # through the pipe.
- try:
- done_r.close()
- # Have to close done_w again here because
- # exit_subprocess() will skip the enclosing with block.
- with closing(done_w):
- try:
- self.run_test()
- except:
- pickle.dump(traceback.format_exc(), done_w)
- else:
- pickle.dump(None, done_w)
- except:
- print('Uh oh, raised from pickle.')
- traceback.print_exc()
- finally:
- exit_subprocess()
-
- done_w.close()
- # Block for up to MAX_DURATION seconds for the test to finish.
- r, w, x = select.select([done_r], [], [], self.MAX_DURATION)
- if done_r in r:
- tb = pickle.load(done_r)
- if tb:
- self.fail(tb)
- else:
- os.kill(child, signal.SIGKILL)
- self.fail('Test deadlocked after %d seconds.' %
- self.MAX_DURATION)
-
-
-@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
class PosixTests(unittest.TestCase):
def trivial_signal_handler(self, *args):
pass
@@ -224,6 +62,15 @@
signal.signal(signal.SIGHUP, hup)
self.assertEqual(signal.getsignal(signal.SIGHUP), hup)
+ # Issue 3864, unknown if this affects earlier versions of freebsd also
+ @unittest.skipIf(sys.platform=='freebsd6',
+ 'inter process signals not reliable (do not mix well with threading) '
+ 'on freebsd6')
+ def test_interprocess_signal(self):
+ dirname = os.path.dirname(__file__)
+ script = os.path.join(dirname, 'signalinterproctester.py')
+ assert_python_ok(script)
+
@unittest.skipUnless(sys.platform == "win32", "Windows specific")
class WindowsSignalTests(unittest.TestCase):
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index da20a3d..f698927 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -75,7 +75,7 @@
def test_init_pathinfo(self):
dir_set = site._init_pathinfo()
for entry in [site.makepath(path)[1] for path in sys.path
- if path and os.path.isdir(path)]:
+ if path and os.path.exists(path)]:
self.assertIn(entry, dir_set,
"%s from sys.path not found in set returned "
"by _init_pathinfo(): %s" % (entry, dir_set))
@@ -243,13 +243,14 @@
self.assertEqual(len(dirs), 2)
wanted = os.path.join('/Library',
sysconfig.get_config_var("PYTHONFRAMEWORK"),
- sys.version[:3],
+ '%d.%d' % sys.version_info[:2],
'site-packages')
self.assertEqual(dirs[1], wanted)
elif os.sep == '/':
# OS X non-framwework builds, Linux, FreeBSD, etc
self.assertEqual(len(dirs), 1)
- wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3],
+ wanted = os.path.join('xoxo', 'lib',
+ 'python%d.%d' % sys.version_info[:2],
'site-packages')
self.assertEqual(dirs[0], wanted)
else:
diff --git a/Lib/test/test_smtpd.py b/Lib/test/test_smtpd.py
index 88dbfdf..3eebe94 100644
--- a/Lib/test/test_smtpd.py
+++ b/Lib/test/test_smtpd.py
@@ -53,10 +53,6 @@
write_line(b'DATA')
self.assertRaises(NotImplementedError, write_line, b'spam\r\n.\r\n')
- def test_decode_data_default_warns(self):
- with self.assertWarns(DeprecationWarning):
- smtpd.SMTPServer((support.HOST, 0), ('b', 0))
-
def test_decode_data_and_enable_SMTPUTF8_raises(self):
self.assertRaises(
ValueError,
@@ -108,10 +104,9 @@
"""))
def test_process_message_with_decode_data_false(self):
- server = smtpd.DebuggingServer((support.HOST, 0), ('b', 0),
- decode_data=False)
+ server = smtpd.DebuggingServer((support.HOST, 0), ('b', 0))
conn, addr = server.accept()
- channel = smtpd.SMTPChannel(server, conn, addr, decode_data=False)
+ channel = smtpd.SMTPChannel(server, conn, addr)
with support.captured_stdout() as s:
self.send_data(channel, b'From: test\n\nh\xc3\xa9llo\xff\n')
stdout = s.getvalue()
@@ -175,13 +170,11 @@
@unittest.skipUnless(support.IPV6_ENABLED, "IPv6 not enabled")
def test_socket_uses_IPv6(self):
- server = smtpd.SMTPServer((support.HOSTv6, 0), (support.HOST, 0),
- decode_data=False)
+ server = smtpd.SMTPServer((support.HOSTv6, 0), (support.HOST, 0))
self.assertEqual(server.socket.family, socket.AF_INET6)
def test_socket_uses_IPv4(self):
- server = smtpd.SMTPServer((support.HOST, 0), (support.HOSTv6, 0),
- decode_data=False)
+ server = smtpd.SMTPServer((support.HOST, 0), (support.HOSTv6, 0))
self.assertEqual(server.socket.family, socket.AF_INET)
@@ -204,18 +197,18 @@
channel.handle_read()
def test_params_rejected(self):
- server = DummyServer((support.HOST, 0), ('b', 0), decode_data=False)
+ server = DummyServer((support.HOST, 0), ('b', 0))
conn, addr = server.accept()
- channel = smtpd.SMTPChannel(server, conn, addr, decode_data=False)
+ channel = smtpd.SMTPChannel(server, conn, addr)
self.write_line(channel, b'EHLO example')
self.write_line(channel, b'MAIL from: <foo@example.com> size=20')
self.write_line(channel, b'RCPT to: <foo@example.com> foo=bar')
self.assertEqual(channel.socket.last, self.error_response)
def test_nothing_accepted(self):
- server = DummyServer((support.HOST, 0), ('b', 0), decode_data=False)
+ server = DummyServer((support.HOST, 0), ('b', 0))
conn, addr = server.accept()
- channel = smtpd.SMTPChannel(server, conn, addr, decode_data=False)
+ channel = smtpd.SMTPChannel(server, conn, addr)
self.write_line(channel, b'EHLO example')
self.write_line(channel, b'MAIL from: <foo@example.com> size=20')
self.write_line(channel, b'RCPT to: <foo@example.com>')
@@ -257,9 +250,9 @@
self.assertEqual(channel.socket.last, b'250 OK\r\n')
def test_with_decode_data_false(self):
- server = DummyServer((support.HOST, 0), ('b', 0), decode_data=False)
+ server = DummyServer((support.HOST, 0), ('b', 0))
conn, addr = server.accept()
- channel = smtpd.SMTPChannel(server, conn, addr, decode_data=False)
+ channel = smtpd.SMTPChannel(server, conn, addr)
self.write_line(channel, b'EHLO example')
for line in [
b'MAIL from: <foo@example.com> size=20 SMTPUTF8',
@@ -765,13 +758,6 @@
with support.check_warnings(('', DeprecationWarning)):
self.channel._SMTPChannel__addr = 'spam'
- def test_decode_data_default_warning(self):
- with self.assertWarns(DeprecationWarning):
- server = DummyServer((support.HOST, 0), ('b', 0))
- conn, addr = self.server.accept()
- with self.assertWarns(DeprecationWarning):
- smtpd.SMTPChannel(server, conn, addr)
-
@unittest.skipUnless(support.IPV6_ENABLED, "IPv6 not enabled")
class SMTPDChannelIPv6Test(SMTPDChannelTest):
def setUp(self):
@@ -845,12 +831,9 @@
smtpd.socket = asyncore.socket = mock_socket
self.old_debugstream = smtpd.DEBUGSTREAM
self.debug = smtpd.DEBUGSTREAM = io.StringIO()
- self.server = DummyServer((support.HOST, 0), ('b', 0),
- decode_data=False)
+ self.server = DummyServer((support.HOST, 0), ('b', 0))
conn, addr = self.server.accept()
- # Set decode_data to False
- self.channel = smtpd.SMTPChannel(self.server, conn, addr,
- decode_data=False)
+ self.channel = smtpd.SMTPChannel(self.server, conn, addr)
def tearDown(self):
asyncore.close_all()
@@ -1015,5 +998,16 @@
self.write_line(b'test\r\n.')
self.assertEqual(self.channel.socket.last[0:3], b'250')
+
+class MiscTestCase(unittest.TestCase):
+ def test__all__(self):
+ blacklist = {
+ "program", "Devnull", "DEBUGSTREAM", "NEWLINE", "COMMASPACE",
+ "DATA_SIZE_DEFAULT", "usage", "Options", "parseargs",
+
+ }
+ support.check__all__(self, smtpd, blacklist=blacklist)
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index c151a50..faacd61 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -13,7 +13,6 @@
import sys
import os
import array
-import platform
import contextlib
from weakref import proxy
import signal
@@ -1161,6 +1160,17 @@
sock.close()
self.assertRaises(OSError, sock.send, b"spam")
+ def testCloseException(self):
+ sock = socket.socket()
+ socket.socket(fileno=sock.fileno()).close()
+ try:
+ sock.close()
+ except OSError as err:
+ # Winsock apparently raises ENOTSOCK
+ self.assertIn(err.errno, (errno.EBADF, errno.ENOTSOCK))
+ else:
+ self.fail("close() should raise EBADF/ENOTSOCK")
+
def testNewAttributes(self):
# testing .family, .type and .protocol
@@ -1207,6 +1217,22 @@
self.assertRaises(ValueError, s.ioctl, -1, None)
s.ioctl(socket.SIO_KEEPALIVE_VALS, (1, 100, 100))
+ @unittest.skipUnless(os.name == "nt", "Windows specific")
+ @unittest.skipUnless(hasattr(socket, 'SIO_LOOPBACK_FAST_PATH'),
+ 'Loopback fast path support required for this test')
+ def test_sio_loopback_fast_path(self):
+ s = socket.socket()
+ self.addCleanup(s.close)
+ try:
+ s.ioctl(socket.SIO_LOOPBACK_FAST_PATH, True)
+ except OSError as exc:
+ WSAEOPNOTSUPP = 10045
+ if exc.winerror == WSAEOPNOTSUPP:
+ self.skipTest("SIO_LOOPBACK_FAST_PATH is defined but "
+ "doesn't implemented in this Windows version")
+ raise
+ self.assertRaises(TypeError, s.ioctl, socket.SIO_LOOPBACK_FAST_PATH, None)
+
def testGetaddrinfo(self):
try:
socket.getaddrinfo('localhost', 80)
@@ -2823,6 +2849,7 @@
nbytes = self.sendmsgToServer([msg])
self.assertEqual(nbytes, len(msg))
+ @unittest.skipIf(sys.platform == "darwin", "see issue #24725")
def testFDPassEmpty(self):
# Try to pass an empty FD array. Can receive either no array
# or an empty array.
diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py
index 0d0f86f..3f4dfa1 100644
--- a/Lib/test/test_socketserver.py
+++ b/Lib/test/test_socketserver.py
@@ -3,12 +3,11 @@
"""
import contextlib
+import io
import os
import select
import signal
import socket
-import select
-import errno
import tempfile
import unittest
import socketserver
@@ -46,7 +45,7 @@
else:
raise RuntimeError("timed out on %r" % (sock,))
-if HAVE_UNIX_SOCKETS:
+if HAVE_UNIX_SOCKETS and HAVE_FORKING:
class ForkingUnixStreamServer(socketserver.ForkingMixIn,
socketserver.UnixStreamServer):
pass
@@ -58,6 +57,7 @@
@contextlib.contextmanager
def simple_subprocess(testcase):
+ """Tests that a custom child process is not waited on (Issue 1540386)"""
pid = os.fork()
if pid == 0:
# Don't raise an exception; it would be caught by the test harness.
@@ -103,7 +103,6 @@
class MyServer(svrcls):
def handle_error(self, request, client_address):
self.close_request(request)
- self.server_close()
raise
class MyHandler(hdlrbase):
@@ -279,6 +278,182 @@
socketserver.TCPServer((HOST, -1),
socketserver.StreamRequestHandler)
+ def test_context_manager(self):
+ with socketserver.TCPServer((HOST, 0),
+ socketserver.StreamRequestHandler) as server:
+ pass
+ self.assertEqual(-1, server.socket.fileno())
+
+
+class ErrorHandlerTest(unittest.TestCase):
+ """Test that the servers pass normal exceptions from the handler to
+ handle_error(), and that exiting exceptions like SystemExit and
+ KeyboardInterrupt are not passed."""
+
+ def tearDown(self):
+ test.support.unlink(test.support.TESTFN)
+
+ def test_sync_handled(self):
+ BaseErrorTestServer(ValueError)
+ self.check_result(handled=True)
+
+ def test_sync_not_handled(self):
+ with self.assertRaises(SystemExit):
+ BaseErrorTestServer(SystemExit)
+ self.check_result(handled=False)
+
+ @unittest.skipUnless(threading, 'Threading required for this test.')
+ def test_threading_handled(self):
+ ThreadingErrorTestServer(ValueError)
+ self.check_result(handled=True)
+
+ @unittest.skipUnless(threading, 'Threading required for this test.')
+ def test_threading_not_handled(self):
+ ThreadingErrorTestServer(SystemExit)
+ self.check_result(handled=False)
+
+ @requires_forking
+ def test_forking_handled(self):
+ ForkingErrorTestServer(ValueError)
+ self.check_result(handled=True)
+
+ @requires_forking
+ def test_forking_not_handled(self):
+ ForkingErrorTestServer(SystemExit)
+ self.check_result(handled=False)
+
+ def check_result(self, handled):
+ with open(test.support.TESTFN) as log:
+ expected = 'Handler called\n' + 'Error handled\n' * handled
+ self.assertEqual(log.read(), expected)
+
+
+class BaseErrorTestServer(socketserver.TCPServer):
+ def __init__(self, exception):
+ self.exception = exception
+ super().__init__((HOST, 0), BadHandler)
+ with socket.create_connection(self.server_address):
+ pass
+ try:
+ self.handle_request()
+ finally:
+ self.server_close()
+ self.wait_done()
+
+ def handle_error(self, request, client_address):
+ with open(test.support.TESTFN, 'a') as log:
+ log.write('Error handled\n')
+
+ def wait_done(self):
+ pass
+
+
+class BadHandler(socketserver.BaseRequestHandler):
+ def handle(self):
+ with open(test.support.TESTFN, 'a') as log:
+ log.write('Handler called\n')
+ raise self.server.exception('Test error')
+
+
+class ThreadingErrorTestServer(socketserver.ThreadingMixIn,
+ BaseErrorTestServer):
+ def __init__(self, *pos, **kw):
+ self.done = threading.Event()
+ super().__init__(*pos, **kw)
+
+ def shutdown_request(self, *pos, **kw):
+ super().shutdown_request(*pos, **kw)
+ self.done.set()
+
+ def wait_done(self):
+ self.done.wait()
+
+
+if HAVE_FORKING:
+ class ForkingErrorTestServer(socketserver.ForkingMixIn, BaseErrorTestServer):
+ def wait_done(self):
+ [child] = self.active_children
+ os.waitpid(child, 0)
+ self.active_children.clear()
+
+
+class SocketWriterTest(unittest.TestCase):
+ def test_basics(self):
+ class Handler(socketserver.StreamRequestHandler):
+ def handle(self):
+ self.server.wfile = self.wfile
+ self.server.wfile_fileno = self.wfile.fileno()
+ self.server.request_fileno = self.request.fileno()
+
+ server = socketserver.TCPServer((HOST, 0), Handler)
+ self.addCleanup(server.server_close)
+ s = socket.socket(
+ server.address_family, socket.SOCK_STREAM, socket.IPPROTO_TCP)
+ with s:
+ s.connect(server.server_address)
+ server.handle_request()
+ self.assertIsInstance(server.wfile, io.BufferedIOBase)
+ self.assertEqual(server.wfile_fileno, server.request_fileno)
+
+ @unittest.skipUnless(threading, 'Threading required for this test.')
+ def test_write(self):
+ # Test that wfile.write() sends data immediately, and that it does
+ # not truncate sends when interrupted by a Unix signal
+ pthread_kill = test.support.get_attribute(signal, 'pthread_kill')
+
+ class Handler(socketserver.StreamRequestHandler):
+ def handle(self):
+ self.server.sent1 = self.wfile.write(b'write data\n')
+ # Should be sent immediately, without requiring flush()
+ self.server.received = self.rfile.readline()
+ big_chunk = bytes(test.support.SOCK_MAX_SIZE)
+ self.server.sent2 = self.wfile.write(big_chunk)
+
+ server = socketserver.TCPServer((HOST, 0), Handler)
+ self.addCleanup(server.server_close)
+ interrupted = threading.Event()
+
+ def signal_handler(signum, frame):
+ interrupted.set()
+
+ original = signal.signal(signal.SIGUSR1, signal_handler)
+ self.addCleanup(signal.signal, signal.SIGUSR1, original)
+ response1 = None
+ received2 = None
+ main_thread = threading.get_ident()
+
+ def run_client():
+ s = socket.socket(server.address_family, socket.SOCK_STREAM,
+ socket.IPPROTO_TCP)
+ with s, s.makefile('rb') as reader:
+ s.connect(server.server_address)
+ nonlocal response1
+ response1 = reader.readline()
+ s.sendall(b'client response\n')
+
+ reader.read(100)
+ # The main thread should now be blocking in a send() syscall.
+ # But in theory, it could get interrupted by other signals,
+ # and then retried. So keep sending the signal in a loop, in
+ # case an earlier signal happens to be delivered at an
+ # inconvenient moment.
+ while True:
+ pthread_kill(main_thread, signal.SIGUSR1)
+ if interrupted.wait(timeout=float(1)):
+ break
+ nonlocal received2
+ received2 = len(reader.read())
+
+ background = threading.Thread(target=run_client)
+ background.start()
+ server.handle_request()
+ background.join()
+ self.assertEqual(server.sent1, len(response1))
+ self.assertEqual(response1, b'write data\n')
+ self.assertEqual(server.received, b'client response\n')
+ self.assertEqual(server.sent2, test.support.SOCK_MAX_SIZE)
+ self.assertEqual(received2, test.support.SOCK_MAX_SIZE - 100)
+
class MiscTestCase(unittest.TestCase):
diff --git a/Lib/test/test_sort.py b/Lib/test/test_sort.py
index a5d0ebf..98ccab5 100644
--- a/Lib/test/test_sort.py
+++ b/Lib/test/test_sort.py
@@ -1,6 +1,5 @@
from test import support
import random
-import sys
import unittest
from functools import cmp_to_key
diff --git a/Lib/test/test_spwd.py b/Lib/test/test_spwd.py
index bea7ab1..e893f3a 100644
--- a/Lib/test/test_spwd.py
+++ b/Lib/test/test_spwd.py
@@ -56,5 +56,20 @@
self.assertRaises(TypeError, spwd.getspnam, bytes_name)
+@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() != 0,
+ 'non-root user required')
+class TestSpwdNonRoot(unittest.TestCase):
+
+ def test_getspnam_exception(self):
+ name = 'bin'
+ try:
+ with self.assertRaises(PermissionError) as cm:
+ spwd.getspnam(name)
+ except KeyError as exc:
+ self.skipTest("spwd entry %r doesn't exist: %s" % (name, exc))
+ else:
+ self.assertEqual(str(cm.exception), '[Errno 13] Permission denied')
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index d2fc36d..7824e9c 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -21,6 +21,13 @@
ssl = support.import_module("ssl")
+try:
+ import threading
+except ImportError:
+ _have_threads = False
+else:
+ _have_threads = True
+
PROTOCOLS = sorted(ssl._PROTOCOL_NAMES)
HOST = support.HOST
@@ -53,10 +60,10 @@
# Two keys and certs signed by the same CA (for SNI tests)
SIGNED_CERTFILE = data_file("keycert3.pem")
SIGNED_CERTFILE2 = data_file("keycert4.pem")
-SIGNING_CA = data_file("pycacert.pem")
+# Same certificate as pycacert.pem, but without extra text in file
+SIGNING_CA = data_file("capath", "ceff1710.0")
REMOTE_HOST = "self-signed.pythontest.net"
-REMOTE_ROOT_CERT = data_file("selfsigned_pythontestdotnet.pem")
EMPTYCERT = data_file("nullcert.pem")
BADCERT = data_file("badcert.pem")
@@ -328,7 +335,7 @@
wr = weakref.ref(ss)
with support.check_warnings(("", ResourceWarning)):
del ss
- self.assertEqual(wr(), None)
+ self.assertEqual(wr(), None)
def test_wrapped_unconnected(self):
# Methods on an unconnected SSLSocket propagate the original
@@ -783,6 +790,22 @@
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")
+ def test_connect_ex_error(self):
+ server = socket.socket(socket.AF_INET)
+ self.addCleanup(server.close)
+ port = support.bind_port(server) # Reserve port but don't listen
+ s = ssl.wrap_socket(socket.socket(socket.AF_INET),
+ cert_reqs=ssl.CERT_REQUIRED)
+ self.addCleanup(s.close)
+ rc = s.connect_ex((HOST, port))
+ # Issue #19919: Windows machines or VMs hosted on Windows
+ # machines sometimes return EWOULDBLOCK.
+ errors = (
+ errno.ECONNREFUSED, errno.EHOSTUNREACH, errno.ETIMEDOUT,
+ errno.EWOULDBLOCK,
+ )
+ self.assertIn(rc, errors)
+
class ContextTests(unittest.TestCase):
@@ -1369,140 +1392,103 @@
self.assertRaises(TypeError, bio.write, 1)
-class NetworkedTests(unittest.TestCase):
+@unittest.skipUnless(_have_threads, "Needs threading module")
+class SimpleBackgroundTests(unittest.TestCase):
+
+ """Tests that connect to a simple server running in the background"""
+
+ def setUp(self):
+ server = ThreadedEchoServer(SIGNED_CERTFILE)
+ self.server_addr = (HOST, server.port)
+ server.__enter__()
+ self.addCleanup(server.__exit__, None, None, None)
def test_connect(self):
- with support.transient_internet(REMOTE_HOST):
- s = ssl.wrap_socket(socket.socket(socket.AF_INET),
- cert_reqs=ssl.CERT_NONE)
- try:
- s.connect((REMOTE_HOST, 443))
- self.assertEqual({}, s.getpeercert())
- finally:
- s.close()
+ with ssl.wrap_socket(socket.socket(socket.AF_INET),
+ cert_reqs=ssl.CERT_NONE) as s:
+ s.connect(self.server_addr)
+ self.assertEqual({}, s.getpeercert())
- # this should fail because we have no verification certs
- s = ssl.wrap_socket(socket.socket(socket.AF_INET),
- cert_reqs=ssl.CERT_REQUIRED)
- self.assertRaisesRegex(ssl.SSLError, "certificate verify failed",
- s.connect, (REMOTE_HOST, 443))
- s.close()
+ # this should succeed because we specify the root cert
+ with ssl.wrap_socket(socket.socket(socket.AF_INET),
+ cert_reqs=ssl.CERT_REQUIRED,
+ ca_certs=SIGNING_CA) as s:
+ s.connect(self.server_addr)
+ self.assertTrue(s.getpeercert())
- # this should succeed because we specify the root cert
- s = ssl.wrap_socket(socket.socket(socket.AF_INET),
- cert_reqs=ssl.CERT_REQUIRED,
- ca_certs=REMOTE_ROOT_CERT)
- try:
- s.connect((REMOTE_HOST, 443))
- self.assertTrue(s.getpeercert())
- finally:
- s.close()
+ def test_connect_fail(self):
+ # This should fail because we have no verification certs. Connection
+ # failure crashes ThreadedEchoServer, so run this in an independent
+ # test method.
+ s = ssl.wrap_socket(socket.socket(socket.AF_INET),
+ cert_reqs=ssl.CERT_REQUIRED)
+ self.addCleanup(s.close)
+ self.assertRaisesRegex(ssl.SSLError, "certificate verify failed",
+ s.connect, self.server_addr)
def test_connect_ex(self):
# Issue #11326: check connect_ex() implementation
- with support.transient_internet(REMOTE_HOST):
- s = ssl.wrap_socket(socket.socket(socket.AF_INET),
- cert_reqs=ssl.CERT_REQUIRED,
- ca_certs=REMOTE_ROOT_CERT)
- try:
- self.assertEqual(0, s.connect_ex((REMOTE_HOST, 443)))
- self.assertTrue(s.getpeercert())
- finally:
- s.close()
+ s = ssl.wrap_socket(socket.socket(socket.AF_INET),
+ cert_reqs=ssl.CERT_REQUIRED,
+ ca_certs=SIGNING_CA)
+ self.addCleanup(s.close)
+ self.assertEqual(0, s.connect_ex(self.server_addr))
+ self.assertTrue(s.getpeercert())
def test_non_blocking_connect_ex(self):
# Issue #11326: non-blocking connect_ex() should allow handshake
# to proceed after the socket gets ready.
- with support.transient_internet(REMOTE_HOST):
- s = ssl.wrap_socket(socket.socket(socket.AF_INET),
- cert_reqs=ssl.CERT_REQUIRED,
- ca_certs=REMOTE_ROOT_CERT,
- do_handshake_on_connect=False)
+ s = ssl.wrap_socket(socket.socket(socket.AF_INET),
+ cert_reqs=ssl.CERT_REQUIRED,
+ ca_certs=SIGNING_CA,
+ do_handshake_on_connect=False)
+ self.addCleanup(s.close)
+ s.setblocking(False)
+ rc = s.connect_ex(self.server_addr)
+ # EWOULDBLOCK under Windows, EINPROGRESS elsewhere
+ self.assertIn(rc, (0, errno.EINPROGRESS, errno.EWOULDBLOCK))
+ # Wait for connect to finish
+ select.select([], [s], [], 5.0)
+ # Non-blocking handshake
+ while True:
try:
- s.setblocking(False)
- rc = s.connect_ex((REMOTE_HOST, 443))
- # EWOULDBLOCK under Windows, EINPROGRESS elsewhere
- self.assertIn(rc, (0, errno.EINPROGRESS, errno.EWOULDBLOCK))
- # Wait for connect to finish
+ s.do_handshake()
+ break
+ except ssl.SSLWantReadError:
+ select.select([s], [], [], 5.0)
+ except ssl.SSLWantWriteError:
select.select([], [s], [], 5.0)
- # Non-blocking handshake
- while True:
- try:
- s.do_handshake()
- break
- except ssl.SSLWantReadError:
- select.select([s], [], [], 5.0)
- except ssl.SSLWantWriteError:
- select.select([], [s], [], 5.0)
- # SSL established
- self.assertTrue(s.getpeercert())
- finally:
- s.close()
-
- def test_timeout_connect_ex(self):
- # Issue #12065: on a timeout, connect_ex() should return the original
- # errno (mimicking the behaviour of non-SSL sockets).
- with support.transient_internet(REMOTE_HOST):
- s = ssl.wrap_socket(socket.socket(socket.AF_INET),
- cert_reqs=ssl.CERT_REQUIRED,
- ca_certs=REMOTE_ROOT_CERT,
- do_handshake_on_connect=False)
- try:
- s.settimeout(0.0000001)
- rc = s.connect_ex((REMOTE_HOST, 443))
- if rc == 0:
- self.skipTest("REMOTE_HOST responded too quickly")
- self.assertIn(rc, (errno.EAGAIN, errno.EWOULDBLOCK))
- finally:
- s.close()
-
- def test_connect_ex_error(self):
- with support.transient_internet(REMOTE_HOST):
- s = ssl.wrap_socket(socket.socket(socket.AF_INET),
- cert_reqs=ssl.CERT_REQUIRED,
- ca_certs=REMOTE_ROOT_CERT)
- try:
- rc = s.connect_ex((REMOTE_HOST, 444))
- # Issue #19919: Windows machines or VMs hosted on Windows
- # machines sometimes return EWOULDBLOCK.
- errors = (
- errno.ECONNREFUSED, errno.EHOSTUNREACH, errno.ETIMEDOUT,
- errno.EWOULDBLOCK,
- )
- self.assertIn(rc, errors)
- finally:
- s.close()
+ # SSL established
+ self.assertTrue(s.getpeercert())
def test_connect_with_context(self):
- with support.transient_internet(REMOTE_HOST):
- # Same as test_connect, but with a separately created context
- ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
- s = ctx.wrap_socket(socket.socket(socket.AF_INET))
- s.connect((REMOTE_HOST, 443))
- try:
- self.assertEqual({}, s.getpeercert())
- finally:
- s.close()
- # Same with a server hostname
- s = ctx.wrap_socket(socket.socket(socket.AF_INET),
- server_hostname=REMOTE_HOST)
- s.connect((REMOTE_HOST, 443))
- s.close()
- # This should fail because we have no verification certs
- ctx.verify_mode = ssl.CERT_REQUIRED
- s = ctx.wrap_socket(socket.socket(socket.AF_INET))
- self.assertRaisesRegex(ssl.SSLError, "certificate verify failed",
- s.connect, (REMOTE_HOST, 443))
- s.close()
- # This should succeed because we specify the root cert
- ctx.load_verify_locations(REMOTE_ROOT_CERT)
- s = ctx.wrap_socket(socket.socket(socket.AF_INET))
- s.connect((REMOTE_HOST, 443))
- try:
- cert = s.getpeercert()
- self.assertTrue(cert)
- finally:
- s.close()
+ # Same as test_connect, but with a separately created context
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ with ctx.wrap_socket(socket.socket(socket.AF_INET)) as s:
+ s.connect(self.server_addr)
+ self.assertEqual({}, s.getpeercert())
+ # Same with a server hostname
+ with ctx.wrap_socket(socket.socket(socket.AF_INET),
+ server_hostname="dummy") as s:
+ s.connect(self.server_addr)
+ ctx.verify_mode = ssl.CERT_REQUIRED
+ # This should succeed because we specify the root cert
+ ctx.load_verify_locations(SIGNING_CA)
+ with ctx.wrap_socket(socket.socket(socket.AF_INET)) as s:
+ s.connect(self.server_addr)
+ cert = s.getpeercert()
+ self.assertTrue(cert)
+
+ def test_connect_with_context_fail(self):
+ # This should fail because we have no verification certs. Connection
+ # failure crashes ThreadedEchoServer, so run this in an independent
+ # test method.
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ ctx.verify_mode = ssl.CERT_REQUIRED
+ s = ctx.wrap_socket(socket.socket(socket.AF_INET))
+ self.addCleanup(s.close)
+ self.assertRaisesRegex(ssl.SSLError, "certificate verify failed",
+ s.connect, self.server_addr)
def test_connect_capath(self):
# Verify server certificates using the `capath` argument
@@ -1510,198 +1496,130 @@
# OpenSSL 0.9.8n and 1.0.0, as a result the capath directory must
# contain both versions of each certificate (same content, different
# filename) for this test to be portable across OpenSSL releases.
- with support.transient_internet(REMOTE_HOST):
- ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
- ctx.verify_mode = ssl.CERT_REQUIRED
- ctx.load_verify_locations(capath=CAPATH)
- s = ctx.wrap_socket(socket.socket(socket.AF_INET))
- s.connect((REMOTE_HOST, 443))
- try:
- cert = s.getpeercert()
- self.assertTrue(cert)
- finally:
- s.close()
- # Same with a bytes `capath` argument
- ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
- ctx.verify_mode = ssl.CERT_REQUIRED
- ctx.load_verify_locations(capath=BYTES_CAPATH)
- s = ctx.wrap_socket(socket.socket(socket.AF_INET))
- s.connect((REMOTE_HOST, 443))
- try:
- cert = s.getpeercert()
- self.assertTrue(cert)
- finally:
- s.close()
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ ctx.verify_mode = ssl.CERT_REQUIRED
+ ctx.load_verify_locations(capath=CAPATH)
+ with ctx.wrap_socket(socket.socket(socket.AF_INET)) as s:
+ s.connect(self.server_addr)
+ cert = s.getpeercert()
+ self.assertTrue(cert)
+ # Same with a bytes `capath` argument
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ ctx.verify_mode = ssl.CERT_REQUIRED
+ ctx.load_verify_locations(capath=BYTES_CAPATH)
+ with ctx.wrap_socket(socket.socket(socket.AF_INET)) as s:
+ s.connect(self.server_addr)
+ cert = s.getpeercert()
+ self.assertTrue(cert)
def test_connect_cadata(self):
- with open(REMOTE_ROOT_CERT) as f:
+ with open(SIGNING_CA) as f:
pem = f.read()
der = ssl.PEM_cert_to_DER_cert(pem)
- with support.transient_internet(REMOTE_HOST):
- ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
- ctx.verify_mode = ssl.CERT_REQUIRED
- ctx.load_verify_locations(cadata=pem)
- with ctx.wrap_socket(socket.socket(socket.AF_INET)) as s:
- s.connect((REMOTE_HOST, 443))
- cert = s.getpeercert()
- self.assertTrue(cert)
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ ctx.verify_mode = ssl.CERT_REQUIRED
+ ctx.load_verify_locations(cadata=pem)
+ with ctx.wrap_socket(socket.socket(socket.AF_INET)) as s:
+ s.connect(self.server_addr)
+ cert = s.getpeercert()
+ self.assertTrue(cert)
- # same with DER
- ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
- ctx.verify_mode = ssl.CERT_REQUIRED
- ctx.load_verify_locations(cadata=der)
- with ctx.wrap_socket(socket.socket(socket.AF_INET)) as s:
- s.connect((REMOTE_HOST, 443))
- cert = s.getpeercert()
- self.assertTrue(cert)
+ # same with DER
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ ctx.verify_mode = ssl.CERT_REQUIRED
+ ctx.load_verify_locations(cadata=der)
+ with ctx.wrap_socket(socket.socket(socket.AF_INET)) as s:
+ s.connect(self.server_addr)
+ cert = s.getpeercert()
+ self.assertTrue(cert)
@unittest.skipIf(os.name == "nt", "Can't use a socket as a file under Windows")
def test_makefile_close(self):
# Issue #5238: creating a file-like object with makefile() shouldn't
# delay closing the underlying "real socket" (here tested with its
# file descriptor, hence skipping the test under Windows).
- with support.transient_internet(REMOTE_HOST):
- ss = ssl.wrap_socket(socket.socket(socket.AF_INET))
- ss.connect((REMOTE_HOST, 443))
- fd = ss.fileno()
- f = ss.makefile()
- f.close()
- # The fd is still open
+ ss = ssl.wrap_socket(socket.socket(socket.AF_INET))
+ ss.connect(self.server_addr)
+ fd = ss.fileno()
+ f = ss.makefile()
+ f.close()
+ # The fd is still open
+ os.read(fd, 0)
+ # Closing the SSL socket should close the fd too
+ ss.close()
+ gc.collect()
+ with self.assertRaises(OSError) as e:
os.read(fd, 0)
- # Closing the SSL socket should close the fd too
- ss.close()
- gc.collect()
- with self.assertRaises(OSError) as e:
- os.read(fd, 0)
- self.assertEqual(e.exception.errno, errno.EBADF)
+ self.assertEqual(e.exception.errno, errno.EBADF)
def test_non_blocking_handshake(self):
- with support.transient_internet(REMOTE_HOST):
- s = socket.socket(socket.AF_INET)
- s.connect((REMOTE_HOST, 443))
- s.setblocking(False)
- s = ssl.wrap_socket(s,
- cert_reqs=ssl.CERT_NONE,
- do_handshake_on_connect=False)
- count = 0
- while True:
- try:
- count += 1
- s.do_handshake()
- break
- except ssl.SSLWantReadError:
- select.select([s], [], [])
- except ssl.SSLWantWriteError:
- select.select([], [s], [])
- s.close()
- if support.verbose:
- sys.stdout.write("\nNeeded %d calls to do_handshake() to establish session.\n" % count)
+ s = socket.socket(socket.AF_INET)
+ s.connect(self.server_addr)
+ s.setblocking(False)
+ s = ssl.wrap_socket(s,
+ cert_reqs=ssl.CERT_NONE,
+ do_handshake_on_connect=False)
+ self.addCleanup(s.close)
+ count = 0
+ while True:
+ try:
+ count += 1
+ s.do_handshake()
+ break
+ except ssl.SSLWantReadError:
+ select.select([s], [], [])
+ except ssl.SSLWantWriteError:
+ select.select([], [s], [])
+ if support.verbose:
+ sys.stdout.write("\nNeeded %d calls to do_handshake() to establish session.\n" % count)
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))
- if not pem:
- self.fail("No server certificate on %s:%s!" % (host, port))
+ _test_get_server_certificate(self, *self.server_addr, cert=SIGNING_CA)
- try:
- pem = ssl.get_server_certificate((host, port),
- ca_certs=CERTFILE)
- except ssl.SSLError as x:
- #should fail
- if support.verbose:
- sys.stdout.write("%s\n" % x)
- else:
- self.fail("Got server certificate %s for %s:%s!" % (pem, host, port))
-
- pem = ssl.get_server_certificate((host, port),
- ca_certs=cert)
- if not pem:
- self.fail("No server certificate on %s:%s!" % (host, port))
- if support.verbose:
- sys.stdout.write("\nVerified certificate for %s:%s is\n%s\n" % (host, port ,pem))
-
- _test_get_server_certificate(REMOTE_HOST, 443, REMOTE_ROOT_CERT)
- if support.IPV6_ENABLED:
- _test_get_server_certificate('ipv6.google.com', 443)
+ def test_get_server_certificate_fail(self):
+ # Connection failure crashes ThreadedEchoServer, so run this in an
+ # independent test method
+ _test_get_server_certificate_fail(self, *self.server_addr)
def test_ciphers(self):
- remote = (REMOTE_HOST, 443)
- with support.transient_internet(remote[0]):
- with ssl.wrap_socket(socket.socket(socket.AF_INET),
- cert_reqs=ssl.CERT_NONE, ciphers="ALL") as s:
- s.connect(remote)
- with ssl.wrap_socket(socket.socket(socket.AF_INET),
- cert_reqs=ssl.CERT_NONE, ciphers="DEFAULT") as s:
- s.connect(remote)
- # Error checking can happen at instantiation or when connecting
- with self.assertRaisesRegex(ssl.SSLError, "No cipher can be selected"):
- with socket.socket(socket.AF_INET) as sock:
- s = ssl.wrap_socket(sock,
- cert_reqs=ssl.CERT_NONE, ciphers="^$:,;?*'dorothyx")
- s.connect(remote)
-
- def test_algorithms(self):
- # Issue #8484: all algorithms should be available when verifying a
- # certificate.
- # SHA256 was added in OpenSSL 0.9.8
- if ssl.OPENSSL_VERSION_INFO < (0, 9, 8, 0, 15):
- self.skipTest("SHA256 not available on %r" % ssl.OPENSSL_VERSION)
- # sha256.tbs-internet.com needs SNI to use the correct certificate
- if not ssl.HAS_SNI:
- self.skipTest("SNI needed for this test")
- # https://sha2.hboeck.de/ was used until 2011-01-08 (no route to host)
- remote = ("sha256.tbs-internet.com", 443)
- sha256_cert = os.path.join(os.path.dirname(__file__), "sha256.pem")
- with support.transient_internet("sha256.tbs-internet.com"):
- ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
- ctx.verify_mode = ssl.CERT_REQUIRED
- ctx.load_verify_locations(sha256_cert)
- s = ctx.wrap_socket(socket.socket(socket.AF_INET),
- server_hostname="sha256.tbs-internet.com")
- try:
- s.connect(remote)
- if support.verbose:
- sys.stdout.write("\nCipher with %r is %r\n" %
- (remote, s.cipher()))
- sys.stdout.write("Certificate is:\n%s\n" %
- pprint.pformat(s.getpeercert()))
- finally:
- s.close()
+ with ssl.wrap_socket(socket.socket(socket.AF_INET),
+ cert_reqs=ssl.CERT_NONE, ciphers="ALL") as s:
+ s.connect(self.server_addr)
+ with ssl.wrap_socket(socket.socket(socket.AF_INET),
+ cert_reqs=ssl.CERT_NONE, ciphers="DEFAULT") as s:
+ s.connect(self.server_addr)
+ # Error checking can happen at instantiation or when connecting
+ with self.assertRaisesRegex(ssl.SSLError, "No cipher can be selected"):
+ with socket.socket(socket.AF_INET) as sock:
+ s = ssl.wrap_socket(sock,
+ cert_reqs=ssl.CERT_NONE, ciphers="^$:,;?*'dorothyx")
+ s.connect(self.server_addr)
def test_get_ca_certs_capath(self):
# capath certs are loaded on request
- with support.transient_internet(REMOTE_HOST):
- ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
- ctx.verify_mode = ssl.CERT_REQUIRED
- ctx.load_verify_locations(capath=CAPATH)
- self.assertEqual(ctx.get_ca_certs(), [])
- s = ctx.wrap_socket(socket.socket(socket.AF_INET))
- s.connect((REMOTE_HOST, 443))
- try:
- cert = s.getpeercert()
- self.assertTrue(cert)
- finally:
- s.close()
- self.assertEqual(len(ctx.get_ca_certs()), 1)
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ ctx.verify_mode = ssl.CERT_REQUIRED
+ ctx.load_verify_locations(capath=CAPATH)
+ self.assertEqual(ctx.get_ca_certs(), [])
+ with ctx.wrap_socket(socket.socket(socket.AF_INET)) as s:
+ s.connect(self.server_addr)
+ cert = s.getpeercert()
+ self.assertTrue(cert)
+ self.assertEqual(len(ctx.get_ca_certs()), 1)
@needs_sni
def test_context_setget(self):
# Check that the context of a connected socket can be replaced.
- with support.transient_internet(REMOTE_HOST):
- ctx1 = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
- ctx2 = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
- s = socket.socket(socket.AF_INET)
- with ctx1.wrap_socket(s) as ss:
- ss.connect((REMOTE_HOST, 443))
- self.assertIs(ss.context, ctx1)
- self.assertIs(ss._sslobj.context, ctx1)
- ss.context = ctx2
- self.assertIs(ss.context, ctx2)
- self.assertIs(ss._sslobj.context, ctx2)
-
-
-class NetworkedBIOTests(unittest.TestCase):
+ ctx1 = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ ctx2 = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ s = socket.socket(socket.AF_INET)
+ with ctx1.wrap_socket(s) as ss:
+ ss.connect(self.server_addr)
+ self.assertIs(ss.context, ctx1)
+ self.assertIs(ss._sslobj.context, ctx1)
+ ss.context = ctx2
+ self.assertIs(ss.context, ctx2)
+ self.assertIs(ss._sslobj.context, ctx2)
def ssl_io_loop(self, sock, incoming, outgoing, func, *args, **kwargs):
# A simple IO loop. Call func(*args) depending on the error we get
@@ -1737,64 +1655,128 @@
% (count, func.__name__))
return ret
- def test_handshake(self):
- with support.transient_internet(REMOTE_HOST):
- sock = socket.socket(socket.AF_INET)
- sock.connect((REMOTE_HOST, 443))
- incoming = ssl.MemoryBIO()
- outgoing = ssl.MemoryBIO()
- ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
- ctx.verify_mode = ssl.CERT_REQUIRED
- ctx.load_verify_locations(REMOTE_ROOT_CERT)
- ctx.check_hostname = True
- sslobj = ctx.wrap_bio(incoming, outgoing, False, REMOTE_HOST)
- self.assertIs(sslobj._sslobj.owner, sslobj)
- self.assertIsNone(sslobj.cipher())
- self.assertIsNone(sslobj.shared_ciphers())
- self.assertRaises(ValueError, sslobj.getpeercert)
- if 'tls-unique' in ssl.CHANNEL_BINDING_TYPES:
- self.assertIsNone(sslobj.get_channel_binding('tls-unique'))
- self.ssl_io_loop(sock, incoming, outgoing, sslobj.do_handshake)
- self.assertTrue(sslobj.cipher())
- self.assertIsNone(sslobj.shared_ciphers())
- self.assertTrue(sslobj.getpeercert())
- if 'tls-unique' in ssl.CHANNEL_BINDING_TYPES:
- self.assertTrue(sslobj.get_channel_binding('tls-unique'))
- try:
- self.ssl_io_loop(sock, incoming, outgoing, sslobj.unwrap)
- except ssl.SSLSyscallError:
- # self-signed.pythontest.net probably shuts down the TCP
- # connection without sending a secure shutdown message, and
- # this is reported as SSL_ERROR_SYSCALL
- pass
- self.assertRaises(ssl.SSLError, sslobj.write, b'foo')
- sock.close()
-
- def test_read_write_data(self):
- with support.transient_internet(REMOTE_HOST):
- sock = socket.socket(socket.AF_INET)
- sock.connect((REMOTE_HOST, 443))
- incoming = ssl.MemoryBIO()
- outgoing = ssl.MemoryBIO()
- ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
- ctx.verify_mode = ssl.CERT_NONE
- sslobj = ctx.wrap_bio(incoming, outgoing, False)
- self.ssl_io_loop(sock, incoming, outgoing, sslobj.do_handshake)
- req = b'GET / HTTP/1.0\r\n\r\n'
- self.ssl_io_loop(sock, incoming, outgoing, sslobj.write, req)
- buf = self.ssl_io_loop(sock, incoming, outgoing, sslobj.read, 1024)
- self.assertEqual(buf[:5], b'HTTP/')
+ def test_bio_handshake(self):
+ sock = socket.socket(socket.AF_INET)
+ self.addCleanup(sock.close)
+ sock.connect(self.server_addr)
+ incoming = ssl.MemoryBIO()
+ outgoing = ssl.MemoryBIO()
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ ctx.verify_mode = ssl.CERT_REQUIRED
+ ctx.load_verify_locations(SIGNING_CA)
+ ctx.check_hostname = True
+ sslobj = ctx.wrap_bio(incoming, outgoing, False, 'localhost')
+ self.assertIs(sslobj._sslobj.owner, sslobj)
+ self.assertIsNone(sslobj.cipher())
+ self.assertIsNone(sslobj.shared_ciphers())
+ self.assertRaises(ValueError, sslobj.getpeercert)
+ if 'tls-unique' in ssl.CHANNEL_BINDING_TYPES:
+ self.assertIsNone(sslobj.get_channel_binding('tls-unique'))
+ self.ssl_io_loop(sock, incoming, outgoing, sslobj.do_handshake)
+ self.assertTrue(sslobj.cipher())
+ self.assertIsNone(sslobj.shared_ciphers())
+ self.assertTrue(sslobj.getpeercert())
+ if 'tls-unique' in ssl.CHANNEL_BINDING_TYPES:
+ self.assertTrue(sslobj.get_channel_binding('tls-unique'))
+ try:
self.ssl_io_loop(sock, incoming, outgoing, sslobj.unwrap)
- sock.close()
+ except ssl.SSLSyscallError:
+ # If the server shuts down the TCP connection without sending a
+ # secure shutdown message, this is reported as SSL_ERROR_SYSCALL
+ pass
+ self.assertRaises(ssl.SSLError, sslobj.write, b'foo')
+
+ def test_bio_read_write_data(self):
+ sock = socket.socket(socket.AF_INET)
+ self.addCleanup(sock.close)
+ sock.connect(self.server_addr)
+ incoming = ssl.MemoryBIO()
+ outgoing = ssl.MemoryBIO()
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ ctx.verify_mode = ssl.CERT_NONE
+ sslobj = ctx.wrap_bio(incoming, outgoing, False)
+ self.ssl_io_loop(sock, incoming, outgoing, sslobj.do_handshake)
+ req = b'FOO\n'
+ self.ssl_io_loop(sock, incoming, outgoing, sslobj.write, req)
+ buf = self.ssl_io_loop(sock, incoming, outgoing, sslobj.read, 1024)
+ self.assertEqual(buf, b'foo\n')
+ self.ssl_io_loop(sock, incoming, outgoing, sslobj.unwrap)
-try:
- import threading
-except ImportError:
- _have_threads = False
-else:
- _have_threads = True
+class NetworkedTests(unittest.TestCase):
+ def test_timeout_connect_ex(self):
+ # Issue #12065: on a timeout, connect_ex() should return the original
+ # errno (mimicking the behaviour of non-SSL sockets).
+ with support.transient_internet(REMOTE_HOST):
+ s = ssl.wrap_socket(socket.socket(socket.AF_INET),
+ cert_reqs=ssl.CERT_REQUIRED,
+ do_handshake_on_connect=False)
+ self.addCleanup(s.close)
+ s.settimeout(0.0000001)
+ rc = s.connect_ex((REMOTE_HOST, 443))
+ if rc == 0:
+ self.skipTest("REMOTE_HOST responded too quickly")
+ self.assertIn(rc, (errno.EAGAIN, errno.EWOULDBLOCK))
+
+ @unittest.skipUnless(support.IPV6_ENABLED, 'Needs IPv6')
+ def test_get_server_certificate_ipv6(self):
+ with support.transient_internet('ipv6.google.com'):
+ _test_get_server_certificate(self, 'ipv6.google.com', 443)
+ _test_get_server_certificate_fail(self, 'ipv6.google.com', 443)
+
+ def test_algorithms(self):
+ # Issue #8484: all algorithms should be available when verifying a
+ # certificate.
+ # SHA256 was added in OpenSSL 0.9.8
+ if ssl.OPENSSL_VERSION_INFO < (0, 9, 8, 0, 15):
+ self.skipTest("SHA256 not available on %r" % ssl.OPENSSL_VERSION)
+ # sha256.tbs-internet.com needs SNI to use the correct certificate
+ if not ssl.HAS_SNI:
+ self.skipTest("SNI needed for this test")
+ # https://sha2.hboeck.de/ was used until 2011-01-08 (no route to host)
+ remote = ("sha256.tbs-internet.com", 443)
+ sha256_cert = os.path.join(os.path.dirname(__file__), "sha256.pem")
+ with support.transient_internet("sha256.tbs-internet.com"):
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ ctx.verify_mode = ssl.CERT_REQUIRED
+ ctx.load_verify_locations(sha256_cert)
+ s = ctx.wrap_socket(socket.socket(socket.AF_INET),
+ server_hostname="sha256.tbs-internet.com")
+ try:
+ s.connect(remote)
+ if support.verbose:
+ sys.stdout.write("\nCipher with %r is %r\n" %
+ (remote, s.cipher()))
+ sys.stdout.write("Certificate is:\n%s\n" %
+ pprint.pformat(s.getpeercert()))
+ finally:
+ s.close()
+
+
+def _test_get_server_certificate(test, host, port, cert=None):
+ pem = ssl.get_server_certificate((host, port))
+ if not pem:
+ test.fail("No server certificate on %s:%s!" % (host, port))
+
+ pem = ssl.get_server_certificate((host, port), ca_certs=cert)
+ if not pem:
+ test.fail("No server certificate on %s:%s!" % (host, port))
+ if support.verbose:
+ sys.stdout.write("\nVerified certificate for %s:%s is\n%s\n" % (host, port ,pem))
+
+def _test_get_server_certificate_fail(test, host, port):
+ try:
+ pem = ssl.get_server_certificate((host, port), ca_certs=CERTFILE)
+ except ssl.SSLError as x:
+ #should fail
+ if support.verbose:
+ sys.stdout.write("%s\n" % x)
+ else:
+ test.fail("Got server certificate %s for %s:%s!" % (pem, host, port))
+
+
+if _have_threads:
from test.ssl_servers import make_https_server
class ThreadedEchoServer(threading.Thread):
@@ -1882,6 +1864,15 @@
if not stripped:
# eof, so quit this handler
self.running = False
+ try:
+ self.sock = self.sslconn.unwrap()
+ except OSError:
+ # Many tests shut the TCP connection down
+ # without an SSL shutdown. This causes
+ # unwrap() to raise OSError with errno=0!
+ pass
+ else:
+ self.sslconn = None
self.close()
elif stripped == b'over':
if support.verbose and self.server.connectionchatty:
@@ -2719,12 +2710,13 @@
count, addr = s.recvfrom_into(b)
return b[:count]
- # (name, method, whether to expect success, *args)
+ # (name, method, expect success?, *args, return value func)
send_methods = [
- ('send', s.send, True, []),
- ('sendto', s.sendto, False, ["some.address"]),
- ('sendall', s.sendall, True, []),
+ ('send', s.send, True, [], len),
+ ('sendto', s.sendto, False, ["some.address"], len),
+ ('sendall', s.sendall, True, [], lambda x: None),
]
+ # (name, method, whether to expect success, *args)
recv_methods = [
('recv', s.recv, True, []),
('recvfrom', s.recvfrom, False, ["some.address"]),
@@ -2733,10 +2725,13 @@
]
data_prefix = "PREFIX_"
- for meth_name, send_meth, expect_success, args in send_methods:
+ for (meth_name, send_meth, expect_success, args,
+ ret_val_meth) in send_methods:
indata = (data_prefix + meth_name).encode('ascii')
try:
- send_meth(indata, *args)
+ ret = send_meth(indata, *args)
+ msg = "sending with {}".format(meth_name)
+ self.assertEqual(ret, ret_val_meth(indata), msg=msg)
outdata = s.read()
if outdata != indata.lower():
self.fail(
@@ -3361,18 +3356,20 @@
pass
for filename in [
- CERTFILE, REMOTE_ROOT_CERT, BYTES_CERTFILE,
+ CERTFILE, BYTES_CERTFILE,
ONLYCERT, ONLYKEY, BYTES_ONLYCERT, BYTES_ONLYKEY,
SIGNED_CERTFILE, SIGNED_CERTFILE2, SIGNING_CA,
BADCERT, BADKEY, EMPTYCERT]:
if not os.path.exists(filename):
raise support.TestFailed("Can't read certificate file %r" % filename)
- tests = [ContextTests, BasicSocketTests, SSLErrorTests, MemoryBIOTests]
+ tests = [
+ ContextTests, BasicSocketTests, SSLErrorTests, MemoryBIOTests,
+ SimpleBackgroundTests,
+ ]
if support.is_resource_enabled('network'):
tests.append(NetworkedTests)
- tests.append(NetworkedBIOTests)
if _have_threads:
thread_info = support.threading_setup()
diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py
index 0089ae8..5dd5048 100644
--- a/Lib/test/test_statistics.py
+++ b/Lib/test/test_statistics.py
@@ -659,7 +659,7 @@
@unittest.skipIf(sys.flags.optimize >= 2,
"Docstrings are omitted with -OO and above")
def test_doc_tests(self):
- failed, tried = doctest.testmod(statistics)
+ failed, tried = doctest.testmod(statistics, optionflags=doctest.ELLIPSIS)
self.assertGreater(tried, 0)
self.assertEqual(failed, 0)
@@ -702,9 +702,9 @@
def test_decimal(self):
D = Decimal
_exact_ratio = statistics._exact_ratio
- self.assertEqual(_exact_ratio(D("0.125")), (125, 1000))
- self.assertEqual(_exact_ratio(D("12.345")), (12345, 1000))
- self.assertEqual(_exact_ratio(D("-1.98")), (-198, 100))
+ self.assertEqual(_exact_ratio(D("0.125")), (1, 8))
+ self.assertEqual(_exact_ratio(D("12.345")), (2469, 200))
+ self.assertEqual(_exact_ratio(D("-1.98")), (-99, 50))
def test_inf(self):
INF = float("INF")
@@ -743,18 +743,18 @@
class DecimalToRatioTest(unittest.TestCase):
- # Test _decimal_to_ratio private function.
+ # Test _exact_ratio private function.
def test_infinity(self):
# Test that INFs are handled correctly.
inf = Decimal('INF')
- self.assertEqual(statistics._decimal_to_ratio(inf), (inf, None))
- self.assertEqual(statistics._decimal_to_ratio(-inf), (-inf, None))
+ self.assertEqual(statistics._exact_ratio(inf), (inf, None))
+ self.assertEqual(statistics._exact_ratio(-inf), (-inf, None))
def test_nan(self):
# Test that NANs are handled correctly.
for nan in (Decimal('NAN'), Decimal('sNAN')):
- num, den = statistics._decimal_to_ratio(nan)
+ num, den = statistics._exact_ratio(nan)
# Because NANs always compare non-equal, we cannot use assertEqual.
# Nor can we use an identity test, as we don't guarantee anything
# about the object identity.
@@ -767,30 +767,30 @@
for d in numbers:
# First test positive decimals.
assert d > 0
- num, den = statistics._decimal_to_ratio(d)
+ num, den = statistics._exact_ratio(d)
self.assertGreaterEqual(num, 0)
self.assertGreater(den, 0)
# Then test negative decimals.
- num, den = statistics._decimal_to_ratio(-d)
+ num, den = statistics._exact_ratio(-d)
self.assertLessEqual(num, 0)
self.assertGreater(den, 0)
def test_negative_exponent(self):
# Test result when the exponent is negative.
- t = statistics._decimal_to_ratio(Decimal("0.1234"))
- self.assertEqual(t, (1234, 10000))
+ t = statistics._exact_ratio(Decimal("0.1234"))
+ self.assertEqual(t, (617, 5000))
def test_positive_exponent(self):
# Test results when the exponent is positive.
- t = statistics._decimal_to_ratio(Decimal("1.234e7"))
+ t = statistics._exact_ratio(Decimal("1.234e7"))
self.assertEqual(t, (12340000, 1))
def test_regression_20536(self):
# Regression test for issue 20536.
# See http://bugs.python.org/issue20536
- t = statistics._decimal_to_ratio(Decimal("1e2"))
+ t = statistics._exact_ratio(Decimal("1e2"))
self.assertEqual(t, (100, 1))
- t = statistics._decimal_to_ratio(Decimal("1.47e5"))
+ t = statistics._exact_ratio(Decimal("1.47e5"))
self.assertEqual(t, (147000, 1))
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index 85126e6..8c8f97b 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -5,7 +5,6 @@
import locale
import re
import os
-import sys
from test import support
from datetime import date as datetime_date
@@ -153,8 +152,8 @@
"'%s' using '%s'; group 'a' = '%s', group 'b' = %s'" %
(found.string, found.re.pattern, found.group('a'),
found.group('b')))
- for directive in ('a','A','b','B','c','d','H','I','j','m','M','p','S',
- 'U','w','W','x','X','y','Y','Z','%'):
+ for directive in ('a','A','b','B','c','d','G','H','I','j','m','M','p',
+ 'S','u','U','V','w','W','x','X','y','Y','Z','%'):
compiled = self.time_re.compile("%" + directive)
found = compiled.match(time.strftime("%" + directive))
self.assertTrue(found, "Matching failed on '%s' using '%s' regex" %
@@ -219,6 +218,26 @@
else:
self.fail("'%s' did not raise ValueError" % bad_format)
+ # Ambiguous or incomplete cases using ISO year/week/weekday directives
+ # 1. ISO week (%V) is specified, but the year is specified with %Y
+ # instead of %G
+ with self.assertRaises(ValueError):
+ _strptime._strptime("1999 50", "%Y %V")
+ # 2. ISO year (%G) and ISO week (%V) are specified, but weekday is not
+ with self.assertRaises(ValueError):
+ _strptime._strptime("1999 51", "%G %V")
+ # 3. ISO year (%G) and weekday are specified, but ISO week (%V) is not
+ for w in ('A', 'a', 'w', 'u'):
+ with self.assertRaises(ValueError):
+ _strptime._strptime("1999 51","%G %{}".format(w))
+ # 4. ISO year is specified alone (e.g. time.strptime('2015', '%G'))
+ with self.assertRaises(ValueError):
+ _strptime._strptime("2015", "%G")
+ # 5. Julian/ordinal day (%j) is specified with %G, but not %Y
+ with self.assertRaises(ValueError):
+ _strptime._strptime("1999 256", "%G %j")
+
+
def test_strptime_exception_context(self):
# check that this doesn't chain exceptions needlessly (see #17572)
with self.assertRaises(ValueError) as e:
@@ -290,7 +309,7 @@
def test_weekday(self):
# Test weekday directives
- for directive in ('A', 'a', 'w'):
+ for directive in ('A', 'a', 'w', 'u'):
self.helper(directive,6)
def test_julian(self):
@@ -457,16 +476,20 @@
# Should be able to infer date if given year, week of year (%U or %W)
# and day of the week
def test_helper(ymd_tuple, test_reason):
- for directive in ('W', 'U'):
- format_string = "%%Y %%%s %%w" % directive
- dt_date = datetime_date(*ymd_tuple)
- strp_input = dt_date.strftime(format_string)
- strp_output = _strptime._strptime_time(strp_input, format_string)
- self.assertTrue(strp_output[:3] == ymd_tuple,
- "%s(%s) test failed w/ '%s': %s != %s (%s != %s)" %
- (test_reason, directive, strp_input,
- strp_output[:3], ymd_tuple,
- strp_output[7], dt_date.timetuple()[7]))
+ for year_week_format in ('%Y %W', '%Y %U', '%G %V'):
+ for weekday_format in ('%w', '%u', '%a', '%A'):
+ format_string = year_week_format + ' ' + weekday_format
+ with self.subTest(test_reason,
+ date=ymd_tuple,
+ format=format_string):
+ dt_date = datetime_date(*ymd_tuple)
+ strp_input = dt_date.strftime(format_string)
+ strp_output = _strptime._strptime_time(strp_input,
+ format_string)
+ msg = "%r: %s != %s" % (strp_input,
+ strp_output[7],
+ dt_date.timetuple()[7])
+ self.assertEqual(strp_output[:3], ymd_tuple, msg)
test_helper((1901, 1, 3), "week 0")
test_helper((1901, 1, 8), "common case")
test_helper((1901, 1, 13), "day on Sunday")
@@ -498,33 +521,48 @@
self.assertEqual(_strptime._strptime_time(value, format)[:-1], expected)
check('2015 0 0', '%Y %U %w', 2014, 12, 28, 0, 0, 0, 6, 362)
check('2015 0 0', '%Y %W %w', 2015, 1, 4, 0, 0, 0, 6, 4)
+ check('2015 1 1', '%G %V %u', 2014, 12, 29, 0, 0, 0, 0, 363)
check('2015 0 1', '%Y %U %w', 2014, 12, 29, 0, 0, 0, 0, 363)
check('2015 0 1', '%Y %W %w', 2014, 12, 29, 0, 0, 0, 0, 363)
+ check('2015 1 2', '%G %V %u', 2014, 12, 30, 0, 0, 0, 1, 364)
check('2015 0 2', '%Y %U %w', 2014, 12, 30, 0, 0, 0, 1, 364)
check('2015 0 2', '%Y %W %w', 2014, 12, 30, 0, 0, 0, 1, 364)
+ check('2015 1 3', '%G %V %u', 2014, 12, 31, 0, 0, 0, 2, 365)
check('2015 0 3', '%Y %U %w', 2014, 12, 31, 0, 0, 0, 2, 365)
check('2015 0 3', '%Y %W %w', 2014, 12, 31, 0, 0, 0, 2, 365)
+ check('2015 1 4', '%G %V %u', 2015, 1, 1, 0, 0, 0, 3, 1)
check('2015 0 4', '%Y %U %w', 2015, 1, 1, 0, 0, 0, 3, 1)
check('2015 0 4', '%Y %W %w', 2015, 1, 1, 0, 0, 0, 3, 1)
+ check('2015 1 5', '%G %V %u', 2015, 1, 2, 0, 0, 0, 4, 2)
check('2015 0 5', '%Y %U %w', 2015, 1, 2, 0, 0, 0, 4, 2)
check('2015 0 5', '%Y %W %w', 2015, 1, 2, 0, 0, 0, 4, 2)
+ check('2015 1 6', '%G %V %u', 2015, 1, 3, 0, 0, 0, 5, 3)
check('2015 0 6', '%Y %U %w', 2015, 1, 3, 0, 0, 0, 5, 3)
check('2015 0 6', '%Y %W %w', 2015, 1, 3, 0, 0, 0, 5, 3)
+ check('2015 1 7', '%G %V %u', 2015, 1, 4, 0, 0, 0, 6, 4)
check('2009 0 0', '%Y %U %w', 2008, 12, 28, 0, 0, 0, 6, 363)
check('2009 0 0', '%Y %W %w', 2009, 1, 4, 0, 0, 0, 6, 4)
+ check('2009 1 1', '%G %V %u', 2008, 12, 29, 0, 0, 0, 0, 364)
check('2009 0 1', '%Y %U %w', 2008, 12, 29, 0, 0, 0, 0, 364)
check('2009 0 1', '%Y %W %w', 2008, 12, 29, 0, 0, 0, 0, 364)
+ check('2009 1 2', '%G %V %u', 2008, 12, 30, 0, 0, 0, 1, 365)
check('2009 0 2', '%Y %U %w', 2008, 12, 30, 0, 0, 0, 1, 365)
check('2009 0 2', '%Y %W %w', 2008, 12, 30, 0, 0, 0, 1, 365)
+ check('2009 1 3', '%G %V %u', 2008, 12, 31, 0, 0, 0, 2, 366)
check('2009 0 3', '%Y %U %w', 2008, 12, 31, 0, 0, 0, 2, 366)
check('2009 0 3', '%Y %W %w', 2008, 12, 31, 0, 0, 0, 2, 366)
+ check('2009 1 4', '%G %V %u', 2009, 1, 1, 0, 0, 0, 3, 1)
check('2009 0 4', '%Y %U %w', 2009, 1, 1, 0, 0, 0, 3, 1)
check('2009 0 4', '%Y %W %w', 2009, 1, 1, 0, 0, 0, 3, 1)
+ check('2009 1 5', '%G %V %u', 2009, 1, 2, 0, 0, 0, 4, 2)
check('2009 0 5', '%Y %U %w', 2009, 1, 2, 0, 0, 0, 4, 2)
check('2009 0 5', '%Y %W %w', 2009, 1, 2, 0, 0, 0, 4, 2)
+ check('2009 1 6', '%G %V %u', 2009, 1, 3, 0, 0, 0, 5, 3)
check('2009 0 6', '%Y %U %w', 2009, 1, 3, 0, 0, 0, 5, 3)
check('2009 0 6', '%Y %W %w', 2009, 1, 3, 0, 0, 0, 5, 3)
+ check('2009 1 7', '%G %V %u', 2009, 1, 4, 0, 0, 0, 6, 4)
+
class CacheTests(unittest.TestCase):
"""Test that caching works properly."""
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 4704d49..ba91bbc 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -1,20 +1,16 @@
import unittest
from unittest import mock
-from test.support import script_helper
from test import support
import subprocess
import sys
import signal
import io
-import locale
import os
import errno
import tempfile
import time
-import re
import selectors
import sysconfig
-import warnings
import select
import shutil
import gc
@@ -448,8 +444,8 @@
p = subprocess.Popen([sys.executable, "-c",
'import sys; sys.stdout.write("orange")'],
stdout=subprocess.PIPE)
- self.addCleanup(p.stdout.close)
- self.assertEqual(p.stdout.read(), b"orange")
+ with p:
+ self.assertEqual(p.stdout.read(), b"orange")
def test_stdout_filedes(self):
# stdout is set to open file descriptor
@@ -479,8 +475,8 @@
p = subprocess.Popen([sys.executable, "-c",
'import sys; sys.stderr.write("strawberry")'],
stderr=subprocess.PIPE)
- self.addCleanup(p.stderr.close)
- self.assertStderrEqual(p.stderr.read(), b"strawberry")
+ with p:
+ self.assertStderrEqual(p.stderr.read(), b"strawberry")
def test_stderr_filedes(self):
# stderr is set to open file descriptor
@@ -535,8 +531,8 @@
'sys.stderr.write("orange")'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
- self.addCleanup(p.stdout.close)
- self.assertStderrEqual(p.stdout.read(), b"appleorange")
+ with p:
+ self.assertStderrEqual(p.stdout.read(), b"appleorange")
def test_stdout_stderr_file(self):
# capture stdout and stderr to the same open file
@@ -794,18 +790,19 @@
stdin=subprocess.PIPE,
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()
- self.addCleanup(p.stdout.close)
- self.assertEqual(p.stdout.readline(),
- "line2\n")
- self.assertEqual(p.stdout.read(6),
- "line3\n")
- self.assertEqual(p.stdout.read(),
- "line4\nline5\nline6\nline7\nline8")
+ with p:
+ p.stdin.write("line1\n")
+ p.stdin.flush()
+ self.assertEqual(p.stdout.readline(), "line1\n")
+ p.stdin.write("line3\n")
+ p.stdin.close()
+ self.addCleanup(p.stdout.close)
+ self.assertEqual(p.stdout.readline(),
+ "line2\n")
+ self.assertEqual(p.stdout.read(6),
+ "line3\n")
+ self.assertEqual(p.stdout.read(),
+ "line4\nline5\nline6\nline7\nline8")
def test_universal_newlines_communicate(self):
# universal newlines through communicate()
@@ -1431,6 +1428,27 @@
p.wait()
self.assertEqual(-p.returncode, signal.SIGABRT)
+ def test_CalledProcessError_str_signal(self):
+ err = subprocess.CalledProcessError(-int(signal.SIGABRT), "fake cmd")
+ error_string = str(err)
+ # We're relying on the repr() of the signal.Signals intenum to provide
+ # the word signal, the signal name and the numeric value.
+ self.assertIn("signal", error_string.lower())
+ # We're not being specific about the signal name as some signals have
+ # multiple names and which name is revealed can vary.
+ self.assertIn("SIG", error_string)
+ self.assertIn(str(signal.SIGABRT), error_string)
+
+ def test_CalledProcessError_str_unknown_signal(self):
+ err = subprocess.CalledProcessError(-9876543, "fake cmd")
+ error_string = str(err)
+ self.assertIn("unknown signal 9876543.", error_string)
+
+ def test_CalledProcessError_str_non_zero(self):
+ err = subprocess.CalledProcessError(2, "fake cmd")
+ error_string = str(err)
+ self.assertIn("non-zero exit status 2.", error_string)
+
def test_preexec(self):
# DISCLAIMER: Setting environment variables is *not* a good use
# of a preexec_fn. This is merely a test.
@@ -1439,8 +1457,8 @@
'sys.stdout.write(os.getenv("FRUIT"))'],
stdout=subprocess.PIPE,
preexec_fn=lambda: os.putenv("FRUIT", "apple"))
- self.addCleanup(p.stdout.close)
- self.assertEqual(p.stdout.read(), b"apple")
+ with p:
+ self.assertEqual(p.stdout.read(), b"apple")
def test_preexec_exception(self):
def raise_it():
@@ -1588,8 +1606,8 @@
p = subprocess.Popen(["echo $FRUIT"], shell=1,
stdout=subprocess.PIPE,
env=newenv)
- self.addCleanup(p.stdout.close)
- self.assertEqual(p.stdout.read().strip(b" \t\r\n\f"), b"apple")
+ with p:
+ self.assertEqual(p.stdout.read().strip(b" \t\r\n\f"), b"apple")
def test_shell_string(self):
# Run command through the shell (string)
@@ -1598,8 +1616,8 @@
p = subprocess.Popen("echo $FRUIT", shell=1,
stdout=subprocess.PIPE,
env=newenv)
- self.addCleanup(p.stdout.close)
- self.assertEqual(p.stdout.read().strip(b" \t\r\n\f"), b"apple")
+ with p:
+ self.assertEqual(p.stdout.read().strip(b" \t\r\n\f"), b"apple")
def test_call_string(self):
# call() function with string argument on UNIX
@@ -1631,8 +1649,8 @@
for sh in shells:
p = subprocess.Popen("echo $0", executable=sh, shell=True,
stdout=subprocess.PIPE)
- self.addCleanup(p.stdout.close)
- self.assertEqual(p.stdout.read().strip(), bytes(sh, 'ascii'))
+ with p:
+ self.assertEqual(p.stdout.read().strip(), bytes(sh, 'ascii'))
def _kill_process(self, method, *args):
# Do not inherit file handles from the parent.
@@ -2290,7 +2308,9 @@
self.addCleanup(p.stderr.close)
ident = id(p)
pid = p.pid
- del p
+ with support.check_warnings(('', ResourceWarning)):
+ p = None
+
# check that p is in the active processes list
self.assertIn(ident, [id(o) for o in subprocess._active])
@@ -2309,7 +2329,9 @@
self.addCleanup(p.stderr.close)
ident = id(p)
pid = p.pid
- del p
+ with support.check_warnings(('', ResourceWarning)):
+ p = None
+
os.kill(pid, signal.SIGKILL)
# check that p is in the active processes list
self.assertIn(ident, [id(o) for o in subprocess._active])
@@ -2501,8 +2523,8 @@
p = subprocess.Popen(["set"], shell=1,
stdout=subprocess.PIPE,
env=newenv)
- self.addCleanup(p.stdout.close)
- self.assertIn(b"physalis", p.stdout.read())
+ with p:
+ self.assertIn(b"physalis", p.stdout.read())
def test_shell_string(self):
# Run command through the shell (string)
@@ -2511,8 +2533,8 @@
p = subprocess.Popen("set", shell=1,
stdout=subprocess.PIPE,
env=newenv)
- self.addCleanup(p.stdout.close)
- self.assertIn(b"physalis", p.stdout.read())
+ with p:
+ self.assertIn(b"physalis", p.stdout.read())
def test_call_string(self):
# call() function with string argument on Windows
@@ -2531,16 +2553,14 @@
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- self.addCleanup(p.stdout.close)
- self.addCleanup(p.stderr.close)
- self.addCleanup(p.stdin.close)
- # Wait for the interpreter to be completely initialized before
- # sending any signal.
- p.stdout.read(1)
- getattr(p, method)(*args)
- _, stderr = p.communicate()
- self.assertStderrEqual(stderr, b'')
- returncode = p.wait()
+ with p:
+ # Wait for the interpreter to be completely initialized before
+ # sending any signal.
+ p.stdout.read(1)
+ getattr(p, method)(*args)
+ _, stderr = p.communicate()
+ self.assertStderrEqual(stderr, b'')
+ returncode = p.wait()
self.assertNotEqual(returncode, 0)
def _kill_dead_process(self, method, *args):
@@ -2553,19 +2573,17 @@
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- self.addCleanup(p.stdout.close)
- self.addCleanup(p.stderr.close)
- self.addCleanup(p.stdin.close)
- # Wait for the interpreter to be completely initialized before
- # sending any signal.
- p.stdout.read(1)
- # The process should end after this
- time.sleep(1)
- # This shouldn't raise even though the child is now dead
- getattr(p, method)(*args)
- _, stderr = p.communicate()
- self.assertStderrEqual(stderr, b'')
- rc = p.wait()
+ with p:
+ # Wait for the interpreter to be completely initialized before
+ # sending any signal.
+ p.stdout.read(1)
+ # The process should end after this
+ time.sleep(1)
+ # This shouldn't raise even though the child is now dead
+ getattr(p, method)(*args)
+ _, stderr = p.communicate()
+ self.assertStderrEqual(stderr, b'')
+ rc = p.wait()
self.assertEqual(rc, 42)
def test_send_signal(self):
@@ -2608,8 +2626,7 @@
def test__all__(self):
"""Ensure that __all__ is populated properly."""
- # STARTUPINFO added to __all__ in 3.6
- intentionally_excluded = {"list2cmdline", "STARTUPINFO", "Handle"}
+ intentionally_excluded = {"list2cmdline", "Handle"}
exported = set(subprocess.__all__)
possible_exports = set()
import types
@@ -2654,11 +2671,11 @@
def with_spaces(self, *args, **kwargs):
kwargs['stdout'] = subprocess.PIPE
p = subprocess.Popen(*args, **kwargs)
- self.addCleanup(p.stdout.close)
- self.assertEqual(
- p.stdout.read ().decode("mbcs"),
- "2 [%r, 'ab cd']" % self.fname
- )
+ with p:
+ self.assertEqual(
+ p.stdout.read ().decode("mbcs"),
+ "2 [%r, 'ab cd']" % self.fname
+ )
def test_shell_string_with_spaces(self):
# call() function with string argument with spaces on Windows
diff --git a/Lib/test/test_sunau.py b/Lib/test/test_sunau.py
index 0f4134e..bc1f46c 100644
--- a/Lib/test/test_sunau.py
+++ b/Lib/test/test_sunau.py
@@ -1,4 +1,3 @@
-from test.support import TESTFN
import unittest
from test import audiotests
from audioop import byteswap
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index 2c00417..269d9bf 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -9,13 +9,11 @@
from test import support
TESTFN = support.TESTFN
-TESTDIRN = os.path.basename(tempfile.mkdtemp(dir='.'))
class TestSupport(unittest.TestCase):
def setUp(self):
support.unlink(TESTFN)
- support.rmtree(TESTDIRN)
tearDown = setUp
def test_import_module(self):
@@ -48,6 +46,10 @@
support.unlink(TESTFN)
def test_rmtree(self):
+ TESTDIRN = os.path.basename(tempfile.mkdtemp(dir='.'))
+ self.addCleanup(support.rmtree, TESTDIRN)
+ support.rmtree(TESTDIRN)
+
os.mkdir(TESTDIRN)
os.mkdir(os.path.join(TESTDIRN, TESTDIRN))
support.rmtree(TESTDIRN)
@@ -228,7 +230,8 @@
def test_check_syntax_error(self):
support.check_syntax_error(self, "def class")
- self.assertRaises(AssertionError, support.check_syntax_error, self, "1")
+ with self.assertRaises(AssertionError):
+ support.check_syntax_error(self, "x=1")
def test_CleanImport(self):
import importlib
@@ -312,6 +315,28 @@
self.OtherClass, self.RefClass, ignore=ignore)
self.assertEqual(set(), missing_items)
+ def test_check__all__(self):
+ extra = {'tempdir'}
+ blacklist = {'template'}
+ support.check__all__(self,
+ tempfile,
+ extra=extra,
+ blacklist=blacklist)
+
+ extra = {'TextTestResult', 'installHandler'}
+ blacklist = {'load_tests', "TestProgram", "BaseTestSuite"}
+
+ support.check__all__(self,
+ unittest,
+ ("unittest.result", "unittest.case",
+ "unittest.suite", "unittest.loader",
+ "unittest.main", "unittest.runner",
+ "unittest.signals"),
+ extra=extra,
+ blacklist=blacklist)
+
+ self.assertRaises(AssertionError, support.check__all__, self, unittest)
+
# XXX -follows a list of untested API
# make_legacy_pyc
# is_resource_enabled
diff --git a/Lib/test/test_symbol.py b/Lib/test/test_symbol.py
new file mode 100644
index 0000000..c1306f5
--- /dev/null
+++ b/Lib/test/test_symbol.py
@@ -0,0 +1,54 @@
+import unittest
+from test import support
+import os
+import sys
+import subprocess
+
+
+SYMBOL_FILE = support.findfile('symbol.py')
+GRAMMAR_FILE = os.path.join(os.path.dirname(__file__),
+ '..', '..', 'Include', 'graminit.h')
+TEST_PY_FILE = 'symbol_test.py'
+
+
+class TestSymbolGeneration(unittest.TestCase):
+
+ def _copy_file_without_generated_symbols(self, source_file, dest_file):
+ with open(source_file) as fp:
+ lines = fp.readlines()
+ with open(dest_file, 'w') as fp:
+ fp.writelines(lines[:lines.index("#--start constants--\n") + 1])
+ fp.writelines(lines[lines.index("#--end constants--\n"):])
+
+ def _generate_symbols(self, grammar_file, target_symbol_py_file):
+ proc = subprocess.Popen([sys.executable,
+ SYMBOL_FILE,
+ grammar_file,
+ target_symbol_py_file], stderr=subprocess.PIPE)
+ stderr = proc.communicate()[1]
+ return proc.returncode, stderr
+
+ def compare_files(self, file1, file2):
+ with open(file1) as fp:
+ lines1 = fp.readlines()
+ with open(file2) as fp:
+ lines2 = fp.readlines()
+ self.assertEqual(lines1, lines2)
+
+ @unittest.skipIf(not os.path.exists(GRAMMAR_FILE),
+ 'test only works from source build directory')
+ def test_real_grammar_and_symbol_file(self):
+ output = support.TESTFN
+ self.addCleanup(support.unlink, output)
+
+ self._copy_file_without_generated_symbols(SYMBOL_FILE, output)
+
+ exitcode, stderr = self._generate_symbols(GRAMMAR_FILE, output)
+ self.assertEqual(b'', stderr)
+ self.assertEqual(0, exitcode)
+
+ self.compare_files(SYMBOL_FILE, output)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 057441c..38fc417 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -35,14 +35,6 @@
Traceback (most recent call last):
SyntaxError: can't assign to keyword
-It's a syntax error to assign to the empty tuple. Why isn't it an
-error to assign to the empty list? It will always raise some error at
-runtime.
-
->>> () = 1
-Traceback (most recent call last):
-SyntaxError: can't assign to ()
-
>>> f() = 1
Traceback (most recent call last):
SyntaxError: can't assign to function call
@@ -491,10 +483,6 @@
...
SyntaxError: keyword argument repeated
->>> del ()
-Traceback (most recent call last):
-SyntaxError: can't delete ()
-
>>> {1, 2, 3} = 42
Traceback (most recent call last):
SyntaxError: can't assign to literal
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py
index 509bc3e..25c5835 100644
--- a/Lib/test/test_sys_settrace.py
+++ b/Lib/test/test_sys_settrace.py
@@ -338,8 +338,8 @@
def test_14_onliner_if(self):
def onliners():
- if True: False
- else: True
+ if True: x=False
+ else: x=True
return 0
self.run_and_compare(
onliners,
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index abfb34d..d7785ce 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -2074,6 +2074,24 @@
with self.assertRaises(ValueError):
tarfile.itn(0x10000000000, 6, tarfile.GNU_FORMAT)
+ def test__all__(self):
+ blacklist = {'version', 'grp', 'pwd', 'symlink_exception',
+ 'NUL', 'BLOCKSIZE', 'RECORDSIZE', 'GNU_MAGIC',
+ 'POSIX_MAGIC', 'LENGTH_NAME', 'LENGTH_LINK',
+ 'LENGTH_PREFIX', 'REGTYPE', 'AREGTYPE', 'LNKTYPE',
+ 'SYMTYPE', 'CHRTYPE', 'BLKTYPE', 'DIRTYPE', 'FIFOTYPE',
+ 'CONTTYPE', 'GNUTYPE_LONGNAME', 'GNUTYPE_LONGLINK',
+ 'GNUTYPE_SPARSE', 'XHDTYPE', 'XGLTYPE', 'SOLARIS_XHDTYPE',
+ 'SUPPORTED_TYPES', 'REGULAR_TYPES', 'GNU_TYPES',
+ 'PAX_FIELDS', 'PAX_NAME_FIELDS', 'PAX_NUMBER_FIELDS',
+ 'stn', 'nts', 'nti', 'itn', 'calc_chksums', 'copyfileobj',
+ 'filemode',
+ 'EmptyHeaderError', 'TruncatedHeaderError',
+ 'EOFHeaderError', 'InvalidHeaderError',
+ 'SubsequentHeaderError', 'ExFileObject',
+ 'main'}
+ support.check__all__(self, tarfile, blacklist=blacklist)
+
class CommandLineTest(unittest.TestCase):
diff --git a/Lib/test/test_telnetlib.py b/Lib/test/test_telnetlib.py
index 8e219f4..51d82e1 100644
--- a/Lib/test/test_telnetlib.py
+++ b/Lib/test/test_telnetlib.py
@@ -1,7 +1,6 @@
import socket
import selectors
import telnetlib
-import time
import contextlib
from test import support
@@ -42,6 +41,11 @@
telnet = telnetlib.Telnet(HOST, self.port)
telnet.sock.close()
+ def testContextManager(self):
+ with telnetlib.Telnet(HOST, self.port) as tn:
+ self.assertIsNotNone(tn.get_socket())
+ self.assertIsNone(tn.get_socket())
+
def testTimeoutDefault(self):
self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(30)
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index b49a961..d6317c7 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -3,11 +3,10 @@
"""
import test.support
-from test.support import verbose, strip_python_stderr, import_module, cpython_only
+from test.support import verbose, import_module, cpython_only
from test.support.script_helper import assert_python_ok, assert_python_failure
import random
-import re
import sys
_thread = import_module('_thread')
threading = import_module('threading')
@@ -18,6 +17,7 @@
import subprocess
from test import lock_tests
+from test import support
# Between fork() and exec(), only async-safe functions are allowed (issues
@@ -1097,5 +1097,12 @@
class BarrierTests(lock_tests.BarrierTests):
barriertype = staticmethod(threading.Barrier)
+class MiscTestCase(unittest.TestCase):
+ def test__all__(self):
+ extra = {"ThreadError"}
+ blacklist = {'currentThread', 'activeCount'}
+ support.check__all__(self, threading, ('threading', '_thread'),
+ extra=extra, blacklist=blacklist)
+
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index 76b894e..f883c45 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -1,6 +1,8 @@
from test import support
+import decimal
import enum
import locale
+import math
import platform
import sys
import sysconfig
@@ -21,17 +23,27 @@
TIME_MAXYEAR = (1 << 8 * SIZEOF_INT - 1) - 1
TIME_MINYEAR = -TIME_MAXYEAR - 1
+SEC_TO_US = 10 ** 6
US_TO_NS = 10 ** 3
MS_TO_NS = 10 ** 6
SEC_TO_NS = 10 ** 9
+NS_TO_SEC = 10 ** 9
class _PyTime(enum.IntEnum):
# Round towards minus infinity (-inf)
ROUND_FLOOR = 0
# Round towards infinity (+inf)
ROUND_CEILING = 1
+ # Round to nearest with ties going to nearest even integer
+ ROUND_HALF_EVEN = 2
-ALL_ROUNDING_METHODS = (_PyTime.ROUND_FLOOR, _PyTime.ROUND_CEILING)
+# Rounding modes supported by PyTime
+ROUNDING_MODES = (
+ # (PyTime rounding method, decimal rounding method)
+ (_PyTime.ROUND_FLOOR, decimal.ROUND_FLOOR),
+ (_PyTime.ROUND_CEILING, decimal.ROUND_CEILING),
+ (_PyTime.ROUND_HALF_EVEN, decimal.ROUND_HALF_EVEN),
+)
class TimeTestCase(unittest.TestCase):
@@ -607,79 +619,6 @@
class TestPytime(unittest.TestCase):
- def setUp(self):
- self.invalid_values = (
- -(2 ** 100), 2 ** 100,
- -(2.0 ** 100.0), 2.0 ** 100.0,
- )
-
- @support.cpython_only
- def test_time_t(self):
- from _testcapi import pytime_object_to_time_t
- for obj, time_t, rnd in (
- # Round towards minus infinity (-inf)
- (0, 0, _PyTime.ROUND_FLOOR),
- (-1, -1, _PyTime.ROUND_FLOOR),
- (-1.0, -1, _PyTime.ROUND_FLOOR),
- (-1.9, -2, _PyTime.ROUND_FLOOR),
- (1.0, 1, _PyTime.ROUND_FLOOR),
- (1.9, 1, _PyTime.ROUND_FLOOR),
- # Round towards infinity (+inf)
- (0, 0, _PyTime.ROUND_CEILING),
- (-1, -1, _PyTime.ROUND_CEILING),
- (-1.0, -1, _PyTime.ROUND_CEILING),
- (-1.9, -1, _PyTime.ROUND_CEILING),
- (1.0, 1, _PyTime.ROUND_CEILING),
- (1.9, 2, _PyTime.ROUND_CEILING),
- ):
- self.assertEqual(pytime_object_to_time_t(obj, rnd), time_t)
-
- rnd = _PyTime.ROUND_FLOOR
- for invalid in self.invalid_values:
- self.assertRaises(OverflowError,
- pytime_object_to_time_t, invalid, rnd)
-
- @support.cpython_only
- def test_timespec(self):
- from _testcapi import pytime_object_to_timespec
- for obj, timespec, rnd in (
- # Round towards minus infinity (-inf)
- (0, (0, 0), _PyTime.ROUND_FLOOR),
- (-1, (-1, 0), _PyTime.ROUND_FLOOR),
- (-1.0, (-1, 0), _PyTime.ROUND_FLOOR),
- (1e-9, (0, 1), _PyTime.ROUND_FLOOR),
- (1e-10, (0, 0), _PyTime.ROUND_FLOOR),
- (-1e-9, (-1, 999999999), _PyTime.ROUND_FLOOR),
- (-1e-10, (-1, 999999999), _PyTime.ROUND_FLOOR),
- (-1.2, (-2, 800000000), _PyTime.ROUND_FLOOR),
- (0.9999999999, (0, 999999999), _PyTime.ROUND_FLOOR),
- (1.1234567890, (1, 123456789), _PyTime.ROUND_FLOOR),
- (1.1234567899, (1, 123456789), _PyTime.ROUND_FLOOR),
- (-1.1234567890, (-2, 876543211), _PyTime.ROUND_FLOOR),
- (-1.1234567891, (-2, 876543210), _PyTime.ROUND_FLOOR),
- # Round towards infinity (+inf)
- (0, (0, 0), _PyTime.ROUND_CEILING),
- (-1, (-1, 0), _PyTime.ROUND_CEILING),
- (-1.0, (-1, 0), _PyTime.ROUND_CEILING),
- (1e-9, (0, 1), _PyTime.ROUND_CEILING),
- (1e-10, (0, 1), _PyTime.ROUND_CEILING),
- (-1e-9, (-1, 999999999), _PyTime.ROUND_CEILING),
- (-1e-10, (0, 0), _PyTime.ROUND_CEILING),
- (-1.2, (-2, 800000000), _PyTime.ROUND_CEILING),
- (0.9999999999, (1, 0), _PyTime.ROUND_CEILING),
- (1.1234567890, (1, 123456790), _PyTime.ROUND_CEILING),
- (1.1234567899, (1, 123456790), _PyTime.ROUND_CEILING),
- (-1.1234567890, (-2, 876543211), _PyTime.ROUND_CEILING),
- (-1.1234567891, (-2, 876543211), _PyTime.ROUND_CEILING),
- ):
- with self.subTest(obj=obj, round=rnd, timespec=timespec):
- self.assertEqual(pytime_object_to_timespec(obj, rnd), timespec)
-
- rnd = _PyTime.ROUND_FLOOR
- for invalid in self.invalid_values:
- self.assertRaises(OverflowError,
- pytime_object_to_timespec, invalid, rnd)
-
@unittest.skipUnless(time._STRUCT_TM_ITEMS == 11, "needs tm_zone support")
def test_localtime_timezone(self):
@@ -734,266 +673,291 @@
self.assertIs(lt.tm_zone, None)
-@unittest.skipUnless(_testcapi is not None,
- 'need the _testcapi module')
-class TestPyTime_t(unittest.TestCase):
+@unittest.skipIf(_testcapi is None, 'need the _testcapi module')
+class CPyTimeTestCase:
+ """
+ Base class to test the C _PyTime_t API.
+ """
+ OVERFLOW_SECONDS = None
+
+ def setUp(self):
+ from _testcapi import SIZEOF_TIME_T
+ bits = SIZEOF_TIME_T * 8 - 1
+ self.time_t_min = -2 ** bits
+ self.time_t_max = 2 ** bits - 1
+
+ def time_t_filter(self, seconds):
+ return (self.time_t_min <= seconds <= self.time_t_max)
+
+ def _rounding_values(self, use_float):
+ "Build timestamps used to test rounding."
+
+ units = [1, US_TO_NS, MS_TO_NS, SEC_TO_NS]
+ if use_float:
+ # picoseconds are only tested to pytime_converter accepting floats
+ units.append(1e-3)
+
+ values = (
+ # small values
+ 1, 2, 5, 7, 123, 456, 1234,
+ # 10^k - 1
+ 9,
+ 99,
+ 999,
+ 9999,
+ 99999,
+ 999999,
+ # test half even rounding near 0.5, 1.5, 2.5, 3.5, 4.5
+ 499, 500, 501,
+ 1499, 1500, 1501,
+ 2500,
+ 3500,
+ 4500,
+ )
+
+ ns_timestamps = [0]
+ for unit in units:
+ for value in values:
+ ns = value * unit
+ ns_timestamps.extend((-ns, ns))
+ for pow2 in (0, 5, 10, 15, 22, 23, 24, 30, 33):
+ ns = (2 ** pow2) * SEC_TO_NS
+ ns_timestamps.extend((
+ -ns-1, -ns, -ns+1,
+ ns-1, ns, ns+1
+ ))
+ for seconds in (_testcapi.INT_MIN, _testcapi.INT_MAX):
+ ns_timestamps.append(seconds * SEC_TO_NS)
+ if use_float:
+ # numbers with an extract representation in IEEE 754 (base 2)
+ for pow2 in (3, 7, 10, 15):
+ ns = 2.0 ** (-pow2)
+ ns_timestamps.extend((-ns, ns))
+
+ # seconds close to _PyTime_t type limit
+ ns = (2 ** 63 // SEC_TO_NS) * SEC_TO_NS
+ ns_timestamps.extend((-ns, ns))
+
+ return ns_timestamps
+
+ def _check_rounding(self, pytime_converter, expected_func,
+ use_float, unit_to_sec, value_filter=None):
+
+ def convert_values(ns_timestamps):
+ if use_float:
+ unit_to_ns = SEC_TO_NS / float(unit_to_sec)
+ values = [ns / unit_to_ns for ns in ns_timestamps]
+ else:
+ unit_to_ns = SEC_TO_NS // unit_to_sec
+ values = [ns // unit_to_ns for ns in ns_timestamps]
+
+ if value_filter:
+ values = filter(value_filter, values)
+
+ # remove duplicates and sort
+ return sorted(set(values))
+
+ # test rounding
+ ns_timestamps = self._rounding_values(use_float)
+ valid_values = convert_values(ns_timestamps)
+ for time_rnd, decimal_rnd in ROUNDING_MODES :
+ context = decimal.getcontext()
+ context.rounding = decimal_rnd
+
+ for value in valid_values:
+ debug_info = {'value': value, 'rounding': decimal_rnd}
+ try:
+ result = pytime_converter(value, time_rnd)
+ expected = expected_func(value)
+ except Exception as exc:
+ self.fail("Error on timestamp conversion: %s" % debug_info)
+ self.assertEqual(result,
+ expected,
+ debug_info)
+
+ # test overflow
+ ns = self.OVERFLOW_SECONDS * SEC_TO_NS
+ ns_timestamps = (-ns, ns)
+ overflow_values = convert_values(ns_timestamps)
+ for time_rnd, _ in ROUNDING_MODES :
+ for value in overflow_values:
+ debug_info = {'value': value, 'rounding': time_rnd}
+ with self.assertRaises(OverflowError, msg=debug_info):
+ pytime_converter(value, time_rnd)
+
+ def check_int_rounding(self, pytime_converter, expected_func,
+ unit_to_sec=1, value_filter=None):
+ self._check_rounding(pytime_converter, expected_func,
+ False, unit_to_sec, value_filter)
+
+ def check_float_rounding(self, pytime_converter, expected_func,
+ unit_to_sec=1, value_filter=None):
+ self._check_rounding(pytime_converter, expected_func,
+ True, unit_to_sec, value_filter)
+
+ def decimal_round(self, x):
+ d = decimal.Decimal(x)
+ d = d.quantize(1)
+ return int(d)
+
+
+class TestCPyTime(CPyTimeTestCase, unittest.TestCase):
+ """
+ Test the C _PyTime_t API.
+ """
+ # _PyTime_t is a 64-bit signed integer
+ OVERFLOW_SECONDS = math.ceil((2**63 + 1) / SEC_TO_NS)
+
def test_FromSeconds(self):
from _testcapi import PyTime_FromSeconds
- for seconds in (0, 3, -456, _testcapi.INT_MAX, _testcapi.INT_MIN):
- with self.subTest(seconds=seconds):
- self.assertEqual(PyTime_FromSeconds(seconds),
- seconds * SEC_TO_NS)
+
+ # PyTime_FromSeconds() expects a C int, reject values out of range
+ def c_int_filter(secs):
+ return (_testcapi.INT_MIN <= secs <= _testcapi.INT_MAX)
+
+ self.check_int_rounding(lambda secs, rnd: PyTime_FromSeconds(secs),
+ lambda secs: secs * SEC_TO_NS,
+ value_filter=c_int_filter)
def test_FromSecondsObject(self):
from _testcapi import PyTime_FromSecondsObject
- # Conversion giving the same result for all rounding methods
- for rnd in ALL_ROUNDING_METHODS:
- for obj, ts in (
- # integers
- (0, 0),
- (1, SEC_TO_NS),
- (-3, -3 * SEC_TO_NS),
+ self.check_int_rounding(
+ PyTime_FromSecondsObject,
+ lambda secs: secs * SEC_TO_NS)
- # float: subseconds
- (0.0, 0),
- (1e-9, 1),
- (1e-6, 10 ** 3),
- (1e-3, 10 ** 6),
-
- # float: seconds
- (2.0, 2 * SEC_TO_NS),
- (123.0, 123 * SEC_TO_NS),
- (-7.0, -7 * SEC_TO_NS),
-
- # nanosecond are kept for value <= 2^23 seconds
- (2**22 - 1e-9, 4194303999999999),
- (2**22, 4194304000000000),
- (2**22 + 1e-9, 4194304000000001),
- (2**23 - 1e-9, 8388607999999999),
- (2**23, 8388608000000000),
-
- # start losing precision for value > 2^23 seconds
- (2**23 + 1e-9, 8388608000000002),
-
- # nanoseconds are lost for value > 2^23 seconds
- (2**24 - 1e-9, 16777215999999998),
- (2**24, 16777216000000000),
- (2**24 + 1e-9, 16777216000000000),
- (2**25 - 1e-9, 33554432000000000),
- (2**25 , 33554432000000000),
- (2**25 + 1e-9, 33554432000000000),
-
- # close to 2^63 nanoseconds (_PyTime_t limit)
- (9223372036, 9223372036 * SEC_TO_NS),
- (9223372036.0, 9223372036 * SEC_TO_NS),
- (-9223372036, -9223372036 * SEC_TO_NS),
- (-9223372036.0, -9223372036 * SEC_TO_NS),
- ):
- with self.subTest(obj=obj, round=rnd, timestamp=ts):
- self.assertEqual(PyTime_FromSecondsObject(obj, rnd), ts)
-
- with self.subTest(round=rnd):
- with self.assertRaises(OverflowError):
- PyTime_FromSecondsObject(9223372037, rnd)
- PyTime_FromSecondsObject(9223372037.0, rnd)
- PyTime_FromSecondsObject(-9223372037, rnd)
- PyTime_FromSecondsObject(-9223372037.0, rnd)
-
- # Conversion giving different results depending on the rounding method
- FLOOR = _PyTime.ROUND_FLOOR
- CEILING = _PyTime.ROUND_CEILING
- for obj, ts, rnd in (
- # close to zero
- ( 1e-10, 0, FLOOR),
- ( 1e-10, 1, CEILING),
- (-1e-10, -1, FLOOR),
- (-1e-10, 0, CEILING),
-
- # test rounding of the last nanosecond
- ( 1.1234567899, 1123456789, FLOOR),
- ( 1.1234567899, 1123456790, CEILING),
- (-1.1234567899, -1123456790, FLOOR),
- (-1.1234567899, -1123456789, CEILING),
-
- # close to 1 second
- ( 0.9999999999, 999999999, FLOOR),
- ( 0.9999999999, 1000000000, CEILING),
- (-0.9999999999, -1000000000, FLOOR),
- (-0.9999999999, -999999999, CEILING),
- ):
- with self.subTest(obj=obj, round=rnd, timestamp=ts):
- self.assertEqual(PyTime_FromSecondsObject(obj, rnd), ts)
+ self.check_float_rounding(
+ PyTime_FromSecondsObject,
+ lambda ns: self.decimal_round(ns * SEC_TO_NS))
def test_AsSecondsDouble(self):
from _testcapi import PyTime_AsSecondsDouble
- for nanoseconds, seconds in (
- # near 1 nanosecond
- ( 0, 0.0),
- ( 1, 1e-9),
- (-1, -1e-9),
+ def float_converter(ns):
+ if abs(ns) % SEC_TO_NS == 0:
+ return float(ns // SEC_TO_NS)
+ else:
+ return float(ns) / SEC_TO_NS
- # near 1 second
- (SEC_TO_NS + 1, 1.0 + 1e-9),
- (SEC_TO_NS, 1.0),
- (SEC_TO_NS - 1, 1.0 - 1e-9),
+ self.check_int_rounding(lambda ns, rnd: PyTime_AsSecondsDouble(ns),
+ float_converter,
+ NS_TO_SEC)
- # a few seconds
- (123 * SEC_TO_NS, 123.0),
- (-567 * SEC_TO_NS, -567.0),
+ def create_decimal_converter(self, denominator):
+ denom = decimal.Decimal(denominator)
- # nanosecond are kept for value <= 2^23 seconds
- (4194303999999999, 2**22 - 1e-9),
- (4194304000000000, 2**22),
- (4194304000000001, 2**22 + 1e-9),
+ def converter(value):
+ d = decimal.Decimal(value) / denom
+ return self.decimal_round(d)
- # start losing precision for value > 2^23 seconds
- (8388608000000002, 2**23 + 1e-9),
+ return converter
- # nanoseconds are lost for value > 2^23 seconds
- (16777215999999998, 2**24 - 1e-9),
- (16777215999999999, 2**24 - 1e-9),
- (16777216000000000, 2**24 ),
- (16777216000000001, 2**24 ),
- (16777216000000002, 2**24 + 2e-9),
-
- (33554432000000000, 2**25 ),
- (33554432000000002, 2**25 ),
- (33554432000000004, 2**25 + 4e-9),
-
- # close to 2^63 nanoseconds (_PyTime_t limit)
- (9223372036 * SEC_TO_NS, 9223372036.0),
- (-9223372036 * SEC_TO_NS, -9223372036.0),
- ):
- with self.subTest(nanoseconds=nanoseconds, seconds=seconds):
- self.assertEqual(PyTime_AsSecondsDouble(nanoseconds),
- seconds)
-
- def test_timeval(self):
+ def test_AsTimeval(self):
from _testcapi import PyTime_AsTimeval
- for rnd in ALL_ROUNDING_METHODS:
- for ns, tv in (
- # microseconds
- (0, (0, 0)),
- (1000, (0, 1)),
- (-1000, (-1, 999999)),
- # seconds
- (2 * SEC_TO_NS, (2, 0)),
- (-3 * SEC_TO_NS, (-3, 0)),
- ):
- with self.subTest(nanoseconds=ns, timeval=tv, round=rnd):
- self.assertEqual(PyTime_AsTimeval(ns, rnd), tv)
+ us_converter = self.create_decimal_converter(US_TO_NS)
- FLOOR = _PyTime.ROUND_FLOOR
- CEILING = _PyTime.ROUND_CEILING
- for ns, tv, rnd in (
- # nanoseconds
- (1, (0, 0), FLOOR),
- (1, (0, 1), CEILING),
- (-1, (-1, 999999), FLOOR),
- (-1, (0, 0), CEILING),
+ def timeval_converter(ns):
+ us = us_converter(ns)
+ return divmod(us, SEC_TO_US)
- # seconds + nanoseconds
- (1234567001, (1, 234567), FLOOR),
- (1234567001, (1, 234568), CEILING),
- (-1234567001, (-2, 765432), FLOOR),
- (-1234567001, (-2, 765433), CEILING),
- ):
- with self.subTest(nanoseconds=ns, timeval=tv, round=rnd):
- self.assertEqual(PyTime_AsTimeval(ns, rnd), tv)
+ if sys.platform == 'win32':
+ from _testcapi import LONG_MIN, LONG_MAX
+
+ # On Windows, timeval.tv_sec type is a C long
+ def seconds_filter(secs):
+ return LONG_MIN <= secs <= LONG_MAX
+ else:
+ seconds_filter = self.time_t_filter
+
+ self.check_int_rounding(PyTime_AsTimeval,
+ timeval_converter,
+ NS_TO_SEC,
+ value_filter=seconds_filter)
@unittest.skipUnless(hasattr(_testcapi, 'PyTime_AsTimespec'),
'need _testcapi.PyTime_AsTimespec')
- def test_timespec(self):
+ def test_AsTimespec(self):
from _testcapi import PyTime_AsTimespec
- for ns, ts in (
- # nanoseconds
- (0, (0, 0)),
- (1, (0, 1)),
- (-1, (-1, 999999999)),
- # seconds
- (2 * SEC_TO_NS, (2, 0)),
- (-3 * SEC_TO_NS, (-3, 0)),
+ def timespec_converter(ns):
+ return divmod(ns, SEC_TO_NS)
- # seconds + nanoseconds
- (1234567890, (1, 234567890)),
- (-1234567890, (-2, 765432110)),
- ):
- with self.subTest(nanoseconds=ns, timespec=ts):
- self.assertEqual(PyTime_AsTimespec(ns), ts)
+ self.check_int_rounding(lambda ns, rnd: PyTime_AsTimespec(ns),
+ timespec_converter,
+ NS_TO_SEC,
+ value_filter=self.time_t_filter)
- def test_milliseconds(self):
+ def test_AsMilliseconds(self):
from _testcapi import PyTime_AsMilliseconds
- for rnd in ALL_ROUNDING_METHODS:
- for ns, tv in (
- # milliseconds
- (1 * MS_TO_NS, 1),
- (-2 * MS_TO_NS, -2),
- # seconds
- (2 * SEC_TO_NS, 2000),
- (-3 * SEC_TO_NS, -3000),
- ):
- with self.subTest(nanoseconds=ns, timeval=tv, round=rnd):
- self.assertEqual(PyTime_AsMilliseconds(ns, rnd), tv)
+ self.check_int_rounding(PyTime_AsMilliseconds,
+ self.create_decimal_converter(MS_TO_NS),
+ NS_TO_SEC)
- FLOOR = _PyTime.ROUND_FLOOR
- CEILING = _PyTime.ROUND_CEILING
- for ns, ms, rnd in (
- # nanoseconds
- (1, 0, FLOOR),
- (1, 1, CEILING),
- (-1, -1, FLOOR),
- (-1, 0, CEILING),
-
- # seconds + nanoseconds
- (1234 * MS_TO_NS + 1, 1234, FLOOR),
- (1234 * MS_TO_NS + 1, 1235, CEILING),
- (-1234 * MS_TO_NS - 1, -1235, FLOOR),
- (-1234 * MS_TO_NS - 1, -1234, CEILING),
- ):
- with self.subTest(nanoseconds=ns, milliseconds=ms, round=rnd):
- self.assertEqual(PyTime_AsMilliseconds(ns, rnd), ms)
-
- def test_microseconds(self):
+ def test_AsMicroseconds(self):
from _testcapi import PyTime_AsMicroseconds
- for rnd in ALL_ROUNDING_METHODS:
- for ns, tv in (
- # microseconds
- (1 * US_TO_NS, 1),
- (-2 * US_TO_NS, -2),
- # milliseconds
- (1 * MS_TO_NS, 1000),
- (-2 * MS_TO_NS, -2000),
+ self.check_int_rounding(PyTime_AsMicroseconds,
+ self.create_decimal_converter(US_TO_NS),
+ NS_TO_SEC)
- # seconds
- (2 * SEC_TO_NS, 2000000),
- (-3 * SEC_TO_NS, -3000000),
- ):
- with self.subTest(nanoseconds=ns, timeval=tv, round=rnd):
- self.assertEqual(PyTime_AsMicroseconds(ns, rnd), tv)
- FLOOR = _PyTime.ROUND_FLOOR
- CEILING = _PyTime.ROUND_CEILING
- for ns, ms, rnd in (
- # nanoseconds
- (1, 0, FLOOR),
- (1, 1, CEILING),
- (-1, -1, FLOOR),
- (-1, 0, CEILING),
+class TestOldPyTime(CPyTimeTestCase, unittest.TestCase):
+ """
+ Test the old C _PyTime_t API: _PyTime_ObjectToXXX() functions.
+ """
- # seconds + nanoseconds
- (1234 * US_TO_NS + 1, 1234, FLOOR),
- (1234 * US_TO_NS + 1, 1235, CEILING),
- (-1234 * US_TO_NS - 1, -1235, FLOOR),
- (-1234 * US_TO_NS - 1, -1234, CEILING),
- ):
- with self.subTest(nanoseconds=ns, milliseconds=ms, round=rnd):
- self.assertEqual(PyTime_AsMicroseconds(ns, rnd), ms)
+ # time_t is a 32-bit or 64-bit signed integer
+ OVERFLOW_SECONDS = 2 ** 64
+
+ def test_object_to_time_t(self):
+ from _testcapi import pytime_object_to_time_t
+
+ self.check_int_rounding(pytime_object_to_time_t,
+ lambda secs: secs,
+ value_filter=self.time_t_filter)
+
+ self.check_float_rounding(pytime_object_to_time_t,
+ self.decimal_round,
+ value_filter=self.time_t_filter)
+
+ def create_converter(self, sec_to_unit):
+ def converter(secs):
+ floatpart, intpart = math.modf(secs)
+ intpart = int(intpart)
+ floatpart *= sec_to_unit
+ floatpart = self.decimal_round(floatpart)
+ if floatpart < 0:
+ floatpart += sec_to_unit
+ intpart -= 1
+ elif floatpart >= sec_to_unit:
+ floatpart -= sec_to_unit
+ intpart += 1
+ return (intpart, floatpart)
+ return converter
+
+ def test_object_to_timeval(self):
+ from _testcapi import pytime_object_to_timeval
+
+ self.check_int_rounding(pytime_object_to_timeval,
+ lambda secs: (secs, 0),
+ value_filter=self.time_t_filter)
+
+ self.check_float_rounding(pytime_object_to_timeval,
+ self.create_converter(SEC_TO_US),
+ value_filter=self.time_t_filter)
+
+ def test_object_to_timespec(self):
+ from _testcapi import pytime_object_to_timespec
+
+ self.check_int_rounding(pytime_object_to_timespec,
+ lambda secs: (secs, 0),
+ value_filter=self.time_t_filter)
+
+ self.check_float_rounding(pytime_object_to_timespec,
+ self.create_converter(SEC_TO_NS),
+ value_filter=self.time_t_filter)
if __name__ == "__main__":
diff --git a/Lib/test/test_tokenize.py b/Lib/test/test_tokenize.py
index 3b17ca6..90438e7 100644
--- a/Lib/test/test_tokenize.py
+++ b/Lib/test/test_tokenize.py
@@ -24,8 +24,7 @@
if type == ENDMARKER:
break
type = tok_name[type]
- result.append(" %(type)-10.10s %(token)-13.13r %(start)s %(end)s" %
- locals())
+ result.append(f" {type:10} {token!r:13} {start} {end}")
self.assertEqual(result,
[" ENCODING 'utf-8' (0, 0) (0, 0)"] +
expected.rstrip().splitlines())
@@ -132,18 +131,18 @@
self.check_tokenize("x = 0xfffffffffff", """\
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
- NUMBER '0xffffffffff (1, 4) (1, 17)
+ NUMBER '0xfffffffffff' (1, 4) (1, 17)
""")
self.check_tokenize("x = 123141242151251616110", """\
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
- NUMBER '123141242151 (1, 4) (1, 25)
+ NUMBER '123141242151251616110' (1, 4) (1, 25)
""")
self.check_tokenize("x = -15921590215012591", """\
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
OP '-' (1, 4) (1, 5)
- NUMBER '159215902150 (1, 5) (1, 22)
+ NUMBER '15921590215012591' (1, 5) (1, 22)
""")
def test_float(self):
@@ -307,6 +306,50 @@
OP '+' (1, 28) (1, 29)
STRING 'RB"abc"' (1, 30) (1, 37)
""")
+ # Check 0, 1, and 2 character string prefixes.
+ self.check_tokenize(r'"a\
+de\
+fg"', """\
+ STRING '"a\\\\\\nde\\\\\\nfg"\' (1, 0) (3, 3)
+ """)
+ self.check_tokenize(r'u"a\
+de"', """\
+ STRING 'u"a\\\\\\nde"\' (1, 0) (2, 3)
+ """)
+ self.check_tokenize(r'rb"a\
+d"', """\
+ STRING 'rb"a\\\\\\nd"\' (1, 0) (2, 2)
+ """)
+ self.check_tokenize(r'"""a\
+b"""', """\
+ STRING '\"\""a\\\\\\nb\"\""' (1, 0) (2, 4)
+ """)
+ self.check_tokenize(r'u"""a\
+b"""', """\
+ STRING 'u\"\""a\\\\\\nb\"\""' (1, 0) (2, 4)
+ """)
+ self.check_tokenize(r'rb"""a\
+b\
+c"""', """\
+ STRING 'rb"\""a\\\\\\nb\\\\\\nc"\""' (1, 0) (3, 4)
+ """)
+ self.check_tokenize('f"abc"', """\
+ STRING 'f"abc"' (1, 0) (1, 6)
+ """)
+ self.check_tokenize('fR"a{b}c"', """\
+ STRING 'fR"a{b}c"' (1, 0) (1, 9)
+ """)
+ self.check_tokenize('f"""abc"""', """\
+ STRING 'f\"\"\"abc\"\"\"' (1, 0) (1, 10)
+ """)
+ self.check_tokenize(r'f"abc\
+def"', """\
+ STRING 'f"abc\\\\\\ndef"' (1, 0) (2, 4)
+ """)
+ self.check_tokenize(r'Rf"abc\
+def"', """\
+ STRING 'Rf"abc\\\\\\ndef"' (1, 0) (2, 4)
+ """)
def test_function(self):
self.check_tokenize("def d22(a, b, c=2, d=2, *k): pass", """\
@@ -505,7 +548,7 @@
# Methods
self.check_tokenize("@staticmethod\ndef foo(x,y): pass", """\
OP '@' (1, 0) (1, 1)
- NAME 'staticmethod (1, 1) (1, 13)
+ NAME 'staticmethod' (1, 1) (1, 13)
NEWLINE '\\n' (1, 13) (1, 14)
NAME 'def' (2, 0) (2, 3)
NAME 'foo' (2, 4) (2, 7)
diff --git a/Lib/test/test_tools/__init__.py b/Lib/test/test_tools/__init__.py
index 04c8726..4d0fca3 100644
--- a/Lib/test/test_tools/__init__.py
+++ b/Lib/test/test_tools/__init__.py
@@ -3,7 +3,6 @@
import unittest
import importlib
from test import support
-from fnmatch import fnmatch
basepath = os.path.dirname( # <src/install dir>
os.path.dirname( # Lib
diff --git a/Lib/test/test_tools/test_gprof2html.py b/Lib/test/test_tools/test_gprof2html.py
index 0c294ec..9489ed9 100644
--- a/Lib/test/test_tools/test_gprof2html.py
+++ b/Lib/test/test_tools/test_gprof2html.py
@@ -2,12 +2,11 @@
import os
import sys
-import importlib
import unittest
from unittest import mock
import tempfile
-from test.test_tools import scriptsdir, skip_if_missing, import_tool
+from test.test_tools import skip_if_missing, import_tool
skip_if_missing()
diff --git a/Lib/test/test_tools/test_md5sum.py b/Lib/test/test_tools/test_md5sum.py
index 1305295..fb565b7 100644
--- a/Lib/test/test_tools/test_md5sum.py
+++ b/Lib/test/test_tools/test_md5sum.py
@@ -1,12 +1,11 @@
"""Tests for the md5sum script in the Tools directory."""
import os
-import sys
import unittest
from test import support
from test.support.script_helper import assert_python_ok, assert_python_failure
-from test.test_tools import scriptsdir, import_tool, skip_if_missing
+from test.test_tools import scriptsdir, skip_if_missing
skip_if_missing()
diff --git a/Lib/test/test_tools/test_pdeps.py b/Lib/test/test_tools/test_pdeps.py
index 091fa6a..27cbfe2 100644
--- a/Lib/test/test_tools/test_pdeps.py
+++ b/Lib/test/test_tools/test_pdeps.py
@@ -1,12 +1,10 @@
"""Tests for the pdeps script in the Tools directory."""
import os
-import sys
import unittest
import tempfile
-from test import support
-from test.test_tools import scriptsdir, skip_if_missing, import_tool
+from test.test_tools import skip_if_missing, import_tool
skip_if_missing()
diff --git a/Lib/test/test_tools/test_unparse.py b/Lib/test/test_tools/test_unparse.py
index 734bbc2..d91ade9 100644
--- a/Lib/test/test_tools/test_unparse.py
+++ b/Lib/test/test_tools/test_unparse.py
@@ -134,6 +134,15 @@
class UnparseTestCase(ASTTestCase):
# Tests for specific bugs found in earlier versions of unparse
+ def test_fstrings(self):
+ # See issue 25180
+ self.check_roundtrip(r"""f'{f"{0}"*3}'""")
+ self.check_roundtrip(r"""f'{f"{y}"*3}'""")
+ self.check_roundtrip(r"""f'{f"{\'x\'}"*3}'""")
+
+ self.check_roundtrip(r'''f"{r'x' f'{\"s\"}'}"''')
+ self.check_roundtrip(r'''f"{r'x'rf'{\"s\"}'}"''')
+
def test_del_statement(self):
self.check_roundtrip("del x, y, z")
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py
index 03dff84..1d894aa 100644
--- a/Lib/test/test_trace.py
+++ b/Lib/test/test_trace.py
@@ -1,11 +1,11 @@
import os
-import io
import sys
from test.support import TESTFN, rmtree, unlink, captured_stdout
+from test.support.script_helper import assert_python_ok, assert_python_failure
import unittest
import trace
-from trace import CoverageResults, Trace
+from trace import Trace
from test.tracedmodules import testmod
@@ -365,51 +365,27 @@
# Matched before.
self.assertTrue(ignore.names(jn('bar', 'baz.py'), 'baz'))
+class TestCommandLine(unittest.TestCase):
-class TestDeprecatedMethods(unittest.TestCase):
+ def test_failures(self):
+ _errors = (
+ (b'filename is missing: required with the main options', '-l', '-T'),
+ (b'cannot specify both --listfuncs and (--trace or --count)', '-lc'),
+ (b'argument -R/--no-report: not allowed with argument -r/--report', '-rR'),
+ (b'must specify one of --trace, --count, --report, --listfuncs, or --trackcalls', '-g'),
+ (b'-r/--report requires -f/--file', '-r'),
+ (b'--summary can only be used with --count or --report', '-sT'),
+ (b'unrecognized arguments: -y', '-y'))
+ for message, *args in _errors:
+ *_, stderr = assert_python_failure('-m', 'trace', *args)
+ self.assertIn(message, stderr)
- def test_deprecated_usage(self):
- sio = io.StringIO()
- with self.assertWarns(DeprecationWarning):
- trace.usage(sio)
- self.assertIn('Usage:', sio.getvalue())
-
- def test_deprecated_Ignore(self):
- with self.assertWarns(DeprecationWarning):
- trace.Ignore()
-
- def test_deprecated_modname(self):
- with self.assertWarns(DeprecationWarning):
- self.assertEqual("spam", trace.modname("spam"))
-
- def test_deprecated_fullmodname(self):
- with self.assertWarns(DeprecationWarning):
- self.assertEqual("spam", trace.fullmodname("spam"))
-
- def test_deprecated_find_lines_from_code(self):
- with self.assertWarns(DeprecationWarning):
- def foo():
- pass
- trace.find_lines_from_code(foo.__code__, ["eggs"])
-
- def test_deprecated_find_lines(self):
- with self.assertWarns(DeprecationWarning):
- def foo():
- pass
- trace.find_lines(foo.__code__, ["eggs"])
-
- def test_deprecated_find_strings(self):
+ def test_listfuncs_flag_success(self):
with open(TESTFN, 'w') as fd:
self.addCleanup(unlink, TESTFN)
- with self.assertWarns(DeprecationWarning):
- trace.find_strings(fd.name)
-
- def test_deprecated_find_executable_linenos(self):
- with open(TESTFN, 'w') as fd:
- self.addCleanup(unlink, TESTFN)
- with self.assertWarns(DeprecationWarning):
- trace.find_executable_linenos(fd.name)
-
+ fd.write("a = 1\n")
+ status, stdout, stderr = assert_python_ok('-m', 'trace', '-l', TESTFN)
+ self.assertIn(b'functions called:', stdout)
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index b7695d6..5e4b6a2 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -129,12 +129,12 @@
def do_test(firstlines, message, charset, lineno):
# Raise the message in a subprocess, and catch the output
try:
- output = open(TESTFN, "w", encoding=charset)
- output.write("""{0}if 1:
- import traceback;
- raise RuntimeError('{1}')
- """.format(firstlines, message))
- output.close()
+ with open(TESTFN, "w", encoding=charset) as output:
+ output.write("""{0}if 1:
+ import traceback;
+ raise RuntimeError('{1}')
+ """.format(firstlines, message))
+
process = subprocess.Popen([sys.executable, TESTFN],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
stdout, stderr = process.communicate()
@@ -175,8 +175,8 @@
text, charset, 5)
do_test(" \t\f\n# coding: {0}\n".format(charset),
text, charset, 5)
- # Issue #18960: coding spec should has no effect
- do_test("0\n# coding: GBK\n", "h\xe9 ho", 'utf-8', 5)
+ # Issue #18960: coding spec should have no effect
+ do_test("x=0\n# coding: GBK\n", "h\xe9 ho", 'utf-8', 5)
def test_print_traceback_at_exit(self):
# Issue #22599: Ensure that it is possible to use the traceback module
diff --git a/Lib/test/test_tracemalloc.py b/Lib/test/test_tracemalloc.py
index da89a9a..790ab7e 100644
--- a/Lib/test/test_tracemalloc.py
+++ b/Lib/test/test_tracemalloc.py
@@ -11,9 +11,15 @@
import threading
except ImportError:
threading = None
+try:
+ import _testcapi
+except ImportError:
+ _testcapi = None
+
EMPTY_STRING_SIZE = sys.getsizeof(b'')
+
def get_frames(nframe, lineno_delta):
frames = []
frame = sys._getframe(1)
@@ -37,28 +43,31 @@
def create_snapshots():
traceback_limit = 2
+ # _tracemalloc._get_traces() returns a list of (domain, size,
+ # traceback_frames) tuples. traceback_frames is a tuple of (filename,
+ # line_number) tuples.
raw_traces = [
- (10, (('a.py', 2), ('b.py', 4))),
- (10, (('a.py', 2), ('b.py', 4))),
- (10, (('a.py', 2), ('b.py', 4))),
+ (0, 10, (('a.py', 2), ('b.py', 4))),
+ (0, 10, (('a.py', 2), ('b.py', 4))),
+ (0, 10, (('a.py', 2), ('b.py', 4))),
- (2, (('a.py', 5), ('b.py', 4))),
+ (1, 2, (('a.py', 5), ('b.py', 4))),
- (66, (('b.py', 1),)),
+ (2, 66, (('b.py', 1),)),
- (7, (('<unknown>', 0),)),
+ (3, 7, (('<unknown>', 0),)),
]
snapshot = tracemalloc.Snapshot(raw_traces, traceback_limit)
raw_traces2 = [
- (10, (('a.py', 2), ('b.py', 4))),
- (10, (('a.py', 2), ('b.py', 4))),
- (10, (('a.py', 2), ('b.py', 4))),
+ (0, 10, (('a.py', 2), ('b.py', 4))),
+ (0, 10, (('a.py', 2), ('b.py', 4))),
+ (0, 10, (('a.py', 2), ('b.py', 4))),
- (2, (('a.py', 5), ('b.py', 4))),
- (5000, (('a.py', 5), ('b.py', 4))),
+ (2, 2, (('a.py', 5), ('b.py', 4))),
+ (2, 5000, (('a.py', 5), ('b.py', 4))),
- (400, (('c.py', 578),)),
+ (4, 400, (('c.py', 578),)),
]
snapshot2 = tracemalloc.Snapshot(raw_traces2, traceback_limit)
@@ -126,7 +135,7 @@
def find_trace(self, traces, traceback):
for trace in traces:
- if trace[1] == traceback._frames:
+ if trace[2] == traceback._frames:
return trace
self.fail("trace not found")
@@ -140,7 +149,7 @@
trace = self.find_trace(traces, obj_traceback)
self.assertIsInstance(trace, tuple)
- size, traceback = trace
+ domain, size, traceback = trace
self.assertEqual(size, obj_size)
self.assertEqual(traceback, obj_traceback._frames)
@@ -167,9 +176,8 @@
trace1 = self.find_trace(traces, obj1_traceback)
trace2 = self.find_trace(traces, obj2_traceback)
- size1, traceback1 = trace1
- size2, traceback2 = trace2
- self.assertEqual(traceback2, traceback1)
+ domain1, size1, traceback1 = trace1
+ domain2, size2, traceback2 = trace2
self.assertIs(traceback2, traceback1)
def test_get_traced_memory(self):
@@ -292,7 +300,7 @@
maxDiff = 4000
def test_create_snapshot(self):
- raw_traces = [(5, (('a.py', 2),))]
+ raw_traces = [(0, 5, (('a.py', 2),))]
with contextlib.ExitStack() as stack:
stack.enter_context(patch.object(tracemalloc, 'is_tracing',
@@ -322,11 +330,11 @@
# exclude b.py
snapshot3 = snapshot.filter_traces((filter1,))
self.assertEqual(snapshot3.traces._traces, [
- (10, (('a.py', 2), ('b.py', 4))),
- (10, (('a.py', 2), ('b.py', 4))),
- (10, (('a.py', 2), ('b.py', 4))),
- (2, (('a.py', 5), ('b.py', 4))),
- (7, (('<unknown>', 0),)),
+ (0, 10, (('a.py', 2), ('b.py', 4))),
+ (0, 10, (('a.py', 2), ('b.py', 4))),
+ (0, 10, (('a.py', 2), ('b.py', 4))),
+ (1, 2, (('a.py', 5), ('b.py', 4))),
+ (3, 7, (('<unknown>', 0),)),
])
# filter_traces() must not touch the original snapshot
@@ -335,10 +343,10 @@
# only include two lines of a.py
snapshot4 = snapshot3.filter_traces((filter2, filter3))
self.assertEqual(snapshot4.traces._traces, [
- (10, (('a.py', 2), ('b.py', 4))),
- (10, (('a.py', 2), ('b.py', 4))),
- (10, (('a.py', 2), ('b.py', 4))),
- (2, (('a.py', 5), ('b.py', 4))),
+ (0, 10, (('a.py', 2), ('b.py', 4))),
+ (0, 10, (('a.py', 2), ('b.py', 4))),
+ (0, 10, (('a.py', 2), ('b.py', 4))),
+ (1, 2, (('a.py', 5), ('b.py', 4))),
])
# No filter: just duplicate the snapshot
@@ -349,6 +357,54 @@
self.assertRaises(TypeError, snapshot.filter_traces, filter1)
+ def test_filter_traces_domain(self):
+ snapshot, snapshot2 = create_snapshots()
+ filter1 = tracemalloc.Filter(False, "a.py", domain=1)
+ filter2 = tracemalloc.Filter(True, "a.py", domain=1)
+
+ original_traces = list(snapshot.traces._traces)
+
+ # exclude a.py of domain 1
+ snapshot3 = snapshot.filter_traces((filter1,))
+ self.assertEqual(snapshot3.traces._traces, [
+ (0, 10, (('a.py', 2), ('b.py', 4))),
+ (0, 10, (('a.py', 2), ('b.py', 4))),
+ (0, 10, (('a.py', 2), ('b.py', 4))),
+ (2, 66, (('b.py', 1),)),
+ (3, 7, (('<unknown>', 0),)),
+ ])
+
+ # include domain 1
+ snapshot3 = snapshot.filter_traces((filter1,))
+ self.assertEqual(snapshot3.traces._traces, [
+ (0, 10, (('a.py', 2), ('b.py', 4))),
+ (0, 10, (('a.py', 2), ('b.py', 4))),
+ (0, 10, (('a.py', 2), ('b.py', 4))),
+ (2, 66, (('b.py', 1),)),
+ (3, 7, (('<unknown>', 0),)),
+ ])
+
+ def test_filter_traces_domain_filter(self):
+ snapshot, snapshot2 = create_snapshots()
+ filter1 = tracemalloc.DomainFilter(False, domain=3)
+ filter2 = tracemalloc.DomainFilter(True, domain=3)
+
+ # exclude domain 2
+ snapshot3 = snapshot.filter_traces((filter1,))
+ self.assertEqual(snapshot3.traces._traces, [
+ (0, 10, (('a.py', 2), ('b.py', 4))),
+ (0, 10, (('a.py', 2), ('b.py', 4))),
+ (0, 10, (('a.py', 2), ('b.py', 4))),
+ (1, 2, (('a.py', 5), ('b.py', 4))),
+ (2, 66, (('b.py', 1),)),
+ ])
+
+ # include domain 2
+ snapshot3 = snapshot.filter_traces((filter2,))
+ self.assertEqual(snapshot3.traces._traces, [
+ (3, 7, (('<unknown>', 0),)),
+ ])
+
def test_snapshot_group_by_line(self):
snapshot, snapshot2 = create_snapshots()
tb_0 = traceback_lineno('<unknown>', 0)
@@ -816,12 +872,121 @@
assert_python_ok('-X', 'tracemalloc', '-c', code)
+@unittest.skipIf(_testcapi is None, 'need _testcapi')
+class TestCAPI(unittest.TestCase):
+ maxDiff = 80 * 20
+
+ def setUp(self):
+ if tracemalloc.is_tracing():
+ self.skipTest("tracemalloc must be stopped before the test")
+
+ self.domain = 5
+ self.size = 123
+ self.obj = allocate_bytes(self.size)[0]
+
+ # for the type "object", id(obj) is the address of its memory block.
+ # This type is not tracked by the garbage collector
+ self.ptr = id(self.obj)
+
+ def tearDown(self):
+ tracemalloc.stop()
+
+ def get_traceback(self):
+ frames = _testcapi.tracemalloc_get_traceback(self.domain, self.ptr)
+ if frames is not None:
+ return tracemalloc.Traceback(frames)
+ else:
+ return None
+
+ def track(self, release_gil=False, nframe=1):
+ frames = get_frames(nframe, 2)
+ _testcapi.tracemalloc_track(self.domain, self.ptr, self.size,
+ release_gil)
+ return frames
+
+ def untrack(self):
+ _testcapi.tracemalloc_untrack(self.domain, self.ptr)
+
+ def get_traced_memory(self):
+ # Get the traced size in the domain
+ snapshot = tracemalloc.take_snapshot()
+ domain_filter = tracemalloc.DomainFilter(True, self.domain)
+ snapshot = snapshot.filter_traces([domain_filter])
+ return sum(trace.size for trace in snapshot.traces)
+
+ def check_track(self, release_gil):
+ nframe = 5
+ tracemalloc.start(nframe)
+
+ size = tracemalloc.get_traced_memory()[0]
+
+ frames = self.track(release_gil, nframe)
+ self.assertEqual(self.get_traceback(),
+ tracemalloc.Traceback(frames))
+
+ self.assertEqual(self.get_traced_memory(), self.size)
+
+ def test_track(self):
+ self.check_track(False)
+
+ def test_track_without_gil(self):
+ # check that calling _PyTraceMalloc_Track() without holding the GIL
+ # works too
+ self.check_track(True)
+
+ def test_track_already_tracked(self):
+ nframe = 5
+ tracemalloc.start(nframe)
+
+ # track a first time
+ self.track()
+
+ # calling _PyTraceMalloc_Track() must remove the old trace and add
+ # a new trace with the new traceback
+ frames = self.track(nframe=nframe)
+ self.assertEqual(self.get_traceback(),
+ tracemalloc.Traceback(frames))
+
+ def test_untrack(self):
+ tracemalloc.start()
+
+ self.track()
+ self.assertIsNotNone(self.get_traceback())
+ self.assertEqual(self.get_traced_memory(), self.size)
+
+ # untrack must remove the trace
+ self.untrack()
+ self.assertIsNone(self.get_traceback())
+ self.assertEqual(self.get_traced_memory(), 0)
+
+ # calling _PyTraceMalloc_Untrack() multiple times must not crash
+ self.untrack()
+ self.untrack()
+
+ def test_stop_track(self):
+ tracemalloc.start()
+ tracemalloc.stop()
+
+ with self.assertRaises(RuntimeError):
+ self.track()
+ self.assertIsNone(self.get_traceback())
+
+ def test_stop_untrack(self):
+ tracemalloc.start()
+ self.track()
+
+ tracemalloc.stop()
+ with self.assertRaises(RuntimeError):
+ self.untrack()
+
+
def test_main():
support.run_unittest(
TestTracemallocEnabled,
TestSnapshot,
TestFilters,
TestCommandLine,
+ TestCAPI,
)
if __name__ == "__main__":
diff --git a/Lib/test/test_ttk_guionly.py b/Lib/test/test_ttk_guionly.py
index 490e723..462665d 100644
--- a/Lib/test/test_ttk_guionly.py
+++ b/Lib/test/test_ttk_guionly.py
@@ -1,4 +1,3 @@
-import os
import unittest
from test import support
diff --git a/Lib/test/test_ttk_textonly.py b/Lib/test/test_ttk_textonly.py
index 566fc9d..7540a43 100644
--- a/Lib/test/test_ttk_textonly.py
+++ b/Lib/test/test_ttk_textonly.py
@@ -1,4 +1,3 @@
-import os
from test import support
# Skip this test if _tkinter does not exist.
diff --git a/Lib/test/test_unpack.py b/Lib/test/test_unpack.py
index d1ccb38..3fcb18f 100644
--- a/Lib/test/test_unpack.py
+++ b/Lib/test/test_unpack.py
@@ -117,6 +117,27 @@
...
test.test_unpack.BozoError
+Allow unpacking empty iterables
+
+ >>> () = []
+ >>> [] = ()
+ >>> [] = []
+ >>> () = ()
+
+Unpacking non-iterables should raise TypeError
+
+ >>> () = 42
+ Traceback (most recent call last):
+ ...
+ TypeError: 'int' object is not iterable
+
+Unpacking to an empty iterable should raise ValueError
+
+ >>> () = [42]
+ Traceback (most recent call last):
+ ...
+ ValueError: too many values to unpack (expected 0)
+
"""
__test__ = {'doctests' : doctests}
diff --git a/Lib/test/test_unpack_ex.py b/Lib/test/test_unpack_ex.py
index 74346b4..6be8f55 100644
--- a/Lib/test/test_unpack_ex.py
+++ b/Lib/test/test_unpack_ex.py
@@ -357,7 +357,6 @@
__test__ = {'doctests' : doctests}
def test_main(verbose=False):
- import sys
from test import support
from test import test_unpack_ex
support.run_doctest(test_unpack_ex, verbose)
diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py
index c8b37ee..e9564fd 100644
--- a/Lib/test/test_urllib2_localnet.py
+++ b/Lib/test/test_urllib2_localnet.py
@@ -289,12 +289,12 @@
def http_server_with_basic_auth_handler(*args, **kwargs):
return BasicAuthHandler(*args, **kwargs)
self.server = LoopbackHttpServerThread(http_server_with_basic_auth_handler)
+ self.addCleanup(self.server.stop)
self.server_url = 'http://127.0.0.1:%s' % self.server.port
self.server.start()
self.server.ready.wait()
def tearDown(self):
- self.server.stop()
super(BasicAuthTests, self).tearDown()
def test_basic_auth_success(self):
@@ -438,17 +438,13 @@
def setUp(self):
super(TestUrlopen, self).setUp()
- # Ignore proxies for localhost tests.
- self.old_environ = os.environ.copy()
- os.environ['NO_PROXY'] = '*'
- self.server = None
- def tearDown(self):
- if self.server is not None:
- self.server.stop()
- os.environ.clear()
- os.environ.update(self.old_environ)
- super(TestUrlopen, self).tearDown()
+ # Ignore proxies for localhost tests.
+ def restore_environ(old_environ):
+ os.environ.clear()
+ os.environ.update(old_environ)
+ self.addCleanup(restore_environ, os.environ.copy())
+ os.environ['NO_PROXY'] = '*'
def urlopen(self, url, data=None, **kwargs):
l = []
@@ -469,6 +465,7 @@
handler = GetRequestHandler(responses)
self.server = LoopbackHttpServerThread(handler)
+ self.addCleanup(self.server.stop)
self.server.start()
self.server.ready.wait()
port = self.server.port
@@ -592,7 +589,8 @@
handler = self.start_server()
req = urllib.request.Request("http://localhost:%s/" % handler.port,
headers={"Range": "bytes=20-39"})
- urllib.request.urlopen(req)
+ with urllib.request.urlopen(req):
+ pass
self.assertEqual(handler.headers_received["Range"], "bytes=20-39")
def test_basic(self):
@@ -608,22 +606,21 @@
def test_info(self):
handler = self.start_server()
- try:
- open_url = urllib.request.urlopen(
- "http://localhost:%s" % handler.port)
+ open_url = urllib.request.urlopen(
+ "http://localhost:%s" % handler.port)
+ with open_url:
info_obj = open_url.info()
- self.assertIsInstance(info_obj, email.message.Message,
- "object returned by 'info' is not an "
- "instance of email.message.Message")
- self.assertEqual(info_obj.get_content_subtype(), "plain")
- finally:
- self.server.stop()
+ self.assertIsInstance(info_obj, email.message.Message,
+ "object returned by 'info' is not an "
+ "instance of email.message.Message")
+ self.assertEqual(info_obj.get_content_subtype(), "plain")
def test_geturl(self):
# Make sure same URL as opened is returned by geturl.
handler = self.start_server()
open_url = urllib.request.urlopen("http://localhost:%s" % handler.port)
- url = open_url.geturl()
+ with open_url:
+ url = open_url.geturl()
self.assertEqual(url, "http://localhost:%s" % handler.port)
def test_iteration(self):
diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py
index b811930..949716c 100644
--- a/Lib/test/test_urllibnet.py
+++ b/Lib/test/test_urllibnet.py
@@ -4,7 +4,6 @@
import contextlib
import socket
import urllib.request
-import sys
import os
import email.message
import time
diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py
index 829997f..9165d73 100644
--- a/Lib/test/test_urlparse.py
+++ b/Lib/test/test_urlparse.py
@@ -605,29 +605,27 @@
self.assertEqual(p.port, 80)
self.assertEqual(p.geturl(), url)
- # Verify an illegal port is returned as None
+ # Verify an illegal port raises ValueError
url = b"HTTP://WWW.PYTHON.ORG:65536/doc/#frag"
p = urllib.parse.urlsplit(url)
- self.assertEqual(p.port, None)
+ with self.assertRaisesRegex(ValueError, "out of range"):
+ p.port
def test_attributes_bad_port(self):
- """Check handling of non-integer ports."""
- p = urllib.parse.urlsplit("http://www.example.net:foo")
- self.assertEqual(p.netloc, "www.example.net:foo")
- self.assertRaises(ValueError, lambda: p.port)
-
- p = urllib.parse.urlparse("http://www.example.net:foo")
- self.assertEqual(p.netloc, "www.example.net:foo")
- self.assertRaises(ValueError, lambda: p.port)
-
- # Once again, repeat ourselves to test bytes
- p = urllib.parse.urlsplit(b"http://www.example.net:foo")
- self.assertEqual(p.netloc, b"www.example.net:foo")
- self.assertRaises(ValueError, lambda: p.port)
-
- p = urllib.parse.urlparse(b"http://www.example.net:foo")
- self.assertEqual(p.netloc, b"www.example.net:foo")
- self.assertRaises(ValueError, lambda: p.port)
+ """Check handling of invalid ports."""
+ for bytes in (False, True):
+ for parse in (urllib.parse.urlsplit, urllib.parse.urlparse):
+ for port in ("foo", "1.5", "-1", "0x10"):
+ with self.subTest(bytes=bytes, parse=parse, port=port):
+ netloc = "www.example.net:" + port
+ url = "http://" + netloc
+ if bytes:
+ netloc = netloc.encode("ascii")
+ url = url.encode("ascii")
+ p = parse(url)
+ self.assertEqual(p.netloc, netloc)
+ with self.assertRaises(ValueError):
+ p.port
def test_attributes_without_netloc(self):
# This example is straight from RFC 3261. It looks like it
diff --git a/Lib/test/test_userdict.py b/Lib/test/test_userdict.py
index 8357f8b..662c7f6 100644
--- a/Lib/test/test_userdict.py
+++ b/Lib/test/test_userdict.py
@@ -1,6 +1,6 @@
# Check every path through every method of UserDict
-from test import support, mapping_tests
+from test import mapping_tests
import unittest
import collections
@@ -30,7 +30,7 @@
self.assertEqual(collections.UserDict(one=1, two=2), d2)
# item sequence constructor
self.assertEqual(collections.UserDict([('one',1), ('two',2)]), d2)
- with self.assertWarnsRegex(PendingDeprecationWarning, "'dict'"):
+ with self.assertWarnsRegex(DeprecationWarning, "'dict'"):
self.assertEqual(collections.UserDict(dict=[('one',1), ('two',2)]), d2)
# both together
self.assertEqual(collections.UserDict([('one',1), ('two',2)], two=3, three=5), d3)
@@ -149,7 +149,7 @@
[('dict', 42)])
self.assertEqual(list(collections.UserDict({}, dict=None).items()),
[('dict', None)])
- with self.assertWarnsRegex(PendingDeprecationWarning, "'dict'"):
+ with self.assertWarnsRegex(DeprecationWarning, "'dict'"):
self.assertEqual(list(collections.UserDict(dict={'a': 42}).items()),
[('a', 42)])
self.assertRaises(TypeError, collections.UserDict, 42)
diff --git a/Lib/test/test_userlist.py b/Lib/test/test_userlist.py
index f92e4d3..8de6c14 100644
--- a/Lib/test/test_userlist.py
+++ b/Lib/test/test_userlist.py
@@ -1,7 +1,7 @@
# Check every path through every method of UserList
from collections import UserList
-from test import support, list_tests
+from test import list_tests
import unittest
class UserListTest(list_tests.CommonTest):
diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py
index 9bc8edd..7152822 100644
--- a/Lib/test/test_userstring.py
+++ b/Lib/test/test_userstring.py
@@ -1,9 +1,8 @@
# UserString is a wrapper around the native builtin string type.
# UserString instances should behave similar to builtin string objects.
-import string
import unittest
-from test import support, string_tests
+from test import string_tests
from collections import UserString
diff --git a/Lib/test/test_uu.py b/Lib/test/test_uu.py
index 25fffbf..ad2f2c5 100644
--- a/Lib/test/test_uu.py
+++ b/Lib/test/test_uu.py
@@ -8,7 +8,6 @@
import sys, os
import uu
-from io import BytesIO
import io
plaintext = b"The smooth-scaled python crept over the sleeping dog\n"
diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py
index d2c986e..a2842b0 100644
--- a/Lib/test/test_venv.py
+++ b/Lib/test/test_venv.py
@@ -15,7 +15,6 @@
import tempfile
from test.support import (captured_stdout, captured_stderr,
can_symlink, EnvironmentVarGuard, rmtree)
-import textwrap
import unittest
import venv
@@ -31,18 +30,17 @@
except ImportError:
threading = None
+try:
+ import ctypes
+except ImportError:
+ ctypes = None
+
skipInVenv = unittest.skipIf(sys.prefix != sys.base_prefix,
'Test not appropriate in a venv')
-# os.path.exists('nul') is False: http://bugs.python.org/issue20541
-if os.devnull.lower() == 'nul':
- failsOnWindows = unittest.expectedFailure
-else:
- def failsOnWindows(f):
- return f
-
class BaseTest(unittest.TestCase):
"""Base class for venv tests."""
+ maxDiff = 80 * 50
def setUp(self):
self.env_dir = os.path.realpath(tempfile.mkdtemp())
@@ -52,7 +50,7 @@
self.include = 'Include'
else:
self.bindir = 'bin'
- self.lib = ('lib', 'python%s' % sys.version[:3])
+ self.lib = ('lib', 'python%d.%d' % sys.version_info[:2])
self.include = 'include'
if sys.platform == 'darwin' and '__PYVENV_LAUNCHER__' in os.environ:
executable = os.environ['__PYVENV_LAUNCHER__']
@@ -313,20 +311,27 @@
self.run_with_capture(venv.create, self.env_dir, with_pip=False)
self.assert_pip_not_installed()
- @failsOnWindows
- def test_devnull_exists_and_is_empty(self):
+ def test_devnull(self):
# Fix for issue #20053 uses os.devnull to force a config file to
# appear empty. However http://bugs.python.org/issue20541 means
# that doesn't currently work properly on Windows. Once that is
# fixed, the "win_location" part of test_with_pip should be restored
- self.assertTrue(os.path.exists(os.devnull))
with open(os.devnull, "rb") as f:
self.assertEqual(f.read(), b"")
+ # Issue #20541: os.path.exists('nul') is False on Windows
+ if os.devnull.lower() == 'nul':
+ self.assertFalse(os.path.exists(os.devnull))
+ else:
+ self.assertTrue(os.path.exists(os.devnull))
+
+
# Requesting pip fails without SSL (http://bugs.python.org/issue19744)
@unittest.skipIf(ssl is None, ensurepip._MISSING_SSL_MESSAGE)
@unittest.skipUnless(threading, 'some dependencies of pip import threading'
' module unconditionally')
+ # Issue #26610: pip/pep425tags.py requires ctypes
+ @unittest.skipUnless(ctypes, 'pip requires ctypes')
def test_with_pip(self):
rmtree(self.env_dir)
with EnvironmentVarGuard() as envvars:
diff --git a/Lib/test/test_warnings/__init__.py b/Lib/test/test_warnings/__init__.py
index 72fcc73..497c5cc 100644
--- a/Lib/test/test_warnings/__init__.py
+++ b/Lib/test/test_warnings/__init__.py
@@ -2,7 +2,9 @@
import linecache
import os
from io import StringIO
+import re
import sys
+import textwrap
import unittest
from test import support
from test.support.script_helper import assert_python_ok, assert_python_failure
@@ -708,6 +710,17 @@
result = stream.getvalue()
self.assertIn(text, result)
+ def test_showwarnmsg_missing(self):
+ # Test that _showwarnmsg() missing is okay.
+ text = 'del _showwarnmsg test'
+ with original_warnings.catch_warnings(module=self.module):
+ self.module.filterwarnings("always", category=UserWarning)
+ del self.module._showwarnmsg
+ with support.captured_output('stderr') as stream:
+ self.module.warn(text)
+ result = stream.getvalue()
+ self.assertIn(text, result)
+
def test_showwarning_not_callable(self):
with original_warnings.catch_warnings(module=self.module):
self.module.filterwarnings("always", category=UserWarning)
@@ -809,12 +822,44 @@
file_object, expected_file_line)
self.assertEqual(expect, file_object.getvalue())
+
class CWarningsDisplayTests(WarningsDisplayTests, unittest.TestCase):
module = c_warnings
class PyWarningsDisplayTests(WarningsDisplayTests, unittest.TestCase):
module = py_warnings
+ def test_tracemalloc(self):
+ self.addCleanup(support.unlink, support.TESTFN)
+
+ with open(support.TESTFN, 'w') as fp:
+ fp.write(textwrap.dedent("""
+ def func():
+ f = open(__file__)
+ # Emit ResourceWarning
+ f = None
+
+ func()
+ """))
+
+ res = assert_python_ok('-Wd', '-X', 'tracemalloc=2', support.TESTFN)
+
+ stderr = res.err.decode('ascii', 'replace')
+ # normalize newlines
+ stderr = '\n'.join(stderr.splitlines())
+ stderr = re.sub('<.*>', '<...>', stderr)
+ expected = textwrap.dedent('''
+ {fname}:5: ResourceWarning: unclosed file <...>
+ f = None
+ Object allocated at (most recent call first):
+ File "{fname}", lineno 3
+ f = open(__file__)
+ File "{fname}", lineno 7
+ func()
+ ''')
+ expected = expected.format(fname=support.TESTFN).strip()
+ self.assertEqual(stderr, expected)
+
class CatchWarningTests(BaseTest):
diff --git a/Lib/test/test_wave.py b/Lib/test/test_wave.py
index 3eff773..8666f72 100644
--- a/Lib/test/test_wave.py
+++ b/Lib/test/test_wave.py
@@ -1,6 +1,6 @@
-from test.support import TESTFN
import unittest
from test import audiotests
+from test import support
from audioop import byteswap
import sys
import wave
@@ -103,5 +103,11 @@
frames = byteswap(frames, 4)
+class MiscTestCase(unittest.TestCase):
+ def test__all__(self):
+ blacklist = {'WAVE_FORMAT_PCM'}
+ support.check__all__(self, wave, blacklist=blacklist)
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/test/test_weakset.py b/Lib/test/test_weakset.py
index 9ce672b..691b95e 100644
--- a/Lib/test/test_weakset.py
+++ b/Lib/test/test_weakset.py
@@ -1,13 +1,6 @@
import unittest
-from weakref import proxy, ref, WeakSet
-import operator
-import copy
+from weakref import WeakSet
import string
-import os
-from random import randrange, shuffle
-import sys
-import warnings
-import collections
from collections import UserString as ustr
import gc
import contextlib
diff --git a/Lib/test/test_winreg.py b/Lib/test/test_winreg.py
index 2c4ac08..ef40e8b 100644
--- a/Lib/test/test_winreg.py
+++ b/Lib/test/test_winreg.py
@@ -37,6 +37,7 @@
test_data = [
("Int Value", 45, REG_DWORD),
+ ("Qword Value", 0x1122334455667788, REG_QWORD),
("String Val", "A string value", REG_SZ),
("StringExpand", "The path is %path%", REG_EXPAND_SZ),
("Multi-string", ["Lots", "of", "string", "values"], REG_MULTI_SZ),
diff --git a/Lib/test/test_with.py b/Lib/test/test_with.py
index e8d789b..e247ff6 100644
--- a/Lib/test/test_with.py
+++ b/Lib/test/test_with.py
@@ -140,11 +140,6 @@
'with mock as (None):\n'
' pass')
- def testAssignmentToEmptyTupleError(self):
- self.assertRaisesSyntaxError(
- 'with mock as ():\n'
- ' pass')
-
def testAssignmentToTupleOnlyContainingNoneError(self):
self.assertRaisesSyntaxError('with mock as None,:\n pass')
self.assertRaisesSyntaxError(
@@ -454,7 +449,7 @@
with cm():
raise StopIteration("from with")
- with self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"):
+ with self.assertWarnsRegex(DeprecationWarning, "StopIteration"):
self.assertRaises(StopIteration, shouldThrow)
def testRaisedStopIteration2(self):
@@ -482,7 +477,7 @@
with cm():
raise next(iter([]))
- with self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"):
+ with self.assertWarnsRegex(DeprecationWarning, "StopIteration"):
self.assertRaises(StopIteration, shouldThrow)
def testRaisedGeneratorExit1(self):
diff --git a/Lib/test/test_wsgiref.py b/Lib/test/test_wsgiref.py
index 61a750c..3c5a27a 100644
--- a/Lib/test/test_wsgiref.py
+++ b/Lib/test/test_wsgiref.py
@@ -165,10 +165,10 @@
self.assertTrue(out.endswith(
b"A server error occurred. Please contact the administrator."
))
- self.assertEqual(
+ self.assertRegex(
err.splitlines()[-2],
- "AssertionError: Headers (('Content-Type', 'text/plain')) must"
- " be of type list: <class 'tuple'>"
+ r"AssertionError: Headers \(\('Content-Type', 'text/plain'\)\) must"
+ r" be of type list: <class 'tuple' at 0x.+>"
)
def test_status_validation_errors(self):
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index bc1dd14..6e54628 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -91,8 +91,6 @@
class ModuleTest(unittest.TestCase):
- # TODO: this should be removed once we get rid of the global module vars
-
def test_sanity(self):
# Import sanity.
@@ -100,6 +98,10 @@
from xml.etree import ElementInclude
from xml.etree import ElementPath
+ def test_all(self):
+ names = ("xml.etree.ElementTree", "_elementtree")
+ support.check__all__(self, ET, names, blacklist=("HTML_EMPTY",))
+
def serialize(elem, to_string=True, encoding='unicode', **options):
if encoding != 'unicode':
@@ -182,10 +184,12 @@
def check_element(element):
self.assertTrue(ET.iselement(element), msg="not an element")
- self.assertTrue(hasattr(element, "tag"), msg="no tag member")
- self.assertTrue(hasattr(element, "attrib"), msg="no attrib member")
- self.assertTrue(hasattr(element, "text"), msg="no text member")
- self.assertTrue(hasattr(element, "tail"), msg="no tail member")
+ direlem = dir(element)
+ for attr in 'tag', 'attrib', 'text', 'tail':
+ self.assertTrue(hasattr(element, attr),
+ msg='no %s member' % attr)
+ self.assertIn(attr, direlem,
+ msg='no %s visible by dir' % attr)
check_string(element.tag)
check_mapping(element.attrib)
diff --git a/Lib/test/test_xml_etree_c.py b/Lib/test/test_xml_etree_c.py
index 96b446e..87f3f27 100644
--- a/Lib/test/test_xml_etree_c.py
+++ b/Lib/test/test_xml_etree_c.py
@@ -1,5 +1,5 @@
# xml.etree test for cElementTree
-import sys, struct
+import struct
from test import support
from test.support import import_fresh_module
import types
@@ -108,7 +108,7 @@
struct.calcsize('8P'))
def test_main():
- from test import test_xml_etree, test_xml_etree_c
+ from test import test_xml_etree
# Run the tests specific to the C implementation
support.run_unittest(
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
index 02d9f5c..f2fdc44 100644
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -9,7 +9,6 @@
import http.client
import http, http.server
import socket
-import os
import re
import io
import contextlib
@@ -776,8 +775,8 @@
# 'method "this_is_not_exists" is not supported'>}]
self.assertEqual(result.results[0]['faultCode'], 1)
- self.assertEqual(result.results[0]['faultString'],
- '<class \'Exception\'>:method "this_is_not_exists" '
+ self.assertRegex(result.results[0]['faultString'],
+ '<class \'Exception\' at 0x.+>:method "this_is_not_exists" '
'is not supported')
except (xmlrpclib.ProtocolError, OSError) as e:
# ignore failures due to non-blocking socket 'unavailable' errors
@@ -1147,7 +1146,6 @@
"""A variation on support.captured_stdout() which gives a text stream
having a `buffer` attribute.
"""
- import io
orig_stdout = sys.stdout
sys.stdout = io.TextIOWrapper(io.BytesIO(), encoding=encoding)
try:
diff --git a/Lib/test/test_xmlrpc_net.py b/Lib/test/test_xmlrpc_net.py
index b60b82f..ae0a28e 100644
--- a/Lib/test/test_xmlrpc_net.py
+++ b/Lib/test/test_xmlrpc_net.py
@@ -1,7 +1,4 @@
import collections.abc
-import errno
-import socket
-import sys
import unittest
from test import support
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
index d278e06..ef3c3d8 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -1,8 +1,8 @@
import contextlib
import io
import os
-import sys
import importlib.util
+import posixpath
import time
import struct
import zipfile
@@ -38,10 +38,6 @@
yield f
test.assertFalse(f.closed)
-def openU(zipfp, fn):
- with check_warnings(('', DeprecationWarning)):
- return zipfp.open(fn, 'rU')
-
class AbstractTestsWithSourceFile:
@classmethod
def setUpClass(cls):
@@ -61,6 +57,9 @@
zipfp.write(TESTFN, "another.name")
zipfp.write(TESTFN, TESTFN)
zipfp.writestr("strfile", self.data)
+ with zipfp.open('written-open-w', mode='w') as f:
+ for line in self.line_gen:
+ f.write(line)
def zip_test(self, f, compression):
self.make_test_archive(f, compression)
@@ -76,7 +75,7 @@
zipfp.printdir(file=fp)
directory = fp.getvalue()
lines = directory.splitlines()
- self.assertEqual(len(lines), 4) # Number of files + header
+ self.assertEqual(len(lines), 5) # Number of files + header
self.assertIn('File Name', lines[0])
self.assertIn('Modified', lines[0])
@@ -90,23 +89,25 @@
# Check the namelist
names = zipfp.namelist()
- self.assertEqual(len(names), 3)
+ self.assertEqual(len(names), 4)
self.assertIn(TESTFN, names)
self.assertIn("another.name", names)
self.assertIn("strfile", names)
+ self.assertIn("written-open-w", names)
# Check infolist
infos = zipfp.infolist()
names = [i.filename for i in infos]
- self.assertEqual(len(names), 3)
+ self.assertEqual(len(names), 4)
self.assertIn(TESTFN, names)
self.assertIn("another.name", names)
self.assertIn("strfile", names)
+ self.assertIn("written-open-w", names)
for i in infos:
self.assertEqual(i.file_size, len(self.data))
# check getinfo
- for nm in (TESTFN, "another.name", "strfile"):
+ for nm in (TESTFN, "another.name", "strfile", "written-open-w"):
info = zipfp.getinfo(nm)
self.assertEqual(info.filename, nm)
self.assertEqual(info.file_size, len(self.data))
@@ -372,14 +373,18 @@
test_low_compression = None
def zip_test_writestr_permissions(self, f, compression):
- # Make sure that writestr creates files with mode 0600,
- # when it is passed a name rather than a ZipInfo instance.
+ # Make sure that writestr and open(... mode='w') create files with
+ # mode 0600, when they are passed a name rather than a ZipInfo
+ # instance.
self.make_test_archive(f, compression)
with zipfile.ZipFile(f, "r") as zipfp:
zinfo = zipfp.getinfo('strfile')
self.assertEqual(zinfo.external_attr, 0o600 << 16)
+ zinfo2 = zipfp.getinfo('written-open-w')
+ self.assertEqual(zinfo2.external_attr, 0o600 << 16)
+
def test_writestr_permissions(self):
for f in get_files(self):
self.zip_test_writestr_permissions(f, zipfile.ZIP_STORED)
@@ -451,6 +456,10 @@
with zipfile.ZipFile(TESTFN2, mode="r") as zipfp:
self.assertRaises(RuntimeError, zipfp.write, TESTFN)
+ with zipfile.ZipFile(TESTFN2, mode="r") as zipfp:
+ with self.assertRaises(RuntimeError):
+ zipfp.open(TESTFN, mode='w')
+
def test_add_file_before_1980(self):
# Set atime and mtime to 1970-01-01
os.utime(TESTFN, (0, 0))
@@ -1022,32 +1031,6 @@
data += zipfp.read(info)
self.assertIn(data, {b"foobar", b"barfoo"})
- def test_universal_deprecation(self):
- f = io.BytesIO()
- with zipfile.ZipFile(f, "w") as zipfp:
- zipfp.writestr('spam.txt', b'ababagalamaga')
-
- with zipfile.ZipFile(f, "r") as zipfp:
- for mode in 'U', 'rU':
- with self.assertWarns(DeprecationWarning):
- zipopen = zipfp.open('spam.txt', mode)
- zipopen.close()
-
- def test_universal_readaheads(self):
- f = io.BytesIO()
-
- data = b'a\r\n' * 16 * 1024
- with zipfile.ZipFile(f, 'w', zipfile.ZIP_STORED) as zipfp:
- zipfp.writestr(TESTFN, data)
-
- data2 = b''
- with zipfile.ZipFile(f, 'r') as zipfp, \
- openU(zipfp, TESTFN) as zipopen:
- for line in zipopen:
- data2 += line
-
- self.assertEqual(data, data2.replace(b'\n', b'\r\n'))
-
def test_writestr_extended_local_header_issue1202(self):
with zipfile.ZipFile(TESTFN2, 'w') as orig_zip:
for data in 'abcdefghijklmnop':
@@ -1255,9 +1238,12 @@
zipf.writestr("foo.txt", "O, for a Muse of Fire!")
with zipfile.ZipFile(TESTFN, mode="r") as zipf:
- # read the data to make sure the file is there
+ # read the data to make sure the file is there
zipf.read("foo.txt")
self.assertRaises(RuntimeError, zipf.open, "foo.txt", "q")
+ # universal newlines support is removed
+ self.assertRaises(RuntimeError, zipf.open, "foo.txt", "U")
+ self.assertRaises(RuntimeError, zipf.open, "foo.txt", "rU")
def test_read0(self):
"""Check that calling read(0) on a ZipExtFile object returns an empty
@@ -1428,6 +1414,35 @@
# testzip returns the name of the first corrupt file, or None
self.assertIsNone(zipf.testzip())
+ def test_open_conflicting_handles(self):
+ # It's only possible to open one writable file handle at a time
+ msg1 = b"It's fun to charter an accountant!"
+ msg2 = b"And sail the wide accountant sea"
+ msg3 = b"To find, explore the funds offshore"
+ with zipfile.ZipFile(TESTFN2, 'w', zipfile.ZIP_STORED) as zipf:
+ with zipf.open('foo', mode='w') as w2:
+ w2.write(msg1)
+ with zipf.open('bar', mode='w') as w1:
+ with self.assertRaises(RuntimeError):
+ zipf.open('handle', mode='w')
+ with self.assertRaises(RuntimeError):
+ zipf.open('foo', mode='r')
+ with self.assertRaises(RuntimeError):
+ zipf.writestr('str', 'abcde')
+ with self.assertRaises(RuntimeError):
+ zipf.write(__file__, 'file')
+ with self.assertRaises(RuntimeError):
+ zipf.close()
+ w1.write(msg2)
+ with zipf.open('baz', mode='w') as w2:
+ w2.write(msg3)
+
+ with zipfile.ZipFile(TESTFN2, 'r') as zipf:
+ self.assertEqual(zipf.read('foo'), msg1)
+ self.assertEqual(zipf.read('bar'), msg2)
+ self.assertEqual(zipf.read('baz'), msg3)
+ self.assertEqual(zipf.namelist(), ['foo', 'bar', 'baz'])
+
def tearDown(self):
unlink(TESTFN)
unlink(TESTFN2)
@@ -1761,6 +1776,22 @@
with zipf.open('twos') as zopen:
self.assertEqual(zopen.read(), b'222')
+ def test_open_write(self):
+ for wrapper in (lambda f: f), Tellable, Unseekable:
+ with self.subTest(wrapper=wrapper):
+ f = io.BytesIO()
+ f.write(b'abc')
+ bf = io.BufferedWriter(f)
+ with zipfile.ZipFile(wrapper(bf), 'w', zipfile.ZIP_STORED) as zipf:
+ with zipf.open('ones', 'w') as zopen:
+ zopen.write(b'111')
+ with zipf.open('twos', 'w') as zopen:
+ zopen.write(b'222')
+ self.assertEqual(f.getvalue()[:5], b'abcPK')
+ with zipfile.ZipFile(f) as zipf:
+ self.assertEqual(zipf.read('ones'), b'111')
+ self.assertEqual(zipf.read('twos'), b'222')
+
@requires_zlib
class TestsWithMultipleOpens(unittest.TestCase):
@@ -1871,6 +1902,19 @@
with open(os.devnull) as f:
self.assertLess(f.fileno(), 100)
+ def test_write_while_reading(self):
+ with zipfile.ZipFile(TESTFN2, 'w', zipfile.ZIP_DEFLATED) as zipf:
+ zipf.writestr('ones', self.data1)
+ with zipfile.ZipFile(TESTFN2, 'a', zipfile.ZIP_DEFLATED) as zipf:
+ with zipf.open('ones', 'r') as r1:
+ data1 = r1.read(500)
+ with zipf.open('twos', 'w') as w1:
+ w1.write(self.data2)
+ data1 += r1.read()
+ self.assertEqual(data1, self.data1)
+ with zipfile.ZipFile(TESTFN2) as zipf:
+ self.assertEqual(zipf.read('twos'), self.data2)
+
def tearDown(self):
unlink(TESTFN2)
@@ -1940,137 +1984,19 @@
unlink(TESTFN)
-class AbstractUniversalNewlineTests:
- @classmethod
- def setUpClass(cls):
- cls.line_gen = [bytes("Test of zipfile line %d." % i, "ascii")
- for i in range(FIXEDTEST_SIZE)]
- cls.seps = (b'\r', b'\r\n', b'\n')
- cls.arcdata = {}
- for n, s in enumerate(cls.seps):
- cls.arcdata[s] = s.join(cls.line_gen) + s
+class ZipInfoTests(unittest.TestCase):
+ def test_from_file(self):
+ zi = zipfile.ZipInfo.from_file(__file__)
+ self.assertEqual(posixpath.basename(zi.filename), 'test_zipfile.py')
+ self.assertFalse(zi.is_dir())
- def setUp(self):
- self.arcfiles = {}
- for n, s in enumerate(self.seps):
- self.arcfiles[s] = '%s-%d' % (TESTFN, n)
- with open(self.arcfiles[s], "wb") as f:
- f.write(self.arcdata[s])
-
- def make_test_archive(self, f, compression):
- # Create the ZIP archive
- with zipfile.ZipFile(f, "w", compression) as zipfp:
- for fn in self.arcfiles.values():
- zipfp.write(fn, fn)
-
- def read_test(self, f, compression):
- self.make_test_archive(f, compression)
-
- # Read the ZIP archive
- with zipfile.ZipFile(f, "r") as zipfp:
- for sep, fn in self.arcfiles.items():
- with openU(zipfp, fn) as fp:
- zipdata = fp.read()
- self.assertEqual(self.arcdata[sep], zipdata)
-
- def test_read(self):
- for f in get_files(self):
- self.read_test(f, self.compression)
-
- def readline_read_test(self, f, compression):
- self.make_test_archive(f, compression)
-
- # Read the ZIP archive
- with zipfile.ZipFile(f, "r") as zipfp:
- for sep, fn in self.arcfiles.items():
- with openU(zipfp, fn) as zipopen:
- data = b''
- while True:
- read = zipopen.readline()
- if not read:
- break
- data += read
-
- read = zipopen.read(5)
- if not read:
- break
- data += read
-
- self.assertEqual(data, self.arcdata[b'\n'])
-
- def test_readline_read(self):
- for f in get_files(self):
- self.readline_read_test(f, self.compression)
-
- def readline_test(self, f, compression):
- self.make_test_archive(f, compression)
-
- # Read the ZIP archive
- with zipfile.ZipFile(f, "r") as zipfp:
- for sep, fn in self.arcfiles.items():
- with openU(zipfp, fn) as zipopen:
- for line in self.line_gen:
- linedata = zipopen.readline()
- self.assertEqual(linedata, line + b'\n')
-
- def test_readline(self):
- for f in get_files(self):
- self.readline_test(f, self.compression)
-
- def readlines_test(self, f, compression):
- self.make_test_archive(f, compression)
-
- # Read the ZIP archive
- with zipfile.ZipFile(f, "r") as zipfp:
- for sep, fn in self.arcfiles.items():
- with openU(zipfp, fn) as fp:
- ziplines = fp.readlines()
- for line, zipline in zip(self.line_gen, ziplines):
- self.assertEqual(zipline, line + b'\n')
-
- def test_readlines(self):
- for f in get_files(self):
- self.readlines_test(f, self.compression)
-
- def iterlines_test(self, f, compression):
- self.make_test_archive(f, compression)
-
- # Read the ZIP archive
- with zipfile.ZipFile(f, "r") as zipfp:
- for sep, fn in self.arcfiles.items():
- with openU(zipfp, fn) as fp:
- for line, zipline in zip(self.line_gen, fp):
- self.assertEqual(zipline, line + b'\n')
-
- def test_iterlines(self):
- for f in get_files(self):
- self.iterlines_test(f, self.compression)
-
- def tearDown(self):
- for sep, fn in self.arcfiles.items():
- unlink(fn)
- unlink(TESTFN)
- unlink(TESTFN2)
-
-
-class StoredUniversalNewlineTests(AbstractUniversalNewlineTests,
- unittest.TestCase):
- compression = zipfile.ZIP_STORED
-
-@requires_zlib
-class DeflateUniversalNewlineTests(AbstractUniversalNewlineTests,
- unittest.TestCase):
- compression = zipfile.ZIP_DEFLATED
-
-@requires_bz2
-class Bzip2UniversalNewlineTests(AbstractUniversalNewlineTests,
- unittest.TestCase):
- compression = zipfile.ZIP_BZIP2
-
-@requires_lzma
-class LzmaUniversalNewlineTests(AbstractUniversalNewlineTests,
- unittest.TestCase):
- compression = zipfile.ZIP_LZMA
+ def test_from_dir(self):
+ dirpath = os.path.dirname(os.path.abspath(__file__))
+ zi = zipfile.ZipInfo.from_file(dirpath, 'stdlib_tests')
+ self.assertEqual(zi.filename, 'stdlib_tests/')
+ self.assertTrue(zi.is_dir())
+ self.assertEqual(zi.compress_type, zipfile.ZIP_STORED)
+ self.assertEqual(zi.file_size, 0)
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py
index 8e5e12d..20491cd 100644
--- a/Lib/test/test_zipimport.py
+++ b/Lib/test/test_zipimport.py
@@ -398,7 +398,8 @@
packdir2 = packdir + TESTPACK2 + os.sep
files = {packdir + "__init__" + pyc_ext: (NOW, test_pyc),
packdir2 + "__init__" + pyc_ext: (NOW, test_pyc),
- packdir2 + TESTMOD + pyc_ext: (NOW, test_pyc)}
+ packdir2 + TESTMOD + pyc_ext: (NOW, test_pyc),
+ "spam" + pyc_ext: (NOW, test_pyc)}
z = ZipFile(TEMP_ZIP, "w")
try:
@@ -412,6 +413,14 @@
zi = zipimport.zipimporter(TEMP_ZIP)
self.assertEqual(zi.archive, TEMP_ZIP)
self.assertEqual(zi.is_package(TESTPACK), True)
+
+ find_mod = zi.find_module('spam')
+ self.assertIsNotNone(find_mod)
+ self.assertIsInstance(find_mod, zipimport.zipimporter)
+ self.assertFalse(find_mod.is_package('spam'))
+ load_mod = find_mod.load_module('spam')
+ self.assertEqual(find_mod.get_filename('spam'), load_mod.__file__)
+
mod = zi.load_module(TESTPACK)
self.assertEqual(zi.get_filename(TESTPACK), mod.__file__)
@@ -471,6 +480,16 @@
self.assertEqual(
zi.is_package(TESTPACK2 + os.sep + TESTMOD), False)
+ pkg_path = TEMP_ZIP + os.sep + packdir + TESTPACK2
+ zi2 = zipimport.zipimporter(pkg_path)
+ find_mod_dotted = zi2.find_module(TESTMOD)
+ self.assertIsNotNone(find_mod_dotted)
+ self.assertIsInstance(find_mod_dotted, zipimport.zipimporter)
+ self.assertFalse(zi2.is_package(TESTMOD))
+ load_mod = find_mod_dotted.load_module(TESTMOD)
+ self.assertEqual(
+ find_mod_dotted.get_filename(TESTMOD), load_mod.__file__)
+
mod_path = TESTPACK2 + os.sep + TESTMOD
mod_name = module_path_to_dotted_name(mod_path)
mod = importlib.import_module(mod_name)
diff --git a/Lib/test/test_zipimport_support.py b/Lib/test/test_zipimport_support.py
index 5913622..84d526c 100644
--- a/Lib/test/test_zipimport_support.py
+++ b/Lib/test/test_zipimport_support.py
@@ -12,7 +12,6 @@
import doctest
import inspect
import linecache
-import pdb
import unittest
from test.support.script_helper import (spawn_python, kill_python, assert_python_ok,
make_script, make_zip_script)
diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py
index 78ecade..bb9292b 100644
--- a/Lib/test/test_zlib.py
+++ b/Lib/test/test_zlib.py
@@ -162,6 +162,12 @@
x = zlib.compress(HAMLET_SCENE)
self.assertEqual(zlib.decompress(x), HAMLET_SCENE)
+ def test_keywords(self):
+ x = zlib.compress(HAMLET_SCENE, level=3)
+ self.assertEqual(zlib.decompress(x), HAMLET_SCENE)
+ with self.assertRaises(TypeError):
+ zlib.compress(data=HAMLET_SCENE, level=3)
+
def test_speech128(self):
# compress more data
data = HAMLET_SCENE * 128
diff --git a/Lib/threading.py b/Lib/threading.py
index c9f8cb6..d09fcae 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -22,9 +22,11 @@
# with the multiprocessing module, which doesn't provide the old
# Java inspired names.
-__all__ = ['active_count', 'Condition', 'current_thread', 'enumerate', 'Event',
- 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread', 'Barrier',
- 'Timer', 'ThreadError', 'setprofile', 'settrace', 'local', 'stack_size']
+__all__ = ['get_ident', 'active_count', 'Condition', 'current_thread',
+ 'enumerate', 'main_thread', 'TIMEOUT_MAX',
+ 'Event', 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread',
+ 'Barrier', 'BrokenBarrierError', 'Timer', 'ThreadError',
+ 'setprofile', 'settrace', 'local', 'stack_size']
# Rename some stuff so "from threading import *" is safe
_start_new_thread = _thread.start_new_thread
diff --git a/Lib/timeit.py b/Lib/timeit.py
old mode 100755
new mode 100644
index 2de88f7..98cb3eb
--- a/Lib/timeit.py
+++ b/Lib/timeit.py
@@ -317,20 +317,26 @@
print("%d loops," % number, end=' ')
usec = best * 1e6 / number
if time_unit is not None:
- print("best of %d: %.*g %s per loop" % (repeat, precision,
- usec/units[time_unit], time_unit))
+ scale = units[time_unit]
else:
- if usec < 1000:
- print("best of %d: %.*g usec per loop" % (repeat, precision, usec))
- else:
- msec = usec / 1000
- if msec < 1000:
- print("best of %d: %.*g msec per loop" % (repeat,
- precision, msec))
- else:
- sec = msec / 1000
- print("best of %d: %.*g sec per loop" % (repeat,
- precision, sec))
+ scales = [(scale, unit) for unit, scale in units.items()]
+ scales.sort(reverse=True)
+ for scale, time_unit in scales:
+ if usec >= scale:
+ break
+ print("best of %d: %.*g %s per loop" % (repeat, precision,
+ usec/scale, time_unit))
+ best = min(r)
+ usec = best * 1e6 / number
+ worst = max(r)
+ if worst >= best * 4:
+ usec = worst * 1e6 / number
+ import warnings
+ warnings.warn_explicit(
+ "The test results are likely unreliable. The worst\n"
+ "time (%.*g %s) was more than four times slower than the best time." %
+ (precision, usec/scale, time_unit),
+ UserWarning, '', 0)
return None
if __name__ == "__main__":
diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py
index 55bfb7f..35643e6 100644
--- a/Lib/tkinter/__init__.py
+++ b/Lib/tkinter/__init__.py
@@ -30,6 +30,7 @@
tk.mainloop()
"""
+import enum
import sys
import _tkinter # If this fails your Python may not be configured for Tk
@@ -132,6 +133,50 @@
dict[key] = value
return dict
+
+class EventType(str, enum.Enum):
+ KeyPress = '2'
+ Key = KeyPress,
+ KeyRelease = '3'
+ ButtonPress = '4'
+ Button = ButtonPress,
+ ButtonRelease = '5'
+ Motion = '6'
+ Enter = '7'
+ Leave = '8'
+ FocusIn = '9'
+ FocusOut = '10'
+ Keymap = '11' # undocumented
+ Expose = '12'
+ GraphicsExpose = '13' # undocumented
+ NoExpose = '14' # undocumented
+ Visibility = '15'
+ Create = '16'
+ Destroy = '17'
+ Unmap = '18'
+ Map = '19'
+ MapRequest = '20'
+ Reparent = '21'
+ Configure = '22'
+ ConfigureRequest = '23'
+ Gravity = '24'
+ ResizeRequest = '25'
+ Circulate = '26'
+ CirculateRequest = '27'
+ Property = '28'
+ SelectionClear = '29' # undocumented
+ SelectionRequest = '30' # undocumented
+ Selection = '31' # undocumented
+ Colormap = '32'
+ ClientMessage = '33' # undocumented
+ Mapping = '34' # undocumented
+ VirtualEvent = '35', # undocumented
+ Activate = '36',
+ Deactivate = '37',
+ MouseWheel = '38',
+ def __str__(self):
+ return self.name
+
class Event:
"""Container for the properties of an event.
@@ -174,7 +219,43 @@
widget - widget in which the event occurred
delta - delta of wheel movement (MouseWheel)
"""
- pass
+ def __repr__(self):
+ attrs = {k: v for k, v in self.__dict__.items() if v != '??'}
+ if not self.char:
+ del attrs['char']
+ elif self.char != '??':
+ attrs['char'] = repr(self.char)
+ if not getattr(self, 'send_event', True):
+ del attrs['send_event']
+ if self.state == 0:
+ del attrs['state']
+ elif isinstance(self.state, int):
+ state = self.state
+ mods = ('Shift', 'Lock', 'Control',
+ 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5',
+ 'Button1', 'Button2', 'Button3', 'Button4', 'Button5')
+ s = []
+ for i, n in enumerate(mods):
+ if state & (1 << i):
+ s.append(n)
+ state = state & ~((1<< len(mods)) - 1)
+ if state or not s:
+ s.append(hex(state))
+ attrs['state'] = '|'.join(s)
+ if self.delta == 0:
+ del attrs['delta']
+ # widget usually is known
+ # serial and time are not very interesing
+ # keysym_num duplicates keysym
+ # x_root and y_root mostly duplicate x and y
+ keys = ('send_event',
+ 'state', 'keysym', 'keycode', 'char',
+ 'num', 'delta', 'focus',
+ 'x', 'y', 'width', 'height')
+ return '<%s event%s>' % (
+ self.type,
+ ''.join(' %s=%s' % (k, attrs[k]) for k in keys if k in attrs)
+ )
_support_default_root = 1
_default_root = None
@@ -262,15 +343,8 @@
def get(self):
"""Return value of variable."""
return self._tk.globalgetvar(self._name)
- def trace_variable(self, mode, callback):
- """Define a trace callback for the variable.
- MODE is one of "r", "w", "u" for read, write, undefine.
- CALLBACK must be a function which is called when
- the variable is read, written or undefined.
-
- Return the name of the callback.
- """
+ def _register(self, callback):
f = CallWrapper(callback, None, self._root).__call__
cbname = repr(id(f))
try:
@@ -285,18 +359,33 @@
if self._tclCommands is None:
self._tclCommands = []
self._tclCommands.append(cbname)
- self._tk.call("trace", "variable", self._name, mode, cbname)
return cbname
- trace = trace_variable
- def trace_vdelete(self, mode, cbname):
+
+ def trace_add(self, mode, callback):
+ """Define a trace callback for the variable.
+
+ Mode is one of "read", "write", "unset", or a list or tuple of
+ such strings.
+ Callback must be a function which is called when the variable is
+ read, written or unset.
+
+ Return the name of the callback.
+ """
+ cbname = self._register(callback)
+ self._tk.call('trace', 'add', 'variable',
+ self._name, mode, (cbname,))
+ return cbname
+
+ def trace_remove(self, mode, cbname):
"""Delete the trace callback for a variable.
- MODE is one of "r", "w", "u" for read, write, undefine.
- CBNAME is the name of the callback returned from trace_variable or trace.
+ Mode is one of "read", "write", "unset" or a list or tuple of
+ such strings. Must be same as were specified in trace_add().
+ cbname is the name of the callback returned from trace_add().
"""
- self._tk.call("trace", "vdelete", self._name, mode, cbname)
- cbname = self._tk.splitlist(cbname)[0]
- for m, ca in self.trace_vinfo():
+ self._tk.call('trace', 'remove', 'variable',
+ self._name, mode, cbname)
+ for m, ca in self.trace_info():
if self._tk.splitlist(ca)[0] == cbname:
break
else:
@@ -305,10 +394,64 @@
self._tclCommands.remove(cbname)
except ValueError:
pass
- def trace_vinfo(self):
+
+ def trace_info(self):
"""Return all trace callback information."""
+ splitlist = self._tk.splitlist
+ return [(splitlist(k), v) for k, v in map(splitlist,
+ splitlist(self._tk.call('trace', 'info', 'variable', self._name)))]
+
+ def trace_variable(self, mode, callback):
+ """Define a trace callback for the variable.
+
+ MODE is one of "r", "w", "u" for read, write, undefine.
+ CALLBACK must be a function which is called when
+ the variable is read, written or undefined.
+
+ Return the name of the callback.
+
+ This deprecated method wraps a deprecated Tcl method that will
+ likely be removed in the future. Use trace_add() instead.
+ """
+ # TODO: Add deprecation warning
+ cbname = self._register(callback)
+ self._tk.call("trace", "variable", self._name, mode, cbname)
+ return cbname
+
+ trace = trace_variable
+
+ def trace_vdelete(self, mode, cbname):
+ """Delete the trace callback for a variable.
+
+ MODE is one of "r", "w", "u" for read, write, undefine.
+ CBNAME is the name of the callback returned from trace_variable or trace.
+
+ This deprecated method wraps a deprecated Tcl method that will
+ likely be removed in the future. Use trace_remove() instead.
+ """
+ # TODO: Add deprecation warning
+ self._tk.call("trace", "vdelete", self._name, mode, cbname)
+ cbname = self._tk.splitlist(cbname)[0]
+ for m, ca in self.trace_info():
+ if self._tk.splitlist(ca)[0] == cbname:
+ break
+ else:
+ self._tk.deletecommand(cbname)
+ try:
+ self._tclCommands.remove(cbname)
+ except ValueError:
+ pass
+
+ def trace_vinfo(self):
+ """Return all trace callback information.
+
+ This deprecated method wraps a deprecated Tcl method that will
+ likely be removed in the future. Use trace_info() instead.
+ """
+ # TODO: Add deprecation warning
return [self._tk.splitlist(x) for x in self._tk.splitlist(
self._tk.call("trace", "vinfo", self._name))]
+
def __eq__(self, other):
"""Comparison for equality (==).
@@ -426,6 +569,9 @@
Base class which defines methods common for interior widgets."""
+ # used for generating child widget names
+ _last_child_ids = None
+
# XXX font command?
_tclCommands = None
def destroy(self):
@@ -473,12 +619,6 @@
disabledForeground, insertBackground, troughColor."""
self.tk.call(('tk_setPalette',)
+ _flatten(args) + _flatten(list(kw.items())))
- def tk_menuBar(self, *args):
- """Do not use. Needed in Tk 3.6 and earlier."""
- # obsolete since Tk 4.0
- import warnings
- warnings.warn('tk_menuBar() does nothing and will be removed in 3.6',
- DeprecationWarning, stacklevel=2)
def wait_variable(self, name='PY_VAR'):
"""Wait until the variable is modified.
@@ -850,8 +990,7 @@
self.tk.call('winfo', 'height', self._w))
def winfo_id(self):
"""Return identifier ID for this widget."""
- return self.tk.getint(
- self.tk.call('winfo', 'id', self._w))
+ return int(self.tk.call('winfo', 'id', self._w), 0)
def winfo_interps(self, displayof=0):
"""Return the name of all Tcl interpreters for this display."""
args = ('winfo', 'interps') + self._displayof(displayof)
@@ -971,18 +1110,16 @@
def winfo_visualid(self):
"""Return the X identifier for the visual for this widget."""
return self.tk.call('winfo', 'visualid', self._w)
- def winfo_visualsavailable(self, includeids=0):
+ def winfo_visualsavailable(self, includeids=False):
"""Return a list of all visuals available for the screen
of this widget.
Each item in the list consists of a visual name (see winfo_visual), a
- depth and if INCLUDEIDS=1 is given also the X identifier."""
- data = self.tk.split(
- self.tk.call('winfo', 'visualsavailable', self._w,
- includeids and 'includeids' or None))
- if isinstance(data, str):
- data = [self.tk.split(data)]
- return [self.__winfo_parseitem(x) for x in data]
+ depth and if includeids is true is given also the X identifier."""
+ data = self.tk.call('winfo', 'visualsavailable', self._w,
+ 'includeids' if includeids else None)
+ data = [self.tk.splitlist(x) for x in self.tk.splitlist(data)]
+ return [self.__winfo_parseitem(x) for x in data]
def __winfo_parseitem(self, t):
"""Internal function."""
return t[:1] + tuple(map(self.__winfo_getint, t[1:]))
@@ -1283,7 +1420,10 @@
except TclError: pass
e.keysym = K
e.keysym_num = getint_event(N)
- e.type = T
+ try:
+ e.type = EventType(T)
+ except ValueError:
+ e.type = T
try:
e.widget = self._nametowidget(W)
except KeyError:
@@ -1893,9 +2033,6 @@
if tcl_version != _tkinter.TCL_VERSION:
raise RuntimeError("tcl.h version (%s) doesn't match libtcl.a version (%s)" \
% (_tkinter.TCL_VERSION, tcl_version))
- if TkVersion < 4.0:
- raise RuntimeError("Tk 4.0 or higher is required; found Tk %s"
- % str(TkVersion))
# Create and register the tkerror and exit commands
# We need to inline parts of _register here, _ register
# would register differently-named commands.
@@ -2118,7 +2255,15 @@
name = cnf['name']
del cnf['name']
if not name:
- name = repr(id(self))
+ name = self.__class__.__name__.lower()
+ if master._last_child_ids is None:
+ master._last_child_ids = {}
+ count = master._last_child_ids.get(name, 0) + 1
+ master._last_child_ids[name] = count
+ if count == 1:
+ name = '`%s' % (name,)
+ else:
+ name = '`%s%d' % (name, count)
self._name = name
if master._w=='.':
self._w = '.' + name
@@ -2714,12 +2859,6 @@
def tk_popup(self, x, y, entry=""):
"""Post the menu at position X,Y with entry ENTRY."""
self.tk.call('tk_popup', self._w, x, y, entry)
- def tk_bindForTraversal(self):
- # obsolete since Tk 4.0
- import warnings
- warnings.warn('tk_bindForTraversal() does nothing and '
- 'will be removed in 3.6',
- DeprecationWarning, stacklevel=2)
def activate(self, index):
"""Activate entry at INDEX."""
self.tk.call(self._w, 'activate', index)
@@ -3342,9 +3481,6 @@
if not name:
Image._last_id += 1
name = "pyimage%r" % (Image._last_id,) # tk itself would use image<x>
- # The following is needed for systems where id(x)
- # can return a negative number, such as Linux/m68k:
- if name[0] == '-': name = '_' + name[1:]
if kw and cnf: cnf = _cnfmerge((cnf, kw))
elif kw: cnf = kw
options = ()
diff --git a/Lib/tkinter/commondialog.py b/Lib/tkinter/commondialog.py
index d2688db..1e75cae 100644
--- a/Lib/tkinter/commondialog.py
+++ b/Lib/tkinter/commondialog.py
@@ -15,11 +15,6 @@
command = None
def __init__(self, master=None, **options):
-
- # FIXME: should this be placed on the module level instead?
- if TkVersion < 4.2:
- raise TclError("this module requires Tk 4.2 or newer")
-
self.master = master
self.options = options
if not master and options.get('parent'):
diff --git a/Lib/tkinter/dialog.py b/Lib/tkinter/dialog.py
index be085ab..f61c5f7 100644
--- a/Lib/tkinter/dialog.py
+++ b/Lib/tkinter/dialog.py
@@ -3,10 +3,7 @@
from tkinter import *
from tkinter import _cnfmerge
-if TkVersion <= 3.6:
- DIALOG_ICON = 'warning'
-else:
- DIALOG_ICON = 'questhead'
+DIALOG_ICON = 'questhead'
class Dialog(Widget):
diff --git a/Lib/tkinter/test/runtktests.py b/Lib/tkinter/test/runtktests.py
index dbe5e88..33dc54a 100644
--- a/Lib/tkinter/test/runtktests.py
+++ b/Lib/tkinter/test/runtktests.py
@@ -7,8 +7,6 @@
"""
import os
-import sys
-import unittest
import importlib
import test.support
diff --git a/Lib/tkinter/test/test_tkinter/test_misc.py b/Lib/tkinter/test/test_tkinter/test_misc.py
index 85ee2c7..9dc1e37 100644
--- a/Lib/tkinter/test/test_tkinter/test_misc.py
+++ b/Lib/tkinter/test/test_tkinter/test_misc.py
@@ -12,6 +12,14 @@
f = tkinter.Frame(t, name='child')
self.assertEqual(repr(f), '<tkinter.Frame object .top.child>')
+ def test_generated_names(self):
+ t = tkinter.Toplevel(self.root)
+ f = tkinter.Frame(t)
+ f2 = tkinter.Frame(t)
+ b = tkinter.Button(f2)
+ for name in str(b).split('.'):
+ self.assertFalse(name.isidentifier(), msg=repr(name))
+
def test_tk_setPalette(self):
root = self.root
root.tk_setPalette('black')
diff --git a/Lib/tkinter/test/test_tkinter/test_variables.py b/Lib/tkinter/test/test_tkinter/test_variables.py
index 1f74453..4485817 100644
--- a/Lib/tkinter/test/test_tkinter/test_variables.py
+++ b/Lib/tkinter/test/test_tkinter/test_variables.py
@@ -87,7 +87,8 @@
v.set("value")
self.assertTrue(v.side_effect)
- def test_trace(self):
+ def test_trace_old(self):
+ # Old interface
v = Variable(self.root)
vname = str(v)
trace = []
@@ -136,6 +137,55 @@
gc.collect()
self.assertEqual(trace, [('write', vname, '', 'u')])
+ def test_trace(self):
+ v = Variable(self.root)
+ vname = str(v)
+ trace = []
+ def read_tracer(*args):
+ trace.append(('read',) + args)
+ def write_tracer(*args):
+ trace.append(('write',) + args)
+ tr1 = v.trace_add('read', read_tracer)
+ tr2 = v.trace_add(['write', 'unset'], write_tracer)
+ self.assertEqual(sorted(v.trace_info()), [
+ (('read',), tr1),
+ (('write', 'unset'), tr2)])
+ self.assertEqual(trace, [])
+
+ v.set('spam')
+ self.assertEqual(trace, [('write', vname, '', 'write')])
+
+ trace = []
+ v.get()
+ self.assertEqual(trace, [('read', vname, '', 'read')])
+
+ trace = []
+ info = sorted(v.trace_info())
+ v.trace_remove('write', tr1) # Wrong mode
+ self.assertEqual(sorted(v.trace_info()), info)
+ with self.assertRaises(TclError):
+ v.trace_remove('read', 'spam') # Wrong command name
+ self.assertEqual(sorted(v.trace_info()), info)
+ v.get()
+ self.assertEqual(trace, [('read', vname, '', 'read')])
+
+ trace = []
+ v.trace_remove('read', tr1)
+ self.assertEqual(v.trace_info(), [(('write', 'unset'), tr2)])
+ v.get()
+ self.assertEqual(trace, [])
+
+ trace = []
+ del write_tracer
+ gc.collect()
+ v.set('eggs')
+ self.assertEqual(trace, [('write', vname, '', 'write')])
+
+ trace = []
+ del v
+ gc.collect()
+ self.assertEqual(trace, [('write', vname, '', 'unset')])
+
class TestStringVar(TestBase):
diff --git a/Lib/tkinter/test/test_tkinter/test_widgets.py b/Lib/tkinter/test/test_tkinter/test_widgets.py
index c924d55..81b52ea 100644
--- a/Lib/tkinter/test/test_tkinter/test_widgets.py
+++ b/Lib/tkinter/test/test_tkinter/test_widgets.py
@@ -91,9 +91,10 @@
widget = self.create()
self.assertEqual(widget['use'], '')
parent = self.create(container=True)
- wid = parent.winfo_id()
- widget2 = self.create(use=wid)
- self.assertEqual(int(widget2['use']), wid)
+ wid = hex(parent.winfo_id())
+ with self.subTest(wid=wid):
+ widget2 = self.create(use=wid)
+ self.assertEqual(widget2['use'], wid)
@add_standard_options(StandardOptionsTests)
diff --git a/Lib/tkinter/test/test_ttk/test_functions.py b/Lib/tkinter/test/test_ttk/test_functions.py
index c68a650..a1b7cdf 100644
--- a/Lib/tkinter/test/test_ttk/test_functions.py
+++ b/Lib/tkinter/test/test_ttk/test_functions.py
@@ -1,6 +1,5 @@
# -*- encoding: utf-8 -*-
import unittest
-import tkinter
from tkinter import ttk
class MockTkApp:
diff --git a/Lib/tkinter/test/test_ttk/test_widgets.py b/Lib/tkinter/test/test_ttk/test_widgets.py
index 8bd22d0..26766a8 100644
--- a/Lib/tkinter/test/test_ttk/test_widgets.py
+++ b/Lib/tkinter/test/test_ttk/test_widgets.py
@@ -1487,6 +1487,7 @@
def test_selection(self):
+ self.assertRaises(TypeError, self.tv.selection, 'spam')
# item 'none' doesn't exist
self.assertRaises(tkinter.TclError, self.tv.selection_set, 'none')
self.assertRaises(tkinter.TclError, self.tv.selection_add, 'none')
@@ -1500,25 +1501,31 @@
c3 = self.tv.insert(item1, 'end')
self.assertEqual(self.tv.selection(), ())
- self.tv.selection_set((c1, item2))
+ self.tv.selection_set(c1, item2)
self.assertEqual(self.tv.selection(), (c1, item2))
self.tv.selection_set(c2)
self.assertEqual(self.tv.selection(), (c2,))
- self.tv.selection_add((c1, item2))
+ self.tv.selection_add(c1, item2)
self.assertEqual(self.tv.selection(), (c1, c2, item2))
self.tv.selection_add(item1)
self.assertEqual(self.tv.selection(), (item1, c1, c2, item2))
+ self.tv.selection_add()
+ self.assertEqual(self.tv.selection(), (item1, c1, c2, item2))
- self.tv.selection_remove((item1, c3))
+ self.tv.selection_remove(item1, c3)
self.assertEqual(self.tv.selection(), (c1, c2, item2))
self.tv.selection_remove(c2)
self.assertEqual(self.tv.selection(), (c1, item2))
+ self.tv.selection_remove()
+ self.assertEqual(self.tv.selection(), (c1, item2))
- self.tv.selection_toggle((c1, c3))
+ self.tv.selection_toggle(c1, c3)
self.assertEqual(self.tv.selection(), (c3, item2))
self.tv.selection_toggle(item2)
self.assertEqual(self.tv.selection(), (c3,))
+ self.tv.selection_toggle()
+ self.assertEqual(self.tv.selection(), (c3,))
self.tv.insert('', 'end', id='with spaces')
self.tv.selection_set('with spaces')
@@ -1536,6 +1543,40 @@
self.tv.selection_set(b'bytes\xe2\x82\xac')
self.assertEqual(self.tv.selection(), ('bytes\xe2\x82\xac',))
+ self.tv.selection_set()
+ self.assertEqual(self.tv.selection(), ())
+
+ # Old interface
+ self.tv.selection_set((c1, item2))
+ self.assertEqual(self.tv.selection(), (c1, item2))
+ self.tv.selection_add((c1, item1))
+ self.assertEqual(self.tv.selection(), (item1, c1, item2))
+ self.tv.selection_remove((item1, c3))
+ self.assertEqual(self.tv.selection(), (c1, item2))
+ self.tv.selection_toggle((c1, c3))
+ self.assertEqual(self.tv.selection(), (c3, item2))
+
+ if sys.version_info >= (3, 7):
+ import warnings
+ warnings.warn(
+ 'Deprecated API of Treeview.selection() should be removed')
+ self.tv.selection_set()
+ self.assertEqual(self.tv.selection(), ())
+ with self.assertWarns(DeprecationWarning):
+ self.tv.selection('set', (c1, item2))
+ self.assertEqual(self.tv.selection(), (c1, item2))
+ with self.assertWarns(DeprecationWarning):
+ self.tv.selection('add', (c1, item1))
+ self.assertEqual(self.tv.selection(), (item1, c1, item2))
+ with self.assertWarns(DeprecationWarning):
+ self.tv.selection('remove', (item1, c3))
+ self.assertEqual(self.tv.selection(), (c1, item2))
+ with self.assertWarns(DeprecationWarning):
+ self.tv.selection('toggle', (c1, c3))
+ self.assertEqual(self.tv.selection(), (c3, item2))
+ with self.assertWarns(DeprecationWarning):
+ selection = self.tv.selection(None)
+ self.assertEqual(selection, (c3, item2))
def test_set(self):
self.tv['columns'] = ['A', 'B']
diff --git a/Lib/tkinter/tix.py b/Lib/tkinter/tix.py
index f667933..3d38e5d 100644
--- a/Lib/tkinter/tix.py
+++ b/Lib/tkinter/tix.py
@@ -29,10 +29,6 @@
from tkinter import *
from tkinter import _cnfmerge, _default_root
-# WARNING - TkVersion is a limited precision floating point number
-if TkVersion < 3.999:
- raise ImportError("This version of Tix.py requires Tk 4.0 or higher")
-
import _tkinter # If this fails your Python may not be configured for Tk
# Some more constants (for consistency with Tkinter)
@@ -1110,7 +1106,7 @@
def pages(self):
# Can't call subwidgets_all directly because we don't want .nbframe
- names = self.tk.split(self.tk.call(self._w, 'pages'))
+ names = self.tk.splitlist(self.tk.call(self._w, 'pages'))
ret = []
for x in names:
ret.append(self.subwidget(x))
@@ -1156,7 +1152,7 @@
def pages(self):
# Can't call subwidgets_all directly because we don't want .nbframe
- names = self.tk.split(self.tk.call(self._w, 'pages'))
+ names = self.tk.splitlist(self.tk.call(self._w, 'pages'))
ret = []
for x in names:
ret.append(self.subwidget(x))
@@ -1579,8 +1575,7 @@
'''Returns a list of items whose status matches status. If status is
not specified, the list of items in the "on" status will be returned.
Mode can be on, off, default'''
- c = self.tk.split(self.tk.call(self._w, 'getselection', mode))
- return self.tk.splitlist(c)
+ return self.tk.splitlist(self.tk.call(self._w, 'getselection', mode))
def getstatus(self, entrypath):
'''Returns the current status of entryPath.'''
@@ -1901,7 +1896,7 @@
or a real number following by the word chars
(e.g. 3.4chars) that sets the width of the column to the
given number of characters."""
- return self.tk.split(self.tk.call(self._w, 'size', 'column', index,
+ return self.tk.splitlist(self.tk.call(self._w, 'size', 'column', index,
*self._options({}, kw)))
def size_row(self, index, **kw):
@@ -1926,7 +1921,7 @@
or a real number following by the word chars
(e.g. 3.4chars) that sets the height of the row to the
given number of characters."""
- return self.tk.split(self.tk.call(
+ return self.tk.splitlist(self.tk.call(
self, 'size', 'row', index, *self._options({}, kw)))
def unset(self, x, y):
diff --git a/Lib/tkinter/ttk.py b/Lib/tkinter/ttk.py
index 0e5759d..71ac2a7 100644
--- a/Lib/tkinter/ttk.py
+++ b/Lib/tkinter/ttk.py
@@ -28,6 +28,8 @@
import tkinter
from tkinter import _flatten, _join, _stringify, _splitdict
+_sentinel = object()
+
# Verify if Tk is new enough to not need the Tile package
_REQUIRE_TILE = True if tkinter.TkVersion < 8.5 else False
@@ -381,7 +383,9 @@
a sequence identifying the value for that option."""
if query_opt is not None:
kw[query_opt] = None
- return _val_or_dict(self.tk, kw, self._name, "configure", style)
+ result = _val_or_dict(self.tk, kw, self._name, "configure", style)
+ if result or query_opt:
+ return result
def map(self, style, query_opt=None, **kw):
@@ -466,12 +470,14 @@
def element_names(self):
"""Returns the list of elements defined in the current theme."""
- return self.tk.splitlist(self.tk.call(self._name, "element", "names"))
+ return tuple(n.lstrip('-') for n in self.tk.splitlist(
+ self.tk.call(self._name, "element", "names")))
def element_options(self, elementname):
"""Return the list of elementname's options."""
- return self.tk.splitlist(self.tk.call(self._name, "element", "options", elementname))
+ return tuple(o.lstrip('-') for o in self.tk.splitlist(
+ self.tk.call(self._name, "element", "options", elementname)))
def theme_create(self, themename, parent=None, settings=None):
@@ -1390,31 +1396,53 @@
self.tk.call(self._w, "see", item)
- def selection(self, selop=None, items=None):
- """If selop is not specified, returns selected items."""
- if isinstance(items, (str, bytes)):
- items = (items,)
+ def selection(self, selop=_sentinel, items=None):
+ """Returns the tuple of selected items."""
+ if selop is _sentinel:
+ selop = None
+ elif selop is None:
+ import warnings
+ warnings.warn(
+ "The selop=None argument of selection() is deprecated "
+ "and will be removed in Python 3.7",
+ DeprecationWarning, 3)
+ elif selop in ('set', 'add', 'remove', 'toggle'):
+ import warnings
+ warnings.warn(
+ "The selop argument of selection() is deprecated "
+ "and will be removed in Python 3.7, "
+ "use selection_%s() instead" % (selop,),
+ DeprecationWarning, 3)
+ else:
+ raise TypeError('Unsupported operation')
return self.tk.splitlist(self.tk.call(self._w, "selection", selop, items))
- def selection_set(self, items):
- """items becomes the new selection."""
- self.selection("set", items)
+ def _selection(self, selop, items):
+ if len(items) == 1 and isinstance(items[0], (tuple, list)):
+ items = items[0]
+
+ self.tk.call(self._w, "selection", selop, items)
- def selection_add(self, items):
- """Add items to the selection."""
- self.selection("add", items)
+ def selection_set(self, *items):
+ """The specified items becomes the new selection."""
+ self._selection("set", items)
- def selection_remove(self, items):
- """Remove items from the selection."""
- self.selection("remove", items)
+ def selection_add(self, *items):
+ """Add all of the specified items to the selection."""
+ self._selection("add", items)
- def selection_toggle(self, items):
- """Toggle the selection state of each item in items."""
- self.selection("toggle", items)
+ def selection_remove(self, *items):
+ """Remove all of the specified items from the selection."""
+ self._selection("remove", items)
+
+
+ def selection_toggle(self, *items):
+ """Toggle the selection state of each specified item."""
+ self._selection("toggle", items)
def set(self, item, column=None, value=None):
diff --git a/Lib/tokenize.py b/Lib/tokenize.py
index b1d0c83..ec79ec8 100644
--- a/Lib/tokenize.py
+++ b/Lib/tokenize.py
@@ -29,6 +29,7 @@
import collections
from io import TextIOWrapper
from itertools import chain
+import itertools as _itertools
import re
import sys
from token import *
@@ -131,7 +132,28 @@
Imagnumber = group(r'[0-9]+[jJ]', Floatnumber + r'[jJ]')
Number = group(Imagnumber, Floatnumber, Intnumber)
-StringPrefix = r'(?:[bB][rR]?|[rR][bB]?|[uU])?'
+# Return the empty string, plus all of the valid string prefixes.
+def _all_string_prefixes():
+ # The valid string prefixes. Only contain the lower case versions,
+ # and don't contain any permuations (include 'fr', but not
+ # 'rf'). The various permutations will be generated.
+ _valid_string_prefixes = ['b', 'r', 'u', 'f', 'br', 'fr']
+ # if we add binary f-strings, add: ['fb', 'fbr']
+ result = set([''])
+ for prefix in _valid_string_prefixes:
+ for t in _itertools.permutations(prefix):
+ # create a list with upper and lower versions of each
+ # character
+ for u in _itertools.product(*[(c, c.upper()) for c in t]):
+ result.add(''.join(u))
+ return result
+
+def _compile(expr):
+ return re.compile(expr, re.UNICODE)
+
+# Note that since _all_string_prefixes includes the empty string,
+# StringPrefix can be the empty string (making it optional).
+StringPrefix = group(*_all_string_prefixes())
# Tail end of ' string.
Single = r"[^'\\]*(?:\\.[^'\\]*)*'"
@@ -169,50 +191,25 @@
PseudoExtras = group(r'\\\r?\n|\Z', Comment, Triple)
PseudoToken = Whitespace + group(PseudoExtras, Number, Funny, ContStr, Name)
-def _compile(expr):
- return re.compile(expr, re.UNICODE)
+# For a given string prefix plus quotes, endpats maps it to a regex
+# to match the remainder of that string. _prefix can be empty, for
+# a normal single or triple quoted string (with no prefix).
+endpats = {}
+for _prefix in _all_string_prefixes():
+ endpats[_prefix + "'"] = Single
+ endpats[_prefix + '"'] = Double
+ endpats[_prefix + "'''"] = Single3
+ endpats[_prefix + '"""'] = Double3
-endpats = {"'": Single, '"': Double,
- "'''": Single3, '"""': Double3,
- "r'''": Single3, 'r"""': Double3,
- "b'''": Single3, 'b"""': Double3,
- "R'''": Single3, 'R"""': Double3,
- "B'''": Single3, 'B"""': Double3,
- "br'''": Single3, 'br"""': Double3,
- "bR'''": Single3, 'bR"""': Double3,
- "Br'''": Single3, 'Br"""': Double3,
- "BR'''": Single3, 'BR"""': Double3,
- "rb'''": Single3, 'rb"""': Double3,
- "Rb'''": Single3, 'Rb"""': Double3,
- "rB'''": Single3, 'rB"""': Double3,
- "RB'''": Single3, 'RB"""': Double3,
- "u'''": Single3, 'u"""': Double3,
- "U'''": Single3, 'U"""': Double3,
- 'r': None, 'R': None, 'b': None, 'B': None,
- 'u': None, 'U': None}
-
-triple_quoted = {}
-for t in ("'''", '"""',
- "r'''", 'r"""', "R'''", 'R"""',
- "b'''", 'b"""', "B'''", 'B"""',
- "br'''", 'br"""', "Br'''", 'Br"""',
- "bR'''", 'bR"""', "BR'''", 'BR"""',
- "rb'''", 'rb"""', "rB'''", 'rB"""',
- "Rb'''", 'Rb"""', "RB'''", 'RB"""',
- "u'''", 'u"""', "U'''", 'U"""',
- ):
- triple_quoted[t] = t
-single_quoted = {}
-for t in ("'", '"',
- "r'", 'r"', "R'", 'R"',
- "b'", 'b"', "B'", 'B"',
- "br'", 'br"', "Br'", 'Br"',
- "bR'", 'bR"', "BR'", 'BR"' ,
- "rb'", 'rb"', "rB'", 'rB"',
- "Rb'", 'Rb"', "RB'", 'RB"' ,
- "u'", 'u"', "U'", 'U"',
- ):
- single_quoted[t] = t
+# A set of all of the single and triple quoted string prefixes,
+# including the opening quotes.
+single_quoted = set()
+triple_quoted = set()
+for t in _all_string_prefixes():
+ for u in (t + '"', t + "'"):
+ single_quoted.add(u)
+ for u in (t + '"""', t + "'''"):
+ triple_quoted.add(u)
tabsize = 8
@@ -626,6 +623,7 @@
yield stashed
stashed = None
yield TokenInfo(COMMENT, token, spos, epos, line)
+
elif token in triple_quoted:
endprog = _compile(endpats[token])
endmatch = endprog.match(line, pos)
@@ -638,19 +636,37 @@
contstr = line[start:]
contline = line
break
- elif initial in single_quoted or \
- token[:2] in single_quoted or \
- token[:3] in single_quoted:
+
+ # Check up to the first 3 chars of the token to see if
+ # they're in the single_quoted set. If so, they start
+ # a string.
+ # We're using the first 3, because we're looking for
+ # "rb'" (for example) at the start of the token. If
+ # we switch to longer prefixes, this needs to be
+ # adjusted.
+ # Note that initial == token[:1].
+ # Also note that single quote checking must come after
+ # triple quote checking (above).
+ elif (initial in single_quoted or
+ token[:2] in single_quoted or
+ token[:3] in single_quoted):
if token[-1] == '\n': # continued string
strstart = (lnum, start)
- endprog = _compile(endpats[initial] or
- endpats[token[1]] or
- endpats[token[2]])
+ # Again, using the first 3 chars of the
+ # token. This is looking for the matching end
+ # regex for the correct type of quote
+ # character. So it's really looking for
+ # endpats["'"] or endpats['"'], by trying to
+ # skip string prefix characters, if any.
+ endprog = _compile(endpats.get(initial) or
+ endpats.get(token[1]) or
+ endpats.get(token[2]))
contstr, needcont = line[start:], 1
contline = line
break
else: # ordinary string
yield TokenInfo(STRING, token, spos, epos, line)
+
elif initial.isidentifier(): # ordinary name
if token in ('async', 'await'):
if async_def:
diff --git a/Lib/trace.py b/Lib/trace.py
index f108266..ae15461 100755
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -48,6 +48,7 @@
r.write_results(show_missing=True, coverdir="/tmp")
"""
__all__ = ['Trace', 'CoverageResults']
+import argparse
import linecache
import os
import re
@@ -58,7 +59,6 @@
import gc
import dis
import pickle
-from warnings import warn as _warn
from time import monotonic as _time
try:
@@ -77,51 +77,6 @@
sys.settrace(None)
threading.settrace(None)
-def _usage(outfile):
- outfile.write("""Usage: %s [OPTIONS] <file> [ARGS]
-
-Meta-options:
---help Display this help then exit.
---version Output version information then exit.
-
-Otherwise, exactly one of the following three options must be given:
--t, --trace Print each line to sys.stdout before it is executed.
--c, --count Count the number of times each line is executed
- and write the counts to <module>.cover for each
- module executed, in the module's directory.
- See also `--coverdir', `--file', `--no-report' below.
--l, --listfuncs Keep track of which functions are executed at least
- once and write the results to sys.stdout after the
- program exits.
--T, --trackcalls Keep track of caller/called pairs and write the
- results to sys.stdout after the program exits.
--r, --report Generate a report from a counts file; do not execute
- any code. `--file' must specify the results file to
- read, which must have been created in a previous run
- with `--count --file=FILE'.
-
-Modifiers:
--f, --file=<file> File to accumulate counts over several runs.
--R, --no-report Do not generate the coverage report files.
- Useful if you want to accumulate over several runs.
--C, --coverdir=<dir> Directory where the report files. The coverage
- report for <package>.<module> is written to file
- <dir>/<package>/<module>.cover.
--m, --missing Annotate executable lines that were not executed
- with '>>>>>> '.
--s, --summary Write a brief summary on stdout for each file.
- (Can only be used with --count or --report.)
--g, --timing Prefix each line with the time since the program started.
- Only used while tracing.
-
-Filters, may be repeated multiple times:
---ignore-module=<mod> Ignore the given module(s) and its submodules
- (if it is a package). Accepts comma separated
- list of module names
---ignore-dir=<dir> Ignore files in the given directory (multiple
- directories can be joined by os.pathsep).
-""" % sys.argv[0])
-
PRAGMA_NOCOVER = "#pragma NO COVER"
# Simple rx to find lines with no code.
@@ -265,7 +220,13 @@
def write_results(self, show_missing=True, summary=False, coverdir=None):
"""
- @param coverdir
+ Write the coverage results.
+
+ :param show_missing: Show lines that had no hits.
+ :param summary: Include coverage summary per module.
+ :param coverdir: If None, the results of each module are placed in its
+ directory, otherwise it is included in the directory
+ specified.
"""
if self.calledfuncs:
print()
@@ -647,210 +608,135 @@
calledfuncs=self._calledfuncs,
callers=self._callers)
-def _err_exit(msg):
- sys.stderr.write("%s: %s\n" % (sys.argv[0], msg))
- sys.exit(1)
+def main():
-def main(argv=None):
- import getopt
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--version', action='version', version='trace 2.0')
- if argv is None:
- argv = sys.argv
+ grp = parser.add_argument_group('Main options',
+ 'One of these (or --report) must be given')
+
+ grp.add_argument('-c', '--count', action='store_true',
+ help='Count the number of times each line is executed and write '
+ 'the counts to <module>.cover for each module executed, in '
+ 'the module\'s directory. See also --coverdir, --file, '
+ '--no-report below.')
+ grp.add_argument('-t', '--trace', action='store_true',
+ help='Print each line to sys.stdout before it is executed')
+ grp.add_argument('-l', '--listfuncs', action='store_true',
+ help='Keep track of which functions are executed at least once '
+ 'and write the results to sys.stdout after the program exits. '
+ 'Cannot be specified alongside --trace or --count.')
+ grp.add_argument('-T', '--trackcalls', action='store_true',
+ help='Keep track of caller/called pairs and write the results to '
+ 'sys.stdout after the program exits.')
+
+ grp = parser.add_argument_group('Modifiers')
+
+ _grp = grp.add_mutually_exclusive_group()
+ _grp.add_argument('-r', '--report', action='store_true',
+ help='Generate a report from a counts file; does not execute any '
+ 'code. --file must specify the results file to read, which '
+ 'must have been created in a previous run with --count '
+ '--file=FILE')
+ _grp.add_argument('-R', '--no-report', action='store_true',
+ help='Do not generate the coverage report files. '
+ 'Useful if you want to accumulate over several runs.')
+
+ grp.add_argument('-f', '--file',
+ help='File to accumulate counts over several runs')
+ grp.add_argument('-C', '--coverdir',
+ help='Directory where the report files go. The coverage report '
+ 'for <package>.<module> will be written to file '
+ '<dir>/<package>/<module>.cover')
+ grp.add_argument('-m', '--missing', action='store_true',
+ help='Annotate executable lines that were not executed with '
+ '">>>>>> "')
+ grp.add_argument('-s', '--summary', action='store_true',
+ help='Write a brief summary for each file to sys.stdout. '
+ 'Can only be used with --count or --report')
+ grp.add_argument('-g', '--timing', action='store_true',
+ help='Prefix each line with the time since the program started. '
+ 'Only used while tracing')
+
+ grp = parser.add_argument_group('Filters',
+ 'Can be specified multiple times')
+ grp.add_argument('--ignore-module', action='append', default=[],
+ help='Ignore the given module(s) and its submodules'
+ '(if it is a package). Accepts comma separated list of '
+ 'module names.')
+ grp.add_argument('--ignore-dir', action='append', default=[],
+ help='Ignore files in the given directory '
+ '(multiple directories can be joined by os.pathsep).')
+
+ parser.add_argument('filename', nargs='?',
+ help='file to run as main program')
+ parser.add_argument('arguments', nargs=argparse.REMAINDER,
+ help='arguments to the program')
+
+ opts = parser.parse_args()
+
+ if opts.ignore_dir:
+ rel_path = 'lib', 'python{0.major}.{0.minor}'.format(sys.version_info)
+ _prefix = os.path.join(sys.base_prefix, *rel_path)
+ _exec_prefix = os.path.join(sys.base_exec_prefix, *rel_path)
+
+ def parse_ignore_dir(s):
+ s = os.path.expanduser(os.path.expandvars(s))
+ s = s.replace('$prefix', _prefix).replace('$exec_prefix', _exec_prefix)
+ return os.path.normpath(s)
+
+ opts.ignore_module = [mod.strip()
+ for i in opts.ignore_module for mod in i.split(',')]
+ opts.ignore_dir = [parse_ignore_dir(s)
+ for i in opts.ignore_dir for s in i.split(os.pathsep)]
+
+ if opts.report:
+ if not opts.file:
+ parser.error('-r/--report requires -f/--file')
+ results = CoverageResults(infile=opts.file, outfile=opts.file)
+ return results.write_results(opts.missing, opts.summary, opts.coverdir)
+
+ if not any([opts.trace, opts.count, opts.listfuncs, opts.trackcalls]):
+ parser.error('must specify one of --trace, --count, --report, '
+ '--listfuncs, or --trackcalls')
+
+ if opts.listfuncs and (opts.count or opts.trace):
+ parser.error('cannot specify both --listfuncs and (--trace or --count)')
+
+ if opts.summary and not opts.count:
+ parser.error('--summary can only be used with --count or --report')
+
+ if opts.filename is None:
+ parser.error('filename is missing: required with the main options')
+
+ sys.argv = opts.filename, *opts.arguments
+ sys.path[0] = os.path.dirname(opts.filename)
+
+ t = Trace(opts.count, opts.trace, countfuncs=opts.listfuncs,
+ countcallers=opts.trackcalls, ignoremods=opts.ignore_module,
+ ignoredirs=opts.ignore_dir, infile=opts.file,
+ outfile=opts.file, timing=opts.timing)
try:
- opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:lTg",
- ["help", "version", "trace", "count",
- "report", "no-report", "summary",
- "file=", "missing",
- "ignore-module=", "ignore-dir=",
- "coverdir=", "listfuncs",
- "trackcalls", "timing"])
+ with open(opts.filename) as fp:
+ code = compile(fp.read(), opts.filename, 'exec')
+ # try to emulate __main__ namespace as much as possible
+ globs = {
+ '__file__': opts.filename,
+ '__name__': '__main__',
+ '__package__': None,
+ '__cached__': None,
+ }
+ t.runctx(code, globs, globs)
+ except OSError as err:
+ sys.exit("Cannot run file %r because: %s" % (sys.argv[0], err))
+ except SystemExit:
+ pass
- except getopt.error as msg:
- sys.stderr.write("%s: %s\n" % (sys.argv[0], msg))
- sys.stderr.write("Try `%s --help' for more information\n"
- % sys.argv[0])
- sys.exit(1)
+ results = t.results()
- trace = 0
- count = 0
- report = 0
- no_report = 0
- counts_file = None
- missing = 0
- ignore_modules = []
- ignore_dirs = []
- coverdir = None
- summary = 0
- listfuncs = False
- countcallers = False
- timing = False
-
- for opt, val in opts:
- if opt == "--help":
- _usage(sys.stdout)
- sys.exit(0)
-
- if opt == "--version":
- sys.stdout.write("trace 2.0\n")
- sys.exit(0)
-
- if opt == "-T" or opt == "--trackcalls":
- countcallers = True
- continue
-
- if opt == "-l" or opt == "--listfuncs":
- listfuncs = True
- continue
-
- if opt == "-g" or opt == "--timing":
- timing = True
- continue
-
- if opt == "-t" or opt == "--trace":
- trace = 1
- continue
-
- if opt == "-c" or opt == "--count":
- count = 1
- continue
-
- if opt == "-r" or opt == "--report":
- report = 1
- continue
-
- if opt == "-R" or opt == "--no-report":
- no_report = 1
- continue
-
- if opt == "-f" or opt == "--file":
- counts_file = val
- continue
-
- if opt == "-m" or opt == "--missing":
- missing = 1
- continue
-
- if opt == "-C" or opt == "--coverdir":
- coverdir = val
- continue
-
- if opt == "-s" or opt == "--summary":
- summary = 1
- continue
-
- if opt == "--ignore-module":
- for mod in val.split(","):
- ignore_modules.append(mod.strip())
- continue
-
- if opt == "--ignore-dir":
- for s in val.split(os.pathsep):
- s = os.path.expandvars(s)
- # should I also call expanduser? (after all, could use $HOME)
-
- s = s.replace("$prefix",
- os.path.join(sys.base_prefix, "lib",
- "python" + sys.version[:3]))
- s = s.replace("$exec_prefix",
- os.path.join(sys.base_exec_prefix, "lib",
- "python" + sys.version[:3]))
- s = os.path.normpath(s)
- ignore_dirs.append(s)
- continue
-
- assert 0, "Should never get here"
-
- if listfuncs and (count or trace):
- _err_exit("cannot specify both --listfuncs and (--trace or --count)")
-
- if not (count or trace or report or listfuncs or countcallers):
- _err_exit("must specify one of --trace, --count, --report, "
- "--listfuncs, or --trackcalls")
-
- if report and no_report:
- _err_exit("cannot specify both --report and --no-report")
-
- if report and not counts_file:
- _err_exit("--report requires a --file")
-
- if no_report and len(prog_argv) == 0:
- _err_exit("missing name of file to run")
-
- # everything is ready
- if report:
- results = CoverageResults(infile=counts_file, outfile=counts_file)
- results.write_results(missing, summary=summary, coverdir=coverdir)
- else:
- sys.argv = prog_argv
- progname = prog_argv[0]
- sys.path[0] = os.path.split(progname)[0]
-
- t = Trace(count, trace, countfuncs=listfuncs,
- countcallers=countcallers, ignoremods=ignore_modules,
- ignoredirs=ignore_dirs, infile=counts_file,
- outfile=counts_file, timing=timing)
- try:
- with open(progname) as fp:
- code = compile(fp.read(), progname, 'exec')
- # try to emulate __main__ namespace as much as possible
- globs = {
- '__file__': progname,
- '__name__': '__main__',
- '__package__': None,
- '__cached__': None,
- }
- t.runctx(code, globs, globs)
- except OSError as err:
- _err_exit("Cannot run file %r because: %s" % (sys.argv[0], err))
- except SystemExit:
- pass
-
- results = t.results()
-
- if not no_report:
- results.write_results(missing, summary=summary, coverdir=coverdir)
-
-# Deprecated API
-def usage(outfile):
- _warn("The trace.usage() function is deprecated",
- DeprecationWarning, 2)
- _usage(outfile)
-
-class Ignore(_Ignore):
- def __init__(self, modules=None, dirs=None):
- _warn("The class trace.Ignore is deprecated",
- DeprecationWarning, 2)
- _Ignore.__init__(self, modules, dirs)
-
-def modname(path):
- _warn("The trace.modname() function is deprecated",
- DeprecationWarning, 2)
- return _modname(path)
-
-def fullmodname(path):
- _warn("The trace.fullmodname() function is deprecated",
- DeprecationWarning, 2)
- return _fullmodname(path)
-
-def find_lines_from_code(code, strs):
- _warn("The trace.find_lines_from_code() function is deprecated",
- DeprecationWarning, 2)
- return _find_lines_from_code(code, strs)
-
-def find_lines(code, strs):
- _warn("The trace.find_lines() function is deprecated",
- DeprecationWarning, 2)
- return _find_lines(code, strs)
-
-def find_strings(filename, encoding=None):
- _warn("The trace.find_strings() function is deprecated",
- DeprecationWarning, 2)
- return _find_strings(filename, encoding=None)
-
-def find_executable_linenos(filename):
- _warn("The trace.find_executable_linenos() function is deprecated",
- DeprecationWarning, 2)
- return _find_executable_linenos(filename)
+ if not opts.no_report:
+ results.write_results(opts.missing, opts.summary, opts.coverdir)
if __name__=='__main__':
main()
diff --git a/Lib/traceback.py b/Lib/traceback.py
index a2eb539..3b46c0b 100644
--- a/Lib/traceback.py
+++ b/Lib/traceback.py
@@ -487,10 +487,9 @@
self._load_lines()
@classmethod
- def from_exception(self, exc, *args, **kwargs):
+ def from_exception(cls, exc, *args, **kwargs):
"""Create a TracebackException from an exception."""
- return TracebackException(
- type(exc), exc, exc.__traceback__, *args, **kwargs)
+ return cls(type(exc), exc, exc.__traceback__, *args, **kwargs)
def _load_lines(self):
"""Private API. force all lines in the stack to be loaded."""
diff --git a/Lib/tracemalloc.py b/Lib/tracemalloc.py
index 6288da8..75b3918 100644
--- a/Lib/tracemalloc.py
+++ b/Lib/tracemalloc.py
@@ -244,17 +244,21 @@
__slots__ = ("_trace",)
def __init__(self, trace):
- # trace is a tuple: (size, traceback), see Traceback constructor
- # for the format of the traceback tuple
+ # trace is a tuple: (domain: int, size: int, traceback: tuple).
+ # See Traceback constructor for the format of the traceback tuple.
self._trace = trace
@property
- def size(self):
+ def domain(self):
return self._trace[0]
@property
+ def size(self):
+ return self._trace[1]
+
+ @property
def traceback(self):
- return Traceback(self._trace[1])
+ return Traceback(self._trace[2])
def __eq__(self, other):
return (self._trace == other._trace)
@@ -266,8 +270,8 @@
return "%s: %s" % (self.traceback, _format_size(self.size, False))
def __repr__(self):
- return ("<Trace size=%s, traceback=%r>"
- % (_format_size(self.size, False), self.traceback))
+ return ("<Trace domain=%s size=%s, traceback=%r>"
+ % (self.domain, _format_size(self.size, False), self.traceback))
class _Traces(Sequence):
@@ -302,19 +306,29 @@
return filename
-class Filter:
+class BaseFilter:
+ def __init__(self, inclusive):
+ self.inclusive = inclusive
+
+ def _match(self, trace):
+ raise NotImplementedError
+
+
+class Filter(BaseFilter):
def __init__(self, inclusive, filename_pattern,
- lineno=None, all_frames=False):
+ lineno=None, all_frames=False, domain=None):
+ super().__init__(inclusive)
self.inclusive = inclusive
self._filename_pattern = _normalize_filename(filename_pattern)
self.lineno = lineno
self.all_frames = all_frames
+ self.domain = domain
@property
def filename_pattern(self):
return self._filename_pattern
- def __match_frame(self, filename, lineno):
+ def _match_frame_impl(self, filename, lineno):
filename = _normalize_filename(filename)
if not fnmatch.fnmatch(filename, self._filename_pattern):
return False
@@ -324,11 +338,11 @@
return (lineno == self.lineno)
def _match_frame(self, filename, lineno):
- return self.__match_frame(filename, lineno) ^ (not self.inclusive)
+ return self._match_frame_impl(filename, lineno) ^ (not self.inclusive)
def _match_traceback(self, traceback):
if self.all_frames:
- if any(self.__match_frame(filename, lineno)
+ if any(self._match_frame_impl(filename, lineno)
for filename, lineno in traceback):
return self.inclusive
else:
@@ -337,6 +351,30 @@
filename, lineno = traceback[0]
return self._match_frame(filename, lineno)
+ def _match(self, trace):
+ domain, size, traceback = trace
+ res = self._match_traceback(traceback)
+ if self.domain is not None:
+ if self.inclusive:
+ return res and (domain == self.domain)
+ else:
+ return res or (domain != self.domain)
+ return res
+
+
+class DomainFilter(BaseFilter):
+ def __init__(self, inclusive, domain):
+ super().__init__(inclusive)
+ self._domain = domain
+
+ @property
+ def domain(self):
+ return self._domain
+
+ def _match(self, trace):
+ domain, size, traceback = trace
+ return (domain == self.domain) ^ (not self.inclusive)
+
class Snapshot:
"""
@@ -365,13 +403,12 @@
return pickle.load(fp)
def _filter_trace(self, include_filters, exclude_filters, trace):
- traceback = trace[1]
if include_filters:
- if not any(trace_filter._match_traceback(traceback)
+ if not any(trace_filter._match(trace)
for trace_filter in include_filters):
return False
if exclude_filters:
- if any(not trace_filter._match_traceback(traceback)
+ if any(not trace_filter._match(trace)
for trace_filter in exclude_filters):
return False
return True
@@ -379,8 +416,8 @@
def filter_traces(self, filters):
"""
Create a new Snapshot instance with a filtered traces sequence, filters
- is a list of Filter instances. If filters is an empty list, return a
- new Snapshot instance with a copy of the traces.
+ is a list of Filter or DomainFilter instances. If filters is an empty
+ list, return a new Snapshot instance with a copy of the traces.
"""
if not isinstance(filters, Iterable):
raise TypeError("filters must be a list of filters, not %s"
@@ -412,7 +449,7 @@
tracebacks = {}
if not cumulative:
for trace in self.traces._traces:
- size, trace_traceback = trace
+ domain, size, trace_traceback = trace
try:
traceback = tracebacks[trace_traceback]
except KeyError:
@@ -433,7 +470,7 @@
else:
# cumulative statistics
for trace in self.traces._traces:
- size, trace_traceback = trace
+ domain, size, trace_traceback = trace
for frame in trace_traceback:
try:
traceback = tracebacks[frame]
diff --git a/Lib/turtledemo/__main__.py b/Lib/turtledemo/__main__.py
index 711d0ab..0a58332 100644
--- a/Lib/turtledemo/__main__.py
+++ b/Lib/turtledemo/__main__.py
@@ -89,13 +89,12 @@
import os
from tkinter import *
-from idlelib.ColorDelegator import ColorDelegator, color_config
-from idlelib.Percolator import Percolator
-from idlelib.textView import view_text
+from idlelib.colorizer import ColorDelegator, color_config
+from idlelib.percolator import Percolator
+from idlelib.textview import view_text
from turtledemo import __doc__ as about_turtledemo
import turtle
-import time
demo_dir = os.path.dirname(os.path.abspath(__file__))
darwin = sys.platform == 'darwin'
diff --git a/Lib/turtledemo/bytedesign.py b/Lib/turtledemo/bytedesign.py
index 64b1d7d..b3b095b 100755
--- a/Lib/turtledemo/bytedesign.py
+++ b/Lib/turtledemo/bytedesign.py
@@ -22,7 +22,6 @@
mode as fast as possible.
"""
-import math
from turtle import Turtle, mainloop
from time import clock
diff --git a/Lib/turtledemo/planet_and_moon.py b/Lib/turtledemo/planet_and_moon.py
index 26abfdb..021ff99 100755
--- a/Lib/turtledemo/planet_and_moon.py
+++ b/Lib/turtledemo/planet_and_moon.py
@@ -18,7 +18,6 @@
"""
from turtle import Shape, Turtle, mainloop, Vec2D as Vec
-from time import sleep
G = 8
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index 1adfcf9..6cc8093 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -523,7 +523,7 @@
side_effect = property(__get_side_effect, __set_side_effect)
- def reset_mock(self, visited=None):
+ def reset_mock(self, visited=None,*, return_value=False, side_effect=False):
"Restore the mock object to its initial state."
if visited is None:
visited = []
@@ -538,6 +538,11 @@
self.call_args_list = _CallList()
self.method_calls = _CallList()
+ if return_value:
+ self._mock_return_value = DEFAULT
+ if side_effect:
+ self._mock_side_effect = None
+
for child in self._mock_children.values():
if isinstance(child, _SpecState):
continue
@@ -772,6 +777,24 @@
(self._mock_name or 'mock', self.call_count))
raise AssertionError(msg)
+ def assert_called(_mock_self):
+ """assert that the mock was called at least once
+ """
+ self = _mock_self
+ if self.call_count == 0:
+ msg = ("Expected '%s' to have been called." %
+ self._mock_name or 'mock')
+ raise AssertionError(msg)
+
+ def assert_called_once(_mock_self):
+ """assert that the mock was called only once.
+ """
+ self = _mock_self
+ if not self.call_count == 1:
+ msg = ("Expected '%s' to have been called once. 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.
@@ -820,7 +843,7 @@
if expected not in all_calls:
raise AssertionError(
'Calls not found.\nExpected: %r\n'
- 'Actual: %r' % (calls, self.mock_calls)
+ 'Actual: %r' % (_CallList(calls), self.mock_calls)
) from cause
return
diff --git a/Lib/unittest/test/testmock/support.py b/Lib/unittest/test/testmock/support.py
index f473879..205431a 100644
--- a/Lib/unittest/test/testmock/support.py
+++ b/Lib/unittest/test/testmock/support.py
@@ -1,5 +1,3 @@
-import sys
-
def is_instance(obj, klass):
"""Version of is_instance that doesn't access __class__"""
return issubclass(type(obj), klass)
diff --git a/Lib/unittest/test/testmock/testmagicmethods.py b/Lib/unittest/test/testmock/testmagicmethods.py
index bb9b956..24569b5 100644
--- a/Lib/unittest/test/testmock/testmagicmethods.py
+++ b/Lib/unittest/test/testmock/testmagicmethods.py
@@ -1,5 +1,4 @@
import unittest
-import inspect
import sys
from unittest.mock import Mock, MagicMock, _magics
diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py
index 5f82b82..b07a7cc 100644
--- a/Lib/unittest/test/testmock/testmock.py
+++ b/Lib/unittest/test/testmock/testmock.py
@@ -1239,6 +1239,27 @@
with self.assertRaises(AssertionError):
m.hello.assert_not_called()
+ def test_assert_called(self):
+ m = Mock()
+ with self.assertRaises(AssertionError):
+ m.hello.assert_called()
+ m.hello()
+ m.hello.assert_called()
+
+ m.hello()
+ m.hello.assert_called()
+
+ def test_assert_called_once(self):
+ m = Mock()
+ with self.assertRaises(AssertionError):
+ m.hello.assert_called_once()
+ m.hello()
+ m.hello.assert_called_once()
+
+ m.hello()
+ with self.assertRaises(AssertionError):
+ m.hello.assert_called_once()
+
#Issue21256 printout of keyword args should be in deterministic order
def test_sorted_call_signature(self):
m = Mock()
@@ -1256,6 +1277,24 @@
self.assertEqual(m.method_calls[0], c)
self.assertEqual(m.method_calls[1], i)
+ def test_reset_return_sideeffect(self):
+ m = Mock(return_value=10, side_effect=[2,3])
+ m.reset_mock(return_value=True, side_effect=True)
+ self.assertIsInstance(m.return_value, Mock)
+ self.assertEqual(m.side_effect, None)
+
+ def test_reset_return(self):
+ m = Mock(return_value=10, side_effect=[2,3])
+ m.reset_mock(return_value=True)
+ self.assertIsInstance(m.return_value, Mock)
+ self.assertNotEqual(m.side_effect, None)
+
+ def test_reset_sideeffect(self):
+ m = Mock(return_value=10, side_effect=[2,3])
+ m.reset_mock(side_effect=True)
+ self.assertEqual(m.return_value, 10)
+ self.assertEqual(m.side_effect, None)
+
def test_mock_add_spec(self):
class _One(object):
one = 1
diff --git a/Lib/unittest/test/testmock/testpatch.py b/Lib/unittest/test/testmock/testpatch.py
index dfce369..2e0c08f 100644
--- a/Lib/unittest/test/testmock/testpatch.py
+++ b/Lib/unittest/test/testmock/testpatch.py
@@ -10,9 +10,9 @@
from unittest.test.testmock.support import SomeClass, is_instance
from unittest.mock import (
- NonCallableMock, CallableMixin, patch, sentinel,
+ NonCallableMock, CallableMixin, sentinel,
MagicMock, Mock, NonCallableMagicMock, patch, _patch,
- DEFAULT, call, _get_target, _patch
+ DEFAULT, call, _get_target
)
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
index 4d7fcec..99a6977 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -156,9 +156,8 @@
port = self._hostinfo[1]
if port is not None:
port = int(port, 10)
- # Return None on an illegal port
if not ( 0 <= port <= 65535):
- return None
+ raise ValueError("Port out of range 0-65535")
return port
@@ -225,8 +224,71 @@
from collections import namedtuple
_DefragResultBase = namedtuple('DefragResult', 'url fragment')
-_SplitResultBase = namedtuple('SplitResult', 'scheme netloc path query fragment')
-_ParseResultBase = namedtuple('ParseResult', 'scheme netloc path params query fragment')
+_SplitResultBase = namedtuple(
+ 'SplitResult', 'scheme netloc path query fragment')
+_ParseResultBase = namedtuple(
+ 'ParseResult', 'scheme netloc path params query fragment')
+
+_DefragResultBase.__doc__ = """
+DefragResult(url, fragment)
+
+A 2-tuple that contains the url without fragment identifier and the fragment
+identifier as a separate argument.
+"""
+
+_DefragResultBase.url.__doc__ = """The URL with no fragment identifier."""
+
+_DefragResultBase.fragment.__doc__ = """
+Fragment identifier separated from URL, that allows indirect identification of a
+secondary resource by reference to a primary resource and additional identifying
+information.
+"""
+
+_SplitResultBase.__doc__ = """
+SplitResult(scheme, netloc, path, query, fragment)
+
+A 5-tuple that contains the different components of a URL. Similar to
+ParseResult, but does not split params.
+"""
+
+_SplitResultBase.scheme.__doc__ = """Specifies URL scheme for the request."""
+
+_SplitResultBase.netloc.__doc__ = """
+Network location where the request is made to.
+"""
+
+_SplitResultBase.path.__doc__ = """
+The hierarchical path, such as the path to a file to download.
+"""
+
+_SplitResultBase.query.__doc__ = """
+The query component, that contains non-hierarchical data, that along with data
+in path component, identifies a resource in the scope of URI's scheme and
+network location.
+"""
+
+_SplitResultBase.fragment.__doc__ = """
+Fragment identifier, that allows indirect identification of a secondary resource
+by reference to a primary resource and additional identifying information.
+"""
+
+_ParseResultBase.__doc__ = """
+ParseResult(scheme, netloc, path, params, query, fragment)
+
+A 6-tuple that contains components of a parsed URL.
+"""
+
+_ParseResultBase.scheme.__doc__ = _SplitResultBase.scheme.__doc__
+_ParseResultBase.netloc.__doc__ = _SplitResultBase.netloc.__doc__
+_ParseResultBase.path.__doc__ = _SplitResultBase.path.__doc__
+_ParseResultBase.params.__doc__ = """
+Parameters for last path element used to dereference the URI in order to provide
+access to perform some operation on the resource.
+"""
+
+_ParseResultBase.query.__doc__ = _SplitResultBase.query.__doc__
+_ParseResultBase.fragment.__doc__ = _SplitResultBase.fragment.__doc__
+
# For backwards compatibility, alias _NetlocResultMixinStr
# ResultBase is no longer part of the documented API, but it is
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index 1731fe3..67e73f9 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -134,11 +134,76 @@
]
# used in User-Agent header sent
-__version__ = sys.version[:3]
+__version__ = '%d.%d' % sys.version_info[:2]
_opener = None
def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
*, cafile=None, capath=None, cadefault=False, context=None):
+ '''Open the URL url, which can be either a string or a Request object.
+
+ *data* must be a bytes object specifying additional data to be sent to the
+ server, or None if no such data is needed. data may also be an iterable
+ object and in that case Content-Length value must be specified in the
+ headers. Currently HTTP requests are the only ones that use data; the HTTP
+ request will be a POST instead of a GET when the data parameter is
+ provided.
+
+ *data* should be a buffer in the standard application/x-www-form-urlencoded
+ format. The urllib.parse.urlencode() function takes a mapping or sequence
+ of 2-tuples and returns an ASCII text string in this format. It should be
+ encoded to bytes before being used as the data parameter.
+
+ urllib.request module uses HTTP/1.1 and includes a "Connection:close"
+ header in its HTTP requests.
+
+ The optional *timeout* parameter specifies a timeout in seconds for
+ blocking operations like the connection attempt (if not specified, the
+ global default timeout setting will be used). This only works for HTTP,
+ HTTPS and FTP connections.
+
+ If *context* is specified, it must be a ssl.SSLContext instance describing
+ the various SSL options. See HTTPSConnection for more details.
+
+ The optional *cafile* and *capath* parameters specify a set of trusted CA
+ certificates for HTTPS requests. cafile should point to a single file
+ containing a bundle of CA certificates, whereas capath should point to a
+ directory of hashed certificate files. More information can be found in
+ ssl.SSLContext.load_verify_locations().
+
+ The *cadefault* parameter is ignored.
+
+ This function always returns an object which can work as a context
+ manager and has methods such as
+
+ * geturl() - return the URL of the resource retrieved, commonly used to
+ determine if a redirect was followed
+
+ * info() - return the meta-information of the page, such as headers, in the
+ form of an email.message_from_string() instance (see Quick Reference to
+ HTTP Headers)
+
+ * getcode() - return the HTTP status code of the response. Raises URLError
+ on errors.
+
+ For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse
+ object slightly modified. In addition to the three new methods above, the
+ msg attribute contains the same information as the reason attribute ---
+ the reason phrase returned by the server --- instead of the response
+ headers as it is specified in the documentation for HTTPResponse.
+
+ For FTP, file, and data URLs and requests explicitly handled by legacy
+ URLopener and FancyURLopener classes, this function returns a
+ urllib.response.addinfourl object.
+
+ Note that None may be returned if no handler handles the request (though
+ the default installed global OpenerDirector uses UnknownHandler to ensure
+ this never happens).
+
+ In addition, if proxy settings are detected (for example, when a *_proxy
+ environment variable like http_proxy is set), ProxyHandler is default
+ installed and makes sure the requests are handled through the proxy.
+
+ '''
global _opener
if cafile or capath or cadefault:
if context is not None:
diff --git a/Lib/urllib/robotparser.py b/Lib/urllib/robotparser.py
index 8b69fd9..85add16 100644
--- a/Lib/urllib/robotparser.py
+++ b/Lib/urllib/robotparser.py
@@ -10,7 +10,9 @@
http://www.robotstxt.org/norobots-rfc.txt
"""
-import urllib.parse, urllib.request
+import collections
+import urllib.parse
+import urllib.request
__all__ = ["RobotFileParser"]
@@ -120,10 +122,29 @@
if state != 0:
entry.rulelines.append(RuleLine(line[1], True))
state = 2
+ elif line[0] == "crawl-delay":
+ if state != 0:
+ # before trying to convert to int we need to make
+ # sure that robots.txt has valid syntax otherwise
+ # it will crash
+ if line[1].strip().isdigit():
+ entry.delay = int(line[1])
+ state = 2
+ elif line[0] == "request-rate":
+ if state != 0:
+ numbers = line[1].split('/')
+ # check if all values are sane
+ if (len(numbers) == 2 and numbers[0].strip().isdigit()
+ and numbers[1].strip().isdigit()):
+ req_rate = collections.namedtuple('req_rate',
+ 'requests seconds')
+ entry.req_rate = req_rate
+ entry.req_rate.requests = int(numbers[0])
+ entry.req_rate.seconds = int(numbers[1])
+ state = 2
if state == 2:
self._add_entry(entry)
-
def can_fetch(self, useragent, url):
"""using the parsed robots.txt decide if useragent can fetch url"""
if self.disallow_all:
@@ -153,6 +174,18 @@
# agent not found ==> access granted
return True
+ def crawl_delay(self, useragent):
+ for entry in self.entries:
+ if entry.applies_to(useragent):
+ return entry.delay
+ return None
+
+ def request_rate(self, useragent):
+ for entry in self.entries:
+ if entry.applies_to(useragent):
+ return entry.req_rate
+ return None
+
def __str__(self):
return ''.join([str(entry) + "\n" for entry in self.entries])
@@ -180,6 +213,8 @@
def __init__(self):
self.useragents = []
self.rulelines = []
+ self.delay = None
+ self.req_rate = None
def __str__(self):
ret = []
diff --git a/Lib/uuid.py b/Lib/uuid.py
index e96e7e0..200c800 100644
--- a/Lib/uuid.py
+++ b/Lib/uuid.py
@@ -487,7 +487,6 @@
# Assume that the uuid_generate functions are broken from 10.5 onward,
# the test can be adjusted when a later version is fixed.
if sys.platform == 'darwin':
- import os
if int(os.uname().release.split('.')[0]) >= 9:
_uuid_generate_time = None
diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py
index 74245ab..fa3d2a3 100644
--- a/Lib/venv/__init__.py
+++ b/Lib/venv/__init__.py
@@ -3,28 +3,6 @@
Copyright (C) 2011-2014 Vinay Sajip.
Licensed to the PSF under a contributor agreement.
-
-usage: python -m venv [-h] [--system-site-packages] [--symlinks] [--clear]
- [--upgrade]
- ENV_DIR [ENV_DIR ...]
-
-Creates virtual Python environments in one or more target directories.
-
-positional arguments:
- ENV_DIR A directory to create the environment in.
-
-optional arguments:
- -h, --help show this help message and exit
- --system-site-packages
- Give the virtual environment access to the system
- site-packages dir.
- --symlinks Attempt to symlink rather than copy.
- --clear Delete the contents of the environment directory if it
- already exists, before environment creation.
- --upgrade Upgrade the environment directory to use this version
- of Python, assuming Python has been upgraded in-place.
- --without-pip Skips installing or upgrading pip in the virtual
- environment (pip is bootstrapped by default)
"""
import logging
import os
@@ -349,23 +327,7 @@
def create(env_dir, system_site_packages=False, clear=False,
symlinks=False, with_pip=False):
- """
- Create a virtual environment in a directory.
-
- By default, makes the system (global) site-packages dir *un*available to
- the created environment, and uses copying rather than symlinking for files
- obtained from the source Python installation.
-
- :param env_dir: The target directory to create an environment in.
- :param system_site_packages: If True, the system (global) site-packages
- dir is available to the environment.
- :param clear: If True, delete the contents of the environment directory if
- it already exists, before environment creation.
- :param symlinks: If True, attempt to symlink rather than copy files into
- virtual environment.
- :param with_pip: If True, ensure pip is installed in the virtual
- environment
- """
+ """Create a virtual environment in a directory."""
builder = EnvBuilder(system_site_packages=system_site_packages,
clear=clear, symlinks=symlinks, with_pip=with_pip)
builder.create(env_dir)
diff --git a/Lib/warnings.py b/Lib/warnings.py
index c6631fc..2b407ff 100644
--- a/Lib/warnings.py
+++ b/Lib/warnings.py
@@ -2,39 +2,112 @@
import sys
+
__all__ = ["warn", "warn_explicit", "showwarning",
"formatwarning", "filterwarnings", "simplefilter",
"resetwarnings", "catch_warnings"]
-
def showwarning(message, category, filename, lineno, file=None, line=None):
"""Hook to write a warning to a file; replace if you like."""
- if file is None:
- file = sys.stderr
- if file is None:
- # sys.stderr is None when run with pythonw.exe - warnings get lost
- return
- try:
- file.write(formatwarning(message, category, filename, lineno, line))
- except OSError:
- pass # the file (probably stderr) is invalid - this warning gets lost.
+ msg = WarningMessage(message, category, filename, lineno, file, line)
+ _showwarnmsg_impl(msg)
def formatwarning(message, category, filename, lineno, line=None):
"""Function to format a warning the standard way."""
- s = "%s:%s: %s: %s\n" % (filename, lineno, category.__name__, message)
- if line is None:
+ msg = WarningMessage(message, category, filename, lineno, None, line)
+ return _formatwarnmsg_impl(msg)
+
+def _showwarnmsg_impl(msg):
+ file = msg.file
+ if file is None:
+ file = sys.stderr
+ if file is None:
+ # sys.stderr is None when run with pythonw.exe:
+ # warnings get lost
+ return
+ text = _formatwarnmsg(msg)
+ try:
+ file.write(text)
+ except OSError:
+ # the file (probably stderr) is invalid - this warning gets lost.
+ pass
+
+def _formatwarnmsg_impl(msg):
+ s = ("%s:%s: %s: %s\n"
+ % (msg.filename, msg.lineno, msg.category.__name__,
+ msg.message))
+
+ if msg.line is None:
try:
import linecache
- line = linecache.getline(filename, lineno)
+ line = linecache.getline(msg.filename, msg.lineno)
except Exception:
# When a warning is logged during Python shutdown, linecache
# and the import machinery don't work anymore
line = None
+ linecache = None
+ else:
+ line = msg.line
if line:
line = line.strip()
s += " %s\n" % line
+
+ if msg.source is not None:
+ try:
+ import tracemalloc
+ tb = tracemalloc.get_object_traceback(msg.source)
+ except Exception:
+ # When a warning is logged during Python shutdown, tracemalloc
+ # and the import machinery don't work anymore
+ tb = None
+
+ if tb is not None:
+ s += 'Object allocated at (most recent call first):\n'
+ for frame in tb:
+ s += (' File "%s", lineno %s\n'
+ % (frame.filename, frame.lineno))
+
+ try:
+ if linecache is not None:
+ line = linecache.getline(frame.filename, frame.lineno)
+ else:
+ line = None
+ except Exception:
+ line = None
+ if line:
+ line = line.strip()
+ s += ' %s\n' % line
return s
+# Keep a reference to check if the function was replaced
+_showwarning = showwarning
+
+def _showwarnmsg(msg):
+ """Hook to write a warning to a file; replace if you like."""
+ showwarning = globals().get('showwarning', _showwarning)
+ if showwarning is not _showwarning:
+ # warnings.showwarning() was replaced
+ if not callable(showwarning):
+ raise TypeError("warnings.showwarning() must be set to a "
+ "function or method")
+
+ showwarning(msg.message, msg.category, msg.filename, msg.lineno,
+ msg.file, msg.line)
+ return
+ _showwarnmsg_impl(msg)
+
+# Keep a reference to check if the function was replaced
+_formatwarning = formatwarning
+
+def _formatwarnmsg(msg):
+ """Function to format a warning the standard way."""
+ formatwarning = globals().get('formatwarning', _formatwarning)
+ if formatwarning is not _formatwarning:
+ # warnings.formatwarning() was replaced
+ return formatwarning(msg.message, msg.category,
+ msg.filename, msg.lineno, line=msg.line)
+ return _formatwarnmsg_impl(msg)
+
def filterwarnings(action, message="", category=Warning, module="", lineno=0,
append=False):
"""Insert an entry into the list of warnings filters (at the front).
@@ -185,7 +258,7 @@
# Code typically replaced by _warnings
-def warn(message, category=None, stacklevel=1):
+def warn(message, category=None, stacklevel=1, source=None):
"""Issue a warning, or maybe ignore it or raise an exception."""
# Check if message is already a Warning object
if isinstance(message, Warning):
@@ -235,10 +308,11 @@
filename = module
registry = globals.setdefault("__warningregistry__", {})
warn_explicit(message, category, filename, lineno, module, registry,
- globals)
+ globals, source)
def warn_explicit(message, category, filename, lineno,
- module=None, registry=None, module_globals=None):
+ module=None, registry=None, module_globals=None,
+ source=None):
lineno = int(lineno)
if module is None:
module = filename or "<unknown>"
@@ -303,22 +377,18 @@
raise RuntimeError(
"Unrecognized action (%r) in warnings.filters:\n %s" %
(action, item))
- if not callable(showwarning):
- raise TypeError("warnings.showwarning() must be set to a "
- "function or method")
# Print message and context
- showwarning(message, category, filename, lineno)
+ msg = WarningMessage(message, category, filename, lineno, source)
+ _showwarnmsg(msg)
class WarningMessage(object):
- """Holds the result of a single showwarning() call."""
-
_WARNING_DETAILS = ("message", "category", "filename", "lineno", "file",
- "line")
+ "line", "source")
def __init__(self, message, category, filename, lineno, file=None,
- line=None):
+ line=None, source=None):
local_values = locals()
for attr in self._WARNING_DETAILS:
setattr(self, attr, local_values[attr])
@@ -376,11 +446,12 @@
self._module.filters = self._filters[:]
self._module._filters_mutated()
self._showwarning = self._module.showwarning
+ self._showwarnmsg = self._module._showwarnmsg
if self._record:
log = []
- def showwarning(*args, **kwargs):
- log.append(WarningMessage(*args, **kwargs))
- self._module.showwarning = showwarning
+ def showarnmsg(msg):
+ log.append(msg)
+ self._module._showwarnmsg = showarnmsg
return log
else:
return None
@@ -391,6 +462,7 @@
self._module.filters = self._filters
self._module._filters_mutated()
self._module.showwarning = self._showwarning
+ self._module._showwarnmsg = self._showwarnmsg
# filters contains a sequence of filter 5-tuples
diff --git a/Lib/wave.py b/Lib/wave.py
index 8a101e3..f71f7e5 100644
--- a/Lib/wave.py
+++ b/Lib/wave.py
@@ -73,7 +73,7 @@
import builtins
-__all__ = ["open", "openfp", "Error"]
+__all__ = ["open", "openfp", "Error", "Wave_read", "Wave_write"]
class Error(Exception):
pass
diff --git a/Lib/wsgiref/simple_server.py b/Lib/wsgiref/simple_server.py
index 7fddbe8..f71563a 100644
--- a/Lib/wsgiref/simple_server.py
+++ b/Lib/wsgiref/simple_server.py
@@ -11,7 +11,6 @@
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
-from io import BufferedWriter
import sys
import urllib.parse
from wsgiref.handlers import SimpleHandler
@@ -127,17 +126,11 @@
if not self.parse_request(): # An error code has been sent, just exit
return
- # Avoid passing the raw file object wfile, which can do partial
- # writes (Issue 24291)
- stdout = BufferedWriter(self.wfile)
- try:
- handler = ServerHandler(
- self.rfile, stdout, self.get_stderr(), self.get_environ()
- )
- handler.request_handler = self # backpointer for logging
- handler.run(self.server.get_app())
- finally:
- stdout.detach()
+ handler = ServerHandler(
+ self.rfile, self.wfile, self.get_stderr(), self.get_environ()
+ )
+ handler.request_handler = self # backpointer for logging
+ handler.run(self.server.get_app())
@@ -163,10 +156,9 @@
if __name__ == '__main__':
- httpd = make_server('', 8000, demo_app)
- sa = httpd.socket.getsockname()
- print("Serving HTTP on", sa[0], "port", sa[1], "...")
- import webbrowser
- webbrowser.open('http://localhost:8000/xyz?abc')
- httpd.handle_request() # serve one request, then exit
- httpd.server_close()
+ with make_server('', 8000, demo_app) as httpd:
+ sa = httpd.socket.getsockname()
+ print("Serving HTTP on", sa[0], "port", sa[1], "...")
+ import webbrowser
+ webbrowser.open('http://localhost:8000/xyz?abc')
+ httpd.handle_request() # serve one request, then exit
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index 6d1b0ab..67b7f2b 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -85,7 +85,7 @@
"TreeBuilder",
"VERSION",
"XML", "XMLID",
- "XMLParser",
+ "XMLParser", "XMLPullParser",
"register_namespace",
]
@@ -95,6 +95,7 @@
import re
import warnings
import io
+import collections
import contextlib
from . import ElementPath
@@ -1200,16 +1201,37 @@
Returns an iterator providing (event, elem) pairs.
"""
+ # Use the internal, undocumented _parser argument for now; When the
+ # parser argument of iterparse is removed, this can be killed.
+ pullparser = XMLPullParser(events=events, _parser=parser)
+ def iterator():
+ try:
+ while True:
+ yield from pullparser.read_events()
+ # load event buffer
+ data = source.read(16 * 1024)
+ if not data:
+ break
+ pullparser.feed(data)
+ root = pullparser._close_and_return_root()
+ yield from pullparser.read_events()
+ it.root = root
+ finally:
+ if close_source:
+ source.close()
+
+ class IterParseIterator(collections.Iterator):
+ __next__ = iterator().__next__
+ it = IterParseIterator()
+ it.root = None
+ del iterator, IterParseIterator
+
close_source = False
if not hasattr(source, "read"):
source = open(source, "rb")
close_source = True
- try:
- return _IterParseIterator(source, events, parser, close_source)
- except:
- if close_source:
- source.close()
- raise
+
+ return it
class XMLPullParser:
@@ -1219,9 +1241,7 @@
# upon in user code. It will be removed in a future release.
# See http://bugs.python.org/issue17741 for more details.
- # _elementtree.c expects a list, not a deque
- self._events_queue = []
- self._index = 0
+ self._events_queue = collections.deque()
self._parser = _parser or XMLParser(target=TreeBuilder())
# wire up the parser for event reporting
if events is None:
@@ -1259,64 +1279,14 @@
retrieved from the iterator.
"""
events = self._events_queue
- while True:
- index = self._index
- try:
- event = events[self._index]
- # Avoid retaining references to past events
- events[self._index] = None
- except IndexError:
- break
- index += 1
- # Compact the list in a O(1) amortized fashion
- # As noted above, _elementree.c needs a list, not a deque
- if index * 2 >= len(events):
- events[:index] = []
- self._index = 0
- else:
- self._index = index
+ while events:
+ event = events.popleft()
if isinstance(event, Exception):
raise event
else:
yield event
-class _IterParseIterator:
-
- def __init__(self, source, events, parser, close_source=False):
- # Use the internal, undocumented _parser argument for now; When the
- # parser argument of iterparse is removed, this can be killed.
- self._parser = XMLPullParser(events=events, _parser=parser)
- self._file = source
- self._close_file = close_source
- self.root = self._root = None
-
- def __next__(self):
- try:
- while 1:
- for event in self._parser.read_events():
- return event
- if self._parser._parser is None:
- break
- # load event buffer
- data = self._file.read(16 * 1024)
- if data:
- self._parser.feed(data)
- else:
- self._root = self._parser._close_and_return_root()
- self.root = self._root
- except:
- if self._close_file:
- self._file.close()
- raise
- if self._close_file:
- self._file.close()
- raise StopIteration
-
- def __iter__(self):
- return self
-
-
def XML(text, parser=None):
"""Parse XML document from string constant.
diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py
index bbf9ee6..581a3b9 100644
--- a/Lib/xmlrpc/client.py
+++ b/Lib/xmlrpc/client.py
@@ -151,7 +151,7 @@
return s.replace(">", ">",)
# used in User-Agent header sent
-__version__ = sys.version[:3]
+__version__ = '%d.%d' % sys.version_info[:2]
# xmlrpc integer limits
MAXINT = 2**31-1
diff --git a/Lib/xmlrpc/server.py b/Lib/xmlrpc/server.py
index 5b5bf7c..78728f2 100644
--- a/Lib/xmlrpc/server.py
+++ b/Lib/xmlrpc/server.py
@@ -971,16 +971,15 @@
def getCurrentTime():
return datetime.datetime.now()
- server = SimpleXMLRPCServer(("localhost", 8000))
- server.register_function(pow)
- server.register_function(lambda x,y: x+y, 'add')
- server.register_instance(ExampleService(), allow_dotted_names=True)
- server.register_multicall_functions()
- print('Serving XML-RPC on localhost port 8000')
- print('It is advisable to run this example server within a secure, closed network.')
- try:
- server.serve_forever()
- except KeyboardInterrupt:
- print("\nKeyboard interrupt received, exiting.")
- server.server_close()
- sys.exit(0)
+ with SimpleXMLRPCServer(("localhost", 8000)) as server:
+ server.register_function(pow)
+ server.register_function(lambda x,y: x+y, 'add')
+ server.register_instance(ExampleService(), allow_dotted_names=True)
+ server.register_multicall_functions()
+ print('Serving XML-RPC on localhost port 8000')
+ print('It is advisable to run this example server within a secure, closed network.')
+ try:
+ server.serve_forever()
+ except KeyboardInterrupt:
+ print("\nKeyboard interrupt received, exiting.")
+ sys.exit(0)
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index 56a2479..8dd064a 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -371,7 +371,7 @@
result.append(' filemode=%r' % stat.filemode(hi))
if lo:
result.append(' external_attr=%#x' % lo)
- isdir = self.filename[-1:] == '/'
+ isdir = self.is_dir()
if not isdir or self.file_size:
result.append(' file_size=%r' % self.file_size)
if ((not isdir or self.compress_size) and
@@ -469,6 +469,42 @@
extra = extra[ln+4:]
+ @classmethod
+ def from_file(cls, filename, arcname=None):
+ """Construct an appropriate ZipInfo for a file on the filesystem.
+
+ filename should be the path to a file or directory on the filesystem.
+
+ arcname is the name which it will have within the archive (by default,
+ this will be the same as filename, but without a drive letter and with
+ leading path separators removed).
+ """
+ st = os.stat(filename)
+ isdir = stat.S_ISDIR(st.st_mode)
+ mtime = time.localtime(st.st_mtime)
+ date_time = mtime[0:6]
+ # Create ZipInfo instance to store file information
+ if arcname is None:
+ arcname = filename
+ arcname = os.path.normpath(os.path.splitdrive(arcname)[1])
+ while arcname[0] in (os.sep, os.altsep):
+ arcname = arcname[1:]
+ if isdir:
+ arcname += '/'
+ zinfo = cls(arcname, date_time)
+ zinfo.external_attr = (st.st_mode & 0xFFFF) << 16 # Unix attributes
+ if isdir:
+ zinfo.file_size = 0
+ zinfo.external_attr |= 0x10 # MS-DOS directory flag
+ else:
+ zinfo.file_size = st.st_size
+
+ return zinfo
+
+ def is_dir(self):
+ """Return True if this archive member is a directory."""
+ return self.filename[-1] == '/'
+
class _ZipDecrypter:
"""Class to handle decryption of files stored within a ZIP archive.
@@ -651,14 +687,19 @@
class _SharedFile:
- def __init__(self, file, pos, close, lock):
+ def __init__(self, file, pos, close, lock, writing):
self._file = file
self._pos = pos
self._close = close
self._lock = lock
+ self._writing = writing
def read(self, n=-1):
with self._lock:
+ if self._writing():
+ raise RuntimeError("Can't read from the ZIP file while there "
+ "is an open writing handle on it. "
+ "Close the writing handle before trying to read.")
self._file.seek(self._pos)
data = self._file.read(n)
self._pos = self._file.tell()
@@ -702,9 +743,6 @@
# Read from compressed files in 4k blocks.
MIN_READ_SIZE = 4096
- # Search for universal newlines or line chunks.
- PATTERN = re.compile(br'^(?P<chunk>[^\r\n]+)|(?P<newline>\n|\r\n?)')
-
def __init__(self, fileobj, mode, zipinfo, decrypter=None,
close_fileobj=False):
self._fileobj = fileobj
@@ -721,7 +759,6 @@
self._readbuffer = b''
self._offset = 0
- self._universal = 'U' in mode
self.newlines = None
# Adjust read size for encrypted files since the first 12 bytes
@@ -758,7 +795,7 @@
If limit is specified, at most limit bytes will be read.
"""
- if not self._universal and limit < 0:
+ if limit < 0:
# Shortcut common case - newline found in buffer.
i = self._readbuffer.find(b'\n', self._offset) + 1
if i > 0:
@@ -766,41 +803,7 @@
self._offset = i
return line
- if not self._universal:
- return io.BufferedIOBase.readline(self, limit)
-
- line = b''
- while limit < 0 or len(line) < limit:
- readahead = self.peek(2)
- if readahead == b'':
- return line
-
- #
- # Search for universal newlines or line chunks.
- #
- # The pattern returns either a line chunk or a newline, but not
- # both. Combined with peek(2), we are assured that the sequence
- # '\r\n' is always retrieved completely and never split into
- # separate newlines - '\r', '\n' due to coincidental readaheads.
- #
- match = self.PATTERN.search(readahead)
- newline = match.group('newline')
- if newline is not None:
- if self.newlines is None:
- self.newlines = []
- if newline not in self.newlines:
- self.newlines.append(newline)
- self._offset += len(newline)
- return line + b'\n'
-
- chunk = match.group('chunk')
- if limit >= 0:
- chunk = chunk[: limit - len(line)]
-
- self._offset += len(chunk)
- line += chunk
-
- return line
+ return io.BufferedIOBase.readline(self, limit)
def peek(self, n=1):
"""Returns buffered bytes without advancing the position."""
@@ -958,6 +961,76 @@
super().close()
+class _ZipWriteFile(io.BufferedIOBase):
+ def __init__(self, zf, zinfo, zip64):
+ self._zinfo = zinfo
+ self._zip64 = zip64
+ self._zipfile = zf
+ self._compressor = _get_compressor(zinfo.compress_type)
+ self._file_size = 0
+ self._compress_size = 0
+ self._crc = 0
+
+ @property
+ def _fileobj(self):
+ return self._zipfile.fp
+
+ def writable(self):
+ return True
+
+ def write(self, data):
+ nbytes = len(data)
+ self._file_size += nbytes
+ self._crc = crc32(data, self._crc)
+ if self._compressor:
+ data = self._compressor.compress(data)
+ self._compress_size += len(data)
+ self._fileobj.write(data)
+ return nbytes
+
+ def close(self):
+ super().close()
+ # Flush any data from the compressor, and update header info
+ if self._compressor:
+ buf = self._compressor.flush()
+ self._compress_size += len(buf)
+ self._fileobj.write(buf)
+ self._zinfo.compress_size = self._compress_size
+ else:
+ self._zinfo.compress_size = self._file_size
+ self._zinfo.CRC = self._crc
+ self._zinfo.file_size = self._file_size
+
+ # Write updated header info
+ if self._zinfo.flag_bits & 0x08:
+ # Write CRC and file sizes after the file data
+ fmt = '<LQQ' if self._zip64 else '<LLL'
+ self._fileobj.write(struct.pack(fmt, self._zinfo.CRC,
+ self._zinfo.compress_size, self._zinfo.file_size))
+ self._zipfile.start_dir = self._fileobj.tell()
+ else:
+ if not self._zip64:
+ if self._file_size > ZIP64_LIMIT:
+ raise RuntimeError('File size unexpectedly exceeded ZIP64 '
+ 'limit')
+ if self._compress_size > ZIP64_LIMIT:
+ raise RuntimeError('Compressed size unexpectedly exceeded '
+ 'ZIP64 limit')
+ # Seek backwards and write file header (which will now include
+ # correct CRC and file sizes)
+
+ # Preserve current position in file
+ self._zipfile.start_dir = self._fileobj.tell()
+ self._fileobj.seek(self._zinfo.header_offset)
+ self._fileobj.write(self._zinfo.FileHeader(self._zip64))
+ self._fileobj.seek(self._zipfile.start_dir)
+
+ self._zipfile._writing = False
+
+ # Successfully written: Add file to our caches
+ self._zipfile.filelist.append(self._zinfo)
+ self._zipfile.NameToInfo[self._zinfo.filename] = self._zinfo
+
class ZipFile:
""" Class with methods to open, read, write, close, list zip files.
@@ -1020,6 +1093,7 @@
self._fileRefCnt = 1
self._lock = threading.RLock()
self._seekable = True
+ self._writing = False
try:
if mode == 'r':
@@ -1232,30 +1306,55 @@
with self.open(name, "r", pwd) as fp:
return fp.read()
- def open(self, name, mode="r", pwd=None):
- """Return file-like object for 'name'."""
- if mode not in ("r", "U", "rU"):
- raise RuntimeError('open() requires mode "r", "U", or "rU"')
- if 'U' in mode:
- import warnings
- warnings.warn("'U' mode is deprecated",
- DeprecationWarning, 2)
+ def open(self, name, mode="r", pwd=None, *, force_zip64=False):
+ """Return file-like object for 'name'.
+
+ name is a string for the file name within the ZIP file, or a ZipInfo
+ object.
+
+ mode should be 'r' to read a file already in the ZIP file, or 'w' to
+ write to a file newly added to the archive.
+
+ pwd is the password to decrypt files (only used for reading).
+
+ When writing, if the file size is not known in advance but may exceed
+ 2 GiB, pass force_zip64 to use the ZIP64 format, which can handle large
+ files. If the size is known in advance, it is best to pass a ZipInfo
+ instance for name, with zinfo.file_size set.
+ """
+ if mode not in {"r", "w"}:
+ raise RuntimeError('open() requires mode "r" or "w"')
if pwd and not isinstance(pwd, bytes):
raise TypeError("pwd: expected bytes, got %s" % type(pwd))
+ if pwd and (mode == "w"):
+ raise ValueError("pwd is only supported for reading files")
if not self.fp:
raise RuntimeError(
- "Attempt to read ZIP archive that was already closed")
+ "Attempt to use ZIP archive that was already closed")
# Make sure we have an info object
if isinstance(name, ZipInfo):
# 'name' is already an info object
zinfo = name
+ elif mode == 'w':
+ zinfo = ZipInfo(name)
+ zinfo.compress_type = self.compression
else:
# Get info object for name
zinfo = self.getinfo(name)
+ if mode == 'w':
+ return self._open_to_write(zinfo, force_zip64=force_zip64)
+
+ if self._writing:
+ raise RuntimeError("Can't read from the ZIP file while there "
+ "is an open writing handle on it. "
+ "Close the writing handle before trying to read.")
+
+ # Open for reading:
self._fileRefCnt += 1
- zef_file = _SharedFile(self.fp, zinfo.header_offset, self._fpclose, self._lock)
+ zef_file = _SharedFile(self.fp, zinfo.header_offset,
+ self._fpclose, self._lock, lambda: self._writing)
try:
# Skip the file header:
fheader = zef_file.read(sizeFileHeader)
@@ -1320,6 +1419,49 @@
zef_file.close()
raise
+ def _open_to_write(self, zinfo, force_zip64=False):
+ if force_zip64 and not self._allowZip64:
+ raise ValueError(
+ "force_zip64 is True, but allowZip64 was False when opening "
+ "the ZIP file."
+ )
+ if self._writing:
+ raise RuntimeError("Can't write to the ZIP file while there is "
+ "another write handle open on it. "
+ "Close the first handle before opening another.")
+
+ # Sizes and CRC are overwritten with correct data after processing the file
+ if not hasattr(zinfo, 'file_size'):
+ zinfo.file_size = 0
+ zinfo.compress_size = 0
+ zinfo.CRC = 0
+
+ zinfo.flag_bits = 0x00
+ if zinfo.compress_type == ZIP_LZMA:
+ # Compressed data includes an end-of-stream (EOS) marker
+ zinfo.flag_bits |= 0x02
+ if not self._seekable:
+ zinfo.flag_bits |= 0x08
+
+ if not zinfo.external_attr:
+ zinfo.external_attr = 0o600 << 16 # permissions: ?rw-------
+
+ # Compressed size can be larger than uncompressed size
+ zip64 = self._allowZip64 and \
+ (force_zip64 or zinfo.file_size * 1.05 > ZIP64_LIMIT)
+
+ if self._seekable:
+ self.fp.seek(self.start_dir)
+ zinfo.header_offset = self.fp.tell()
+
+ self._writecheck(zinfo)
+ self._didModify = True
+
+ self.fp.write(zinfo.FileHeader(zip64))
+
+ self._writing = True
+ return _ZipWriteFile(self, zinfo, zip64)
+
def extract(self, member, path=None, pwd=None):
"""Extract a member from the archive to the current working directory,
using its full name. Its file information is extracted as accurately
@@ -1389,7 +1531,7 @@
if upperdirs and not os.path.exists(upperdirs):
os.makedirs(upperdirs)
- if member.filename[-1] == '/':
+ if member.is_dir():
if not os.path.isdir(targetpath):
os.mkdir(targetpath)
return targetpath
@@ -1429,103 +1571,41 @@
if not self.fp:
raise RuntimeError(
"Attempt to write to ZIP archive that was already closed")
+ if self._writing:
+ raise RuntimeError(
+ "Can't write to ZIP archive while an open writing handle exists"
+ )
- st = os.stat(filename)
- isdir = stat.S_ISDIR(st.st_mode)
- mtime = time.localtime(st.st_mtime)
- date_time = mtime[0:6]
- # Create ZipInfo instance to store file information
- if arcname is None:
- arcname = filename
- arcname = os.path.normpath(os.path.splitdrive(arcname)[1])
- while arcname[0] in (os.sep, os.altsep):
- arcname = arcname[1:]
- if isdir:
- arcname += '/'
- zinfo = ZipInfo(arcname, date_time)
- zinfo.external_attr = (st[0] & 0xFFFF) << 16 # Unix attributes
- if isdir:
- zinfo.compress_type = ZIP_STORED
- elif compress_type is None:
- zinfo.compress_type = self.compression
+ zinfo = ZipInfo.from_file(filename, arcname)
+
+ if zinfo.is_dir():
+ zinfo.compress_size = 0
+ zinfo.CRC = 0
else:
- zinfo.compress_type = compress_type
+ if compress_type is not None:
+ zinfo.compress_type = compress_type
+ else:
+ zinfo.compress_type = self.compression
- zinfo.file_size = st.st_size
- zinfo.flag_bits = 0x00
- with self._lock:
- if self._seekable:
- self.fp.seek(self.start_dir)
- zinfo.header_offset = self.fp.tell() # Start of header bytes
- if zinfo.compress_type == ZIP_LZMA:
+ if zinfo.is_dir():
+ with self._lock:
+ if self._seekable:
+ self.fp.seek(self.start_dir)
+ zinfo.header_offset = self.fp.tell() # Start of header bytes
+ if zinfo.compress_type == ZIP_LZMA:
# Compressed data includes an end-of-stream (EOS) marker
- zinfo.flag_bits |= 0x02
+ zinfo.flag_bits |= 0x02
- self._writecheck(zinfo)
- self._didModify = True
+ self._writecheck(zinfo)
+ self._didModify = True
- if isdir:
- zinfo.file_size = 0
- zinfo.compress_size = 0
- zinfo.CRC = 0
- zinfo.external_attr |= 0x10 # MS-DOS directory flag
self.filelist.append(zinfo)
self.NameToInfo[zinfo.filename] = zinfo
self.fp.write(zinfo.FileHeader(False))
self.start_dir = self.fp.tell()
- return
-
- cmpr = _get_compressor(zinfo.compress_type)
- if not self._seekable:
- zinfo.flag_bits |= 0x08
- with open(filename, "rb") as fp:
- # Must overwrite CRC and sizes with correct data later
- zinfo.CRC = CRC = 0
- zinfo.compress_size = compress_size = 0
- # Compressed size can be larger than uncompressed size
- zip64 = self._allowZip64 and \
- zinfo.file_size * 1.05 > ZIP64_LIMIT
- self.fp.write(zinfo.FileHeader(zip64))
- file_size = 0
- while 1:
- buf = fp.read(1024 * 8)
- if not buf:
- break
- file_size = file_size + len(buf)
- CRC = crc32(buf, CRC)
- if cmpr:
- buf = cmpr.compress(buf)
- compress_size = compress_size + len(buf)
- self.fp.write(buf)
- if cmpr:
- buf = cmpr.flush()
- compress_size = compress_size + len(buf)
- self.fp.write(buf)
- zinfo.compress_size = compress_size
- else:
- zinfo.compress_size = file_size
- zinfo.CRC = CRC
- zinfo.file_size = file_size
- if zinfo.flag_bits & 0x08:
- # Write CRC and file sizes after the file data
- fmt = '<LQQ' if zip64 else '<LLL'
- self.fp.write(struct.pack(fmt, zinfo.CRC, zinfo.compress_size,
- zinfo.file_size))
- self.start_dir = self.fp.tell()
- else:
- if not zip64 and self._allowZip64:
- if file_size > ZIP64_LIMIT:
- raise RuntimeError('File size has increased during compressing')
- if compress_size > ZIP64_LIMIT:
- raise RuntimeError('Compressed size larger than uncompressed size')
- # Seek backwards and write file header (which will now include
- # correct CRC and file sizes)
- self.start_dir = self.fp.tell() # Preserve current position in file
- self.fp.seek(zinfo.header_offset)
- self.fp.write(zinfo.FileHeader(zip64))
- self.fp.seek(self.start_dir)
- self.filelist.append(zinfo)
- self.NameToInfo[zinfo.filename] = zinfo
+ else:
+ with open(filename, "rb") as src, self.open(zinfo, 'w') as dest:
+ shutil.copyfileobj(src, dest, 1024*8)
def writestr(self, zinfo_or_arcname, data, compress_type=None):
"""Write a file into the archive. The contents is 'data', which
@@ -1550,45 +1630,18 @@
if not self.fp:
raise RuntimeError(
"Attempt to write to ZIP archive that was already closed")
+ if self._writing:
+ raise RuntimeError(
+ "Can't write to ZIP archive while an open writing handle exists."
+ )
+
+ if compress_type is not None:
+ zinfo.compress_type = compress_type
zinfo.file_size = len(data) # Uncompressed size
with self._lock:
- if self._seekable:
- self.fp.seek(self.start_dir)
- zinfo.header_offset = self.fp.tell() # Start of header data
- if compress_type is not None:
- zinfo.compress_type = compress_type
- zinfo.header_offset = self.fp.tell() # Start of header data
- if compress_type is not None:
- zinfo.compress_type = compress_type
- if zinfo.compress_type == ZIP_LZMA:
- # Compressed data includes an end-of-stream (EOS) marker
- zinfo.flag_bits |= 0x02
-
- self._writecheck(zinfo)
- self._didModify = True
- zinfo.CRC = crc32(data) # CRC-32 checksum
- co = _get_compressor(zinfo.compress_type)
- if co:
- data = co.compress(data) + co.flush()
- zinfo.compress_size = len(data) # Compressed size
- else:
- zinfo.compress_size = zinfo.file_size
- zip64 = zinfo.file_size > ZIP64_LIMIT or \
- zinfo.compress_size > ZIP64_LIMIT
- if zip64 and not self._allowZip64:
- raise LargeZipFile("Filesize would require ZIP64 extensions")
- self.fp.write(zinfo.FileHeader(zip64))
- self.fp.write(data)
- if zinfo.flag_bits & 0x08:
- # Write CRC and file sizes after the file data
- fmt = '<LQQ' if zip64 else '<LLL'
- self.fp.write(struct.pack(fmt, zinfo.CRC, zinfo.compress_size,
- zinfo.file_size))
- self.fp.flush()
- self.start_dir = self.fp.tell()
- self.filelist.append(zinfo)
- self.NameToInfo[zinfo.filename] = zinfo
+ with self.open(zinfo, mode='w') as dest:
+ dest.write(data)
def __del__(self):
"""Call the "close()" method in case the user forgot."""
@@ -1600,6 +1653,11 @@
if self.fp is None:
return
+ if self._writing:
+ raise RuntimeError("Can't close the ZIP file while there is "
+ "an open writing handle on it. "
+ "Close the writing handle before closing the zip.")
+
try:
if self.mode in ('w', 'x', 'a') and self._didModify: # write ending records
with self._lock:
diff --git a/Mac/BuildScript/resources/ReadMe.rtf b/Mac/BuildScript/resources/ReadMe.rtf
index 65e3f14..1af2451 100644
--- a/Mac/BuildScript/resources/ReadMe.rtf
+++ b/Mac/BuildScript/resources/ReadMe.rtf
@@ -1,29 +1,25 @@
-{\rtf1\ansi\ansicpg1252\cocoartf1348\cocoasubrtf170
+{\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf460
{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fmodern\fcharset0 CourierNewPSMT;}
{\colortbl;\red255\green255\blue255;}
\margl1440\margr1440\vieww13380\viewh14600\viewkind0
-\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
+\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\f0\fs24 \cf0 This package will install Python $FULL_VERSION for Mac OS X $MACOSX_DEPLOYMENT_TARGET for the following architecture(s): $ARCHITECTURES.\
\
-\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
+\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\b \cf0 \ul \ulc0 Which installer variant should I use?
\b0 \ulnone \
\
-Python.org provides two installer variants for download: one that installs a
+For the initial alpha releases of Python 3.6, Python.org provides only one installer variant for download: one that installs a
\i 64-bit/32-bit Intel
\i0 Python capable of running on
\i Mac OS X 10.6 (Snow Leopard)
-\i0 or later; and one that installs a
-\i 32-bit-only (Intel and PPC)
-\i0 Python capable of running on
-\i Mac OS X 10.5 (Leopard)
-\i0 or later. This ReadMe was installed with the
+\i0 or later. This will change prior to the beta releases of 3.6.0. This ReadMe was installed with the
\i $MACOSX_DEPLOYMENT_TARGET
-\i0 variant. Unless you are installing to an 10.5 system or you need to build applications that can run on 10.5 systems, use the 10.6 variant if possible. There are some additional operating system functions that are supported starting with 10.6 and you may see better performance using 64-bit mode. By default, Python will automatically run in 64-bit mode if your system supports it. Also see
+\i0 variant. By default, Python will automatically run in 64-bit mode if your system supports it. Also see
\i Certificate verification and OpenSSL
-\i0 below. The Pythons installed by these installers are built with private copies of some third-party libraries not included with or newer than those in OS X itself. The list of these libraries varies by installer variant and is included at the end of the License.rtf file.
+\i0 below. The Pythons installed by this installer is built with private copies of some third-party libraries not included with or newer than those in OS X itself. The list of these libraries varies by installer variant and is included at the end of the License.rtf file.
\b \ul \
\
Update your version of Tcl/Tk to use IDLE or other Tk applications
@@ -33,13 +29,13 @@
\i Tcl/Tk
\i0 frameworks. Visit {\field{\*\fldinst{HYPERLINK "https://www.python.org/download/mac/tcltk/"}}{\fldrslt https://www.python.org/download/mac/tcltk/}} for current information about supported and recommended versions of
\i Tcl/Tk
-\i0 for this version of Python and of Mac OS X.\
+\i0 for this version of Python and of Mac OS X. For the initial alpha releases of Python 3.6, the installer is linked with Tcl/Tk 8.5; this will change prior to the beta releases of 3.6.0.\
\b \ul \
Certificate verification and OpenSSL\
\b0 \ulnone \
-Python 3.5 includes a number of network security enhancements that were released in Python 3.4.3 and Python 2.7.10. {\field{\*\fldinst{HYPERLINK "https://www.python.org/dev/peps/pep-0476/"}}{\fldrslt PEP 476}} changes several standard library modules, like
+Python 3.6 includes a number of network security enhancements that were released in Python 3.4.3 and Python 2.7.10. {\field{\*\fldinst{HYPERLINK "https://www.python.org/dev/peps/pep-0476/"}}{\fldrslt PEP 476}} changes several standard library modules, like
\i httplib
\i0 ,
\i urllib
@@ -51,56 +47,33 @@
\i security
\i0 command line utility.\
\
-For OS X 10.5, Apple provides
-\i OpenSSL 0.9.7
-\i0 libraries. This version of Apple's OpenSSL
-\b does not
-\b0 use the certificates from the system security framework, even when used on newer versions of OS X. Instead it consults a traditional OpenSSL concatenated certificate file (
-\i cafile
-\i0 ) or certificate directory (
-\i capath
-\i0 ), located in
-\f1 /System/Library/OpenSSL
-\f0 . These directories are typically empty and not managed by OS X; you must manage them yourself or supply your own SSL contexts. OpenSSL 0.9.7 is obsolete by current security standards, lacking a number of important features found in later versions. Among the problems this causes is the inability to verify higher-security certificates now used by python.org services, including
-\i t{\field{\*\fldinst{HYPERLINK "https://pypi.python.org/pypi"}}{\fldrslt he Python Package Index, PyPI}}
-\i0 . To solve this problem, the
-\i 10.5+ 32-bit-only python.org variant
-\i0 is linked with a private copy of
-\i OpenSSL 1.0.2
-\i0 ; it consults the same default certificate directory,
-\f1 /System/Library/OpenSSL
-\f0 . As before, it is still necessary to manage certificates yourself when you use this Python variant and, with certificate verification now enabled by default, you may now need to take additional steps to ensure your Python programs have access to CA certificates you trust. If you use this Python variant to build standalone applications with third-party tools like {\field{\*\fldinst{HYPERLINK "https://pypi.python.org/pypi/py2app/"}}{\fldrslt
-\f1 py2app}}, you may now need to bundle CA certificates in them or otherwise supply non-default SSL contexts.\
-\
For OS X 10.6+, Apple also provides
\i OpenSSL
\i0
\i 0.9.8 libraries
\i0 . Apple's 0.9.8 version includes an important additional feature: if a certificate cannot be verified using the manually administered certificates in
\f1 /System/Library/OpenSSL
-\f0 , the certificates managed by the system security framework In the user and system keychains are also consulted (using Apple private APIs). For this reason, the
+\f0 , the certificates managed by the system security framework In the user and system keychains are also consulted (using Apple private APIs). For the initial alpha releases of Python 3.6, the
\i 64-bit/32-bit 10.6+ python.org variant
-\i0 continues to be dynamically linked with Apple's OpenSSL 0.9.8 since it was felt that the loss of the system-provided certificates and management tools outweighs the additional security features provided by newer versions of OpenSSL. This will likely change in future releases of the python.org installers as Apple has deprecated use of the system-supplied OpenSSL libraries. If you do need features from newer versions of OpenSSL, there are third-party OpenSSL wrapper packages available through
+\i0 continues to be dynamically linked with Apple's OpenSSL 0.9.8 since it was felt that the loss of the system-provided certificates and management tools outweighs the additional security features provided by newer versions of OpenSSL. This will change prior to the beta releases of 3.6.0 as Apple has deprecated use of the system-supplied OpenSSL libraries. If you do need features from newer versions of OpenSSL, there are third-party OpenSSL wrapper packages available through
\i PyPI
\i0 .\
\
The bundled
\f1 pip
-\f0 included with the Python 3.5 installers has its own default certificate store for verifying download connections.\
+\f0 included with the Python 3.6 installers has its own default certificate store for verifying download connections.\
\
\b \ul Other changes\
\b0 \ulnone \
-\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
-\cf0 For other changes in this release, see the
+For other changes in this release, see the
\i What's new
\i0 section in the {\field{\*\fldinst{HYPERLINK "https://www.python.org/doc/"}}{\fldrslt Documentation Set}} for this release and its
\i Release Notes
\i0 link at {\field{\*\fldinst{HYPERLINK "https://www.python.org/downloads/"}}{\fldrslt https://www.python.org/downloads/}}.\
-\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
-\b \cf0 \ul \
+\b \ul \
Python 3 and Python 2 Co-existence\
\b0 \ulnone \
diff --git a/Mac/IDLE/IDLE.app/Contents/Resources/idlemain.py b/Mac/IDLE/IDLE.app/Contents/Resources/idlemain.py
index 986760d..5994c18 100644
--- a/Mac/IDLE/IDLE.app/Contents/Resources/idlemain.py
+++ b/Mac/IDLE/IDLE.app/Contents/Resources/idlemain.py
@@ -68,6 +68,6 @@
break
# Now it is safe to import idlelib.
-from idlelib.PyShell import main
+from idlelib.pyshell import main
if __name__ == '__main__':
main()
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 87528a0..2bc91d7 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -109,6 +109,7 @@
# Multiarch directory (may be empty)
MULTIARCH= @MULTIARCH@
+MULTIARCH_CPPFLAGS = @MULTIARCH_CPPFLAGS@
# Install prefix for architecture-independent files
prefix= @prefix@
@@ -571,7 +572,7 @@
$(LINKCC) $(PY_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
platform: $(BUILDPYTHON) pybuilddir.txt
- $(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print(get_platform()+"-"+sys.version[0:3])' >platform
+ $(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform
# Create build directory and generate the sysconfig build-time data there.
# pybuilddir.txt contains the name of the build dir and is used for
@@ -784,6 +785,7 @@
Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile
$(CC) -c $(PY_CORE_CFLAGS) \
-DABIFLAGS='"$(ABIFLAGS)"' \
+ $(MULTIARCH_CPPFLAGS) \
-o $@ $(srcdir)/Python/sysmodule.c
$(IO_OBJS): $(IO_H)
@@ -943,6 +945,7 @@
$(srcdir)/Include/objimpl.h \
$(OPCODE_H) \
$(srcdir)/Include/osdefs.h \
+ $(srcdir)/Include/osmodule.h \
$(srcdir)/Include/patchlevel.h \
$(srcdir)/Include/pgen.h \
$(srcdir)/Include/pgenheaders.h \
@@ -992,7 +995,7 @@
TESTOPTS= $(EXTRATESTOPTS)
TESTPYTHON= $(RUNSHARED) ./$(BUILDPYTHON) $(TESTPYTHONOPTS)
TESTRUNNER= $(TESTPYTHON) $(srcdir)/Tools/scripts/run_tests.py
-TESTTIMEOUT= 3600
+TESTTIMEOUT= 900
# Run a basic set of regression tests.
# This excludes some tests that are particularly resource-intensive.
@@ -1193,6 +1196,7 @@
test/cjkencodings test/decimaltestdata test/xmltestdata \
test/eintrdata \
test/imghdrdata \
+ test/libregrtest \
test/subprocessdata test/sndhdrdata test/support \
test/tracedmodules test/encoded_modules \
test/test_import \
@@ -1261,7 +1265,7 @@
else true; \
fi; \
done
- @for i in $(srcdir)/Lib/*.py `cat pybuilddir.txt`/_sysconfigdata.py; \
+ @for i in $(srcdir)/Lib/*.py; \
do \
if test -x $$i; then \
$(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
@@ -1296,6 +1300,10 @@
esac; \
done; \
done
+ $(INSTALL_DATA) `cat pybuilddir.txt`/_sysconfigdata_$(ABIFLAGS).py \
+ $(DESTDIR)$(LIBDEST)/$(PLATDIR); \
+ echo $(INSTALL_DATA) `cat pybuilddir.txt`/_sysconfigdata_$(ABIFLAGS).py \
+ $(LIBDEST)/$(PLATDIR)
$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
if test -d $(DESTDIR)$(LIBDEST)/distutils/tests; then \
$(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \
@@ -1334,13 +1342,19 @@
$(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
# Create the PLATDIR source directory, if one wasn't distributed..
+# For multiarch targets, use the plat-linux/regen script.
$(srcdir)/Lib/$(PLATDIR):
mkdir $(srcdir)/Lib/$(PLATDIR)
- cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen
+ if [ -n "$(MULTIARCH)" ]; then \
+ cp $(srcdir)/Lib/plat-linux/regen $(srcdir)/Lib/$(PLATDIR)/regen; \
+ else \
+ cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen; \
+ fi; \
export PATH; PATH="`pwd`:$$PATH"; \
export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \
export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
export EXE; EXE="$(BUILDEXE)"; \
+ export CC; CC="$(CC)"; \
if [ -n "$(MULTIARCH)" ]; then export MULTIARCH; MULTIARCH=$(MULTIARCH); fi; \
export PYTHON_FOR_BUILD; \
if [ "$(BUILD_GNU_TYPE)" = "$(HOST_GNU_TYPE)" ]; then \
@@ -1348,6 +1362,7 @@
else \
PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)"; \
fi; \
+ export H2PY; H2PY="$$PYTHON_FOR_BUILD $(abs_srcdir)/Tools/scripts/h2py.py"; \
cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh
@@ -1446,7 +1461,7 @@
--install-scripts=$(BINDIR) \
--install-platlib=$(DESTSHARED) \
--root=$(DESTDIR)/
- -rm $(DESTDIR)$(DESTSHARED)/_sysconfigdata.py
+ -rm $(DESTDIR)$(DESTSHARED)/_sysconfigdata_$(ABIFLAGS).py
-rm -r $(DESTDIR)$(DESTSHARED)/__pycache__
# Here are a couple of targets for MacOSX again, to install a full
@@ -1492,10 +1507,10 @@
# Install a number of symlinks to keep software that expects a normal unix
# install (which includes python-config) happy.
frameworkinstallmaclib:
- $(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config-$(LDVERSION)/libpython$(LDVERSION).a"
- $(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config-$(LDVERSION)/libpython$(LDVERSION).dylib"
- $(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config-$(LDVERSION)/libpython$(VERSION).a"
- $(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config-$(LDVERSION)/libpython$(VERSION).dylib"
+ $(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBPL)/libpython$(LDVERSION).a"
+ $(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBPL)/libpython$(LDVERSION).dylib"
+ $(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBPL)/libpython$(VERSION).a"
+ $(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBPL)/libpython$(VERSION).dylib"
$(LN) -fs "../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/libpython$(LDVERSION).dylib"
$(LN) -fs "../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/libpython$(VERSION).dylib"
@@ -1625,6 +1640,9 @@
-rm -rf build platform
-rm -rf $(PYTHONFRAMEWORKDIR)
-rm -f python-config.py python-config
+ if [ -n "$(MULTIARCH)" ]; then \
+ rm -rf $(srcdir)/Lib/$(PLATDIR); \
+ fi
# Make things extra clean, before making a distribution:
# remove all generated files, even Makefile[.pre]
diff --git a/Misc/ACKS b/Misc/ACKS
index 27bd691..9494406 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -154,6 +154,7 @@
Paul Boddie
Matthew Boedicker
Robin Boerdijk
+Nikolay Bogoychev
David Bolen
Wouter Bolsterlee
Gawain Bolton
@@ -239,6 +240,7 @@
Michael Cetrulo
Dave Chambers
Pascal Chambon
+Nicholas Chammas
John Chandler
Hye-Shik Chang
Jeffrey Chang
@@ -309,9 +311,11 @@
Christopher A. Craig
Jeremy Craven
Laura Creighton
+Tyler Crompton
Simon Cross
Felipe Cruz
Drew Csillag
+Alessandro Cucci
Joaquin Cuenca Abela
John Cugini
Tom Culliton
@@ -355,6 +359,7 @@
Yves Dionne
Daniel Dittmar
Josip Djolonga
+Walter Dörwald
Jaromir Dolecek
Ismail Donmez
Robert Donohue
@@ -382,7 +387,6 @@
Karmen Dykstra
Josip Dzolonga
Maxim Dzumanenko
-Walter Dörwald
Hans Eckardt
Rodolpho Eckhardt
Ulrich Eckhardt
@@ -540,6 +544,7 @@
Lars Gustäbel
Thomas Güttler
Jonas H.
+Joseph Hackman
Barry Haddow
Philipp Hagemeister
Paul ten Hagen
@@ -777,6 +782,7 @@
Marko Kohtala
Vajrasky Kok
Guido Kollerie
+Jacek Kołodziej
Jacek Konieczny
Arkady Koplyarov
Peter A. Koren
@@ -820,6 +826,7 @@
Tino Lange
Glenn Langford
Andrew Langmead
+Wolfgang Langner
Detlef Lannert
Soren Larsen
Amos Latteier
@@ -881,24 +888,27 @@
Gregor Lingl
Everett Lipman
Mirko Liss
+Alexander Liu
Nick Lockwood
Stephanie Lockwood
+Martin von Löwis
Hugo Lopes Tavares
Guillermo López-Anglada
Anne Lord
+Alex LordThorsen
Tom Loredo
Justin Love
Ned Jackson Lovely
Peter Lovett
Chalmer Lowe
Jason Lowe
-Martin von Löwis
Tony Lownds
Ray Loyzaga
Kang-Hao (Kenny) Lu
Lukas Lueg
Loren Luke
Fredrik Lundh
+Mike Lundy
Zhongyue Luo
Mark Lutz
Taras Lyapun
@@ -1136,6 +1146,7 @@
Geoff Philbrick
Gavrie Philipson
Adrian Phillips
+Dusty Phillips
Christopher J. Phoenix
James Pickering
Neale Pickett
@@ -1239,6 +1250,7 @@
Kevin Rodgers
Sean Rodman
Giampaolo Rodola
+Mauro S. M. Rodrigues
Elson Rodriguez
Adi Roiban
Luis Rojas
@@ -1280,6 +1292,7 @@
Constantina S.
Patrick Sabin
Sébastien Sablé
+Amit Saha
Suman Saha
Hajime Saitou
George Sakkis
@@ -1385,6 +1398,7 @@
Roy Smith
Ryan Smith-Roberts
Rafal Smotrzyk
+Josh Snider
Eric Snow
Dirk Soede
Nir Soffer
@@ -1417,6 +1431,7 @@
Richard Stoakley
Peter Stoehr
Casper Stoel
+Daniel Stokes
Michael Stone
Serhiy Storchaka
Ken Stox
@@ -1441,6 +1456,7 @@
John Szakmeister
Amir Szekely
Maciej Szulik
+Joel Taddei
Arfrever Frehtes Taifersar Arahesis
Hideaki Takahashi
Takase Arihiro
@@ -1452,6 +1468,7 @@
Christian Tanzer
Steven Taschuk
Amy Taylor
+Julian Taylor
Monty Taylor
Anatoly Techtonik
Gustavo Temple
@@ -1633,6 +1650,7 @@
Arnon Yaari
Hirokazu Yamamoto
Ka-Ping Yee
+Chi Hsuan Yen
Jason Yeo
EungJun Yi
Bob Yodlowski
diff --git a/Misc/NEWS b/Misc/NEWS
index 330d170..a6634f8 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -2,31 +2,58 @@
Python News
+++++++++++
-What's New in Python 3.5.3 release candidate 1?
-===============================================
+What's New in Python 3.6.0 alpha 3
+==================================
-Release date: TBA
-
-Core and Builtins
------------------
+*Release date: XXXX-XX-XX*
Library
-------
-- Issue #22115: Fixed tracing Tkinter variables: trace_vdelete() with wrong
- mode no longer break tracing, trace_vinfo() now always returns a list of
- pairs of strings, tracing in the "u" mode now works.
+- Issue #26721: Change the socketserver.StreamRequestHandler.wfile attribute
+ to implement BufferedIOBase. In particular, the write() method no longer
+ does partial writes.
-- Fix a scoping issue in importlib.util.LazyLoader which triggered an
- UnboundLocalError when lazy-loading a module that was already put into
- sys.modules.
+- Issue #22115: Added methods trace_add, trace_remove and trace_info in the
+ tkinter.Variable class. They replace old methods trace_variable, trace,
+ trace_vdelete and trace_vinfo that use obsolete Tcl commands and might
+ not work in future versions of Tcl. Fixed old tracing methods:
+ trace_vdelete() with wrong mode no longer break tracing, trace_vinfo() now
+ always returns a list of pairs of strings, tracing in the "u" mode now works.
+
+- Issue #26243: Only the level argument to zlib.compress() is keyword argument
+ now. The first argument is positional-only.
+
+- Issue #27038: Expose the DirEntry type as os.DirEntry. Code patch by
+ Jelle Zijlstra.
+
+- Issue #27186: Update os.fspath()/PyOS_FSPath() to check the return value of
+ __fspath__() to be either str or bytes.
+
+- Issue #18726: All optional parameters of the dump(), dumps(),
+ load() and loads() functions and JSONEncoder and JSONDecoder class
+ constructors in the json module are now keyword-only.
+
+- Issue #27319: Methods selection_set(), selection_add(), selection_remove()
+ and selection_toggle() of ttk.TreeView now allow passing multiple items as
+ multiple arguments instead of passing them as a tuple. Deprecated
+ undocumented ability of calling the selection() method with arguments.
- Issue #27079: Fixed curses.ascii functions isblank(), iscntrl() and ispunct().
+- Issue #27294: Numerical state in the repr for Tkinter event objects is now
+ represented as a compination of known flags.
+
+- Issue #27177: Match objects in the re module now support index-like objects
+ as group indices. Based on patches by Jeroen Demeyer and Xiang Zhang.
+
- Issue #26754: Some functions (compile() etc) accepted a filename argument
encoded as an iterable of integers. Now only strings and byte-like objects
are accepted.
+- Issue #26536: socket.ioctl now supports SIO_LOOPBACK_FAST_PATH. Patch by
+ Daniel Stokes.
+
- Issue #27048: Prevents distutils failing on Windows when environment
variables contain non-ASCII characters
@@ -45,9 +72,15 @@
Truncate size to INT_MAX and loop until we collected enough random bytes,
instead of casting a directly Py_ssize_t to int.
+- Issue #16864: sqlite3.Cursor.lastrowid now supports REPLACE statement.
+ Initial patch by Alex LordThorsen.
+
- Issue #26386: Fixed ttk.TreeView selection operations with item id's
containing spaces.
+- Issue #8637: Honor a pager set by the env var MANPAGER (in preference to
+ one set by the env var PAGER).
+
- Issue #22636: Avoid shell injection problems with
ctypes.util.find_library().
@@ -55,22 +88,42 @@
locale encoding, and fix get_begidx() and get_endidx() to return code point
indexes.
-- Issue #26930: Update Windows builds to use OpenSSL 1.0.2h.
-
IDLE
----
+- Issue #27372: Test_idle no longer changes the locale.
+
- Issue #27365: Allow non-ascii chars in IDLE NEWS.txt, for contributor names.
- Issue #27245: IDLE: Cleanly delete custom themes and key bindings.
Previously, when IDLE was started from a console or by import, a cascade
of warnings was emitted. Patch by Serhiy Storchaka.
+- Issue #24137: Run IDLE, test_idle, and htest with tkinter default root disabled.
+ Fix code and tests that fail with this restriction.
+ Fix htests to not create a second and redundant root and mainloop.
+
+- Issue #27310: Fix IDLE.app failure to launch on OS X due to vestigial import.
+
C API
-----
- Issue #26754: PyUnicode_FSDecoder() accepted a filename argument encoded as
- an iterable of integers. Now only strings and bytes-like objects are accepted.
+ an iterable of integers. Now only strings and byte-like objects are accepted.
+
+Build
+-----
+
+- Issue #26930: Update Windows builds to use OpenSSL 1.0.2h.
+
+- Issue #23968: Rename the platform directory from plat-$(MACHDEP) to
+ plat-$(PLATFORM_TRIPLET).
+ Rename the config directory (LIBPL) from config-$(LDVERSION) to
+ config-$(LDVERSION)-$(PLATFORM_TRIPLET).
+ Install the platform specifc _sysconfigdata module into the platform
+ directory and rename it to include the ABIFLAGS.
+
+- Don't use largefile support for GNU/Hurd.
Tools/Demos
-----------
@@ -78,38 +131,310 @@
- Issue #27418: Fixed Tools/importbench/importbench.py.
-What's New in Python 3.5.2?
-===========================
+What's New in Python 3.6.0 alpha 2
+==================================
-Release date: 2016-06-26
+*Release date: 2016-06-13*
Core and Builtins
-----------------
-- Issue #26930: Update Windows builds to use OpenSSL 1.0.2h.
+- Issue #27095: Simplified MAKE_FUNCTION and removed MAKE_CLOSURE opcodes.
+ Patch by Demur Rumed.
-Tests
------
+- Issue #27190: Raise NotSupportedError if sqlite3 is older than 3.3.1.
+ Patch by Dave Sawyer.
-- Issue #26867: Ubuntu's openssl OP_NO_SSLv3 is forced on by default; fix test.
+- Issue #27286: Fixed compiling BUILD_MAP_UNPACK_WITH_CALL opcode. Calling
+ function with generalized unpacking (PEP 448) and conflicting keyword names
+ could cause undefined behavior.
+
+- Issue #27140: Added BUILD_CONST_KEY_MAP opcode.
+
+- Issue #27186: Add support for os.PathLike objects to open() (part of PEP 519).
+
+- Issue #27066: Fixed SystemError if a custom opener (for open()) returns a
+ negative number without setting an exception.
+
+- Issue #26983: float() now always return an instance of exact float.
+ The deprecation warning is emitted if __float__ returns an instance of
+ a strict subclass of float. In a future versions of Python this can
+ be an error.
+
+- Issue #27097: Python interpreter is now about 7% faster due to optimized
+ instruction decoding. Based on patch by Demur Rumed.
+
+- Issue #26647: Python interpreter now uses 16-bit wordcode instead of bytecode.
+ Patch by Demur Rumed.
+
+- Issue #23275: Allow assigning to an empty target list in round brackets:
+ () = iterable.
+
+- Issue #27243: Update the __aiter__ protocol: instead of returning
+ an awaitable that resolves to an asynchronous iterator, the asynchronous
+ iterator should be returned directly. Doing the former will trigger a
+ PendingDeprecationWarning.
+
+
+Library
+-------
+
+- Comment out socket (SO_REUSEPORT) and posix (O_SHLOCK, O_EXLOCK) constants
+ exposed on the API which are not implemented on GNU/Hurd. They would not
+ work at runtime anyway.
+
+- Issue #25455: Fixed crashes in repr of recursive ElementTree.Element and
+ functools.partial objects.
+
+- Issue #27294: Improved repr for Tkinter event objects.
+
+- Issue #20508: Improve exception message of IPv{4,6}Network.__getitem__.
+ Patch by Gareth Rees.
+
+- Issue #26556: Update expat to 2.1.1, fixes CVE-2015-1283.
+
+- Fix TLS stripping vulnerability in smptlib, CVE-2016-0772. Reported by Team
+ Oststrom
+
+- Issue #21386: Implement missing IPv4Address.is_global property. It was
+ documented since 07a5610bae9d. Initial patch by Roger Luethi.
+
+- Issue #27029: Removed deprecated support of universal newlines mode from
+ ZipFile.open().
+
+- Issue #27030: Unknown escapes consisting of ``'\'`` and an ASCII letter in
+ regular expressions now are errors. The re.LOCALE flag now can be used
+ only with bytes patterns.
+
+- Issue #27186: Add os.PathLike support to DirEntry (part of PEP 519).
+ Initial patch by Jelle Zijlstra.
+
+- Issue #20900: distutils register command now decodes HTTP responses
+ correctly. Initial patch by ingrid.
+
+- Issue #27186: Add os.PathLike support to pathlib, removing its provisional
+ status (part of PEP 519). Initial patch by Dusty Phillips.
+
+- Issue #27186: Add support for os.PathLike objects to os.fsencode() and
+ os.fsdecode() (part of PEP 519).
+
+- Issue #27186: Introduce os.PathLike and os.fspath() (part of PEP 519).
+
+- A new version of typing.py provides several new classes and
+ features: @overload outside stubs, Reversible, DefaultDict, Text,
+ ContextManager, Type[], NewType(), TYPE_CHECKING, and numerous bug
+ fixes (note that some of the new features are not yet implemented in
+ mypy or other static analyzers). Also classes for PEP 492
+ (Awaitable, AsyncIterable, AsyncIterator) have been added (in fact
+ they made it into 3.5.1 but were never mentioned).
+
+- Issue #25738: Stop http.server.BaseHTTPRequestHandler.send_error() from
+ sending a message body for 205 Reset Content. Also, don't send Content
+ header fields in responses that don't have a body. Patch by Susumu
+ Koshiba.
+
+- Issue #21313: Fix the "platform" module to tolerate when sys.version
+ contains truncated build information.
+
+- Issue #26839: On Linux, :func:`os.urandom` now calls ``getrandom()`` with
+ ``GRND_NONBLOCK`` to fall back on reading ``/dev/urandom`` if the urandom
+ entropy pool is not initialized yet. Patch written by Colm Buckley.
+
+- Issue #23883: Added missing APIs to __all__ to match the documented APIs
+ for the following modules: cgi, mailbox, mimetypes, plistlib and smtpd.
+ Patches by Jacek Kołodziej.
+
+- Issue #27164: In the zlib module, allow decompressing raw Deflate streams
+ with a predefined zdict. Based on patch by Xiang Zhang.
+
+- Issue #24291: Fix wsgiref.simple_server.WSGIRequestHandler to completely
+ write data to the client. Previously it could do partial writes and
+ truncate data. Also, wsgiref.handler.ServerHandler can now handle stdout
+ doing partial writes, but this is deprecated.
+
+- Issue #21272: Use _sysconfigdata.py to initialize distutils.sysconfig.
+
+- Issue #19611: :mod:`inspect` now reports the implicit ``.0`` parameters
+ generated by the compiler for comprehension and generator expression scopes
+ as if they were positional-only parameters called ``implicit0``.
+ Patch by Jelle Zijlstra.
+
+- Issue #26809: Add ``__all__`` to :mod:`string`. Patch by Emanuel Barry.
+
+- Issue #26373: subprocess.Popen.communicate now correctly ignores
+ BrokenPipeError when the child process dies before .communicate()
+ is called in more/all circumstances.
+
+- signal, socket, and ssl module IntEnum constant name lookups now return a
+ consistent name for values having multiple names. Ex: signal.Signals(6)
+ now refers to itself as signal.SIGALRM rather than flipping between that
+ and signal.SIGIOT based on the interpreter's hash randomization seed.
+
+- Issue #27167: Clarify the subprocess.CalledProcessError error message text
+ when the child process died due to a signal.
+
+- Issue #25931: Don't define socketserver.Forking* names on platforms such
+ as Windows that do not support os.fork().
+
+- Issue #21776: distutils.upload now correctly handles HTTPError.
+ Initial patch by Claudiu Popa.
+
+- Issue #26526: Replace custom parse tree validation in the parser
+ module with a simple DFA validator.
+
+- Issue #27114: Fix SSLContext._load_windows_store_certs fails with
+ PermissionError
+
+- Issue #18383: Avoid creating duplicate filters when using filterwarnings
+ and simplefilter. Based on patch by Alex Shkop.
+
+- Issue #23026: winreg.QueryValueEx() now return an integer for REG_QWORD type.
+
+- Issue #26741: subprocess.Popen destructor now emits a ResourceWarning warning
+ if the child process is still running.
+
+- Issue #27056: Optimize pickle.load() and pickle.loads(), up to 10% faster
+ to deserialize a lot of small objects.
+
+- Issue #21271: New keyword only parameters in reset_mock call.
+
+- Issue #25548: Showing memory address of class objects in repl.
IDLE
----
-- Issue #27365: Allow non-ascii in idlelib/NEWS.txt - minimal part for 3.5.2.
+- Issue #5124: Paste with text selected now replaces the selection on X11.
+ This matches how paste works on Windows, Mac, most modern Linux apps,
+ and ttk widgets. Original patch by Serhiy Storchaka.
+
+- Issue #24750: Switch all scrollbars in IDLE to ttk versions.
+ Where needed, minimal tests are added to cover changes.
+
+- Issue #24759: IDLE requires tk 8.5 and availability ttk widgets.
+ Delete now unneeded tk version tests and code for older versions.
+ Add test for IDLE syntax colorizoer.
+
+- Issue #27239: idlelib.macosx.isXyzTk functions initialize as needed.
+
+- Issue #27262: move Aqua unbinding code, which enable context menus, to maxosx.
+
+- Issue #24759: Make clear in idlelib.idle_test.__init__ that the directory
+ is a private implementation of test.test_idle and tool for maintainers.
+
+- Issue #27196: Stop 'ThemeChanged' warnings when running IDLE tests.
+ These persisted after other warnings were suppressed in #20567.
+ Apply Serhiy Storchaka's update_idletasks solution to four test files.
+ Record this additional advice in idle_test/README.txt
+
+- Issue #20567: Revise idle_test/README.txt with advice about avoiding
+ tk warning messages from tests. Apply advice to several IDLE tests.
+
+- Issue #24225: Update idlelib/README.txt with new file names
+ and event handlers.
+
+- Issue #27156: Remove obsolete code not used by IDLE. Replacements:
+ 1. help.txt, replaced by help.html, is out-of-date and should not be used.
+ Its dedicated viewer has be replaced by the html viewer in help.py.
+ 2. ‘`import idlever; I = idlever.IDLE_VERSION`’ is the same as
+ ‘`import sys; I = version[:version.index(' ')]`’
+ 3. After ‘`ob = stackviewer.VariablesTreeItem(*args)`’,
+ ‘`ob.keys() == list(ob.object.keys)`’.
+ 4. In macosc, runningAsOSXAPP == isAquaTk; idCarbonAquaTk == isCarbonTk
+
+- Issue #27117: Make colorizer htest and turtledemo work with dark themes.
+ Move code for configuring text widget colors to a new function.
+
+- Issue #24225: Rename many `idlelib/*.py` and `idle_test/test_*.py` files.
+ Edit files to replace old names with new names when the old name
+ referred to the module rather than the class it contained.
+ See the issue and IDLE section in What's New in 3.6 for more.
+
+- Issue #26673: When tk reports font size as 0, change to size 10.
+ Such fonts on Linux prevented the configuration dialog from opening.
+
+- Issue #21939: Add test for IDLE's percolator.
+ Original patch by Saimadhav Heblikar.
+
+- Issue #21676: Add test for IDLE's replace dialog.
+ Original patch by Saimadhav Heblikar.
+
+- Issue #18410: Add test for IDLE's search dialog.
+ Original patch by Westley Martínez.
+
+- Issue #21703: Add test for undo delegator. Patch mostly by
+ Saimadhav Heblikar .
+
+- Issue #27044: Add ConfigDialog.remove_var_callbacks to stop memory leaks.
+
+- Issue #23977: Add more asserts to test_delegator.
+
+Documentation
+-------------
+
+- Issue #16484: Change the default PYTHONDOCS URL to "https:", and fix the
+ resulting links to use lowercase. Patch by Sean Rodman, test by Kaushik
+ Nadikuditi.
+
+- Issue #24136: Document the new PEP 448 unpacking syntax of 3.5.
+
+- Issue #22558: Add remaining doc links to source code for Python-coded modules.
+ Patch by Yoni Lavi.
+
+Tests
+-----
+
+- Issue #25285: regrtest now uses subprocesses when the -j1 command line option
+ is used: each test file runs in a fresh child process. Before, the -j1 option
+ was ignored.
+
+- Issue #25285: Tools/buildbot/test.bat script now uses -j1 by default to run
+ each test file in fresh child process.
+
+Windows
+-------
+
+- Issue #27064: The py.exe launcher now defaults to Python 3.
+ The Windows launcher ``py.exe`` no longer prefers an installed
+ Python 2 version over Python 3 by default when used interactively.
+
+Build
+-----
+
+- Issue #27229: Fix the cross-compiling pgen rule for in-tree builds. Patch
+ by Xavier de Gaye.
+
+- Issue #26930: Update OS X 10.5+ 32-bit-only installer to build
+ and link with OpenSSL 1.0.2h.
+
+Misc
+----
+
+- Issue #17500, and https://github.com/python/pythondotorg/issues/945: Remove
+ unused and outdated icons.
+
+C API
+-----
+
+- Issue #27186: Add the PyOS_FSPath() function (part of PEP 519).
+
+- Issue #26282: PyArg_ParseTupleAndKeywords() now supports positional-only
+ parameters.
+
+Tools/Demos
+-----------
+
+- Issue #26282: Argument Clinic now supports positional-only and keyword
+ parameters in the same function.
-What's New in Python 3.5.2 release candidate 1?
-===============================================
+What's New in Python 3.6.0 alpha 1?
+===================================
-Release date: 2016-06-12
+Release date: 2016-05-16
Core and Builtins
-----------------
-- Issue #27066: Fixed SystemError if a custom opener (for open()) returns a
- negative number without setting an exception.
-
- Issue #20041: Fixed TypeError when frame.f_trace is set to None.
Patch by Xavier de Gaye.
@@ -118,11 +443,17 @@
- Issue #26991: Fix possible refleak when creating a function with annotations.
-- Issue #27039: Fixed bytearray.remove() for values greater than 127. Patch by
- Joe Jevnik.
+- Issue #27039: Fixed bytearray.remove() for values greater than 127. Based on
+ patch by Joe Jevnik.
- Issue #23640: int.from_bytes() no longer bypasses constructors for subclasses.
+- Issue #27005: Optimized the float.fromhex() class method for exact float.
+ It is now 2 times faster.
+
+- Issue #18531: Single var-keyword argument of dict subtype was passed
+ unscathed to the C-defined function. Now it is converted to exact dict.
+
- Issue #26811: gc.get_objects() no longer contains a broken tuple with NULL
pointer.
@@ -132,11 +463,26 @@
interpolation in .pypirc files, matching behavior in Python
2.7 and Setuptools 19.0.
+- Issue #26249: Memory functions of the :c:func:`PyMem_Malloc` domain
+ (:c:data:`PYMEM_DOMAIN_MEM`) now use the :ref:`pymalloc allocator <pymalloc>`
+ rather than system :c:func:`malloc`. Applications calling
+ :c:func:`PyMem_Malloc` without holding the GIL can now crash: use
+ ``PYTHONMALLOC=debug`` environment variable to validate the usage of memory
+ allocators in your application.
+
+- Issue #26802: Optimize function calls only using unpacking like
+ ``func(*tuple)`` (no other positional argument, no keyword): avoid copying
+ the tuple. Patch written by Joe Jevnik.
+
- Issue #26659: Make the builtin slice type support cycle collection.
- Issue #26718: super.__init__ no longer leaks memory if called multiple times.
NOTE: A direct call of super.__init__ is not endorsed!
+- Issue #27138: Fix the doc comment for FileFinder.find_spec().
+
+- Issue #27147: Mention PEP 420 in the importlib docs.
+
- Issue #25339: PYTHONIOENCODING now has priority over locale in setting the
error handler for stdin and stdout.
@@ -145,9 +491,41 @@
bytearray, list, tuple, set, frozenset, dict, OrderedDict, corresponding
views and os.scandir() iterator.
+- Issue #26574: Optimize ``bytes.replace(b'', b'.')`` and
+ ``bytearray.replace(b'', b'.')``. Patch written by Josh Snider.
+
- Issue #26581: If coding cookie is specified multiple times on a line in
Python source code file, only the first one is taken to account.
+- Issue #19711: Add tests for reloading namespace packages.
+
+- Issue #21099: Switch applicable importlib tests to use PEP 451 API.
+
+- Issue #26563: Debug hooks on Python memory allocators now raise a fatal
+ error if functions of the :c:func:`PyMem_Malloc` family are called without
+ holding the GIL.
+
+- Issue #26564: On error, the debug hooks on Python memory allocators now use
+ the :mod:`tracemalloc` module to get the traceback where a memory block was
+ allocated.
+
+- Issue #26558: The debug hooks on Python memory allocator
+ :c:func:`PyObject_Malloc` now detect when functions are called without
+ holding the GIL.
+
+- Issue #26516: Add :envvar:`PYTHONMALLOC` environment variable to set the
+ Python memory allocators and/or install debug hooks.
+
+- Issue #26516: The :c:func:`PyMem_SetupDebugHooks` function can now also be
+ used on Python compiled in release mode.
+
+- Issue #26516: The :envvar:`PYTHONMALLOCSTATS` environment variable can now
+ also be used on Python compiled in release mode. It now has no effect if
+ set to an empty string.
+
+- Issue #26516: In debug mode, debug hooks are now also installed on Python
+ memory allocators when Python is configured without pymalloc.
+
- Issue #26464: Fix str.translate() when string is ASCII and first replacements
removes character, but next replacement uses a non-ASCII character or a
string longer than 1 character. Regression introduced in Python 3.5.0.
@@ -160,11 +538,37 @@
- Issue #26302: Correct behavior to reject comma as a legal character for
cookie names.
+- Issue #26136: Upgrade the warning when a generator raises StopIteration
+ from PendingDeprecationWarning to DeprecationWarning. Patch by Anish
+ Shah.
+
+- Issue #26204: The compiler now ignores all constant statements: bytes, str,
+ int, float, complex, name constants (None, False, True), Ellipsis
+ and ast.Constant; not only str and int. For example, ``1.0`` is now ignored
+ in ``def f(): 1.0``.
+
- Issue #4806: Avoid masking the original TypeError exception when using star
(*) unpacking in function calls. Based on patch by Hagen Fürstenau and
Daniel Urban.
-- Issue #27138: Fix the doc comment for FileFinder.find_spec().
+- Issue #26146: Add a new kind of AST node: ``ast.Constant``. It can be used
+ by external AST optimizers, but the compiler does not emit directly such
+ node.
+
+- Issue #23601: Sped-up allocation of dict key objects by using Python's
+ small object allocator. (Contributed by Julian Taylor.)
+
+- Issue #18018: Import raises ImportError instead of SystemError if a relative
+ import is attempted without a known parent package.
+
+- Issue #25843: When compiling code, don't merge constants if they are equal
+ but have a different types. For example, ``f1, f2 = lambda: 1, lambda: 1.0``
+ is now correctly compiled to two different functions: ``f1()`` returns ``1``
+ (``int``) and ``f2()`` returns ``1.0`` (``float``), even if ``1`` and ``1.0``
+ are equal.
+
+- Issue #26107: The format of the ``co_lnotab`` attribute of code objects
+ changes to support negative line number delta.
- Issue #26154: Add a new private _PyThreadState_UncheckedGet() function to get
the current Python thread state, but don't issue a fatal error if it is NULL.
@@ -173,15 +577,8 @@
Python 3.5.1 to hide the exact implementation of atomic C types, to avoid
compiler issues.
-- Issue #26194: Deque.insert() gave odd results for bounded deques that had
- reached their maximum size. Now an IndexError will be raised when attempting
- to insert into a full deque.
-
-- Issue #25843: When compiling code, don't merge constants if they are equal
- but have a different types. For example, ``f1, f2 = lambda: 1, lambda: 1.0``
- is now correctly compiled to two different functions: ``f1()`` returns ``1``
- (``int``) and ``f2()`` returns ``1.0`` (``int``), even if ``1`` and ``1.0``
- are equal.
+- Issue #25791: If __package__ != __spec__.parent or if neither __package__ or
+ __spec__ are defined then ImportWarning is raised.
- Issue #22995: [UPDATE] Comment out the one of the pickleability tests in
_PyObject_GetState() due to regressions observed in Cython-based projects.
@@ -207,7 +604,10 @@
- Issue #25709: Fixed problem with in-place string concatenation and utf-8 cache.
-- Issue #27147: Mention PEP 420 in the importlib docs.
+- Issue #5319: New Py_FinalizeEx() API allowing Python to set an exit status
+ of 120 on failure to flush buffered streams.
+
+- Issue #25485: telnetlib.Telnet is now a context manager.
- Issue #24097: Fixed crash in object.__reduce__() if slot name is freed inside
__getattr__.
@@ -216,6 +616,88 @@
__bytes__, __trunc__, and __float__ returning instances of subclasses of
bytes, int, and float to subclasses of bytes, int, and float correspondingly.
+- Issue #25630: Fix a possible segfault during argument parsing in functions
+ that accept filesystem paths.
+
+- Issue #23564: Fixed a partially broken sanity check in the _posixsubprocess
+ internals regarding how fds_to_pass were passed to the child. The bug had
+ no actual impact as subprocess.py already avoided it.
+
+- Issue #25388: Fixed tokenizer crash when processing undecodable source code
+ with a null byte.
+
+- Issue #25462: The hash of the key now is calculated only once in most
+ operations in C implementation of OrderedDict.
+
+- Issue #22995: Default implementation of __reduce__ and __reduce_ex__ now
+ rejects builtin types with not defined __new__.
+
+- Issue #24802: Avoid buffer overreads when int(), float(), compile(), exec()
+ and eval() are passed bytes-like objects. These objects are not
+ necessarily terminated by a null byte, but the functions assumed they were.
+
+- Issue #25555: Fix parser and AST: fill lineno and col_offset of "arg" node
+ when compiling AST from Python objects.
+
+- Issue #24726: Fixed a crash and leaking NULL in repr() of OrderedDict that
+ was mutated by direct calls of dict methods.
+
+- Issue #25449: Iterating OrderedDict with keys with unstable hash now raises
+ KeyError in C implementations as well as in Python implementation.
+
+- Issue #25395: Fixed crash when highly nested OrderedDict structures were
+ garbage collected.
+
+- Issue #25401: Optimize bytes.fromhex() and bytearray.fromhex(): they are now
+ between 2x and 3.5x faster.
+
+- Issue #25399: Optimize bytearray % args using the new private _PyBytesWriter
+ API. Formatting is now between 2.5 and 5 times faster.
+
+- Issue #25274: sys.setrecursionlimit() now raises a RecursionError if the new
+ recursion limit is too low depending at the current recursion depth. Modify
+ also the "lower-water mark" formula to make it monotonic. This mark is used
+ to decide when the overflowed flag of the thread state is reset.
+
+- Issue #24402: Fix input() to prompt to the redirected stdout when
+ sys.stdout.fileno() fails.
+
+- Issue #25349: Optimize bytes % args using the new private _PyBytesWriter API.
+ Formatting is now up to 2 times faster.
+
+- Issue #24806: Prevent builtin types that are not allowed to be subclassed from
+ being subclassed through multiple inheritance.
+
+- Issue #25301: The UTF-8 decoder is now up to 15 times as fast for error
+ handlers: ``ignore``, ``replace`` and ``surrogateescape``.
+
+- Issue #24848: Fixed a number of bugs in UTF-7 decoding of misformed data.
+
+- Issue #25267: The UTF-8 encoder is now up to 75 times as fast for error
+ handlers: ``ignore``, ``replace``, ``surrogateescape``, ``surrogatepass``.
+ Patch co-written with Serhiy Storchaka.
+
+- Issue #25280: Import trace messages emitted in verbose (-v) mode are no
+ longer formatted twice.
+
+- Issue #25227: Optimize ASCII and latin1 encoders with the ``surrogateescape``
+ error handler: the encoders are now up to 3 times as fast. Initial patch
+ written by Serhiy Storchaka.
+
+- Issue #25003: On Solaris 11.3 or newer, os.urandom() now uses the
+ getrandom() function instead of the getentropy() function. The getentropy()
+ function is blocking to generate very good quality entropy, os.urandom()
+ doesn't need such high-quality entropy.
+
+- Issue #9232: Modify Python's grammar to allow trailing commas in the
+ argument list of a function declaration. For example, "def f(\*, a =
+ 3,): pass" is now legal. Patch from Mark Dickinson.
+
+- Issue #24965: Implement PEP 498 "Literal String Interpolation". This
+ allows you to embed expressions inside f-strings, which are
+ converted to normal strings at run time. Given x=3, then
+ f'value={x}' == 'value=3'. Patch by Eric V. Smith.
+
- Issue #26478: Fix semantic bugs when using binary operators with dictionary
views and tuples.
@@ -224,78 +706,27 @@
- Issue #25660: Fix TAB key behaviour in REPL with readline.
+- Issue #26288: Optimize PyLong_AsDouble.
+
+- Issues #26289 and #26315: Optimize floor and modulo division for
+ single-digit longs. Microbenchmarks show 2-2.5x improvement. Built-in
+ 'divmod' function is now also ~10% faster.
+
- Issue #25887: Raise a RuntimeError when a coroutine object is awaited
more than once.
-- Issue #27243: Update the __aiter__ protocol: instead of returning
- an awaitable that resolves to an asynchronous iterator, the asynchronous
- iterator should be returned directly. Doing the former will trigger a
- PendingDeprecationWarning.
-
-
Library
-------
-- Issue #26556: Update expat to 2.1.1, fixes CVE-2015-1283.
-
-- Fix TLS stripping vulnerability in smptlib, CVE-2016-0772. Reported by Team
- Oststrom
-
-- Issue #21386: Implement missing IPv4Address.is_global property. It was
- documented since 07a5610bae9d. Initial patch by Roger Luethi.
-
-- Issue #20900: distutils register command now decodes HTTP responses
- correctly. Initial patch by ingrid.
-
-- A new version of typing.py provides several new classes and
- features: @overload outside stubs, Reversible, DefaultDict, Text,
- ContextManager, Type[], NewType(), TYPE_CHECKING, and numerous bug
- fixes (note that some of the new features are not yet implemented in
- mypy or other static analyzers). Also classes for PEP 492
- (Awaitable, AsyncIterable, AsyncIterator) have been added (in fact
- they made it into 3.5.1 but were never mentioned).
-
-- Issue #25738: Stop http.server.BaseHTTPRequestHandler.send_error() from
- sending a message body for 205 Reset Content. Also, don't send Content
- header fields in responses that don't have a body. Patch by Susumu
- Koshiba.
-
-- Issue #21313: Fix the "platform" module to tolerate when sys.version
- contains truncated build information.
-
-- Issue #26839: On Linux, :func:`os.urandom` now calls ``getrandom()`` with
- ``GRND_NONBLOCK`` to fall back on reading ``/dev/urandom`` if the urandom
- entropy pool is not initialized yet. Patch written by Colm Buckley.
-
-- Issue #27164: In the zlib module, allow decompressing raw Deflate streams
- with a predefined zdict. Based on patch by Xiang Zhang.
-
-- Issue #24291: Fix wsgiref.simple_server.WSGIRequestHandler to completely
- write data to the client. Previously it could do partial writes and
- truncate data. Also, wsgiref.handler.ServerHandler can now handle stdout
- doing partial writes, but this is deprecated.
-
-- Issue #26809: Add ``__all__`` to :mod:`string`. Patch by Emanuel Barry.
-
-- Issue #26373: subprocess.Popen.communicate now correctly ignores
- BrokenPipeError when the child process dies before .communicate()
- is called in more/all circumstances.
-
-- Issue #21776: distutils.upload now correctly handles HTTPError.
- Initial patch by Claudiu Popa.
-
-- Issue #27114: Fix SSLContext._load_windows_store_certs fails with
- PermissionError
-
-- Issue #18383: Avoid creating duplicate filters when using filterwarnings
- and simplefilter. Based on patch by Alex Shkop.
-
- Issue #27057: Fix os.set_inheritable() on Android, ioctl() is blocked by
SELinux and fails with EACCESS. The function now falls back to fcntl().
Patch written by Michał Bednarski.
- Issue #27014: Fix infinite recursion using typing.py. Thanks to Kalle Tuure!
+- Issue #27031: Removed dummy methods in Tkinter widget classes: tk_menuBar()
+ and tk_bindForTraversal().
+
- Issue #14132: Fix urllib.request redirect handling when the target only has
a query string. Original fix by Ján Janech.
@@ -305,6 +736,18 @@
to be ASCII-encodable, otherwise a UnicodeEncodeError is raised. Based on
patch by Christian Heimes.
+- Issue #27033: The default value of the decode_data parameter for
+ smtpd.SMTPChannel and smtpd.SMTPServer constructors is changed to False.
+
+- Issue #27034: Removed deprecated class asynchat.fifo.
+
+- Issue #26870: Added readline.set_auto_history(), which can stop entries
+ being automatically added to the history list. Based on patch by Tyler
+ Crompton.
+
+- Issue #26039: zipfile.ZipFile.open() can now be used to write data into a ZIP
+ file, as well as for extracting data. Patch by Thomas Kluyver.
+
- Issue #26892: Honor debuglevel flag in urllib.request.HTTPHandler. Patch
contributed by Chi Hsuan Yen.
@@ -319,6 +762,14 @@
- Issue #26977: Removed unnecessary, and ignored, call to sum of squares helper
in statistics.pvariance.
+- Issue #26002: Use bisect in statistics.median instead of a linear search.
+ Patch by Upendra Kuma.
+
+- Issue #25974: Make use of new Decimal.as_integer_ratio() method in statistics
+ module. Patch by Stefan Krah.
+
+- Issue #26996: Add secrets module as described in PEP 506.
+
- Issue #26881: The modulefinder module now supports extended opcode arguments.
- Issue #23815: Fixed crashes related to directly created instances of types in
@@ -330,6 +781,11 @@
- Issue #26873: xmlrpc now raises ResponseError on unsupported type tags
instead of silently return incorrect result.
+- Issue #26915: The __contains__ methods in the collections ABCs now check
+ for identity before checking equality. This better matches the behavior
+ of the concrete classes, allows sensible handling of NaNs, and makes it
+ easier to reason about container invariants.
+
- Issue #26711: Fixed the comparison of plistlib.Data with other types.
- Issue #24114: Fix an uninitialized variable in `ctypes.util`.
@@ -343,6 +799,12 @@
names that happen to have a bypassed hostname as a suffix. Patch by Xiang
Zhang.
+- Issue #24902: Print server URL on http.server startup. Initial patch by
+ Felix Kaiser.
+
+- Issue #25788: fileinput.hook_encoded() now supports an "errors" argument
+ for passing to open. Original patch by Joseph Hackman.
+
- Issue #26634: recursive_repr() now sets __qualname__ of wrapper. Patch by
Xiang Zhang.
@@ -378,26 +840,54 @@
- Issue #26717: Stop encoding Latin-1-ized WSGI paths with UTF-8. Patch by
Anthony Sottile.
+- Issue #26782: Add STARTUPINFO to subprocess.__all__ on Windows.
+
+- Issue #26404: Add context manager to socketserver. Patch by Aviv Palivoda.
+
- Issue #26735: Fix :func:`os.urandom` on Solaris 11.3 and newer when reading
more than 1,024 bytes: call ``getrandom()`` multiple times with a limit of
1024 bytes per call.
+- Issue #26585: Eliminate http.server._quote_html() and use
+ html.escape(quote=False). Patch by Xiang Zhang.
+
+- Issue #26685: Raise OSError if closing a socket fails.
+
- Issue #16329: Add .webm to mimetypes.types_map. Patch by Giampaolo Rodola'.
- Issue #13952: Add .csv to mimetypes.types_map. Patch by Geoff Wilson.
+- Issue #26587: the site module now allows .pth files to specify files to be
+ added to sys.path (e.g. zip files).
+
+- Issue #25609: Introduce contextlib.AbstractContextManager and
+ typing.ContextManager.
+
- Issue #26709: Fixed Y2038 problem in loading binary PLists.
- Issue #23735: Handle terminal resizing with Readline 6.3+ by installing our
own SIGWINCH handler. Patch by Eric Price.
+- Issue #25951: Change SSLSocket.sendall() to return None, as explicitly
+ documented for plain socket objects. Patch by Aviv Palivoda.
+
- Issue #26586: In http.server, respond with "413 Request header fields too
large" if there are too many header fields to parse, rather than killing
the connection and raising an unhandled exception. Patch by Xiang Zhang.
+- Issue #26676: Added missing XMLPullParser to ElementTree.__all__.
+
- Issue #22854: Change BufferedReader.writable() and
BufferedWriter.readable() to always return False.
+- Issue #26492: Exhausted iterator of array.array now conforms with the behavior
+ of iterators of other mutable sequences: it lefts exhausted even if iterated
+ array is extended.
+
+- Issue #26641: doctest.DocFileTest and doctest.testfile() now support
+ packages (module splitted into multiple directories) for the package
+ parameter.
+
- Issue #25195: Fix a regression in mock.MagicMock. _Call is a subclass of
tuple (changeset 3603bae63c13 only works for classes) so we need to
implement __ne__ ourselves. Patch by Andrew Plummer.
@@ -410,16 +900,45 @@
- Issue #26616: Fixed a bug in datetime.astimezone() method.
-- Issue #21925: :func:`warnings.formatwarning` now catches exceptions on
- ``linecache.getline(...)`` to be able to log :exc:`ResourceWarning` emitted
- late during the Python shutdown process.
+- Issue #26637: The :mod:`importlib` module now emits an :exc:`ImportError`
+ rather than a :exc:`TypeError` if :func:`__import__` is tried during the
+ Python shutdown process but :data:`sys.path` is already cleared (set to
+ ``None``).
+
+- Issue #21925: :func:`warnings.formatwarning` now catches exceptions when
+ calling :func:`linecache.getline` and
+ :func:`tracemalloc.get_object_traceback` to be able to log
+ :exc:`ResourceWarning` emitted late during the Python shutdown process.
+
+- Issue #23848: On Windows, faulthandler.enable() now also installs an
+ exception handler to dump the traceback of all Python threads on any Windows
+ exception, not only on UNIX signals (SIGSEGV, SIGFPE, SIGABRT).
+
+- Issue #26530: Add C functions :c:func:`_PyTraceMalloc_Track` and
+ :c:func:`_PyTraceMalloc_Untrack` to track memory blocks using the
+ :mod:`tracemalloc` module. Add :c:func:`_PyTraceMalloc_GetTraceback` to get
+ the traceback of an object.
+
+- Issue #26588: The _tracemalloc now supports tracing memory allocations of
+ multiple address spaces (domains).
- Issue #24266: Ctrl+C during Readline history search now cancels the search
mode when compiled with Readline 7.
+- Issue #26590: Implement a safe finalizer for the _socket.socket type. It now
+ releases the GIL to close the socket.
+
+- Issue #18787: spwd.getspnam() now raises a PermissionError if the user
+ doesn't have privileges.
+
- Issue #26560: Avoid potential ValueError in BaseHandler.start_response.
Initial patch by Peter Inglesby.
+- Issue #26567: Add a new function :c:func:`PyErr_ResourceWarning` function to
+ pass the destroyed object. Add a *source* attribute to
+ :class:`warnings.WarningMessage`. Add warnings._showwarnmsg() which uses
+ tracemalloc to get the traceback where source object was allocated.
+
- Issue #26313: ssl.py _load_windows_store_certs fails if windows cert store
is empty. Patch by Baji.
@@ -441,23 +960,38 @@
- Issue #23718: Fixed parsing time in week 0 before Jan 1. Original patch by
Tamás Bence Gedai.
+- Issue #26323: Add Mock.assert_called() and Mock.assert_called_once()
+ methods to unittest.mock. Patch written by Amit Saha.
+
- Issue #20589: Invoking Path.owner() and Path.group() on Windows now raise
NotImplementedError instead of ImportError.
- Issue #26177: Fixed the keys() method for Canvas and Scrollbar widgets.
-- Issue #15068: Got rid of excessive buffering in the fileinput module.
- The bufsize parameter is no longer used.
+- Issue #15068: Got rid of excessive buffering in fileinput.
+ The bufsize parameter is now deprecated and ignored.
+
+- Issue #19475: Added an optional argument timespec to the datetime
+ isoformat() method to choose the precision of the time component.
- Issue #2202: Fix UnboundLocalError in
AbstractDigestAuthHandler.get_algorithm_impls. Initial patch by Mathieu Dupuy.
+- Issue #26167: Minimized overhead in copy.copy() and copy.deepcopy().
+ Optimized copying and deepcopying bytearrays, NotImplemented, slices,
+ short lists, tuples, dicts, sets.
+
- Issue #25718: Fixed pickling and copying the accumulate() iterator with
total is None.
- Issue #26475: Fixed debugging output for regular expressions with the (?x)
flag.
+- Issue #26482: Allowed pickling recursive dequeues.
+
+- Issue #26335: Make mmap.write() return the number of bytes written like
+ other write methods. Patch by Jakub Stasiak.
+
- Issue #26457: Fixed the subnets() methods in IP network classes for the case
when resulting prefix length is equal to maximal prefix length.
Based on patch by Xiang Zhang.
@@ -474,7 +1008,7 @@
- Issue #26186: Remove an invalid type check in importlib.util.LazyLoader.
-- Issue #26367: importlib.__import__() raises SystemError like
+- Issue #26367: importlib.__import__() raises ImportError like
builtins.__import__() when ``level`` is specified but without an accompanying
package specified.
@@ -482,18 +1016,38 @@
the connected socket) when verify_request() returns false. Patch by Aviv
Palivoda.
+- Issue #23430: Change the socketserver module to only catch exceptions
+ raised from a request handler that are derived from Exception (instead of
+ BaseException). Therefore SystemExit and KeyboardInterrupt no longer
+ trigger the handle_error() method, and will now to stop a single-threaded
+ server.
+
- Issue #25939: On Windows open the cert store readonly in ssl.enum_certificates.
- Issue #25995: os.walk() no longer uses FDs proportional to the tree depth.
+- Issue #25994: Added the close() method and the support of the context manager
+ protocol for the os.scandir() iterator.
+
+- Issue #23992: multiprocessing: make MapResult not fail-fast upon exception.
+
+- Issue #26243: Support keyword arguments to zlib.compress(). Patch by Aviv
+ Palivoda.
+
- Issue #26117: The os.scandir() iterator now closes file descriptor not only
when the iteration is finished, but when it was failed with error.
+- Issue #25949: __dict__ for an OrderedDict instance is now created only when
+ needed.
+
- Issue #25911: Restored support of bytes paths in os.walk() on Windows.
- Issue #26045: Add UTF-8 suggestion to error message when posting a
non-Latin-1 string with http.client.
+- Issue #26039: Added zipfile.ZipInfo.from_file() and zipinfo.ZipInfo.is_dir().
+ Patch by Thomas Kluyver.
+
- Issue #12923: Reset FancyURLopener's redirect counter even if there is an
exception. Based on patches by Brian Brazil and Daniel Rocco.
@@ -514,6 +1068,10 @@
gethostbyname_ex() functions of the socket module now decode the hostname
from the ANSI code page rather than UTF-8.
+- Issue #26099: The site module now writes an error into stderr if
+ sitecustomize module can be imported but executing the module raise an
+ ImportError. Same change for usercustomize.
+
- Issue #26147: xmlrpc now works with strings not encodable with used
non-UTF-8 encoding.
@@ -524,13 +1082,21 @@
- Issue #26013: Added compatibility with broken protocol 2 pickles created
in old Python 3 versions (3.4.3 and lower).
+- Issue #26129: Deprecated accepting non-integers in grp.getgrgid().
+
- Issue #25850: Use cross-compilation by default for 64-bit Windows.
-- Issue #17633: Improve zipimport's support for namespace packages.
+- Issue #25822: Add docstrings to the fields of urllib.parse results.
+ Patch contributed by Swati Jaiswal.
+
+- Issue #22642: Convert trace module option parsing mechanism to argparse.
+ Patch contributed by SilentGhost.
- Issue #24705: Fix sysconfig._parse_makefile not expanding ${} vars
appearing before $() vars.
+- Issue #26069: Remove the deprecated apis in the trace module.
+
- Issue #22138: Fix mock.patch behavior when patching descriptors. Restore
original values after patching. Patch contributed by Sean McCully.
@@ -543,13 +1109,28 @@
- Issue #24120: Ignore PermissionError when traversing a tree with
pathlib.Path.[r]glob(). Patch by Ulrich Petri.
+- Issue #21815: Accept ] characters in the data portion of imap responses,
+ in order to handle the flags with square brackets accepted and produced
+ by servers such as gmail.
+
- Issue #25447: fileinput now uses sys.stdin as-is if it does not have a
buffer attribute (restores backward compatibility).
+- Issue #25971: Optimized creating Fractions from floats by 2 times and from
+ Decimals by 3 times.
+
+- Issue #25802: Document as deprecated the remaining implementations of
+ importlib.abc.Loader.load_module().
+
+- Issue #25928: Add Decimal.as_integer_ratio().
+
- Issue #25447: Copying the lru_cache() wrapper object now always works,
- independedly from the type of the wrapped object (by returning the original
+ independently from the type of the wrapped object (by returning the original
object unchanged).
+- Issue #25768: Have the functions in compileall return booleans instead of
+ ints and add proper documentation and tests for the return values.
+
- Issue #24103: Fixed possible use after free in ElementTree.XMLPullParser.
- Issue #25860: os.fwalk() no longer skips remaining directories when error
@@ -557,8 +1138,22 @@
- Issue #25914: Fixed and simplified OrderedDict.__sizeof__.
+- Issue #25869: Optimized deepcopying ElementTree; it is now 20 times faster.
+
+- Issue #25873: Optimized iterating ElementTree. Iterating elements
+ Element.iter() is now 40% faster, iterating text Element.itertext()
+ is now up to 2.5 times faster.
+
- Issue #25902: Fixed various refcount issues in ElementTree iteration.
+- Issue #22227: The TarFile iterator is reimplemented using generator.
+ This implementation is simpler that using class.
+
+- Issue #25638: Optimized ElementTree.iterparse(); it is now 2x faster.
+ Optimized ElementTree parsing; it is now 10% faster.
+
+- Issue #25761: Improved detecting errors in broken pickle data.
+
- Issue #25717: Restore the previous behaviour of tolerating most fstat()
errors when opening files. This was a regression in 3.5a1, and stopped
anonymous temporary files from working in special cases.
@@ -570,6 +1165,9 @@
- Issue #25764: In the subprocess module, preserve any exception caused by
fork() failure when preexec_fn is used.
+- Issue #25771: Tweak the exception message for importlib.util.resolve_name()
+ when 'package' isn't specified but necessary.
+
- Issue #6478: _strptime's regexp cache now is reset after changing timezone
with time.tzset().
@@ -591,6 +1189,9 @@
- Issue #10131: Fixed deep copying of minidom documents. Based on patch
by Marian Ganisin.
+- Issue #7990: dir() on ElementTree.Element now lists properties: "tag",
+ "text", "tail" and "attrib". Original patch by Santoso Wijaya.
+
- Issue #25725: Fixed a reference leak in pickle.loads() when unpickling
invalid data including tuple instructions.
@@ -606,6 +1207,202 @@
- Issue #25624: ZipFile now always writes a ZIP_STORED header for directory
entries. Patch by Dingyuan Wang.
+- Issue #25626: Change three zlib functions to accept sizes that fit in
+ Py_ssize_t, but internally cap those sizes to UINT_MAX. This resolves a
+ regression in 3.5 where GzipFile.read() failed to read chunks larger than 2
+ or 4 GiB. The change affects the zlib.Decompress.decompress() max_length
+ parameter, the zlib.decompress() bufsize parameter, and the
+ zlib.Decompress.flush() length parameter.
+
+- Issue #25583: Avoid incorrect errors raised by os.makedirs(exist_ok=True)
+ when the OS gives priority to errors such as EACCES over EEXIST.
+
+- Issue #25593: Change semantics of EventLoop.stop() in asyncio.
+
+- Issue #6973: When we know a subprocess.Popen process has died, do
+ not allow the send_signal(), terminate(), or kill() methods to do
+ anything as they could potentially signal a different process.
+
+- Issue #23883: Added missing APIs to __all__ to match the documented APIs
+ for the following modules: calendar, csv, enum, fileinput, ftplib, logging,
+ optparse, tarfile, threading and wave. Also added a
+ test.support.check__all__() helper. Patches by Jacek Kołodziej, Mauro
+ S. M. Rodrigues and Joel Taddei.
+
+- Issue #25590: In the Readline completer, only call getattr() once per
+ attribute. Also complete names of attributes such as properties and slots
+ which are listed by dir() but not yet created on an instance.
+
+- Issue #25498: Fix a crash when garbage-collecting ctypes objects created
+ by wrapping a memoryview. This was a regression made in 3.5a1. Based
+ on patch by Eryksun.
+
+- Issue #25584: Added "escape" to the __all__ list in the glob module.
+
+- Issue #25584: Fixed recursive glob() with patterns starting with '\*\*'.
+
+- Issue #25446: Fix regression in smtplib's AUTH LOGIN support.
+
+- Issue #18010: Fix the pydoc web server's module search function to handle
+ exceptions from importing packages.
+
+- Issue #25554: Got rid of circular references in regular expression parsing.
+
+- Issue #18973: Command-line interface of the calendar module now uses argparse
+ instead of optparse.
+
+- Issue #25510: fileinput.FileInput.readline() now returns b'' instead of ''
+ at the end if the FileInput was opened with binary mode.
+ Patch by Ryosuke Ito.
+
+- Issue #25503: Fixed inspect.getdoc() for inherited docstrings of properties.
+ Original patch by John Mark Vandenberg.
+
+- Issue #25515: Always use os.urandom as a source of randomness in uuid.uuid4.
+
+- Issue #21827: Fixed textwrap.dedent() for the case when largest common
+ whitespace is a substring of smallest leading whitespace.
+ Based on patch by Robert Li.
+
+- Issue #25447: The lru_cache() wrapper objects now can be copied and pickled
+ (by returning the original object unchanged).
+
+- Issue #25390: typing: Don't crash on Union[str, Pattern].
+
+- Issue #25441: asyncio: Raise error from drain() when socket is closed.
+
+- Issue #25410: Cleaned up and fixed minor bugs in C implementation of
+ OrderedDict.
+
+- Issue #25411: Improved Unicode support in SMTPHandler through better use of
+ the email package. Thanks to user simon04 for the patch.
+
+- Move the imp module from a PendingDeprecationWarning to DeprecationWarning.
+
+- Issue #25407: Remove mentions of the formatter module being removed in
+ Python 3.6.
+
+- Issue #25406: Fixed a bug in C implementation of OrderedDict.move_to_end()
+ that caused segmentation fault or hang in iterating after moving several
+ items to the start of ordered dict.
+
+- Issue #25382: pickletools.dis() now outputs implicit memo index for the
+ MEMOIZE opcode.
+
+- Issue #25357: Add an optional newline paramer to binascii.b2a_base64().
+ base64.b64encode() uses it to avoid a memory copy.
+
+- Issue #24164: Objects that need calling ``__new__`` with keyword arguments,
+ can now be pickled using pickle protocols older than protocol version 4.
+
+- Issue #25364: zipfile now works in threads disabled builds.
+
+- Issue #25328: smtpd's SMTPChannel now correctly raises a ValueError if both
+ decode_data and enable_SMTPUTF8 are set to true.
+
+- Issue #16099: RobotFileParser now supports Crawl-delay and Request-rate
+ extensions. Patch by Nikolay Bogoychev.
+
+- Issue #25316: distutils raises OSError instead of DistutilsPlatformError
+ when MSVC is not installed.
+
+- Issue #25380: Fixed protocol for the STACK_GLOBAL opcode in
+ pickletools.opcodes.
+
+- Issue #23972: Updates asyncio datagram create method allowing reuseport
+ and reuseaddr socket options to be set prior to binding the socket.
+ Mirroring the existing asyncio create_server method the reuseaddr option
+ for datagram sockets defaults to True if the O/S is 'posix' (except if the
+ platform is Cygwin). Patch by Chris Laws.
+
+- Issue #25304: Add asyncio.run_coroutine_threadsafe(). This lets you
+ submit a coroutine to a loop from another thread, returning a
+ concurrent.futures.Future. By Vincent Michel.
+
+- Issue #25232: Fix CGIRequestHandler to split the query from the URL at the
+ first question mark (?) rather than the last. Patch from Xiang Zhang.
+
+- Issue #24657: Prevent CGIRequestHandler from collapsing slashes in the
+ query part of the URL as if it were a path. Patch from Xiang Zhang.
+
+- Issue #25287: Don't add crypt.METHOD_CRYPT to crypt.methods if it's not
+ supported. Check if it is supported, it may not be supported on OpenBSD for
+ example.
+
+- Issue #23600: Default implementation of tzinfo.fromutc() was returning
+ wrong results in some cases.
+
+- Issue #25203: Failed readline.set_completer_delims() no longer left the
+ module in inconsistent state.
+
+- Issue #25011: rlcompleter now omits private and special attribute names unless
+ the prefix starts with underscores.
+
+- Issue #25209: rlcompleter now can add a space or a colon after completed keyword.
+
+- Issue #22241: timezone.utc name is now plain 'UTC', not 'UTC-00:00'.
+
+- Issue #23517: fromtimestamp() and utcfromtimestamp() methods of
+ datetime.datetime now round microseconds to nearest with ties going to
+ nearest even integer (ROUND_HALF_EVEN), as round(float), instead of rounding
+ towards -Infinity (ROUND_FLOOR).
+
+- Issue #23552: Timeit now warns when there is substantial (4x) variance
+ between best and worst times. Patch from Serhiy Storchaka.
+
+- Issue #24633: site-packages/README -> README.txt.
+
+- Issue #24879: help() and pydoc can now list named tuple fields in the
+ order they were defined rather than alphabetically. The ordering is
+ determined by the _fields attribute if present.
+
+- Issue #24874: Improve speed of itertools.cycle() and make its
+ pickle more compact.
+
+- Fix crash in itertools.cycle.__setstate__() when the first argument wasn't
+ a list.
+
+- Issue #20059: urllib.parse raises ValueError on all invalid ports.
+ Patch by Martin Panter.
+
+- Issue #24360: Improve __repr__ of argparse.Namespace() for invalid
+ identifiers. Patch by Matthias Bussonnier.
+
+- Issue #23426: run_setup was broken in distutils.
+ Patch from Alexander Belopolsky.
+
+- Issue #13938: 2to3 converts StringTypes to a tuple. Patch from Mark Hammond.
+
+- Issue #2091: open() accepted a 'U' mode string containing '+', but 'U' can
+ only be used with 'r'. Patch from Jeff Balogh and John O'Connor.
+
+- Issue #8585: improved tests for zipimporter2. Patch from Mark Lawrence.
+
+- Issue #18622: unittest.mock.mock_open().reset_mock would recurse infinitely.
+ Patch from Nicola Palumbo and Laurent De Buyst.
+
+- Issue #24426: Fast searching optimization in regular expressions now works
+ for patterns that starts with capturing groups. Fast searching optimization
+ now can't be disabled at compile time.
+
+- Issue #23661: unittest.mock side_effects can now be exceptions again. This
+ was a regression vs Python 3.4. Patch from Ignacio Rossi
+
+- Issue #13248: Remove deprecated inspect.getmoduleinfo function.
+
+- Issue #25578: Fix (another) memory leak in SSLSocket.getpeercer().
+
+- Issue #25530: Disable the vulnerable SSLv3 protocol by default when creating
+ ssl.SSLContext.
+
+- Issue #25569: Fix memory leak in SSLSocket.getpeercert().
+
+- Issue #25471: Sockets returned from accept() shouldn't appear to be
+ nonblocking.
+
+- Issue #25319: When threading.Event is reinitialized, the underlying condition
+ should use a regular lock rather than a recursive lock.
+
- Skip getaddrinfo if host is already resolved.
Patch by A. Jesse Jiryu Davis.
@@ -625,53 +1422,9 @@
- Issue #27041: asyncio: Add loop.create_future method
-- Issue #27223: asyncio: Fix _read_ready and _write_ready to respect
- _conn_lost.
- Patch by Łukasz Langa.
-
-- Issue #22970: asyncio: Fix inconsistency cancelling Condition.wait.
- Patch by David Coles.
-
IDLE
----
-- Issue #5124: Paste with text selected now replaces the selection on X11.
- This matches how paste works on Windows, Mac, most modern Linux apps,
- and ttk widgets. Original patch by Serhiy Storchaka.
-
-- Issue #24759: Make clear in idlelib.idle_test.__init__ that the directory
- is a private implementation of test.test_idle and tool for maintainers.
-
-- Issue #27196: Stop 'ThemeChanged' warnings when running IDLE tests.
- These persisted after other warnings were suppressed in #20567.
- Apply Serhiy Storchaka's update_idletasks solution to four test files.
- Record this additional advice in idle_test/README.txt
-
-- Issue #20567: Revise idle_test/README.txt with advice about avoiding
- tk warning messages from tests. Apply advice to several IDLE tests.
-
-- Issue #27117: Make colorizer htest and turtledemo work with dark themes.
- Move code for configuring text widget colors to a new function.
-
-- Issue #26673: When tk reports font size as 0, change to size 10.
- Such fonts on Linux prevented the configuration dialog from opening.
-
-- Issue #21939: Add test for IDLE's percolator.
- Original patch by Saimadhav Heblikar.
-
-- Issue #21676: Add test for IDLE's replace dialog.
- Original patch by Saimadhav Heblikar.
-
-- Issue #18410: Add test for IDLE's search dialog.
- Original patch by Westley Martínez.
-
-- Issue #21703: Add test for IDLE's undo delegator.
- Original patch by Saimadhav Heblikar .
-
-- Issue #27044: Add ConfigDialog.remove_var_callbacks to stop memory leaks.
-
-- Issue #23977: Add more asserts to test_delegator.
-
- Issue #20640: Add tests for idlelib.configHelpSourceEdit.
Patch by Saimadhav Heblikar.
@@ -685,11 +1438,103 @@
MARK in README.txt and open this and NEWS.txt with 'ascii'.
Re-encode CREDITS.txt to utf-8 and open it with 'utf-8'.
+- Issue #15348: Stop the debugger engine (normally in a user process)
+ before closing the debugger window (running in the IDLE process).
+ This prevents the RuntimeErrors that were being caught and ignored.
+
+- Issue #24455: Prevent IDLE from hanging when a) closing the shell while the
+ debugger is active (15347); b) closing the debugger with the [X] button
+ (15348); and c) activating the debugger when already active (24455).
+ The patch by Mark Roseman does this by making two changes.
+ 1. Suspend and resume the gui.interaction method with the tcl vwait
+ mechanism intended for this purpose (instead of root.mainloop & .quit).
+ 2. In gui.run, allow any existing interaction to terminate first.
+
+- Change 'The program' to 'Your program' in an IDLE 'kill program?' message
+ to make it clearer that the program referred to is the currently running
+ user program, not IDLE itself.
+
+- Issue #24750: Improve the appearance of the IDLE editor window status bar.
+ Patch by Mark Roseman.
+
+- Issue #25313: Change the handling of new built-in text color themes to better
+ address the compatibility problem introduced by the addition of IDLE Dark.
+ Consistently use the revised idleConf.CurrentTheme everywhere in idlelib.
+
+- Issue #24782: Extension configuration is now a tab in the IDLE Preferences
+ dialog rather than a separate dialog. The former tabs are now a sorted
+ list. Patch by Mark Roseman.
+
+- Issue #22726: Re-activate the config dialog help button with some content
+ about the other buttons and the new IDLE Dark theme.
+
+- Issue #24820: IDLE now has an 'IDLE Dark' built-in text color theme.
+ It is more or less IDLE Classic inverted, with a cobalt blue background.
+ Strings, comments, keywords, ... are still green, red, orange, ... .
+ To use it with IDLEs released before November 2015, hit the
+ 'Save as New Custom Theme' button and enter a new name,
+ such as 'Custom Dark'. The custom theme will work with any IDLE
+ release, and can be modified.
+
+- Issue #25224: README.txt is now an idlelib index for IDLE developers and
+ curious users. The previous user content is now in the IDLE doc chapter.
+ 'IDLE' now means 'Integrated Development and Learning Environment'.
+
+- Issue #24820: Users can now set breakpoint colors in
+ Settings -> Custom Highlighting. Original patch by Mark Roseman.
+
+- Issue #24972: Inactive selection background now matches active selection
+ background, as configured by users, on all systems. Found items are now
+ always highlighted on Windows. Initial patch by Mark Roseman.
+
+- Issue #24570: Idle: make calltip and completion boxes appear on Macs
+ affected by a tk regression. Initial patch by Mark Roseman.
+
+- Issue #24988: Idle ScrolledList context menus (used in debugger)
+ now work on Mac Aqua. Patch by Mark Roseman.
+
+- Issue #24801: Make right-click for context menu work on Mac Aqua.
+ Patch by Mark Roseman.
+
+- Issue #25173: Associate tkinter messageboxes with a specific widget.
+ For Mac OSX, make them a 'sheet'. Patch by Mark Roseman.
+
+- Issue #25198: Enhance the initial html viewer now used for Idle Help.
+ * Properly indent fixed-pitch text (patch by Mark Roseman).
+ * Give code snippet a very Sphinx-like light blueish-gray background.
+ * Re-use initial width and height set by users for shell and editor.
+ * When the Table of Contents (TOC) menu is used, put the section header
+ at the top of the screen.
+
+- Issue #25225: Condense and rewrite Idle doc section on text colors.
+
+- Issue #21995: Explain some differences between IDLE and console Python.
+
+- Issue #22820: Explain need for *print* when running file from Idle editor.
+
+- Issue #25224: Doc: augment Idle feature list and no-subprocess section.
+
+- Issue #25219: Update doc for Idle command line options.
+ Some were missing and notes were not correct.
+
+- Issue #24861: Most of idlelib is private and subject to change.
+ Use idleib.idle.* to start Idle. See idlelib.__init__.__doc__.
+
+- Issue #25199: Idle: add synchronization comments for future maintainers.
+
+- Issue #16893: Replace help.txt with help.html for Idle doc display.
+ The new idlelib/help.html is rstripped Doc/build/html/library/idle.html.
+ It looks better than help.txt and will better document Idle as released.
+ The tkinter html viewer that works for this file was written by Rose Roseman.
+ The now unused EditorWindow.HelpDialog class and helt.txt file are deprecated.
+
+- Issue #24199: Deprecate unused idlelib.idlever with possible removal in 3.6.
+
+- Issue #24790: Remove extraneous code (which also create 2 & 3 conflicts).
+
Documentation
-------------
-- Issue #24136: Document the new PEP 448 unpacking syntax of 3.5.
-
- Issue #26736: Used HTTPS for external links in the documentation if possible.
- Issue #6953: Rework the Readline module documentation to group related
@@ -698,8 +1543,8 @@
- Issue #23606: Adds note to ctypes documentation regarding cdll.msvcrt.
-- Issue #25500: Fix documentation to not claim that __import__ is searched for
- in the global scope.
+- Issue #24952: Clarify the default size argument of stack_size() in
+ the "threading" and "_thread" modules. Patch from Mattip.
- Issue #26014: Update 3.x packaging documentation:
* "See also" links to the new docs are now provided in the legacy pages
@@ -711,6 +1556,9 @@
- Issue #21916: Added tests for the turtle module. Patch by ingrid,
Gregory Loyse and Jelle Zijlstra.
+- Issue #26295: When using "python3 -m test --testdir=TESTDIR", regrtest
+ doesn't add "test." prefix to test module names.
+
- Issue #26523: The multiprocessing thread pool (multiprocessing.dummy.Pool)
was untested.
@@ -719,31 +1567,50 @@
- Issue #26325: Added test.support.check_no_resource_warning() to check that
no ResourceWarning is emitted.
-- Issue #25940: Changed test_ssl to use self-signed.pythontest.net. This
+- Issue #25940: Changed test_ssl to use its internal local server more. This
avoids relying on svn.python.org, which recently changed root certificate.
- Issue #25616: Tests for OrderedDict are extracted from test_collections
into separate file test_ordered_dict.
+- Issue #25449: Added tests for OrderedDict subclasses.
+
+- Issue #25188: Add -P/--pgo to test.regrtest to suppress error output when
+ running the test suite for the purposes of a PGO build. Initial patch by
+ Alecsandru Patrascu.
+
+- Issue #22806: Add ``python -m test --list-tests`` command to list tests.
+
+- Issue #18174: ``python -m test --huntrleaks ...`` now also checks for leak of
+ file descriptors. Patch written by Richard Oudkerk.
+
+- Issue #25260: Fix ``python -m test --coverage`` on Windows. Remove the
+ list of ignored directories.
+
+- ``PCbuild\rt.bat`` now accepts an unlimited number of arguments to pass along
+ to regrtest.py. Previously there was a limit of 9.
+
- Issue #26583: Skip test_timestamp_overflow in test_import if bytecode
files cannot be written.
Build
-----
+- Issue #21277: Don't try to link _ctypes with a ffi_convenience library.
+
- Issue #26884: Fix linking extension modules for cross builds.
Patch by Xavier de Gaye.
+- Issue #26932: Fixed support of RTLD_* constants defined as enum values,
+ not via macros (in particular on Android). Patch by Chi Hsuan Yen.
+
- Issue #22359: Disable the rules for running _freeze_importlib and pgen when
cross-compiling. The output of these programs is normally saved with the
source code anyway, and is still regenerated when doing a native build.
Patch by Xavier de Gaye.
-- Issue #27229: Fix the cross-compiling pgen rule for in-tree builds. Patch
- by Xavier de Gaye.
-
- Issue #21668: Link audioop, _datetime, _ctypes_test modules to libm,
- except on Mac OS X. Patch written by Xavier de Gaye.
+ except on Mac OS X. Patch written by Chi Hsuan Yen.
- Issue #25702: A --with-lto configure option has been added that will
enable link time optimizations at build time during a make profile-opt.
@@ -762,22 +1629,24 @@
- Issue #26465: Update Windows builds to use OpenSSL 1.0.2g.
-- Issue #24421: Compile Modules/_math.c once, before building extensions.
- Previously it could fail to compile properly if the math and cmath builds
- were concurrent.
-
- Issue #25348: Added ``--pgo`` and ``--pgo-job`` arguments to
``PCbuild\build.bat`` for building with Profile-Guided Optimization. The
- old ``PCbuild\build_pgo.bat`` script is now deprecated, and simply calls
- ``PCbuild\build.bat --pgo %*``.
+ old ``PCbuild\build_pgo.bat`` script is removed.
- Issue #25827: Add support for building with ICC to ``configure``, including
a new ``--with-icc`` flag.
- Issue #25696: Fix installation of Python on UNIX with make -j9.
-- Issue #26930: Update OS X 10.5+ 32-bit-only installer to build
- and link with OpenSSL 1.0.2h.
+- Issue #24986: It is now possible to build Python on Windows without errors
+ when external libraries are not available.
+
+- Issue #24421: Compile Modules/_math.c once, before building extensions.
+ Previously it could fail to compile properly if the math and cmath builds
+ were concurrent.
+
+- Issue #26465: Update OS X 10.5+ 32-bit-only installer to build
+ and link with OpenSSL 1.0.2g.
- Issue #26268: Update Windows builds to use OpenSSL 1.0.2f.
@@ -804,6 +1673,8 @@
- Issue #26065: Excludes venv from library when generating embeddable
distro.
+- Issue #25022: Removed very outdated PC/example_nt/ directory.
+
Tools/Demos
-----------
@@ -820,11 +1691,21 @@
- Issue #26316: Fix variable name typo in Argument Clinic.
-Misc
-----
+- Issue #25440: Fix output of python-config --extension-suffix.
-- Issue #17500, and https://github.com/python/pythondotorg/issues/945: Remove
- unused and outdated icons.
+- Issue #25154: The pyvenv script has been deprecated in favour of
+ `python3 -m venv`.
+
+C API
+-----
+
+- Issue #26312: SystemError is now raised in all programming bugs with using
+ PyArg_ParseTupleAndKeywords(). RuntimeError did raised before in some
+ programming bugs.
+
+- Issue #26198: ValueError is now raised instead of TypeError on buffer
+ overflow in parsing "es#" and "et#" format units. SystemError is now raised
+ instead of TypeError on programmical error in parsing format string.
What's New in Python 3.5.1 final?
@@ -1246,9 +2127,6 @@
Documentation
-------------
-- Issue #22558: Add remaining doc links to source code for Python-coded modules.
- Patch by Yoni Lavi.
-
- Issue #12067: Rewrite Comparisons section in the Expressions chapter of the
language reference. Some of the details of comparing mixed types were
incorrect or ambiguous. NotImplemented is only relevant at a lower level
@@ -1578,12 +2456,6 @@
- Issue #24631: Fixed regression in the timeit module with multiline setup.
-- Issue #18622: unittest.mock.mock_open().reset_mock would recurse infinitely.
- Patch from Nicola Palumbo and Laurent De Buyst.
-
-- Issue #23661: unittest.mock side_effects can now be exceptions again. This
- was a regression vs Python 3.4. Patch from Ignacio Rossi
-
- Issue #24608: chunk.Chunk.read() now always returns bytes, not str.
- Issue #18684: Fixed reading out of the buffer in the re module.
@@ -1594,6 +2466,9 @@
- Issue #15014: SMTP.auth() and SMTP.login() now support RFC 4954's optional
initial-response argument to the SMTP AUTH command.
+- Issue #6549: Remove hyphen from ttk.Style().element options. Only return result
+ from ttk.Style().configure if a result was generated or a query submitted.
+
- Issue #24669: Fix inspect.getsource() for 'async def' functions.
Patch by Kai Groner.
@@ -1605,7 +2480,6 @@
- Issue #24603: Update Windows builds and OS X 10.5 installer to use OpenSSL
1.0.2d.
-
What's New in Python 3.5.0 beta 3?
==================================
@@ -1766,6 +2640,9 @@
- Issue #24268: PEP 489: Multi-phase extension module initialization.
Patch by Petr Viktorin.
+- Issue #23359: Optimize set object internals by specializing the
+ hash table search into a lookup function and an insert function.
+
- Issue #23955: Add pyvenv.cfg option to suppress registry/environment
lookup for generating sys.path on Windows.
@@ -2308,8 +3185,8 @@
writer failed in BufferedRWPair.close().
- Issue #23622: Unknown escapes in regular expressions that consist of ``'\'``
- and ASCII letter now raise a deprecation warning and will be forbidden in
- Python 3.6.
+ and an ASCII letter now raise a deprecation warning and will be forbidden
+ in Python 3.6.
- Issue #23671: string.Template now allows specifying the "self" parameter as
a keyword argument. string.Formatter now allows specifying the "self" and
diff --git a/Misc/README.valgrind b/Misc/README.valgrind
index b5a9a32..908f137 100644
--- a/Misc/README.valgrind
+++ b/Misc/README.valgrind
@@ -2,6 +2,9 @@
Python. Valgrind is used periodically by Python developers to try
to ensure there are no memory leaks or invalid memory reads/writes.
+UPDATE: Python 3.6 now supports PYTHONMALLOC=malloc environment variable which
+can be used to force the usage of the malloc() allocator of the C library.
+
If you don't want to read about the details of using Valgrind, there
are still two things you must do to suppress the warnings. First,
you must use a suppressions file. One is supplied in
diff --git a/Misc/SpecialBuilds.txt b/Misc/SpecialBuilds.txt
index 3004174..4b673fd 100644
--- a/Misc/SpecialBuilds.txt
+++ b/Misc/SpecialBuilds.txt
@@ -65,9 +65,9 @@
simply by virtue of being in the list.
envvar PYTHONDUMPREFS
- If this envvar exists, Py_Finalize() arranges to print a list of all
+ If this envvar exists, Py_FinalizeEx() arranges to print a list of all
still-live heap objects. This is printed twice, in different formats,
- before and after Py_Finalize has cleaned up everything it can clean up. The
+ before and after Py_FinalizeEx has cleaned up everything it can clean up. The
first output block produces the repr() of each object so is more
informative; however, a lot of stuff destined to die is still alive then.
The second output block is much harder to work with (repr() can't be invoked
@@ -144,7 +144,7 @@
envvar PYTHONMALLOCSTATS
If this envvar exists, a report of pymalloc summary statistics is printed to
- stderr whenever a new arena is allocated, and also by Py_Finalize().
+ stderr whenever a new arena is allocated, and also by Py_FinalizeEx().
Changed in 2.5: The number of extra bytes allocated is 4*sizeof(size_t).
Before it was 16 on all boxes, reflecting that Python couldn't make use of
@@ -179,7 +179,7 @@
*/
int tp_maxalloc;
-Allocation and deallocation code keeps these counts up to date. Py_Finalize()
+Allocation and deallocation code keeps these counts up to date. Py_FinalizeEx()
displays a summary of the info returned by sys.getcounts() (see below), along
with assorted other special allocation counts (like the number of tuple
allocations satisfied by a tuple free-list, the number of 1-character strings
diff --git a/Misc/coverity_model.c b/Misc/coverity_model.c
index 493e7c1..f776d76 100644
--- a/Misc/coverity_model.c
+++ b/Misc/coverity_model.c
@@ -94,7 +94,7 @@
}
/* Parser/pgenmain.c */
-grammar *getgrammar(char *filename)
+grammar *getgrammar(const char *filename)
{
grammar *g;
__coverity_tainted_data_sink__(filename);
diff --git a/Modules/_bisectmodule.c b/Modules/_bisectmodule.c
index 02b55d1..22ddbf2 100644
--- a/Modules/_bisectmodule.c
+++ b/Modules/_bisectmodule.c
@@ -12,7 +12,8 @@
internal_bisect_right(PyObject *list, PyObject *item, Py_ssize_t lo, Py_ssize_t hi)
{
PyObject *litem;
- Py_ssize_t mid, res;
+ Py_ssize_t mid;
+ int res;
if (lo < 0) {
PyErr_SetString(PyExc_ValueError, "lo must be non-negative");
@@ -115,7 +116,8 @@
internal_bisect_left(PyObject *list, PyObject *item, Py_ssize_t lo, Py_ssize_t hi)
{
PyObject *litem;
- Py_ssize_t mid, res;
+ Py_ssize_t mid;
+ int res;
if (lo < 0) {
PyErr_SetString(PyExc_ValueError, "lo must be non-negative");
diff --git a/Modules/_bz2module.c b/Modules/_bz2module.c
index e3e0eb1..f4077fa 100644
--- a/Modules/_bz2module.c
+++ b/Modules/_bz2module.c
@@ -592,7 +592,6 @@
/*[clinic input]
_bz2.BZ2Decompressor.decompress
- self: self(type="BZ2Decompressor *")
data: Py_buffer
max_length: Py_ssize_t=-1
@@ -615,7 +614,7 @@
static PyObject *
_bz2_BZ2Decompressor_decompress_impl(BZ2Decompressor *self, Py_buffer *data,
Py_ssize_t max_length)
-/*[clinic end generated code: output=23e41045deb240a3 input=9558b424c8b00516]*/
+/*[clinic end generated code: output=23e41045deb240a3 input=52e1ffc66a8ea624]*/
{
PyObject *result = NULL;
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
index 7575773..611ca82 100644
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -20,10 +20,6 @@
<encoding>_decode(char_buffer_obj[,errors='strict']) ->
(Unicode object, bytes consumed)
- <encoding>_encode() interfaces also accept non-Unicode object as
- input. The objects are then converted to Unicode using
- PyUnicode_FromObject() prior to applying the conversion.
-
These <encoding>s are available: utf_8, unicode_escape,
raw_unicode_escape, unicode_internal, latin_1, ascii (7-bit),
mbcs (on win32).
@@ -718,7 +714,7 @@
/*[clinic input]
_codecs.utf_7_encode
- str: object
+ str: unicode
errors: str(accept={str, NoneType}) = NULL
/
[clinic start generated code]*/
@@ -726,24 +722,15 @@
static PyObject *
_codecs_utf_7_encode_impl(PyModuleDef *module, PyObject *str,
const char *errors)
-/*[clinic end generated code: output=a7accc496a32b759 input=fd91a78f103b0421]*/
+/*[clinic end generated code: output=a7accc496a32b759 input=d1a47579e79cbe15]*/
{
- PyObject *v;
-
- str = PyUnicode_FromObject(str);
- if (str == NULL || PyUnicode_READY(str) < 0) {
- Py_XDECREF(str);
- return NULL;
- }
- v = codec_tuple(_PyUnicode_EncodeUTF7(str, 0, 0, errors),
- PyUnicode_GET_LENGTH(str));
- Py_DECREF(str);
- return v;
+ return codec_tuple(_PyUnicode_EncodeUTF7(str, 0, 0, errors),
+ PyUnicode_GET_LENGTH(str));
}
/*[clinic input]
_codecs.utf_8_encode
- str: object
+ str: unicode
errors: str(accept={str, NoneType}) = NULL
/
[clinic start generated code]*/
@@ -751,19 +738,10 @@
static PyObject *
_codecs_utf_8_encode_impl(PyModuleDef *module, PyObject *str,
const char *errors)
-/*[clinic end generated code: output=ec831d80e7aedede input=2c22d40532f071f3]*/
+/*[clinic end generated code: output=ec831d80e7aedede input=42e3ba73c4392eef]*/
{
- PyObject *v;
-
- str = PyUnicode_FromObject(str);
- if (str == NULL || PyUnicode_READY(str) < 0) {
- Py_XDECREF(str);
- return NULL;
- }
- v = codec_tuple(PyUnicode_AsEncodedString(str, "utf-8", errors),
- PyUnicode_GET_LENGTH(str));
- Py_DECREF(str);
- return v;
+ return codec_tuple(_PyUnicode_AsUTF8String(str, errors),
+ PyUnicode_GET_LENGTH(str));
}
/* This version provides access to the byteorder parameter of the
@@ -775,7 +753,7 @@
/*[clinic input]
_codecs.utf_16_encode
- str: object
+ str: unicode
errors: str(accept={str, NoneType}) = NULL
byteorder: int = 0
/
@@ -784,24 +762,15 @@
static PyObject *
_codecs_utf_16_encode_impl(PyModuleDef *module, PyObject *str,
const char *errors, int byteorder)
-/*[clinic end generated code: output=93ac58e960a9ee4d input=3935a489b2d5385e]*/
+/*[clinic end generated code: output=93ac58e960a9ee4d input=ff46416b04edb944]*/
{
- PyObject *v;
-
- str = PyUnicode_FromObject(str);
- if (str == NULL || PyUnicode_READY(str) < 0) {
- Py_XDECREF(str);
- return NULL;
- }
- v = codec_tuple(_PyUnicode_EncodeUTF16(str, errors, byteorder),
- PyUnicode_GET_LENGTH(str));
- Py_DECREF(str);
- return v;
+ return codec_tuple(_PyUnicode_EncodeUTF16(str, errors, byteorder),
+ PyUnicode_GET_LENGTH(str));
}
/*[clinic input]
_codecs.utf_16_le_encode
- str: object
+ str: unicode
errors: str(accept={str, NoneType}) = NULL
/
[clinic start generated code]*/
@@ -809,24 +778,15 @@
static PyObject *
_codecs_utf_16_le_encode_impl(PyModuleDef *module, PyObject *str,
const char *errors)
-/*[clinic end generated code: output=422bedb8da34fb66 input=bc27df05d1d20dfe]*/
+/*[clinic end generated code: output=422bedb8da34fb66 input=cb385455ea8f2fe0]*/
{
- PyObject *v;
-
- str = PyUnicode_FromObject(str);
- if (str == NULL || PyUnicode_READY(str) < 0) {
- Py_XDECREF(str);
- return NULL;
- }
- v = codec_tuple(_PyUnicode_EncodeUTF16(str, errors, -1),
- PyUnicode_GET_LENGTH(str));
- Py_DECREF(str);
- return v;
+ return codec_tuple(_PyUnicode_EncodeUTF16(str, errors, -1),
+ PyUnicode_GET_LENGTH(str));
}
/*[clinic input]
_codecs.utf_16_be_encode
- str: object
+ str: unicode
errors: str(accept={str, NoneType}) = NULL
/
[clinic start generated code]*/
@@ -834,19 +794,10 @@
static PyObject *
_codecs_utf_16_be_encode_impl(PyModuleDef *module, PyObject *str,
const char *errors)
-/*[clinic end generated code: output=3aa7ee9502acdd77 input=5a69d4112763462b]*/
+/*[clinic end generated code: output=3aa7ee9502acdd77 input=9119997066bdaefd]*/
{
- PyObject *v;
-
- str = PyUnicode_FromObject(str);
- if (str == NULL || PyUnicode_READY(str) < 0) {
- Py_XDECREF(str);
- return NULL;
- }
- v = codec_tuple(_PyUnicode_EncodeUTF16(str, errors, +1),
- PyUnicode_GET_LENGTH(str));
- Py_DECREF(str);
- return v;
+ return codec_tuple(_PyUnicode_EncodeUTF16(str, errors, +1),
+ PyUnicode_GET_LENGTH(str));
}
/* This version provides access to the byteorder parameter of the
@@ -858,7 +809,7 @@
/*[clinic input]
_codecs.utf_32_encode
- str: object
+ str: unicode
errors: str(accept={str, NoneType}) = NULL
byteorder: int = 0
/
@@ -867,24 +818,15 @@
static PyObject *
_codecs_utf_32_encode_impl(PyModuleDef *module, PyObject *str,
const char *errors, int byteorder)
-/*[clinic end generated code: output=3e7d5a003b02baed input=434a1efa492b8d58]*/
+/*[clinic end generated code: output=3e7d5a003b02baed input=c5e77da82fbe5c2a]*/
{
- PyObject *v;
-
- str = PyUnicode_FromObject(str);
- if (str == NULL || PyUnicode_READY(str) < 0) {
- Py_XDECREF(str);
- return NULL;
- }
- v = codec_tuple(_PyUnicode_EncodeUTF32(str, errors, byteorder),
- PyUnicode_GET_LENGTH(str));
- Py_DECREF(str);
- return v;
+ return codec_tuple(_PyUnicode_EncodeUTF32(str, errors, byteorder),
+ PyUnicode_GET_LENGTH(str));
}
/*[clinic input]
_codecs.utf_32_le_encode
- str: object
+ str: unicode
errors: str(accept={str, NoneType}) = NULL
/
[clinic start generated code]*/
@@ -892,24 +834,15 @@
static PyObject *
_codecs_utf_32_le_encode_impl(PyModuleDef *module, PyObject *str,
const char *errors)
-/*[clinic end generated code: output=5dda641cd33dbfc2 input=dfa2d7dc78b99422]*/
+/*[clinic end generated code: output=5dda641cd33dbfc2 input=9993b25fe0877848]*/
{
- PyObject *v;
-
- str = PyUnicode_FromObject(str);
- if (str == NULL || PyUnicode_READY(str) < 0) {
- Py_XDECREF(str);
- return NULL;
- }
- v = codec_tuple(_PyUnicode_EncodeUTF32(str, errors, -1),
- PyUnicode_GET_LENGTH(str));
- Py_DECREF(str);
- return v;
+ return codec_tuple(_PyUnicode_EncodeUTF32(str, errors, -1),
+ PyUnicode_GET_LENGTH(str));
}
/*[clinic input]
_codecs.utf_32_be_encode
- str: object
+ str: unicode
errors: str(accept={str, NoneType}) = NULL
/
[clinic start generated code]*/
@@ -917,24 +850,15 @@
static PyObject *
_codecs_utf_32_be_encode_impl(PyModuleDef *module, PyObject *str,
const char *errors)
-/*[clinic end generated code: output=ccca8b44d91a7c7a input=4595617b18169002]*/
+/*[clinic end generated code: output=ccca8b44d91a7c7a input=d3e0ccaa02920431]*/
{
- PyObject *v;
-
- str = PyUnicode_FromObject(str);
- if (str == NULL || PyUnicode_READY(str) < 0) {
- Py_XDECREF(str);
- return NULL;
- }
- v = codec_tuple(_PyUnicode_EncodeUTF32(str, errors, +1),
- PyUnicode_GET_LENGTH(str));
- Py_DECREF(str);
- return v;
+ return codec_tuple(_PyUnicode_EncodeUTF32(str, errors, +1),
+ PyUnicode_GET_LENGTH(str));
}
/*[clinic input]
_codecs.unicode_escape_encode
- str: object
+ str: unicode
errors: str(accept={str, NoneType}) = NULL
/
[clinic start generated code]*/
@@ -942,24 +866,15 @@
static PyObject *
_codecs_unicode_escape_encode_impl(PyModuleDef *module, PyObject *str,
const char *errors)
-/*[clinic end generated code: output=389f23d2b8f8d80b input=8273506f14076912]*/
+/*[clinic end generated code: output=389f23d2b8f8d80b input=65d9eefca65b455a]*/
{
- PyObject *v;
-
- str = PyUnicode_FromObject(str);
- if (str == NULL || PyUnicode_READY(str) < 0) {
- Py_XDECREF(str);
- return NULL;
- }
- v = codec_tuple(PyUnicode_AsUnicodeEscapeString(str),
- PyUnicode_GET_LENGTH(str));
- Py_DECREF(str);
- return v;
+ return codec_tuple(PyUnicode_AsUnicodeEscapeString(str),
+ PyUnicode_GET_LENGTH(str));
}
/*[clinic input]
_codecs.raw_unicode_escape_encode
- str: object
+ str: unicode
errors: str(accept={str, NoneType}) = NULL
/
[clinic start generated code]*/
@@ -967,24 +882,15 @@
static PyObject *
_codecs_raw_unicode_escape_encode_impl(PyModuleDef *module, PyObject *str,
const char *errors)
-/*[clinic end generated code: output=fec4e39d6ec37a62 input=181755d5dfacef3c]*/
+/*[clinic end generated code: output=fec4e39d6ec37a62 input=5aa33e4a133391ab]*/
{
- PyObject *v;
-
- str = PyUnicode_FromObject(str);
- if (str == NULL || PyUnicode_READY(str) < 0) {
- Py_XDECREF(str);
- return NULL;
- }
- v = codec_tuple(PyUnicode_AsRawUnicodeEscapeString(str),
- PyUnicode_GET_LENGTH(str));
- Py_DECREF(str);
- return v;
+ return codec_tuple(PyUnicode_AsRawUnicodeEscapeString(str),
+ PyUnicode_GET_LENGTH(str));
}
/*[clinic input]
_codecs.latin_1_encode
- str: object
+ str: unicode
errors: str(accept={str, NoneType}) = NULL
/
[clinic start generated code]*/
@@ -992,24 +898,15 @@
static PyObject *
_codecs_latin_1_encode_impl(PyModuleDef *module, PyObject *str,
const char *errors)
-/*[clinic end generated code: output=ecf00eb8e48c889c input=f03f6dcf1d84bee4]*/
+/*[clinic end generated code: output=ecf00eb8e48c889c input=30b11c9e49a65150]*/
{
- PyObject *v;
-
- str = PyUnicode_FromObject(str);
- if (str == NULL || PyUnicode_READY(str) < 0) {
- Py_XDECREF(str);
- return NULL;
- }
- v = codec_tuple(_PyUnicode_AsLatin1String(str, errors),
- PyUnicode_GET_LENGTH(str));
- Py_DECREF(str);
- return v;
+ return codec_tuple(_PyUnicode_AsLatin1String(str, errors),
+ PyUnicode_GET_LENGTH(str));
}
/*[clinic input]
_codecs.ascii_encode
- str: object
+ str: unicode
errors: str(accept={str, NoneType}) = NULL
/
[clinic start generated code]*/
@@ -1017,24 +914,15 @@
static PyObject *
_codecs_ascii_encode_impl(PyModuleDef *module, PyObject *str,
const char *errors)
-/*[clinic end generated code: output=a9d18fc6b6b91cfb input=d87e25a10a593fee]*/
+/*[clinic end generated code: output=a9d18fc6b6b91cfb input=843a1d268e6dfa8e]*/
{
- PyObject *v;
-
- str = PyUnicode_FromObject(str);
- if (str == NULL || PyUnicode_READY(str) < 0) {
- Py_XDECREF(str);
- return NULL;
- }
- v = codec_tuple(_PyUnicode_AsASCIIString(str, errors),
- PyUnicode_GET_LENGTH(str));
- Py_DECREF(str);
- return v;
+ return codec_tuple(_PyUnicode_AsASCIIString(str, errors),
+ PyUnicode_GET_LENGTH(str));
}
/*[clinic input]
_codecs.charmap_encode
- str: object
+ str: unicode
errors: str(accept={str, NoneType}) = NULL
mapping: object = NULL
/
@@ -1043,22 +931,13 @@
static PyObject *
_codecs_charmap_encode_impl(PyModuleDef *module, PyObject *str,
const char *errors, PyObject *mapping)
-/*[clinic end generated code: output=14ca42b83853c643 input=85f4172661e8dad9]*/
+/*[clinic end generated code: output=14ca42b83853c643 input=0752cde07a6d6d00]*/
{
- PyObject *v;
-
if (mapping == Py_None)
mapping = NULL;
- str = PyUnicode_FromObject(str);
- if (str == NULL || PyUnicode_READY(str) < 0) {
- Py_XDECREF(str);
- return NULL;
- }
- v = codec_tuple(_PyUnicode_EncodeCharmap(str, mapping, errors),
- PyUnicode_GET_LENGTH(str));
- Py_DECREF(str);
- return v;
+ return codec_tuple(_PyUnicode_EncodeCharmap(str, mapping, errors),
+ PyUnicode_GET_LENGTH(str));
}
/*[clinic input]
@@ -1078,7 +957,7 @@
/*[clinic input]
_codecs.mbcs_encode
- str: object
+ str: unicode
errors: str(accept={str, NoneType}) = NULL
/
[clinic start generated code]*/
@@ -1086,25 +965,16 @@
static PyObject *
_codecs_mbcs_encode_impl(PyModuleDef *module, PyObject *str,
const char *errors)
-/*[clinic end generated code: output=d1a013bc68798bd7 input=65c09ee1e4203263]*/
+/*[clinic end generated code: output=d1a013bc68798bd7 input=de471e0815947553]*/
{
- PyObject *v;
-
- str = PyUnicode_FromObject(str);
- if (str == NULL || PyUnicode_READY(str) < 0) {
- Py_XDECREF(str);
- return NULL;
- }
- v = codec_tuple(PyUnicode_EncodeCodePage(CP_ACP, str, errors),
- PyUnicode_GET_LENGTH(str));
- Py_DECREF(str);
- return v;
+ return codec_tuple(PyUnicode_EncodeCodePage(CP_ACP, str, errors),
+ PyUnicode_GET_LENGTH(str));
}
/*[clinic input]
_codecs.code_page_encode
code_page: int
- str: object
+ str: unicode
errors: str(accept={str, NoneType}) = NULL
/
[clinic start generated code]*/
@@ -1112,21 +982,10 @@
static PyObject *
_codecs_code_page_encode_impl(PyModuleDef *module, int code_page,
PyObject *str, const char *errors)
-/*[clinic end generated code: output=3b406618dbfbce25 input=c8562ec460c2e309]*/
+/*[clinic end generated code: output=3b406618dbfbce25 input=786421ae617d680b]*/
{
- PyObject *v;
-
- str = PyUnicode_FromObject(str);
- if (str == NULL || PyUnicode_READY(str) < 0) {
- Py_XDECREF(str);
- return NULL;
- }
- v = codec_tuple(PyUnicode_EncodeCodePage(code_page,
- str,
- errors),
- PyUnicode_GET_LENGTH(str));
- Py_DECREF(str);
- return v;
+ return codec_tuple(PyUnicode_EncodeCodePage(code_page, str, errors),
+ PyUnicode_GET_LENGTH(str));
}
#endif /* HAVE_MBCS */
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index 10fbcfe..3410dfe 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -81,7 +81,7 @@
Py_ssize_t leftindex; /* 0 <= leftindex < BLOCKLEN */
Py_ssize_t rightindex; /* 0 <= rightindex < BLOCKLEN */
size_t state; /* incremented whenever the indices move */
- Py_ssize_t maxlen;
+ Py_ssize_t maxlen; /* maxlen is -1 for unbounded deques */
PyObject *weakreflist;
} dequeobject;
@@ -108,29 +108,18 @@
#define CHECK_NOT_END(link)
#endif
-/* To prevent len from overflowing PY_SSIZE_T_MAX, we refuse to
- allocate new blocks if the current len is nearing overflow.
-*/
-
-#define MAX_DEQUE_LEN (PY_SSIZE_T_MAX - 3*BLOCKLEN)
-
/* A simple freelisting scheme is used to minimize calls to the memory
allocator. It accommodates common use cases where new blocks are being
added at about the same rate as old blocks are being freed.
*/
-#define MAXFREEBLOCKS 10
+#define MAXFREEBLOCKS 16
static Py_ssize_t numfreeblocks = 0;
static block *freeblocks[MAXFREEBLOCKS];
static block *
-newblock(Py_ssize_t len) {
+newblock(void) {
block *b;
- if (len >= MAX_DEQUE_LEN) {
- PyErr_SetString(PyExc_OverflowError,
- "cannot add more blocks to the deque");
- return NULL;
- }
if (numfreeblocks) {
numfreeblocks--;
return freeblocks[numfreeblocks];
@@ -154,12 +143,6 @@
}
}
-/* 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)
{
@@ -171,7 +154,7 @@
if (deque == NULL)
return NULL;
- b = newblock(0);
+ b = newblock();
if (b == NULL) {
Py_DECREF(deque);
return NULL;
@@ -207,7 +190,7 @@
Py_SIZE(deque)--;
deque->state++;
- if (deque->rightindex == -1) {
+ if (deque->rightindex < 0) {
if (Py_SIZE(deque)) {
prevblock = deque->rightblock->leftlink;
assert(deque->leftblock != deque->rightblock);
@@ -270,42 +253,24 @@
/* The deque's size limit is d.maxlen. The limit can be zero or positive.
* If there is no limit, then d.maxlen == -1.
*
- * After an item is added to a deque, we check to see if the size has grown past
- * the limit. If it has, we get the size back down to the limit by popping an
- * item off of the opposite end. The methods that can trigger this are append(),
- * appendleft(), extend(), and extendleft().
+ * After an item is added to a deque, we check to see if the size has
+ * grown past the limit. If it has, we get the size back down to the limit
+ * by popping an item off of the opposite end. The methods that can
+ * trigger this are append(), appendleft(), extend(), and extendleft().
+ *
+ * The macro to check whether a deque needs to be trimmed uses a single
+ * unsigned test that returns true whenever 0 <= maxlen < Py_SIZE(deque).
*/
-static void
-deque_trim_right(dequeobject *deque)
-{
- if (deque->maxlen != -1 && Py_SIZE(deque) > deque->maxlen) {
- PyObject *rv = deque_pop(deque, NULL);
- assert(rv != NULL);
- assert(Py_SIZE(deque) <= deque->maxlen);
- Py_DECREF(rv);
- }
-}
+#define NEEDS_TRIM(deque, maxlen) ((size_t)(maxlen) < (size_t)(Py_SIZE(deque)))
-static void
-deque_trim_left(dequeobject *deque)
+static int
+deque_append_internal(dequeobject *deque, PyObject *item, Py_ssize_t maxlen)
{
- if (deque->maxlen != -1 && Py_SIZE(deque) > deque->maxlen) {
- PyObject *rv = deque_popleft(deque, NULL);
- assert(rv != NULL);
- assert(Py_SIZE(deque) <= deque->maxlen);
- Py_DECREF(rv);
- }
-}
-
-static PyObject *
-deque_append(dequeobject *deque, PyObject *item)
-{
- deque->state++;
if (deque->rightindex == BLOCKLEN - 1) {
- block *b = newblock(Py_SIZE(deque));
+ block *b = newblock();
if (b == NULL)
- return NULL;
+ return -1;
b->leftlink = deque->rightblock;
CHECK_END(deque->rightblock->rightlink);
deque->rightblock->rightlink = b;
@@ -313,24 +278,36 @@
MARK_END(b->rightlink);
deque->rightindex = -1;
}
- Py_INCREF(item);
Py_SIZE(deque)++;
deque->rightindex++;
deque->rightblock->data[deque->rightindex] = item;
- deque_trim_left(deque);
+ if (NEEDS_TRIM(deque, maxlen)) {
+ PyObject *olditem = deque_popleft(deque, NULL);
+ Py_DECREF(olditem);
+ } else {
+ deque->state++;
+ }
+ return 0;
+}
+
+static PyObject *
+deque_append(dequeobject *deque, PyObject *item)
+{
+ Py_INCREF(item);
+ if (deque_append_internal(deque, item, deque->maxlen) < 0)
+ return NULL;
Py_RETURN_NONE;
}
PyDoc_STRVAR(append_doc, "Add an element to the right side of the deque.");
-static PyObject *
-deque_appendleft(dequeobject *deque, PyObject *item)
+static int
+deque_appendleft_internal(dequeobject *deque, PyObject *item, Py_ssize_t maxlen)
{
- deque->state++;
if (deque->leftindex == 0) {
- block *b = newblock(Py_SIZE(deque));
+ block *b = newblock();
if (b == NULL)
- return NULL;
+ return -1;
b->rightlink = deque->leftblock;
CHECK_END(deque->leftblock->leftlink);
deque->leftblock->leftlink = b;
@@ -338,37 +315,65 @@
MARK_END(b->leftlink);
deque->leftindex = BLOCKLEN;
}
- Py_INCREF(item);
Py_SIZE(deque)++;
deque->leftindex--;
deque->leftblock->data[deque->leftindex] = item;
- deque_trim_right(deque);
+ if (NEEDS_TRIM(deque, deque->maxlen)) {
+ PyObject *olditem = deque_pop(deque, NULL);
+ Py_DECREF(olditem);
+ } else {
+ deque->state++;
+ }
+ return 0;
+}
+
+static PyObject *
+deque_appendleft(dequeobject *deque, PyObject *item)
+{
+ Py_INCREF(item);
+ if (deque_appendleft_internal(deque, item, deque->maxlen) < 0)
+ return NULL;
Py_RETURN_NONE;
}
PyDoc_STRVAR(appendleft_doc, "Add an element to the left side of the deque.");
+static PyObject*
+finalize_iterator(PyObject *it)
+{
+ if (PyErr_Occurred()) {
+ if (PyErr_ExceptionMatches(PyExc_StopIteration))
+ PyErr_Clear();
+ else {
+ Py_DECREF(it);
+ return NULL;
+ }
+ }
+ Py_DECREF(it);
+ Py_RETURN_NONE;
+}
/* Run an iterator to exhaustion. Shortcut for
the extend/extendleft methods when maxlen == 0. */
static PyObject*
consume_iterator(PyObject *it)
{
+ PyObject *(*iternext)(PyObject *);
PyObject *item;
- while ((item = PyIter_Next(it)) != NULL) {
+ iternext = *Py_TYPE(it)->tp_iternext;
+ while ((item = iternext(it)) != NULL) {
Py_DECREF(item);
}
- Py_DECREF(it);
- if (PyErr_Occurred())
- return NULL;
- Py_RETURN_NONE;
+ return finalize_iterator(it);
}
static PyObject *
deque_extend(dequeobject *deque, PyObject *iterable)
{
PyObject *it, *item;
+ PyObject *(*iternext)(PyObject *);
+ Py_ssize_t maxlen = deque->maxlen;
/* Handle case where id(deque) == id(iterable) */
if ((PyObject *)deque == iterable) {
@@ -381,6 +386,13 @@
return result;
}
+ it = PyObject_GetIter(iterable);
+ if (it == NULL)
+ return NULL;
+
+ if (maxlen == 0)
+ return consume_iterator(it);
+
/* Space saving heuristic. Start filling from the left */
if (Py_SIZE(deque) == 0) {
assert(deque->leftblock == deque->rightblock);
@@ -389,40 +401,15 @@
deque->rightindex = 0;
}
- it = PyObject_GetIter(iterable);
- if (it == NULL)
- return NULL;
-
- if (deque->maxlen == 0)
- return consume_iterator(it);
-
- while ((item = PyIter_Next(it)) != NULL) {
- deque->state++;
- if (deque->rightindex == BLOCKLEN - 1) {
- block *b = newblock(Py_SIZE(deque));
- if (b == NULL) {
- Py_DECREF(item);
- Py_DECREF(it);
- return NULL;
- }
- b->leftlink = deque->rightblock;
- CHECK_END(deque->rightblock->rightlink);
- deque->rightblock->rightlink = b;
- deque->rightblock = b;
- MARK_END(b->rightlink);
- deque->rightindex = -1;
+ iternext = *Py_TYPE(it)->tp_iternext;
+ while ((item = iternext(it)) != NULL) {
+ if (deque_append_internal(deque, item, maxlen) < 0) {
+ Py_DECREF(item);
+ Py_DECREF(it);
+ return NULL;
}
- Py_SIZE(deque)++;
- deque->rightindex++;
- deque->rightblock->data[deque->rightindex] = item;
- deque_trim_left(deque);
}
- if (PyErr_Occurred()) {
- Py_DECREF(it);
- return NULL;
- }
- Py_DECREF(it);
- Py_RETURN_NONE;
+ return finalize_iterator(it);
}
PyDoc_STRVAR(extend_doc,
@@ -432,6 +419,8 @@
deque_extendleft(dequeobject *deque, PyObject *iterable)
{
PyObject *it, *item;
+ PyObject *(*iternext)(PyObject *);
+ Py_ssize_t maxlen = deque->maxlen;
/* Handle case where id(deque) == id(iterable) */
if ((PyObject *)deque == iterable) {
@@ -444,6 +433,13 @@
return result;
}
+ it = PyObject_GetIter(iterable);
+ if (it == NULL)
+ return NULL;
+
+ if (maxlen == 0)
+ return consume_iterator(it);
+
/* Space saving heuristic. Start filling from the right */
if (Py_SIZE(deque) == 0) {
assert(deque->leftblock == deque->rightblock);
@@ -452,40 +448,15 @@
deque->rightindex = BLOCKLEN - 2;
}
- it = PyObject_GetIter(iterable);
- if (it == NULL)
- return NULL;
-
- if (deque->maxlen == 0)
- return consume_iterator(it);
-
- while ((item = PyIter_Next(it)) != NULL) {
- deque->state++;
- if (deque->leftindex == 0) {
- block *b = newblock(Py_SIZE(deque));
- if (b == NULL) {
- Py_DECREF(item);
- Py_DECREF(it);
- return NULL;
- }
- b->rightlink = deque->leftblock;
- CHECK_END(deque->leftblock->leftlink);
- deque->leftblock->leftlink = b;
- deque->leftblock = b;
- MARK_END(b->leftlink);
- deque->leftindex = BLOCKLEN;
+ iternext = *Py_TYPE(it)->tp_iternext;
+ while ((item = iternext(it)) != NULL) {
+ if (deque_appendleft_internal(deque, item, maxlen) < 0) {
+ Py_DECREF(item);
+ Py_DECREF(it);
+ return NULL;
}
- Py_SIZE(deque)++;
- deque->leftindex--;
- deque->leftblock->data[deque->leftindex] = item;
- deque_trim_right(deque);
}
- if (PyErr_Occurred()) {
- Py_DECREF(it);
- return NULL;
- }
- Py_DECREF(it);
- Py_RETURN_NONE;
+ return finalize_iterator(it);
}
PyDoc_STRVAR(extendleft_doc,
@@ -504,7 +475,40 @@
return (PyObject *)deque;
}
-static PyObject *deque_copy(PyObject *deque);
+static PyObject *
+deque_copy(PyObject *deque)
+{
+ dequeobject *old_deque = (dequeobject *)deque;
+ if (Py_TYPE(deque) == &deque_type) {
+ dequeobject *new_deque;
+ PyObject *rv;
+
+ new_deque = (dequeobject *)deque_new(&deque_type, (PyObject *)NULL, (PyObject *)NULL);
+ if (new_deque == NULL)
+ return NULL;
+ new_deque->maxlen = old_deque->maxlen;
+ /* Fast path for the deque_repeat() common case where len(deque) == 1 */
+ if (Py_SIZE(deque) == 1) {
+ PyObject *item = old_deque->leftblock->data[old_deque->leftindex];
+ rv = deque_append(new_deque, item);
+ } else {
+ rv = deque_extend(new_deque, deque);
+ }
+ if (rv != NULL) {
+ Py_DECREF(rv);
+ return (PyObject *)new_deque;
+ }
+ Py_DECREF(new_deque);
+ return NULL;
+ }
+ if (old_deque->maxlen < 0)
+ return PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "O", deque, NULL);
+ else
+ return PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "Oi",
+ deque, old_deque->maxlen, NULL);
+}
+
+PyDoc_STRVAR(copy_doc, "Return a shallow copy of a deque.");
static PyObject *
deque_concat(dequeobject *deque, PyObject *other)
@@ -534,38 +538,102 @@
return new_deque;
}
-static void deque_clear(dequeobject *deque);
+static void
+deque_clear(dequeobject *deque)
+{
+ block *b;
+ block *prevblock;
+ block *leftblock;
+ Py_ssize_t leftindex;
+ Py_ssize_t n, m;
+ PyObject *item;
+ PyObject **itemptr, **limit;
+
+ if (Py_SIZE(deque) == 0)
+ return;
+
+ /* During the process of clearing a deque, decrefs can cause the
+ deque to mutate. To avoid fatal confusion, we have to make the
+ deque empty before clearing the blocks and never refer to
+ anything via deque->ref while clearing. (This is the same
+ technique used for clearing lists, sets, and dicts.)
+
+ Making the deque empty requires allocating a new empty block. In
+ the unlikely event that memory is full, we fall back to an
+ alternate method that doesn't require a new block. Repeating
+ pops in a while-loop is slower, possibly re-entrant (and a clever
+ adversary could cause it to never terminate).
+ */
+
+ b = newblock();
+ if (b == NULL) {
+ PyErr_Clear();
+ goto alternate_method;
+ }
+
+ /* Remember the old size, leftblock, and leftindex */
+ n = Py_SIZE(deque);
+ leftblock = deque->leftblock;
+ leftindex = deque->leftindex;
+
+ /* Set the deque to be empty using the newly allocated block */
+ MARK_END(b->leftlink);
+ MARK_END(b->rightlink);
+ Py_SIZE(deque) = 0;
+ deque->leftblock = b;
+ deque->rightblock = b;
+ deque->leftindex = CENTER + 1;
+ deque->rightindex = CENTER;
+ deque->state++;
+
+ /* Now the old size, leftblock, and leftindex are disconnected from
+ the empty deque and we can use them to decref the pointers.
+ */
+ m = (BLOCKLEN - leftindex > n) ? n : BLOCKLEN - leftindex;
+ itemptr = &leftblock->data[leftindex];
+ limit = itemptr + m;
+ n -= m;
+ while (1) {
+ if (itemptr == limit) {
+ if (n == 0)
+ break;
+ CHECK_NOT_END(leftblock->rightlink);
+ prevblock = leftblock;
+ leftblock = leftblock->rightlink;
+ m = (n > BLOCKLEN) ? BLOCKLEN : n;
+ itemptr = leftblock->data;
+ limit = itemptr + m;
+ n -= m;
+ freeblock(prevblock);
+ }
+ item = *(itemptr++);
+ Py_DECREF(item);
+ }
+ CHECK_END(leftblock->rightlink);
+ freeblock(leftblock);
+ return;
+
+ alternate_method:
+ while (Py_SIZE(deque)) {
+ item = deque_pop(deque, NULL);
+ assert (item != NULL);
+ Py_DECREF(item);
+ }
+}
static PyObject *
-deque_repeat(dequeobject *deque, Py_ssize_t n)
+deque_clearmethod(dequeobject *deque)
{
- dequeobject *new_deque;
- PyObject *result;
-
- /* XXX add a special case for when maxlen is defined */
- if (n < 0)
- n = 0;
- else if (n > 0 && Py_SIZE(deque) > MAX_DEQUE_LEN / n)
- return PyErr_NoMemory();
-
- new_deque = (dequeobject *)deque_new(&deque_type, (PyObject *)NULL, (PyObject *)NULL);
- new_deque->maxlen = deque->maxlen;
-
- for ( ; n ; n--) {
- result = deque_extend(new_deque, (PyObject *)deque);
- if (result == NULL) {
- Py_DECREF(new_deque);
- return NULL;
- }
- Py_DECREF(result);
- }
- return (PyObject *)new_deque;
+ deque_clear(deque);
+ Py_RETURN_NONE;
}
+PyDoc_STRVAR(clear_doc, "Remove all elements from the deque.");
+
static PyObject *
deque_inplace_repeat(dequeobject *deque, Py_ssize_t n)
{
- Py_ssize_t i, size;
+ Py_ssize_t i, m, size;
PyObject *seq;
PyObject *rv;
@@ -581,27 +649,47 @@
return (PyObject *)deque;
}
- if (size > MAX_DEQUE_LEN / n) {
- return PyErr_NoMemory();
- }
-
if (size == 1) {
/* common case, repeating a single element */
PyObject *item = deque->leftblock->data[deque->leftindex];
- if (deque->maxlen != -1 && n > deque->maxlen)
+ if (deque->maxlen >= 0 && n > deque->maxlen)
n = deque->maxlen;
- for (i = 0 ; i < n-1 ; i++) {
- rv = deque_append(deque, item);
- if (rv == NULL)
- return NULL;
- Py_DECREF(rv);
+ deque->state++;
+ for (i = 0 ; i < n-1 ; ) {
+ if (deque->rightindex == BLOCKLEN - 1) {
+ block *b = newblock();
+ if (b == NULL) {
+ Py_SIZE(deque) += i;
+ return NULL;
+ }
+ b->leftlink = deque->rightblock;
+ CHECK_END(deque->rightblock->rightlink);
+ deque->rightblock->rightlink = b;
+ deque->rightblock = b;
+ MARK_END(b->rightlink);
+ deque->rightindex = -1;
+ }
+ m = n - 1 - i;
+ if (m > BLOCKLEN - 1 - deque->rightindex)
+ m = BLOCKLEN - 1 - deque->rightindex;
+ i += m;
+ while (m--) {
+ deque->rightindex++;
+ Py_INCREF(item);
+ deque->rightblock->data[deque->rightindex] = item;
+ }
}
+ Py_SIZE(deque) += i;
Py_INCREF(deque);
return (PyObject *)deque;
}
+ if ((size_t)size > PY_SSIZE_T_MAX / (size_t)n) {
+ return PyErr_NoMemory();
+ }
+
seq = PySequence_List((PyObject *)deque);
if (seq == NULL)
return seq;
@@ -619,6 +707,20 @@
return (PyObject *)deque;
}
+static PyObject *
+deque_repeat(dequeobject *deque, Py_ssize_t n)
+{
+ dequeobject *new_deque;
+ PyObject *rv;
+
+ new_deque = (dequeobject *)deque_copy((PyObject *) deque);
+ if (new_deque == NULL)
+ return NULL;
+ rv = deque_inplace_repeat(new_deque, n);
+ Py_DECREF(new_deque);
+ return rv;
+}
+
/* The rotate() method is part of the public API and is used internally
as a primitive for other methods.
@@ -671,7 +773,7 @@
while (n > 0) {
if (leftindex == 0) {
if (b == NULL) {
- b = newblock(len);
+ b = newblock();
if (b == NULL)
goto done;
}
@@ -702,7 +804,7 @@
*(dest++) = *(src++);
} while (--m);
}
- if (rightindex == -1) {
+ if (rightindex < 0) {
assert(leftblock != rightblock);
assert(b == NULL);
b = rightblock;
@@ -715,7 +817,7 @@
while (n < 0) {
if (rightindex == BLOCKLEN - 1) {
if (b == NULL) {
- b = newblock(len);
+ b = newblock();
if (b == NULL)
goto done;
}
@@ -790,11 +892,11 @@
block *rightblock = deque->rightblock;
Py_ssize_t leftindex = deque->leftindex;
Py_ssize_t rightindex = deque->rightindex;
- Py_ssize_t n = Py_SIZE(deque) / 2;
- Py_ssize_t i;
+ Py_ssize_t n = Py_SIZE(deque) >> 1;
PyObject *tmp;
- for (i=0 ; i<n ; i++) {
+ n++;
+ while (--n) {
/* Validate that pointers haven't met in the middle */
assert(leftblock != rightblock || leftindex < rightindex);
CHECK_NOT_END(leftblock);
@@ -814,7 +916,7 @@
/* Step backwards with the right block/index pair */
rightindex--;
- if (rightindex == -1) {
+ if (rightindex < 0) {
rightblock = rightblock->leftlink;
rightindex = BLOCKLEN - 1;
}
@@ -831,20 +933,19 @@
block *b = deque->leftblock;
Py_ssize_t index = deque->leftindex;
Py_ssize_t n = Py_SIZE(deque);
- Py_ssize_t i;
Py_ssize_t count = 0;
size_t start_state = deque->state;
PyObject *item;
int cmp;
- for (i=0 ; i<n ; i++) {
+ n++;
+ while (--n) {
CHECK_NOT_END(b);
item = b->data[index];
cmp = PyObject_RichCompareBool(item, v, Py_EQ);
- if (cmp > 0)
- count++;
- else if (cmp < 0)
+ if (cmp < 0)
return NULL;
+ count += cmp;
if (start_state != deque->state) {
PyErr_SetString(PyExc_RuntimeError,
@@ -871,12 +972,12 @@
block *b = deque->leftblock;
Py_ssize_t index = deque->leftindex;
Py_ssize_t n = Py_SIZE(deque);
- Py_ssize_t i;
size_t start_state = deque->state;
PyObject *item;
int cmp;
- for (i=0 ; i<n ; i++) {
+ n++;
+ while (--n) {
CHECK_NOT_END(b);
item = b->data[index];
cmp = PyObject_RichCompareBool(item, v, Py_EQ);
@@ -906,11 +1007,12 @@
static PyObject *
deque_index(dequeobject *deque, PyObject *args)
{
- Py_ssize_t i, start=0, stop=Py_SIZE(deque);
+ Py_ssize_t i, n, start=0, stop=Py_SIZE(deque);
PyObject *v, *item;
block *b = deque->leftblock;
Py_ssize_t index = deque->leftindex;
size_t start_state = deque->state;
+ int cmp;
if (!PyArg_ParseTuple(args, "O|O&O&:index", &v,
_PyEval_SliceIndex, &start,
@@ -928,22 +1030,32 @@
}
if (stop > Py_SIZE(deque))
stop = Py_SIZE(deque);
+ if (start > stop)
+ start = stop;
+ assert(0 <= start && start <= stop && stop <= Py_SIZE(deque));
- for (i=0 ; i<stop ; i++) {
- if (i >= start) {
- int cmp;
- CHECK_NOT_END(b);
- item = b->data[index];
- cmp = PyObject_RichCompareBool(item, v, Py_EQ);
- if (cmp > 0)
- return PyLong_FromSsize_t(i);
- else if (cmp < 0)
- return NULL;
- if (start_state != deque->state) {
- PyErr_SetString(PyExc_RuntimeError,
- "deque mutated during iteration");
- return NULL;
- }
+ /* XXX Replace this loop with faster code from deque_item() */
+ for (i=0 ; i<start ; i++) {
+ index++;
+ if (index == BLOCKLEN) {
+ b = b->rightlink;
+ index = 0;
+ }
+ }
+
+ n = stop - i + 1;
+ while (--n) {
+ CHECK_NOT_END(b);
+ item = b->data[index];
+ cmp = PyObject_RichCompareBool(item, v, Py_EQ);
+ if (cmp > 0)
+ return PyLong_FromSsize_t(stop - n);
+ if (cmp < 0)
+ return NULL;
+ if (start_state != deque->state) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "deque mutated during iteration");
+ return NULL;
}
index++;
if (index == BLOCKLEN) {
@@ -1037,84 +1149,10 @@
PyDoc_STRVAR(remove_doc,
"D.remove(value) -- remove first occurrence of value.");
-static void
-deque_clear(dequeobject *deque)
-{
- block *b;
- block *prevblock;
- block *leftblock;
- Py_ssize_t leftindex;
- Py_ssize_t n;
- PyObject *item;
-
- if (Py_SIZE(deque) == 0)
- return;
-
- /* During the process of clearing a deque, decrefs can cause the
- deque to mutate. To avoid fatal confusion, we have to make the
- deque empty before clearing the blocks and never refer to
- anything via deque->ref while clearing. (This is the same
- technique used for clearing lists, sets, and dicts.)
-
- Making the deque empty requires allocating a new empty block. In
- the unlikely event that memory is full, we fall back to an
- alternate method that doesn't require a new block. Repeating
- pops in a while-loop is slower, possibly re-entrant (and a clever
- adversary could cause it to never terminate).
- */
-
- b = newblock(0);
- if (b == NULL) {
- PyErr_Clear();
- goto alternate_method;
- }
-
- /* Remember the old size, leftblock, and leftindex */
- leftblock = deque->leftblock;
- leftindex = deque->leftindex;
- n = Py_SIZE(deque);
-
- /* Set the deque to be empty using the newly allocated block */
- MARK_END(b->leftlink);
- MARK_END(b->rightlink);
- Py_SIZE(deque) = 0;
- deque->leftblock = b;
- deque->rightblock = b;
- deque->leftindex = CENTER + 1;
- deque->rightindex = CENTER;
- deque->state++;
-
- /* Now the old size, leftblock, and leftindex are disconnected from
- the empty deque and we can use them to decref the pointers.
- */
- while (n--) {
- item = leftblock->data[leftindex];
- Py_DECREF(item);
- leftindex++;
- if (leftindex == BLOCKLEN && n) {
- CHECK_NOT_END(leftblock->rightlink);
- prevblock = leftblock;
- leftblock = leftblock->rightlink;
- leftindex = 0;
- freeblock(prevblock);
- }
- }
- CHECK_END(leftblock->rightlink);
- freeblock(leftblock);
- return;
-
- alternate_method:
- while (Py_SIZE(deque)) {
- item = deque_pop(deque, NULL);
- assert (item != NULL);
- Py_DECREF(item);
- }
-}
-
static int
valid_index(Py_ssize_t i, Py_ssize_t limit)
{
- /* The cast to size_t let us use just a single comparison
+ /* The cast to size_t lets us use just a single comparison
to check whether i is in the range: 0 <= i < limit */
return (size_t) i < (size_t) limit;
}
@@ -1143,14 +1181,16 @@
i = (Py_ssize_t)((size_t) i % BLOCKLEN);
if (index < (Py_SIZE(deque) >> 1)) {
b = deque->leftblock;
- while (n--)
+ n++;
+ while (--n)
b = b->rightlink;
} else {
n = (Py_ssize_t)(
((size_t)(deque->leftindex + Py_SIZE(deque) - 1))
/ BLOCKLEN - n);
b = deque->rightblock;
- while (n--)
+ n++;
+ while (--n)
b = b->leftlink;
}
}
@@ -1194,14 +1234,16 @@
i = (Py_ssize_t)((size_t) i % BLOCKLEN);
if (index <= halflen) {
b = deque->leftblock;
- while (n--)
+ n++;
+ while (--n)
b = b->rightlink;
} else {
n = (Py_ssize_t)(
((size_t)(deque->leftindex + Py_SIZE(deque) - 1))
/ BLOCKLEN - n);
b = deque->rightblock;
- while (n--)
+ n++;
+ while (--n)
b = b->leftlink;
}
Py_INCREF(v);
@@ -1211,15 +1253,6 @@
return 0;
}
-static PyObject *
-deque_clearmethod(dequeobject *deque)
-{
- deque_clear(deque);
- Py_RETURN_NONE;
-}
-
-PyDoc_STRVAR(clear_doc, "Remove all elements from the deque.");
-
static void
deque_dealloc(dequeobject *deque)
{
@@ -1243,6 +1276,7 @@
PyObject *item;
Py_ssize_t index;
Py_ssize_t indexlo = deque->leftindex;
+ Py_ssize_t indexhigh;
for (b = deque->leftblock; b != deque->rightblock; b = b->rightlink) {
for (index = indexlo; index < BLOCKLEN ; index++) {
@@ -1251,7 +1285,8 @@
}
indexlo = 0;
}
- for (index = indexlo; index <= deque->rightindex; index++) {
+ indexhigh = deque->rightindex;
+ for (index = indexlo; index <= indexhigh; index++) {
item = b->data[index];
Py_VISIT(item);
}
@@ -1259,45 +1294,33 @@
}
static PyObject *
-deque_copy(PyObject *deque)
-{
- if (((dequeobject *)deque)->maxlen == -1)
- return PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "O", deque, NULL);
- else
- return PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "Oi",
- deque, ((dequeobject *)deque)->maxlen, NULL);
-}
-
-PyDoc_STRVAR(copy_doc, "Return a shallow copy of a deque.");
-
-static PyObject *
deque_reduce(dequeobject *deque)
{
- PyObject *dict, *result, *aslist;
+ PyObject *dict, *it;
_Py_IDENTIFIER(__dict__);
dict = _PyObject_GetAttrId((PyObject *)deque, &PyId___dict__);
- if (dict == NULL)
+ if (dict == NULL) {
+ if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ return NULL;
+ }
PyErr_Clear();
- aslist = PySequence_List((PyObject *)deque);
- if (aslist == NULL) {
- Py_XDECREF(dict);
+ dict = Py_None;
+ Py_INCREF(dict);
+ }
+
+ it = PyObject_GetIter((PyObject *)deque);
+ if (it == NULL) {
+ Py_DECREF(dict);
return NULL;
}
- if (dict == NULL) {
- if (deque->maxlen == -1)
- result = Py_BuildValue("O(O)", Py_TYPE(deque), aslist);
- else
- result = Py_BuildValue("O(On)", Py_TYPE(deque), aslist, deque->maxlen);
- } else {
- if (deque->maxlen == -1)
- result = Py_BuildValue("O(OO)O", Py_TYPE(deque), aslist, Py_None, dict);
- else
- result = Py_BuildValue("O(On)O", Py_TYPE(deque), aslist, deque->maxlen, dict);
+
+ if (deque->maxlen < 0) {
+ return Py_BuildValue("O()NN", Py_TYPE(deque), dict, it);
}
- Py_XDECREF(dict);
- Py_DECREF(aslist);
- return result;
+ else {
+ return Py_BuildValue("O(()n)NN", Py_TYPE(deque), deque->maxlen, dict, it);
+ }
}
PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");
@@ -1320,7 +1343,7 @@
Py_ReprLeave(deque);
return NULL;
}
- if (((dequeobject *)deque)->maxlen != -1)
+ if (((dequeobject *)deque)->maxlen >= 0)
result = PyUnicode_FromFormat("deque(%R, maxlen=%zd)",
aslist, ((dequeobject *)deque)->maxlen);
else
@@ -1381,7 +1404,7 @@
}
Py_DECREF(x);
Py_DECREF(y);
- if (b == -1)
+ if (b < 0)
goto done;
}
/* We reached the end of one deque or both */
@@ -1416,8 +1439,14 @@
Py_ssize_t maxlen = -1;
char *kwlist[] = {"iterable", "maxlen", 0};
- if (!PyArg_ParseTupleAndKeywords(args, kwdargs, "|OO:deque", kwlist, &iterable, &maxlenobj))
- return -1;
+ if (kwdargs == NULL) {
+ if (!PyArg_UnpackTuple(args, "deque()", 0, 2, &iterable, &maxlenobj))
+ return -1;
+ } else {
+ if (!PyArg_ParseTupleAndKeywords(args, kwdargs, "|OO:deque", kwlist,
+ &iterable, &maxlenobj))
+ return -1;
+ }
if (maxlenobj != NULL && maxlenobj != Py_None) {
maxlen = PyLong_AsSsize_t(maxlenobj);
if (maxlen == -1 && PyErr_Occurred())
@@ -1446,7 +1475,7 @@
Py_ssize_t blocks;
res = _PyObject_SIZE(Py_TYPE(deque));
- blocks = (deque->leftindex + Py_SIZE(deque) + BLOCKLEN - 1) / BLOCKLEN;
+ blocks = (size_t)(deque->leftindex + Py_SIZE(deque) + BLOCKLEN - 1) / BLOCKLEN;
assert(deque->leftindex + Py_SIZE(deque) - 1 ==
(blocks - 1) * BLOCKLEN + deque->rightindex);
res += blocks * sizeof(block);
@@ -1465,7 +1494,7 @@
static PyObject *
deque_get_maxlen(dequeobject *deque)
{
- if (deque->maxlen == -1)
+ if (deque->maxlen < 0)
Py_RETURN_NONE;
return PyLong_FromSsize_t(deque->maxlen);
}
@@ -1806,7 +1835,7 @@
item = it->b->data[it->index];
it->index--;
it->counter--;
- if (it->index == -1 && it->counter > 0) {
+ if (it->index < 0 && it->counter > 0) {
CHECK_NOT_END(it->b->leftlink);
it->b = it->b->leftlink;
it->index = BLOCKLEN - 1;
@@ -2235,13 +2264,13 @@
oldval = _PyDict_GetItem_KnownHash(mapping, key, hash);
if (oldval == NULL) {
- if (_PyDict_SetItem_KnownHash(mapping, key, one, hash) == -1)
+ if (_PyDict_SetItem_KnownHash(mapping, key, one, hash) < 0)
goto done;
} else {
newval = PyNumber_Add(oldval, one);
if (newval == NULL)
goto done;
- if (_PyDict_SetItem_KnownHash(mapping, key, newval, hash) == -1)
+ if (_PyDict_SetItem_KnownHash(mapping, key, newval, hash) < 0)
goto done;
Py_CLEAR(newval);
}
@@ -2267,7 +2296,7 @@
Py_DECREF(oldval);
if (newval == NULL)
break;
- if (PyObject_SetItem(mapping, key, newval) == -1)
+ if (PyObject_SetItem(mapping, key, newval) < 0)
break;
Py_CLEAR(newval);
Py_DECREF(key);
diff --git a/Modules/_csv.c b/Modules/_csv.c
index 101f449..4284477 100644
--- a/Modules/_csv.c
+++ b/Modules/_csv.c
@@ -60,10 +60,10 @@
typedef struct {
QuoteStyle style;
- char *name;
+ const char *name;
} StyleDesc;
-static StyleDesc quote_styles[] = {
+static const StyleDesc quote_styles[] = {
{ QUOTE_MINIMAL, "QUOTE_MINIMAL" },
{ QUOTE_ALL, "QUOTE_ALL" },
{ QUOTE_NONNUMERIC, "QUOTE_NONNUMERIC" },
@@ -286,7 +286,7 @@
static int
dialect_check_quoting(int quoting)
{
- StyleDesc *qs;
+ const StyleDesc *qs;
for (qs = quote_styles; qs->name; qs++) {
if ((int)qs->style == quoting)
@@ -1633,7 +1633,7 @@
PyInit__csv(void)
{
PyObject *module;
- StyleDesc *style;
+ const StyleDesc *style;
if (PyType_Ready(&Dialect_Type) < 0)
return NULL;
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index a7a8105..331343b 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -435,7 +435,7 @@
return StructUnionType_new(type, args, kwds, 0);
}
-static char from_address_doc[] =
+static const char from_address_doc[] =
"C.from_address(integer) -> C instance\naccess a C instance at the specified address";
static PyObject *
@@ -453,7 +453,7 @@
return PyCData_AtAddress(type, buf);
}
-static char from_buffer_doc[] =
+static const char from_buffer_doc[] =
"C.from_buffer(object, offset=0) -> C instance\ncreate a C instance from a writeable buffer";
static int
@@ -524,7 +524,7 @@
return result;
}
-static char from_buffer_copy_doc[] =
+static const char from_buffer_copy_doc[] =
"C.from_buffer_copy(object, offset=0) -> C instance\ncreate a C instance from a readable buffer";
static PyObject *
@@ -566,7 +566,7 @@
return result;
}
-static char in_dll_doc[] =
+static const char in_dll_doc[] =
"C.in_dll(dll, name) -> C instance\naccess a C instance in a dll";
static PyObject *
@@ -623,7 +623,7 @@
return PyCData_AtAddress(type, address);
}
-static char from_param_doc[] =
+static const char from_param_doc[] =
"Convert a Python object into a function call parameter.";
static PyObject *
@@ -1487,7 +1487,7 @@
*/
-static char *SIMPLE_TYPE_CHARS = "cbBhHiIlLdfuzZqQPXOv?g";
+static const char SIMPLE_TYPE_CHARS[] = "cbBhHiIlLdfuzZqQPXOv?g";
static PyObject *
c_wchar_p_from_param(PyObject *type, PyObject *value)
@@ -2412,7 +2412,7 @@
char *cp = string;
size_t bytes_left;
- assert(sizeof(string) - 1 > sizeof(Py_ssize_t) * 2);
+ Py_BUILD_ASSERT(sizeof(string) - 1 > sizeof(Py_ssize_t) * 2);
cp += sprintf(cp, "%x", Py_SAFE_DOWNCAST(index, Py_ssize_t, int));
while (target->b_base) {
bytes_left = sizeof(string) - (cp - string) - 1;
@@ -3207,7 +3207,7 @@
}
static int
-_get_name(PyObject *obj, char **pname)
+_get_name(PyObject *obj, const char **pname)
{
#ifdef MS_WIN32
if (PyLong_Check(obj)) {
@@ -3235,7 +3235,7 @@
static PyObject *
PyCFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
- char *name;
+ const char *name;
int (* address)(void);
PyObject *ftuple;
PyObject *dll;
@@ -5125,29 +5125,28 @@
#ifdef MS_WIN32
-static char comerror_doc[] = "Raised when a COM method call failed.";
+static const char comerror_doc[] = "Raised when a COM method call failed.";
int
comerror_init(PyObject *self, PyObject *args, PyObject *kwds)
{
PyObject *hresult, *text, *details;
- PyBaseExceptionObject *bself;
PyObject *a;
int status;
if (!_PyArg_NoKeywords(Py_TYPE(self)->tp_name, kwds))
- return -1;
+ return -1;
if (!PyArg_ParseTuple(args, "OOO:COMError", &hresult, &text, &details))
return -1;
a = PySequence_GetSlice(args, 1, PySequence_Size(args));
if (!a)
- return -1;
+ return -1;
status = PyObject_SetAttrString(self, "args", a);
Py_DECREF(a);
if (status < 0)
- return -1;
+ return -1;
if (PyObject_SetAttrString(self, "hresult", hresult) < 0)
return -1;
@@ -5158,9 +5157,8 @@
if (PyObject_SetAttrString(self, "details", details) < 0)
return -1;
- bself = (PyBaseExceptionObject *)self;
Py_INCREF(args);
- Py_SETREF(bself->args, args);
+ Py_SETREF(((PyBaseExceptionObject *)self)->args, args);
return 0;
}
@@ -5490,14 +5488,14 @@
#endif
/* If RTLD_LOCAL is not defined (Windows!), set it to zero. */
-#ifndef RTLD_LOCAL
+#if !HAVE_DECL_RTLD_LOCAL
#define RTLD_LOCAL 0
#endif
/* If RTLD_GLOBAL is not defined (cygwin), set it to the same value as
RTLD_LOCAL.
*/
-#ifndef RTLD_GLOBAL
+#if !HAVE_DECL_RTLD_GLOBAL
#define RTLD_GLOBAL RTLD_LOCAL
#endif
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index 7cd6164..00e8e66 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -77,7 +77,7 @@
/**************************************************************/
static void
-PrintError(char *msg, ...)
+PrintError(const char *msg, ...)
{
char buf[512];
PyObject *f = PySys_GetObject("stderr");
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index 30e3a96..a276fcd 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -382,7 +382,7 @@
whose operation is not allowed in the current
machine mode. */
PyErr_SetString(PyExc_OSError,
- "exception: priviledged instruction");
+ "exception: privileged instruction");
break;
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
@@ -930,7 +930,7 @@
* Raise a new exception 'exc_class', adding additional text to the original
* exception string.
*/
-void _ctypes_extend_error(PyObject *exc_class, char *fmt, ...)
+void _ctypes_extend_error(PyObject *exc_class, const char *fmt, ...)
{
va_list vargs;
PyObject *tp, *v, *tb, *s, *cls_str, *msg_str;
@@ -1203,7 +1203,7 @@
#ifdef MS_WIN32
-static char format_error_doc[] =
+static const char format_error_doc[] =
"FormatError([integer]) -> string\n\
\n\
Convert a win32 error code into a string. If the error code is not\n\
@@ -1227,7 +1227,7 @@
return result;
}
-static char load_library_doc[] =
+static const char load_library_doc[] =
"LoadLibrary(name) -> handle\n\
\n\
Load an executable (usually a DLL), and return a handle to it.\n\
@@ -1256,7 +1256,7 @@
#endif
}
-static char free_library_doc[] =
+static const char free_library_doc[] =
"FreeLibrary(handle) -> void\n\
\n\
Free the handle of an executable previously loaded by LoadLibrary.\n";
@@ -1271,7 +1271,7 @@
return Py_None;
}
-static char copy_com_pointer_doc[] =
+static const char copy_com_pointer_doc[] =
"CopyComPointer(src, dst) -> HRESULT value\n";
static PyObject *
@@ -1309,7 +1309,7 @@
PyObject *name, *name2;
char *name_str;
void * handle;
-#ifdef RTLD_LOCAL
+#if HAVE_DECL_RTLD_LOCAL
int mode = RTLD_NOW | RTLD_LOCAL;
#else
/* cygwin doesn't define RTLD_LOCAL */
@@ -1441,7 +1441,7 @@
/*****************************************************************
* functions
*/
-static char sizeof_doc[] =
+static const char sizeof_doc[] =
"sizeof(C type) -> integer\n"
"sizeof(C instance) -> integer\n"
"Return the size in bytes of a C instance";
@@ -1462,7 +1462,7 @@
return NULL;
}
-static char alignment_doc[] =
+static const char alignment_doc[] =
"alignment(C type) -> integer\n"
"alignment(C instance) -> integer\n"
"Return the alignment requirements of a C instance";
@@ -1485,7 +1485,7 @@
return NULL;
}
-static char byref_doc[] =
+static const char byref_doc[] =
"byref(C instance[, offset=0]) -> byref-object\n"
"Return a pointer lookalike to a C instance, only usable\n"
"as function argument";
@@ -1529,7 +1529,7 @@
return (PyObject *)parg;
}
-static char addressof_doc[] =
+static const char addressof_doc[] =
"addressof(C instance) -> integer\n"
"Return the address of the C instance internal buffer";
diff --git a/Modules/_ctypes/ctypes.h b/Modules/_ctypes/ctypes.h
index 0d3f724..b06ba8a 100644
--- a/Modules/_ctypes/ctypes.h
+++ b/Modules/_ctypes/ctypes.h
@@ -327,7 +327,7 @@
PyCData_set(PyObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
Py_ssize_t index, Py_ssize_t size, char *ptr);
-extern void _ctypes_extend_error(PyObject *exc_class, char *fmt, ...);
+extern void _ctypes_extend_error(PyObject *exc_class, const char *fmt, ...);
struct basespec {
CDataObject *base;
diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c
index 228f497..18ef335 100644
--- a/Modules/_curses_panel.c
+++ b/Modules/_curses_panel.c
@@ -6,7 +6,7 @@
/* Release Number */
-static char *PyCursesVersion = "2.1";
+static const char PyCursesVersion[] = "2.1";
/* Includes */
@@ -56,7 +56,7 @@
*/
static PyObject *
-PyCursesCheckERR(int code, char *fname)
+PyCursesCheckERR(int code, const char *fname)
{
if (code != ERR) {
Py_INCREF(Py_None);
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index f419cb2..61b66a6 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -184,12 +184,12 @@
* and the number of days before that month in the same year. These
* are correct for non-leap years only.
*/
-static int _days_in_month[] = {
+static const int _days_in_month[] = {
0, /* unused; this vector uses 1-based indexing */
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
-static int _days_before_month[] = {
+static const int _days_before_month[] = {
0, /* unused; this vector uses 1-based indexing */
0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
};
@@ -873,7 +873,7 @@
* this returns NULL. Else result is returned.
*/
static PyObject *
-call_tzinfo_method(PyObject *tzinfo, char *name, PyObject *tzinfoarg)
+call_tzinfo_method(PyObject *tzinfo, const char *name, PyObject *tzinfoarg)
{
PyObject *offset;
@@ -1009,10 +1009,10 @@
static PyObject *
format_ctime(PyDateTime_Date *date, int hours, int minutes, int seconds)
{
- static const char *DayNames[] = {
+ static const char * const DayNames[] = {
"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"
};
- static const char *MonthNames[] = {
+ static const char * const MonthNames[] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
@@ -1057,10 +1057,8 @@
}
/* Offset is normalized, so it is negative if days < 0 */
if (GET_TD_DAYS(offset) < 0) {
- PyObject *temp = offset;
sign = '-';
- offset = delta_negative((PyDateTime_Delta *)offset);
- Py_DECREF(temp);
+ Py_SETREF(offset, delta_negative((PyDateTime_Delta *)offset));
if (offset == NULL)
return -1;
}
@@ -2307,7 +2305,7 @@
{NULL, NULL},
};
-static char delta_doc[] =
+static const char delta_doc[] =
PyDoc_STR("Difference between two datetime values.");
static PyNumberMethods delta_as_number = {
@@ -2886,7 +2884,7 @@
{NULL, NULL}
};
-static char date_doc[] =
+static const char date_doc[] =
PyDoc_STR("date(year, month, day) --> date object");
static PyNumberMethods date_as_number = {
@@ -3047,10 +3045,8 @@
if (dst == Py_None)
goto Inconsistent;
if (delta_bool((PyDateTime_Delta *)dst) != 0) {
- PyObject *temp = result;
- result = add_datetime_timedelta((PyDateTime_DateTime *)result,
- (PyDateTime_Delta *)dst, 1);
- Py_DECREF(temp);
+ Py_SETREF(result, add_datetime_timedelta((PyDateTime_DateTime *)result,
+ (PyDateTime_Delta *)dst, 1));
if (result == NULL)
goto Fail;
}
@@ -3155,7 +3151,7 @@
{NULL, NULL}
};
-static char tzinfo_doc[] =
+static const char tzinfo_doc[] =
PyDoc_STR("Abstract base class for time zone info objects.");
static PyTypeObject PyDateTime_TZInfoType = {
@@ -3287,6 +3283,11 @@
Py_INCREF(self->name);
return self->name;
}
+ if ((PyObject *)self == PyDateTime_TimeZone_UTC ||
+ (GET_TD_DAYS(self->offset) == 0 &&
+ GET_TD_SECONDS(self->offset) == 0 &&
+ GET_TD_MICROSECONDS(self->offset) == 0))
+ return PyUnicode_FromString("UTC");
/* Offset is normalized, so it is negative if days < 0 */
if (GET_TD_DAYS(self->offset) < 0) {
sign = '-';
@@ -3382,7 +3383,7 @@
{NULL, NULL}
};
-static char timezone_doc[] =
+static const char timezone_doc[] =
PyDoc_STR("Fixed offset from UTC implementation of tzinfo.");
static PyTypeObject PyDateTime_TimeZoneType = {
@@ -3607,23 +3608,56 @@
}
static PyObject *
-time_isoformat(PyDateTime_Time *self, PyObject *unused)
+time_isoformat(PyDateTime_Time *self, PyObject *args, PyObject *kw)
{
char buf[100];
+ char *timespec = NULL;
+ static char *keywords[] = {"timespec", NULL};
PyObject *result;
int us = TIME_GET_MICROSECOND(self);
+ static char *specs[][2] = {
+ {"hours", "%02d"},
+ {"minutes", "%02d:%02d"},
+ {"seconds", "%02d:%02d:%02d"},
+ {"milliseconds", "%02d:%02d:%02d.%03d"},
+ {"microseconds", "%02d:%02d:%02d.%06d"},
+ };
+ size_t given_spec;
- if (us)
- result = PyUnicode_FromFormat("%02d:%02d:%02d.%06d",
- TIME_GET_HOUR(self),
- TIME_GET_MINUTE(self),
- TIME_GET_SECOND(self),
- us);
- else
- result = PyUnicode_FromFormat("%02d:%02d:%02d",
- TIME_GET_HOUR(self),
- TIME_GET_MINUTE(self),
- TIME_GET_SECOND(self));
+ if (!PyArg_ParseTupleAndKeywords(args, kw, "|s:isoformat", keywords, ×pec))
+ return NULL;
+
+ if (timespec == NULL || strcmp(timespec, "auto") == 0) {
+ if (us == 0) {
+ /* seconds */
+ given_spec = 2;
+ }
+ else {
+ /* microseconds */
+ given_spec = 4;
+ }
+ }
+ else {
+ for (given_spec = 0; given_spec < Py_ARRAY_LENGTH(specs); given_spec++) {
+ if (strcmp(timespec, specs[given_spec][0]) == 0) {
+ if (given_spec == 3) {
+ /* milliseconds */
+ us = us / 1000;
+ }
+ break;
+ }
+ }
+ }
+
+ if (given_spec == Py_ARRAY_LENGTH(specs)) {
+ PyErr_Format(PyExc_ValueError, "Unknown timespec value");
+ return NULL;
+ }
+ else {
+ result = PyUnicode_FromFormat(specs[given_spec][1],
+ TIME_GET_HOUR(self), TIME_GET_MINUTE(self),
+ TIME_GET_SECOND(self), us);
+ }
if (result == NULL || !HASTZINFO(self) || self->tzinfo == Py_None)
return result;
@@ -3844,9 +3878,10 @@
static PyMethodDef time_methods[] = {
- {"isoformat", (PyCFunction)time_isoformat, METH_NOARGS,
- PyDoc_STR("Return string in ISO 8601 format, HH:MM:SS[.mmmmmm]"
- "[+HH:MM].")},
+ {"isoformat", (PyCFunction)time_isoformat, METH_VARARGS | METH_KEYWORDS,
+ PyDoc_STR("Return string in ISO 8601 format, [HH[:MM[:SS[.mmm[uuu]]]]]"
+ "[+HH:MM].\n\n"
+ "timespec specifies what components of the time to include.\n")},
{"strftime", (PyCFunction)time_strftime, METH_VARARGS | METH_KEYWORDS,
PyDoc_STR("format -> strftime() style string.")},
@@ -3872,7 +3907,7 @@
{NULL, NULL}
};
-static char time_doc[] =
+static const char time_doc[] =
PyDoc_STR("time([hour[, minute[, second[, microsecond[, tzinfo]]]]]) --> a time object\n\
\n\
All arguments are optional. tzinfo may be None, or an instance of\n\
@@ -4083,44 +4118,6 @@
tzinfo);
}
-static time_t
-_PyTime_DoubleToTimet(double x)
-{
- time_t result;
- double diff;
-
- result = (time_t)x;
- /* How much info did we lose? time_t may be an integral or
- * floating type, and we don't know which. If it's integral,
- * we don't know whether C truncates, rounds, returns the floor,
- * etc. If we lost a second or more, the C rounding is
- * unreasonable, or the input just doesn't fit in a time_t;
- * call it an error regardless. Note that the original cast to
- * time_t can cause a C error too, but nothing we can do to
- * worm around that.
- */
- diff = x - (double)result;
- if (diff <= -1.0 || diff >= 1.0) {
- PyErr_SetString(PyExc_OverflowError,
- "timestamp out of range for platform time_t");
- result = (time_t)-1;
- }
- return result;
-}
-
-/* Round a double to the nearest long. |x| must be small enough to fit
- * in a C long; this is not checked.
- */
-static double
-_PyTime_RoundHalfEven(double x)
-{
- double rounded = round(x);
- if (fabs(x-rounded) == 0.5)
- /* halfway case: round to even */
- rounded = 2.0*round(x/2.0);
- return rounded;
-}
-
/* Internal helper.
* Build datetime from a Python timestamp. Pass localtime or gmtime for f,
* to control the interpretation of the timestamp. Since a double doesn't
@@ -4129,32 +4126,17 @@
* to get that much precision (e.g., C time() isn't good enough).
*/
static PyObject *
-datetime_from_timestamp(PyObject *cls, TM_FUNC f, double timestamp,
+datetime_from_timestamp(PyObject *cls, TM_FUNC f, PyObject *timestamp,
PyObject *tzinfo)
{
time_t timet;
- double fraction;
- int us;
+ long us;
- timet = _PyTime_DoubleToTimet(timestamp);
- if (timet == (time_t)-1 && PyErr_Occurred())
+ if (_PyTime_ObjectToTimeval(timestamp,
+ &timet, &us, _PyTime_ROUND_HALF_EVEN) == -1)
return NULL;
- fraction = timestamp - (double)timet;
- us = (int)_PyTime_RoundHalfEven(fraction * 1e6);
- if (us < 0) {
- /* Truncation towards zero is not what we wanted
- for negative numbers (Python's mod semantics) */
- timet -= 1;
- us += 1000000;
- }
- /* If timestamp is less than one microsecond smaller than a
- * full second, round up. Otherwise, ValueErrors are raised
- * for some floats. */
- if (us == 1000000) {
- timet += 1;
- us = 0;
- }
- return datetime_from_timet_and_us(cls, f, timet, us, tzinfo);
+
+ return datetime_from_timet_and_us(cls, f, timet, (int)us, tzinfo);
}
/* Internal helper.
@@ -4205,10 +4187,7 @@
tz);
if (self != NULL && tz != Py_None) {
/* Convert UTC to tzinfo's zone. */
- PyObject *temp = self;
-
- self = _PyObject_CallMethodId(tz, &PyId_fromutc, "O", self);
- Py_DECREF(temp);
+ self = _PyObject_CallMethodId(tz, &PyId_fromutc, "N", self);
}
return self;
}
@@ -4227,11 +4206,11 @@
datetime_fromtimestamp(PyObject *cls, PyObject *args, PyObject *kw)
{
PyObject *self;
- double timestamp;
+ PyObject *timestamp;
PyObject *tzinfo = Py_None;
static char *keywords[] = {"timestamp", "tz", NULL};
- if (! PyArg_ParseTupleAndKeywords(args, kw, "d|O:fromtimestamp",
+ if (! PyArg_ParseTupleAndKeywords(args, kw, "O|O:fromtimestamp",
keywords, ×tamp, &tzinfo))
return NULL;
if (check_tzinfo_subclass(tzinfo) < 0)
@@ -4243,10 +4222,7 @@
tzinfo);
if (self != NULL && tzinfo != Py_None) {
/* Convert UTC to tzinfo's zone. */
- PyObject *temp = self;
-
- self = _PyObject_CallMethodId(tzinfo, &PyId_fromutc, "O", self);
- Py_DECREF(temp);
+ self = _PyObject_CallMethodId(tzinfo, &PyId_fromutc, "N", self);
}
return self;
}
@@ -4255,10 +4231,10 @@
static PyObject *
datetime_utcfromtimestamp(PyObject *cls, PyObject *args)
{
- double timestamp;
+ PyObject *timestamp;
PyObject *result = NULL;
- if (PyArg_ParseTuple(args, "d:utcfromtimestamp", ×tamp))
+ if (PyArg_ParseTuple(args, "O:utcfromtimestamp", ×tamp))
result = datetime_from_timestamp(cls, gmtime, timestamp,
Py_None);
return result;
@@ -4469,9 +4445,7 @@
return NULL;
if (offdiff != NULL) {
- PyObject *temp = result;
- result = delta_subtract(result, offdiff);
- Py_DECREF(temp);
+ Py_SETREF(result, delta_subtract(result, offdiff));
Py_DECREF(offdiff);
}
}
@@ -4536,25 +4510,55 @@
datetime_isoformat(PyDateTime_DateTime *self, PyObject *args, PyObject *kw)
{
int sep = 'T';
- static char *keywords[] = {"sep", NULL};
+ char *timespec = NULL;
+ static char *keywords[] = {"sep", "timespec", NULL};
char buffer[100];
- PyObject *result;
+ PyObject *result = NULL;
int us = DATE_GET_MICROSECOND(self);
+ static char *specs[][2] = {
+ {"hours", "%04d-%02d-%02d%c%02d"},
+ {"minutes", "%04d-%02d-%02d%c%02d:%02d"},
+ {"seconds", "%04d-%02d-%02d%c%02d:%02d:%02d"},
+ {"milliseconds", "%04d-%02d-%02d%c%02d:%02d:%02d.%03d"},
+ {"microseconds", "%04d-%02d-%02d%c%02d:%02d:%02d.%06d"},
+ };
+ size_t given_spec;
- if (!PyArg_ParseTupleAndKeywords(args, kw, "|C:isoformat", keywords, &sep))
+ if (!PyArg_ParseTupleAndKeywords(args, kw, "|Cs:isoformat", keywords, &sep, ×pec))
return NULL;
- if (us)
- result = PyUnicode_FromFormat("%04d-%02d-%02d%c%02d:%02d:%02d.%06d",
+
+ if (timespec == NULL || strcmp(timespec, "auto") == 0) {
+ if (us == 0) {
+ /* seconds */
+ given_spec = 2;
+ }
+ else {
+ /* microseconds */
+ given_spec = 4;
+ }
+ }
+ else {
+ for (given_spec = 0; given_spec < Py_ARRAY_LENGTH(specs); given_spec++) {
+ if (strcmp(timespec, specs[given_spec][0]) == 0) {
+ if (given_spec == 3) {
+ us = us / 1000;
+ }
+ break;
+ }
+ }
+ }
+
+ if (given_spec == Py_ARRAY_LENGTH(specs)) {
+ PyErr_Format(PyExc_ValueError, "Unknown timespec value");
+ return NULL;
+ }
+ else {
+ result = PyUnicode_FromFormat(specs[given_spec][1],
GET_YEAR(self), GET_MONTH(self),
GET_DAY(self), (int)sep,
DATE_GET_HOUR(self), DATE_GET_MINUTE(self),
DATE_GET_SECOND(self), us);
- else
- result = PyUnicode_FromFormat("%04d-%02d-%02d%c%02d:%02d:%02d",
- GET_YEAR(self), GET_MONTH(self),
- GET_DAY(self), (int)sep,
- DATE_GET_HOUR(self), DATE_GET_MINUTE(self),
- DATE_GET_SECOND(self));
+ }
if (!result || !HASTZINFO(self))
return result;
@@ -4766,7 +4770,7 @@
if (seconds == NULL)
goto error;
Py_DECREF(delta);
- timestamp = PyLong_AsLong(seconds);
+ timestamp = _PyLong_AsTime_t(seconds);
Py_DECREF(seconds);
if (timestamp == -1 && PyErr_Occurred())
return NULL;
@@ -5093,9 +5097,12 @@
{"isoformat", (PyCFunction)datetime_isoformat, METH_VARARGS | METH_KEYWORDS,
PyDoc_STR("[sep] -> string in ISO 8601 format, "
- "YYYY-MM-DDTHH:MM:SS[.mmmmmm][+HH:MM].\n\n"
+ "YYYY-MM-DDT[HH[:MM[:SS[.mmm[uuu]]]]][+HH:MM].\n"
"sep is used to separate the year from the time, and "
- "defaults to 'T'.")},
+ "defaults to 'T'.\n"
+ "timespec specifies what components of the time to include"
+ " (allowed values are 'auto', 'hours', 'minutes', 'seconds',"
+ " 'milliseconds', and 'microseconds').\n")},
{"utcoffset", (PyCFunction)datetime_utcoffset, METH_NOARGS,
PyDoc_STR("Return self.tzinfo.utcoffset(self).")},
@@ -5118,7 +5125,7 @@
{NULL, NULL}
};
-static char datetime_doc[] =
+static const char datetime_doc[] =
PyDoc_STR("datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])\n\
\n\
The year, month and day arguments are required. tzinfo may be None, or an\n\
@@ -5382,19 +5389,19 @@
/* A 4-year cycle has an extra leap day over what we'd get from
* pasting together 4 single years.
*/
- assert(DI4Y == 4 * 365 + 1);
+ Py_BUILD_ASSERT(DI4Y == 4 * 365 + 1);
assert(DI4Y == days_before_year(4+1));
/* Similarly, a 400-year cycle has an extra leap day over what we'd
* get from pasting together 4 100-year cycles.
*/
- assert(DI400Y == 4 * DI100Y + 1);
+ Py_BUILD_ASSERT(DI400Y == 4 * DI100Y + 1);
assert(DI400Y == days_before_year(400+1));
/* OTOH, a 100-year cycle has one fewer leap day than we'd get from
* pasting together 25 4-year cycles.
*/
- assert(DI100Y == 25 * DI4Y - 1);
+ Py_BUILD_ASSERT(DI100Y == 25 * DI4Y - 1);
assert(DI100Y == days_before_year(100+1));
one = PyLong_FromLong(1);
diff --git a/Modules/_dbmmodule.c b/Modules/_dbmmodule.c
index 02899e4..5e7ec1a 100644
--- a/Modules/_dbmmodule.c
+++ b/Modules/_dbmmodule.c
@@ -14,16 +14,16 @@
*/
#if defined(HAVE_NDBM_H)
#include <ndbm.h>
-static char *which_dbm = "GNU gdbm"; /* EMX port of GDBM */
+static const char which_dbm[] = "GNU gdbm"; /* EMX port of GDBM */
#elif defined(HAVE_GDBM_NDBM_H)
#include <gdbm/ndbm.h>
-static char *which_dbm = "GNU gdbm";
+static const char which_dbm[] = "GNU gdbm";
#elif defined(HAVE_GDBM_DASH_NDBM_H)
#include <gdbm-ndbm.h>
-static char *which_dbm = "GNU gdbm";
+static const char which_dbm[] = "GNU gdbm";
#elif defined(HAVE_BERKDB_H)
#include <db.h>
-static char *which_dbm = "Berkeley DB";
+static const char which_dbm[] = "Berkeley DB";
#else
#error "No ndbm.h available!"
#endif
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c
index 22053b4..dd33f97 100644
--- a/Modules/_decimal/_decimal.c
+++ b/Modules/_decimal/_decimal.c
@@ -36,7 +36,6 @@
#include <stdlib.h>
#include "docstrings.h"
-#include "memory.h"
#if !defined(MPD_VERSION_HEX) || MPD_VERSION_HEX < 0x02040100
@@ -3386,6 +3385,106 @@
return (PyObject *) pylong;
}
+/* Convert a Decimal to its exact integer ratio representation. */
+static PyObject *
+dec_as_integer_ratio(PyObject *self, PyObject *args UNUSED)
+{
+ PyObject *numerator = NULL;
+ PyObject *denominator = NULL;
+ PyObject *exponent = NULL;
+ PyObject *result = NULL;
+ PyObject *tmp;
+ mpd_ssize_t exp;
+ PyObject *context;
+ uint32_t status = 0;
+ PyNumberMethods *long_methods = PyLong_Type.tp_as_number;
+
+ if (mpd_isspecial(MPD(self))) {
+ if (mpd_isnan(MPD(self))) {
+ PyErr_SetString(PyExc_ValueError,
+ "cannot convert NaN to integer ratio");
+ }
+ else {
+ PyErr_SetString(PyExc_OverflowError,
+ "cannot convert Infinity to integer ratio");
+ }
+ return NULL;
+ }
+
+ CURRENT_CONTEXT(context);
+
+ tmp = dec_alloc();
+ if (tmp == NULL) {
+ return NULL;
+ }
+
+ if (!mpd_qcopy(MPD(tmp), MPD(self), &status)) {
+ Py_DECREF(tmp);
+ PyErr_NoMemory();
+ return NULL;
+ }
+
+ exp = mpd_iszero(MPD(tmp)) ? 0 : MPD(tmp)->exp;
+ MPD(tmp)->exp = 0;
+
+ /* context and rounding are unused here: the conversion is exact */
+ numerator = dec_as_long(tmp, context, MPD_ROUND_FLOOR);
+ Py_DECREF(tmp);
+ if (numerator == NULL) {
+ goto error;
+ }
+
+ exponent = PyLong_FromSsize_t(exp < 0 ? -exp : exp);
+ if (exponent == NULL) {
+ goto error;
+ }
+
+ tmp = PyLong_FromLong(10);
+ if (tmp == NULL) {
+ goto error;
+ }
+
+ Py_SETREF(exponent, long_methods->nb_power(tmp, exponent, Py_None));
+ Py_DECREF(tmp);
+ if (exponent == NULL) {
+ goto error;
+ }
+
+ if (exp >= 0) {
+ Py_SETREF(numerator, long_methods->nb_multiply(numerator, exponent));
+ if (numerator == NULL) {
+ goto error;
+ }
+ denominator = PyLong_FromLong(1);
+ if (denominator == NULL) {
+ goto error;
+ }
+ }
+ else {
+ denominator = exponent;
+ exponent = NULL;
+ tmp = _PyLong_GCD(numerator, denominator);
+ if (tmp == NULL) {
+ goto error;
+ }
+ Py_SETREF(numerator, long_methods->nb_floor_divide(numerator, tmp));
+ Py_SETREF(denominator, long_methods->nb_floor_divide(denominator, tmp));
+ Py_DECREF(tmp);
+ if (numerator == NULL || denominator == NULL) {
+ goto error;
+ }
+ }
+
+ result = PyTuple_Pack(2, numerator, denominator);
+
+
+error:
+ Py_XDECREF(exponent);
+ Py_XDECREF(denominator);
+ Py_XDECREF(numerator);
+ return result;
+}
+
static PyObject *
PyDec_ToIntegralValue(PyObject *dec, PyObject *args, PyObject *kwds)
{
@@ -4694,6 +4793,7 @@
/* Miscellaneous */
{ "from_float", dec_from_float, METH_O|METH_CLASS, doc_from_float },
{ "as_tuple", PyDec_AsTuple, METH_NOARGS, doc_as_tuple },
+ { "as_integer_ratio", dec_as_integer_ratio, METH_NOARGS, doc_as_integer_ratio },
/* Special methods */
{ "__copy__", dec_copy, METH_NOARGS, NULL },
diff --git a/Modules/_decimal/docstrings.h b/Modules/_decimal/docstrings.h
index 71029a9..f7fd6e7 100644
--- a/Modules/_decimal/docstrings.h
+++ b/Modules/_decimal/docstrings.h
@@ -70,6 +70,15 @@
Return a tuple representation of the number.\n\
\n");
+PyDoc_STRVAR(doc_as_integer_ratio,
+"as_integer_ratio($self, /)\n--\n\n\
+Decimal.as_integer_ratio() -> (int, int)\n\
+\n\
+Return a pair of integers, whose ratio is exactly equal to the original\n\
+Decimal and with a positive denominator. The ratio is in lowest terms.\n\
+Raise OverflowError on infinities and a ValueError on NaNs.\n\
+\n");
+
PyDoc_STRVAR(doc_canonical,
"canonical($self, /)\n--\n\n\
Return the canonical encoding of the argument. Currently, the encoding\n\
diff --git a/Modules/_decimal/libmpdec/basearith.c b/Modules/_decimal/libmpdec/basearith.c
index 35de6b8..dfe1523 100644
--- a/Modules/_decimal/libmpdec/basearith.c
+++ b/Modules/_decimal/libmpdec/basearith.c
@@ -32,7 +32,6 @@
#include <string.h>
#include <assert.h>
#include "constants.h"
-#include "memory.h"
#include "typearith.h"
#include "basearith.h"
diff --git a/Modules/_decimal/libmpdec/io.c b/Modules/_decimal/libmpdec/io.c
index a45a429..3aadfb0 100644
--- a/Modules/_decimal/libmpdec/io.c
+++ b/Modules/_decimal/libmpdec/io.c
@@ -37,7 +37,6 @@
#include <locale.h>
#include "bits.h"
#include "constants.h"
-#include "memory.h"
#include "typearith.h"
#include "io.h"
diff --git a/Modules/_decimal/libmpdec/memory.c b/Modules/_decimal/libmpdec/memory.c
index 0f41fe5..a854e09 100644
--- a/Modules/_decimal/libmpdec/memory.c
+++ b/Modules/_decimal/libmpdec/memory.c
@@ -30,7 +30,12 @@
#include <stdio.h>
#include <stdlib.h>
#include "typearith.h"
-#include "memory.h"
+#include "mpalloc.h"
+
+
+#if defined(_MSC_VER)
+ #pragma warning(disable : 4232)
+#endif
/* Guaranteed minimum allocation for a coefficient. May be changed once
diff --git a/Modules/_decimal/libmpdec/memory.h b/Modules/_decimal/libmpdec/mpalloc.h
similarity index 97%
rename from Modules/_decimal/libmpdec/memory.h
rename to Modules/_decimal/libmpdec/mpalloc.h
index 9c98d1a..efd7119 100644
--- a/Modules/_decimal/libmpdec/memory.h
+++ b/Modules/_decimal/libmpdec/mpalloc.h
@@ -26,8 +26,8 @@
*/
-#ifndef MEMORY_H
-#define MEMORY_H
+#ifndef MPALLOC_H
+#define MPALLOC_H
#include "mpdecimal.h"
diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c
index 593f9f5..328ab92 100644
--- a/Modules/_decimal/libmpdec/mpdecimal.c
+++ b/Modules/_decimal/libmpdec/mpdecimal.c
@@ -36,7 +36,7 @@
#include "bits.h"
#include "convolute.h"
#include "crt.h"
-#include "memory.h"
+#include "mpalloc.h"
#include "typearith.h"
#include "umodarith.h"
diff --git a/Modules/_decimal/libmpdec/mpdecimal.h b/Modules/_decimal/libmpdec/mpdecimal.h
index 5ca7413..56e4887 100644
--- a/Modules/_decimal/libmpdec/mpdecimal.h
+++ b/Modules/_decimal/libmpdec/mpdecimal.h
@@ -108,9 +108,9 @@
#define MPD_MAJOR_VERSION 2
#define MPD_MINOR_VERSION 4
-#define MPD_MICRO_VERSION 1
+#define MPD_MICRO_VERSION 2
-#define MPD_VERSION "2.4.1"
+#define MPD_VERSION "2.4.2"
#define MPD_VERSION_HEX ((MPD_MAJOR_VERSION << 24) | \
(MPD_MINOR_VERSION << 16) | \
diff --git a/Modules/_decimal/tests/deccheck.py b/Modules/_decimal/tests/deccheck.py
index ab7d5bd..f907531 100644
--- a/Modules/_decimal/tests/deccheck.py
+++ b/Modules/_decimal/tests/deccheck.py
@@ -50,8 +50,8 @@
'__abs__', '__bool__', '__ceil__', '__complex__', '__copy__',
'__floor__', '__float__', '__hash__', '__int__', '__neg__',
'__pos__', '__reduce__', '__repr__', '__str__', '__trunc__',
- 'adjusted', 'as_tuple', 'canonical', 'conjugate', 'copy_abs',
- 'copy_negate', 'is_canonical', 'is_finite', 'is_infinite',
+ 'adjusted', 'as_integer_ratio', 'as_tuple', 'canonical', 'conjugate',
+ 'copy_abs', 'copy_negate', 'is_canonical', 'is_finite', 'is_infinite',
'is_nan', 'is_qnan', 'is_signed', 'is_snan', 'is_zero', 'radix'
),
# Unary with optional context:
@@ -128,7 +128,7 @@
# Functions that require a restricted exponent range for reasonable runtimes.
UnaryRestricted = [
'__ceil__', '__floor__', '__int__', '__trunc__',
- 'to_integral', 'to_integral_value'
+ 'as_integer_ratio', 'to_integral', 'to_integral_value'
]
BinaryRestricted = ['__round__']
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 85ffca2..b32f2ad 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -129,30 +129,6 @@
/* helpers */
LOCAL(PyObject*)
-deepcopy(PyObject* object, PyObject* memo)
-{
- /* do a deep copy of the given object */
- PyObject* args;
- PyObject* result;
- elementtreestate *st = ET_STATE_GLOBAL;
-
- if (!st->deepcopy_obj) {
- PyErr_SetString(
- PyExc_RuntimeError,
- "deepcopy helper not found"
- );
- return NULL;
- }
-
- args = PyTuple_Pack(2, object, memo);
- if (!args)
- return NULL;
- result = PyObject_CallObject(st->deepcopy_obj, args);
- Py_DECREF(args);
- return result;
-}
-
-LOCAL(PyObject*)
list_join(PyObject* list)
{
/* join list elements (destroying the list in the process) */
@@ -420,10 +396,8 @@
Py_XDECREF(attrib);
/* Replace the objects already pointed to by tag, text and tail. */
- tmp = self_elem->tag;
Py_INCREF(tag);
- self_elem->tag = tag;
- Py_DECREF(tmp);
+ Py_XSETREF(self_elem->tag, tag);
tmp = self_elem->text;
Py_INCREF(Py_None);
@@ -748,6 +722,9 @@
return (PyObject*) element;
}
+/* Helper for a deep copy. */
+LOCAL(PyObject *) deepcopy(PyObject *, PyObject *);
+
/*[clinic input]
_elementtree.Element.__deepcopy__
@@ -838,6 +815,57 @@
return NULL;
}
+LOCAL(PyObject *)
+deepcopy(PyObject *object, PyObject *memo)
+{
+ /* do a deep copy of the given object */
+ PyObject *args;
+ PyObject *result;
+ elementtreestate *st;
+
+ /* Fast paths */
+ if (object == Py_None || PyUnicode_CheckExact(object)) {
+ Py_INCREF(object);
+ return object;
+ }
+
+ if (Py_REFCNT(object) == 1) {
+ if (PyDict_CheckExact(object)) {
+ PyObject *key, *value;
+ Py_ssize_t pos = 0;
+ int simple = 1;
+ while (PyDict_Next(object, &pos, &key, &value)) {
+ if (!PyUnicode_CheckExact(key) || !PyUnicode_CheckExact(value)) {
+ simple = 0;
+ break;
+ }
+ }
+ if (simple)
+ return PyDict_Copy(object);
+ /* Fall through to general case */
+ }
+ else if (Element_CheckExact(object)) {
+ return _elementtree_Element___deepcopy__((ElementObject *)object, memo);
+ }
+ }
+
+ /* General case */
+ st = ET_STATE_GLOBAL;
+ if (!st->deepcopy_obj) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "deepcopy helper not found");
+ return NULL;
+ }
+
+ args = PyTuple_Pack(2, object, memo);
+ if (!args)
+ return NULL;
+ result = PyObject_CallObject(st->deepcopy_obj, args);
+ Py_DECREF(args);
+ return result;
+}
+
+
/*[clinic input]
_elementtree.Element.__sizeof__ -> Py_ssize_t
@@ -1892,92 +1920,90 @@
}
static PyObject*
-element_getattro(ElementObject* self, PyObject* nameobj)
+element_tag_getter(ElementObject *self, void *closure)
{
- PyObject* res;
- char *name = "";
-
- if (PyUnicode_Check(nameobj))
- name = _PyUnicode_AsString(nameobj);
-
- if (name == NULL)
- return NULL;
-
- /* handle common attributes first */
- if (strcmp(name, "tag") == 0) {
- res = self->tag;
- Py_INCREF(res);
- return res;
- } else if (strcmp(name, "text") == 0) {
- res = element_get_text(self);
- Py_XINCREF(res);
- return res;
- }
-
- /* methods */
- res = PyObject_GenericGetAttr((PyObject*) self, nameobj);
- if (res)
- return res;
-
- /* less common attributes */
- if (strcmp(name, "tail") == 0) {
- PyErr_Clear();
- res = element_get_tail(self);
- } else if (strcmp(name, "attrib") == 0) {
- PyErr_Clear();
- if (!self->extra) {
- if (create_extra(self, NULL) < 0)
- return NULL;
- }
- res = element_get_attrib(self);
- }
-
- if (!res)
- return NULL;
-
+ PyObject *res = self->tag;
Py_INCREF(res);
return res;
}
-static int
-element_setattro(ElementObject* self, PyObject* nameobj, PyObject* value)
+static PyObject*
+element_text_getter(ElementObject *self, void *closure)
{
- char *name = "";
+ PyObject *res = element_get_text(self);
+ Py_XINCREF(res);
+ return res;
+}
- if (value == NULL) {
- PyErr_SetString(PyExc_AttributeError,
- "can't delete attribute");
- return -1;
+static PyObject*
+element_tail_getter(ElementObject *self, void *closure)
+{
+ PyObject *res = element_get_tail(self);
+ Py_XINCREF(res);
+ return res;
+}
+
+static PyObject*
+element_attrib_getter(ElementObject *self, void *closure)
+{
+ PyObject *res;
+ if (!self->extra) {
+ if (create_extra(self, NULL) < 0)
+ return NULL;
}
- if (PyUnicode_Check(nameobj))
- name = _PyUnicode_AsString(nameobj);
- if (name == NULL)
- return -1;
+ res = element_get_attrib(self);
+ Py_XINCREF(res);
+ return res;
+}
- if (strcmp(name, "tag") == 0) {
- Py_INCREF(value);
- Py_SETREF(self->tag, value);
- } else if (strcmp(name, "text") == 0) {
- Py_DECREF(JOIN_OBJ(self->text));
- self->text = value;
- Py_INCREF(self->text);
- } else if (strcmp(name, "tail") == 0) {
- Py_DECREF(JOIN_OBJ(self->tail));
- self->tail = value;
- Py_INCREF(self->tail);
- } else if (strcmp(name, "attrib") == 0) {
- if (!self->extra) {
- if (create_extra(self, NULL) < 0)
- return -1;
- }
- Py_INCREF(value);
- Py_SETREF(self->extra->attrib, value);
- } else {
- PyErr_SetString(PyExc_AttributeError,
- "Can't set arbitrary attributes on Element");
- return -1;
+/* macro for setter validation */
+#define _VALIDATE_ATTR_VALUE(V) \
+ if ((V) == NULL) { \
+ PyErr_SetString( \
+ PyExc_AttributeError, \
+ "can't delete element attribute"); \
+ return -1; \
}
+static int
+element_tag_setter(ElementObject *self, PyObject *value, void *closure)
+{
+ _VALIDATE_ATTR_VALUE(value);
+ Py_INCREF(value);
+ Py_SETREF(self->tag, value);
+ return 0;
+}
+
+static int
+element_text_setter(ElementObject *self, PyObject *value, void *closure)
+{
+ _VALIDATE_ATTR_VALUE(value);
+ Py_INCREF(value);
+ Py_DECREF(JOIN_OBJ(self->text));
+ self->text = value;
+ return 0;
+}
+
+static int
+element_tail_setter(ElementObject *self, PyObject *value, void *closure)
+{
+ _VALIDATE_ATTR_VALUE(value);
+ Py_INCREF(value);
+ Py_DECREF(JOIN_OBJ(self->tail));
+ self->tail = value;
+ return 0;
+}
+
+static int
+element_attrib_setter(ElementObject *self, PyObject *value, void *closure)
+{
+ _VALIDATE_ATTR_VALUE(value);
+ if (!self->extra) {
+ if (create_extra(self, NULL) < 0)
+ return -1;
+ }
+ Py_INCREF(value);
+ Py_SETREF(self->extra->attrib, value);
return 0;
}
@@ -1997,22 +2023,22 @@
* pre-order traversal. To keep track of which sub-element should be returned
* next, a stack of parents is maintained. This is a standard stack-based
* iterative pre-order traversal of a tree.
- * The stack is managed using a single-linked list starting at parent_stack.
- * Each stack node contains the saved parent to which we should return after
+ * The stack is managed using a continuous array.
+ * Each stack item contains the saved parent to which we should return after
* the current one is exhausted, and the next child to examine in that parent.
*/
typedef struct ParentLocator_t {
ElementObject *parent;
Py_ssize_t child_index;
- struct ParentLocator_t *next;
} ParentLocator;
typedef struct {
PyObject_HEAD
ParentLocator *parent_stack;
+ Py_ssize_t parent_stack_used;
+ Py_ssize_t parent_stack_size;
ElementObject *root_element;
PyObject *sought_tag;
- int root_done;
int gettext;
} ElementIterObject;
@@ -2020,13 +2046,11 @@
static void
elementiter_dealloc(ElementIterObject *it)
{
- ParentLocator *p = it->parent_stack;
- while (p) {
- ParentLocator *temp = p;
- Py_XDECREF(p->parent);
- p = p->next;
- PyObject_Free(temp);
- }
+ Py_ssize_t i = it->parent_stack_used;
+ it->parent_stack_used = 0;
+ while (i--)
+ Py_XDECREF(it->parent_stack[i].parent);
+ PyMem_Free(it->parent_stack);
Py_XDECREF(it->sought_tag);
Py_XDECREF(it->root_element);
@@ -2038,11 +2062,9 @@
static int
elementiter_traverse(ElementIterObject *it, visitproc visit, void *arg)
{
- ParentLocator *p = it->parent_stack;
- while (p) {
- Py_VISIT(p->parent);
- p = p->next;
- }
+ Py_ssize_t i = it->parent_stack_used;
+ while (i--)
+ Py_VISIT(it->parent_stack[i].parent);
Py_VISIT(it->root_element);
Py_VISIT(it->sought_tag);
@@ -2051,17 +2073,25 @@
/* Helper function for elementiter_next. Add a new parent to the parent stack.
*/
-static ParentLocator *
-parent_stack_push_new(ParentLocator *stack, ElementObject *parent)
+static int
+parent_stack_push_new(ElementIterObject *it, ElementObject *parent)
{
- ParentLocator *new_node = PyObject_Malloc(sizeof(ParentLocator));
- if (new_node) {
- new_node->parent = parent;
- Py_INCREF(parent);
- new_node->child_index = 0;
- new_node->next = stack;
+ ParentLocator *item;
+
+ if (it->parent_stack_used >= it->parent_stack_size) {
+ Py_ssize_t new_size = it->parent_stack_size * 2; /* never overflow */
+ ParentLocator *parent_stack = it->parent_stack;
+ PyMem_Resize(parent_stack, ParentLocator, new_size);
+ if (parent_stack == NULL)
+ return -1;
+ it->parent_stack = parent_stack;
+ it->parent_stack_size = new_size;
}
- return new_node;
+ item = it->parent_stack + it->parent_stack_used++;
+ Py_INCREF(parent);
+ item->parent = parent;
+ item->child_index = 0;
+ return 0;
}
static PyObject *
@@ -2078,151 +2108,91 @@
* - itertext() also has to handle tail, after finishing with all the
* children of a node.
*/
- ElementObject *cur_parent;
- Py_ssize_t child_index;
int rc;
ElementObject *elem;
+ PyObject *text;
while (1) {
/* Handle the case reached in the beginning and end of iteration, where
- * the parent stack is empty. The root_done flag gives us indication
- * whether we've just started iterating (so root_done is 0), in which
- * case the root is returned. If root_done is 1 and we're here, the
+ * the parent stack is empty. If root_element is NULL and we're here, the
* iterator is exhausted.
*/
- if (!it->parent_stack->parent) {
- if (it->root_done) {
+ if (!it->parent_stack_used) {
+ if (!it->root_element) {
PyErr_SetNone(PyExc_StopIteration);
return NULL;
- } else {
- elem = it->root_element;
- it->parent_stack = parent_stack_push_new(it->parent_stack,
- elem);
- if (!it->parent_stack) {
- PyErr_NoMemory();
- return NULL;
- }
-
- Py_INCREF(elem);
- it->root_done = 1;
- rc = (it->sought_tag == Py_None);
- if (!rc) {
- rc = PyObject_RichCompareBool(elem->tag,
- it->sought_tag, Py_EQ);
- if (rc < 0) {
- Py_DECREF(elem);
- return NULL;
- }
- }
- if (rc) {
- if (it->gettext) {
- PyObject *text = element_get_text(elem);
- if (!text) {
- Py_DECREF(elem);
- return NULL;
- }
- Py_INCREF(text);
- Py_DECREF(elem);
- rc = PyObject_IsTrue(text);
- if (rc > 0)
- return text;
- Py_DECREF(text);
- if (rc < 0)
- return NULL;
- } else {
- return (PyObject *)elem;
- }
- }
- else {
- Py_DECREF(elem);
- }
- }
- }
-
- /* See if there are children left to traverse in the current parent. If
- * yes, visit the next child. If not, pop the stack and try again.
- */
- cur_parent = it->parent_stack->parent;
- child_index = it->parent_stack->child_index;
- if (cur_parent->extra && child_index < cur_parent->extra->length) {
- elem = (ElementObject *)cur_parent->extra->children[child_index];
- it->parent_stack->child_index++;
- it->parent_stack = parent_stack_push_new(it->parent_stack,
- elem);
- if (!it->parent_stack) {
- PyErr_NoMemory();
- return NULL;
}
- Py_INCREF(elem);
- if (it->gettext) {
- PyObject *text = element_get_text(elem);
- if (!text) {
- Py_DECREF(elem);
- return NULL;
- }
- Py_INCREF(text);
- Py_DECREF(elem);
- rc = PyObject_IsTrue(text);
- if (rc > 0)
- return text;
- Py_DECREF(text);
- if (rc < 0)
- return NULL;
- } else {
- rc = (it->sought_tag == Py_None);
- if (!rc) {
- rc = PyObject_RichCompareBool(elem->tag,
- it->sought_tag, Py_EQ);
- if (rc < 0) {
- Py_DECREF(elem);
- return NULL;
- }
- }
- if (rc) {
- return (PyObject *)elem;
- }
- Py_DECREF(elem);
- }
+ elem = it->root_element; /* steals a reference */
+ it->root_element = NULL;
}
else {
- PyObject *tail;
- ParentLocator *next;
- if (it->gettext) {
- Py_INCREF(cur_parent);
- tail = element_get_tail(cur_parent);
- if (!tail) {
- Py_DECREF(cur_parent);
- return NULL;
- }
- Py_INCREF(tail);
- Py_DECREF(cur_parent);
- }
- else {
- tail = Py_None;
- Py_INCREF(tail);
- }
- next = it->parent_stack->next;
- cur_parent = it->parent_stack->parent;
- PyObject_Free(it->parent_stack);
- it->parent_stack = next;
- Py_XDECREF(cur_parent);
-
- /* Note that extra condition on it->parent_stack->parent here;
- * this is because itertext() is supposed to only return *inner*
- * text, not text following the element it began iteration with.
+ /* See if there are children left to traverse in the current parent. If
+ * yes, visit the next child. If not, pop the stack and try again.
*/
- if (it->parent_stack->parent) {
- rc = PyObject_IsTrue(tail);
- if (rc > 0)
- return tail;
- Py_DECREF(tail);
- if (rc < 0)
- return NULL;
+ ParentLocator *item = &it->parent_stack[it->parent_stack_used - 1];
+ Py_ssize_t child_index = item->child_index;
+ ElementObjectExtra *extra;
+ elem = item->parent;
+ extra = elem->extra;
+ if (!extra || child_index >= extra->length) {
+ it->parent_stack_used--;
+ /* Note that extra condition on it->parent_stack_used here;
+ * this is because itertext() is supposed to only return *inner*
+ * text, not text following the element it began iteration with.
+ */
+ if (it->gettext && it->parent_stack_used) {
+ text = element_get_tail(elem);
+ goto gettext;
+ }
+ Py_DECREF(elem);
+ continue;
}
- else {
- Py_DECREF(tail);
- }
+
+ elem = (ElementObject *)extra->children[child_index];
+ item->child_index++;
+ Py_INCREF(elem);
+ }
+
+ if (parent_stack_push_new(it, elem) < 0) {
+ Py_DECREF(elem);
+ PyErr_NoMemory();
+ return NULL;
+ }
+ if (it->gettext) {
+ text = element_get_text(elem);
+ goto gettext;
+ }
+
+ if (it->sought_tag == Py_None)
+ return (PyObject *)elem;
+
+ rc = PyObject_RichCompareBool(elem->tag, it->sought_tag, Py_EQ);
+ if (rc > 0)
+ return (PyObject *)elem;
+
+ Py_DECREF(elem);
+ if (rc < 0)
+ return NULL;
+ continue;
+
+gettext:
+ if (!text) {
+ Py_DECREF(elem);
+ return NULL;
+ }
+ if (text == Py_None) {
+ Py_DECREF(elem);
+ }
+ else {
+ Py_INCREF(text);
+ Py_DECREF(elem);
+ rc = PyObject_IsTrue(text);
+ if (rc > 0)
+ return text;
+ Py_DECREF(text);
+ if (rc < 0)
+ return NULL;
}
}
@@ -2274,6 +2244,7 @@
0, /* tp_new */
};
+#define INIT_PARENT_STACK_SIZE 8
static PyObject *
create_elementiter(ElementObject *self, PyObject *tag, int gettext)
@@ -2286,22 +2257,20 @@
Py_INCREF(tag);
it->sought_tag = tag;
- it->root_done = 0;
it->gettext = gettext;
Py_INCREF(self);
it->root_element = self;
PyObject_GC_Track(it);
- it->parent_stack = PyObject_Malloc(sizeof(ParentLocator));
+ it->parent_stack = PyMem_New(ParentLocator, INIT_PARENT_STACK_SIZE);
if (it->parent_stack == NULL) {
Py_DECREF(it);
PyErr_NoMemory();
return NULL;
}
- it->parent_stack->parent = NULL;
- it->parent_stack->child_index = 0;
- it->parent_stack->next = NULL;
+ it->parent_stack_used = 0;
+ it->parent_stack_size = INIT_PARENT_STACK_SIZE;
return (PyObject *)it;
}
@@ -2326,7 +2295,7 @@
PyObject *element_factory;
/* element tracing */
- PyObject *events; /* list of events, or NULL if not collecting */
+ PyObject *events_append; /* the append method of the list of events, or NULL */
PyObject *start_event_obj; /* event objects (NULL to ignore) */
PyObject *end_event_obj;
PyObject *start_ns_event_obj;
@@ -2361,7 +2330,7 @@
}
t->index = 0;
- t->events = NULL;
+ t->events_append = NULL;
t->start_event_obj = t->end_event_obj = NULL;
t->start_ns_event_obj = t->end_ns_event_obj = NULL;
}
@@ -2380,13 +2349,9 @@
PyObject *element_factory)
/*[clinic end generated code: output=91cfa7558970ee96 input=1b424eeefc35249c]*/
{
- PyObject *tmp;
-
if (element_factory) {
Py_INCREF(element_factory);
- tmp = self->element_factory;
- self->element_factory = element_factory;
- Py_XDECREF(tmp);
+ Py_XSETREF(self->element_factory, element_factory);
}
return 0;
@@ -2411,7 +2376,7 @@
Py_CLEAR(self->start_ns_event_obj);
Py_CLEAR(self->end_event_obj);
Py_CLEAR(self->start_event_obj);
- Py_CLEAR(self->events);
+ Py_CLEAR(self->events_append);
Py_CLEAR(self->stack);
Py_CLEAR(self->data);
Py_CLEAR(self->last);
@@ -2492,13 +2457,14 @@
PyObject *node)
{
if (action != NULL) {
- PyObject *res = PyTuple_Pack(2, action, node);
+ PyObject *res;
+ PyObject *event = PyTuple_Pack(2, action, node);
+ if (event == NULL)
+ return -1;
+ res = PyObject_CallFunctionObjArgs(self->events_append, event, NULL);
+ Py_DECREF(event);
if (res == NULL)
return -1;
- if (PyList_Append(self->events, res) < 0) {
- Py_DECREF(res);
- return -1;
- }
Py_DECREF(res);
}
return 0;
@@ -2527,10 +2493,17 @@
self->data = NULL;
}
- if (self->element_factory && self->element_factory != Py_None) {
- node = PyObject_CallFunction(self->element_factory, "OO", tag, attrib);
- } else {
+ if (!self->element_factory || self->element_factory == Py_None) {
node = create_new_element(tag, attrib);
+ } else if (attrib == Py_None) {
+ attrib = PyDict_New();
+ if (!attrib)
+ return NULL;
+ node = PyObject_CallFunction(self->element_factory, "OO", tag, attrib);
+ Py_DECREF(attrib);
+ }
+ else {
+ node = PyObject_CallFunction(self->element_factory, "OO", tag, attrib);
}
if (!node) {
return NULL;
@@ -2989,12 +2962,8 @@
attrib_in += 2;
}
} else {
- /* Pass an empty dictionary on */
- attrib = PyDict_New();
- if (!attrib) {
- Py_DECREF(tag);
- return;
- }
+ Py_INCREF(Py_None);
+ attrib = Py_None;
}
if (TreeBuilder_CheckExact(self->target)) {
@@ -3003,6 +2972,14 @@
tag, attrib);
}
else if (self->handle_start) {
+ if (attrib == Py_None) {
+ Py_DECREF(attrib);
+ attrib = PyDict_New();
+ if (!attrib) {
+ Py_DECREF(tag);
+ return;
+ }
+ }
res = PyObject_CallFunction(self->handle_start, "OO", tag, attrib);
} else
res = NULL;
@@ -3076,7 +3053,7 @@
if (PyErr_Occurred())
return;
- if (!target->events || !target->start_ns_event_obj)
+ if (!target->events_append || !target->start_ns_event_obj)
return;
if (!uri)
@@ -3099,7 +3076,7 @@
if (PyErr_Occurred())
return;
- if (!target->events)
+ if (!target->events_append)
return;
treebuilder_append_event(target, target->end_ns_event_obj, Py_None);
@@ -3588,7 +3565,7 @@
/*[clinic input]
_elementtree.XMLParser._setevents
- events_queue: object(subclass_of='&PyList_Type')
+ events_queue: object
events_to_report: object = None
/
@@ -3598,12 +3575,12 @@
_elementtree_XMLParser__setevents_impl(XMLParserObject *self,
PyObject *events_queue,
PyObject *events_to_report)
-/*[clinic end generated code: output=1440092922b13ed1 input=59db9742910c6174]*/
+/*[clinic end generated code: output=1440092922b13ed1 input=abf90830a1c3b0fc]*/
{
/* activate element event reporting */
Py_ssize_t i;
TreeBuilderObject *target;
- PyObject *events_seq;
+ PyObject *events_append, *events_seq;
if (!TreeBuilder_CheckExact(self->target)) {
PyErr_SetString(
@@ -3616,8 +3593,10 @@
target = (TreeBuilderObject*) self->target;
- Py_INCREF(events_queue);
- Py_XSETREF(target->events, events_queue);
+ events_append = PyObject_GetAttrString(events_queue, "append");
+ if (events_append == NULL)
+ return NULL;
+ Py_XSETREF(target->events_append, events_append);
/* clear out existing events */
Py_CLEAR(target->start_event_obj);
@@ -3750,6 +3729,26 @@
(objobjargproc) element_ass_subscr,
};
+static PyGetSetDef element_getsetlist[] = {
+ {"tag",
+ (getter)element_tag_getter,
+ (setter)element_tag_setter,
+ "A string identifying what kind of data this element represents"},
+ {"text",
+ (getter)element_text_getter,
+ (setter)element_text_setter,
+ "A string of text directly after the start tag, or None"},
+ {"tail",
+ (getter)element_tail_getter,
+ (setter)element_tail_setter,
+ "A string of text directly after the end tag, or None"},
+ {"attrib",
+ (getter)element_attrib_getter,
+ (setter)element_attrib_setter,
+ "A dictionary containing the element's attributes"},
+ {NULL},
+};
+
static PyTypeObject Element_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
"xml.etree.ElementTree.Element", sizeof(ElementObject), 0,
@@ -3766,8 +3765,8 @@
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
- (getattrofunc)element_getattro, /* tp_getattro */
- (setattrofunc)element_setattro, /* tp_setattro */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ 0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
/* tp_flags */
@@ -3780,7 +3779,7 @@
0, /* tp_iternext */
element_methods, /* tp_methods */
0, /* tp_members */
- 0, /* tp_getset */
+ element_getsetlist, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
diff --git a/Modules/_gdbmmodule.c b/Modules/_gdbmmodule.c
index f070a14..bf7b036 100644
--- a/Modules/_gdbmmodule.c
+++ b/Modules/_gdbmmodule.c
@@ -615,7 +615,7 @@
return newdbmobject(name, iflags, mode);
}
-static char dbmmodule_open_flags[] = "rwcn"
+static const char dbmmodule_open_flags[] = "rwcn"
#ifdef GDBM_FAST
"f"
#endif
diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c
index 136abf5..b499e1f 100644
--- a/Modules/_heapqmodule.c
+++ b/Modules/_heapqmodule.c
@@ -66,7 +66,7 @@
/* Bubble up the smaller child until hitting a leaf. */
arr = _PyList_ITEMS(heap);
- limit = endpos / 2; /* smallest pos that has no child */
+ limit = endpos >> 1; /* smallest pos that has no child */
while (pos < limit) {
/* Set childpos to index of smaller child. */
childpos = 2*pos + 1; /* leftmost child position */
@@ -78,6 +78,7 @@
if (cmp < 0)
return -1;
childpos += ((unsigned)cmp ^ 1); /* increment when cmp==0 */
+ arr = _PyList_ITEMS(heap); /* arr may have changed */
if (endpos != PyList_GET_SIZE(heap)) {
PyErr_SetString(PyExc_RuntimeError,
"list changed size during iteration");
@@ -85,7 +86,6 @@
}
}
/* Move the smaller child up. */
- arr = _PyList_ITEMS(heap);
tmp1 = arr[childpos];
tmp2 = arr[pos];
arr[childpos] = tmp2;
@@ -347,7 +347,7 @@
n is odd = 2*j+1, this is (2*j+1-1)/2 = j so j-1 is the largest,
and that's again n//2-1.
*/
- for (i = n/2 - 1 ; i >= 0 ; i--)
+ for (i = (n >> 1) - 1 ; i >= 0 ; i--)
if (siftup_func((PyListObject *)heap, i))
return NULL;
Py_RETURN_NONE;
@@ -420,7 +420,7 @@
/* Bubble up the smaller child until hitting a leaf. */
arr = _PyList_ITEMS(heap);
- limit = endpos / 2; /* smallest pos that has no child */
+ limit = endpos >> 1; /* smallest pos that has no child */
while (pos < limit) {
/* Set childpos to index of smaller child. */
childpos = 2*pos + 1; /* leftmost child position */
@@ -432,6 +432,7 @@
if (cmp < 0)
return -1;
childpos += ((unsigned)cmp ^ 1); /* increment when cmp==0 */
+ arr = _PyList_ITEMS(heap); /* arr may have changed */
if (endpos != PyList_GET_SIZE(heap)) {
PyErr_SetString(PyExc_RuntimeError,
"list changed size during iteration");
@@ -439,7 +440,6 @@
}
}
/* Move the smaller child up. */
- arr = _PyList_ITEMS(heap);
tmp1 = arr[childpos];
tmp2 = arr[pos];
arr[childpos] = tmp2;
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c
index ec68170..85b1813 100644
--- a/Modules/_io/_iomodule.c
+++ b/Modules/_io/_iomodule.c
@@ -238,20 +238,33 @@
int text = 0, binary = 0, universal = 0;
char rawmode[6], *m;
- int line_buffering, isatty;
+ int line_buffering, is_number;
+ long isatty;
- PyObject *raw, *modeobj = NULL, *buffer, *wrapper, *result = NULL;
+ PyObject *raw, *modeobj = NULL, *buffer, *wrapper, *result = NULL, *path_or_fd = NULL;
_Py_IDENTIFIER(_blksize);
_Py_IDENTIFIER(isatty);
_Py_IDENTIFIER(mode);
_Py_IDENTIFIER(close);
- if (!PyUnicode_Check(file) &&
- !PyBytes_Check(file) &&
- !PyNumber_Check(file)) {
+ is_number = PyNumber_Check(file);
+
+ if (is_number) {
+ path_or_fd = file;
+ Py_INCREF(path_or_fd);
+ } else {
+ path_or_fd = PyOS_FSPath(file);
+ if (path_or_fd == NULL) {
+ return NULL;
+ }
+ }
+
+ if (!is_number &&
+ !PyUnicode_Check(path_or_fd) &&
+ !PyBytes_Check(path_or_fd)) {
PyErr_Format(PyExc_TypeError, "invalid file: %R", file);
- return NULL;
+ goto error;
}
/* Decode mode */
@@ -292,7 +305,7 @@
if (strchr(mode+i+1, c)) {
invalid_mode:
PyErr_Format(PyExc_ValueError, "invalid mode: '%s'", mode);
- return NULL;
+ goto error;
}
}
@@ -307,54 +320,57 @@
/* Parameters validation */
if (universal) {
- if (writing || appending) {
+ if (creating || writing || appending || updating) {
PyErr_SetString(PyExc_ValueError,
- "can't use U and writing mode at once");
- return NULL;
+ "mode U cannot be combined with x', 'w', 'a', or '+'");
+ goto error;
}
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"'U' mode is deprecated", 1) < 0)
- return NULL;
+ goto error;
reading = 1;
}
if (text && binary) {
PyErr_SetString(PyExc_ValueError,
"can't have text and binary mode at once");
- return NULL;
+ goto error;
}
if (creating + reading + writing + appending > 1) {
PyErr_SetString(PyExc_ValueError,
"must have exactly one of create/read/write/append mode");
- return NULL;
+ goto error;
}
if (binary && encoding != NULL) {
PyErr_SetString(PyExc_ValueError,
"binary mode doesn't take an encoding argument");
- return NULL;
+ goto error;
}
if (binary && errors != NULL) {
PyErr_SetString(PyExc_ValueError,
"binary mode doesn't take an errors argument");
- return NULL;
+ goto error;
}
if (binary && newline != NULL) {
PyErr_SetString(PyExc_ValueError,
"binary mode doesn't take a newline argument");
- return NULL;
+ goto error;
}
/* Create the Raw file stream */
raw = PyObject_CallFunction((PyObject *)&PyFileIO_Type,
- "OsiO", file, rawmode, closefd, opener);
+ "OsiO", path_or_fd, rawmode, closefd, opener);
if (raw == NULL)
- return NULL;
+ goto error;
result = raw;
+ Py_DECREF(path_or_fd);
+ path_or_fd = NULL;
+
modeobj = PyUnicode_FromString(mode);
if (modeobj == NULL)
goto error;
@@ -437,10 +453,10 @@
/* wraps into a TextIOWrapper */
wrapper = PyObject_CallFunction((PyObject *)&PyTextIOWrapper_Type,
- "Osssi",
- buffer,
- encoding, errors, newline,
- line_buffering);
+ "Osssi",
+ buffer,
+ encoding, errors, newline,
+ line_buffering);
if (wrapper == NULL)
goto error;
result = wrapper;
@@ -460,6 +476,7 @@
Py_XDECREF(close_result);
Py_DECREF(result);
}
+ Py_XDECREF(path_or_fd);
Py_XDECREF(modeobj);
return NULL;
}
diff --git a/Modules/_io/_iomodule.h b/Modules/_io/_iomodule.h
index 0c6eae2..3c48ff3 100644
--- a/Modules/_io/_iomodule.h
+++ b/Modules/_io/_iomodule.h
@@ -60,7 +60,7 @@
* Otherwise, the line ending is specified by readnl, a str object */
extern Py_ssize_t _PyIO_find_line_ending(
int translated, int universal, PyObject *readnl,
- int kind, char *start, char *end, Py_ssize_t *consumed);
+ int kind, const char *start, const char *end, Py_ssize_t *consumed);
/* Return 1 if an EnvironmentError with errno == EINTR is set (and then
clears the error indicator), 0 otherwise.
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index 6d67751..cbe7425 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -659,7 +659,7 @@
/* Sets the current error to BlockingIOError */
static void
-_set_BlockingIOError(char *msg, Py_ssize_t written)
+_set_BlockingIOError(const char *msg, Py_ssize_t written)
{
PyObject *err;
PyErr_Clear();
diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c
index 9e5d78b..a1ba121 100644
--- a/Modules/_io/bytesio.c
+++ b/Modules/_io/bytesio.c
@@ -87,7 +87,7 @@
static int
unshare_buffer(bytesio *self, size_t size)
{
- PyObject *new_buf, *old_buf;
+ PyObject *new_buf;
assert(SHARED_BUF(self));
assert(self->exports == 0);
assert(size >= (size_t)self->string_size);
@@ -96,9 +96,7 @@
return -1;
memcpy(PyBytes_AS_STRING(new_buf), PyBytes_AS_STRING(self->buf),
self->string_size);
- old_buf = self->buf;
- self->buf = new_buf;
- Py_DECREF(old_buf);
+ Py_SETREF(self->buf, new_buf);
return 0;
}
diff --git a/Modules/_io/clinic/_iomodule.c.h b/Modules/_io/clinic/_iomodule.c.h
index a3abb93..6dcfc08 100644
--- a/Modules/_io/clinic/_iomodule.c.h
+++ b/Modules/_io/clinic/_iomodule.c.h
@@ -149,11 +149,12 @@
PyObject *opener = Py_None;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|sizzziO:open", _keywords,
- &file, &mode, &buffering, &encoding, &errors, &newline, &closefd, &opener))
+ &file, &mode, &buffering, &encoding, &errors, &newline, &closefd, &opener)) {
goto exit;
+ }
return_value = _io_open_impl(module, file, mode, buffering, encoding, errors, newline, closefd, opener);
exit:
return return_value;
}
-/*[clinic end generated code: output=97cdc09bf68a8064 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=079f597e71e9f0c6 input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/bufferedio.c.h b/Modules/_io/clinic/bufferedio.c.h
index 437e275..c4dfc16 100644
--- a/Modules/_io/clinic/bufferedio.c.h
+++ b/Modules/_io/clinic/bufferedio.c.h
@@ -19,14 +19,16 @@
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
- if (!PyArg_Parse(arg, "w*:readinto", &buffer))
+ if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
goto exit;
+ }
return_value = _io__BufferedIOBase_readinto_impl(self, &buffer);
exit:
/* Cleanup for buffer */
- if (buffer.obj)
+ if (buffer.obj) {
PyBuffer_Release(&buffer);
+ }
return return_value;
}
@@ -48,14 +50,16 @@
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
- if (!PyArg_Parse(arg, "w*:readinto1", &buffer))
+ if (!PyArg_Parse(arg, "w*:readinto1", &buffer)) {
goto exit;
+ }
return_value = _io__BufferedIOBase_readinto1_impl(self, &buffer);
exit:
/* Cleanup for buffer */
- if (buffer.obj)
+ if (buffer.obj) {
PyBuffer_Release(&buffer);
+ }
return return_value;
}
@@ -99,8 +103,9 @@
Py_ssize_t size = 0;
if (!PyArg_ParseTuple(args, "|n:peek",
- &size))
+ &size)) {
goto exit;
+ }
return_value = _io__Buffered_peek_impl(self, size);
exit:
@@ -125,8 +130,9 @@
Py_ssize_t n = -1;
if (!PyArg_ParseTuple(args, "|O&:read",
- _PyIO_ConvertSsize_t, &n))
+ _PyIO_ConvertSsize_t, &n)) {
goto exit;
+ }
return_value = _io__Buffered_read_impl(self, n);
exit:
@@ -150,8 +156,9 @@
PyObject *return_value = NULL;
Py_ssize_t n;
- if (!PyArg_Parse(arg, "n:read1", &n))
+ if (!PyArg_Parse(arg, "n:read1", &n)) {
goto exit;
+ }
return_value = _io__Buffered_read1_impl(self, n);
exit:
@@ -175,14 +182,16 @@
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
- if (!PyArg_Parse(arg, "w*:readinto", &buffer))
+ if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
goto exit;
+ }
return_value = _io__Buffered_readinto_impl(self, &buffer);
exit:
/* Cleanup for buffer */
- if (buffer.obj)
+ if (buffer.obj) {
PyBuffer_Release(&buffer);
+ }
return return_value;
}
@@ -204,14 +213,16 @@
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
- if (!PyArg_Parse(arg, "w*:readinto1", &buffer))
+ if (!PyArg_Parse(arg, "w*:readinto1", &buffer)) {
goto exit;
+ }
return_value = _io__Buffered_readinto1_impl(self, &buffer);
exit:
/* Cleanup for buffer */
- if (buffer.obj)
+ if (buffer.obj) {
PyBuffer_Release(&buffer);
+ }
return return_value;
}
@@ -234,8 +245,9 @@
Py_ssize_t size = -1;
if (!PyArg_ParseTuple(args, "|O&:readline",
- _PyIO_ConvertSsize_t, &size))
+ _PyIO_ConvertSsize_t, &size)) {
goto exit;
+ }
return_value = _io__Buffered_readline_impl(self, size);
exit:
@@ -261,8 +273,9 @@
int whence = 0;
if (!PyArg_ParseTuple(args, "O|i:seek",
- &targetobj, &whence))
+ &targetobj, &whence)) {
goto exit;
+ }
return_value = _io__Buffered_seek_impl(self, targetobj, whence);
exit:
@@ -288,8 +301,9 @@
if (!PyArg_UnpackTuple(args, "truncate",
0, 1,
- &pos))
+ &pos)) {
goto exit;
+ }
return_value = _io__Buffered_truncate_impl(self, pos);
exit:
@@ -315,8 +329,9 @@
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|n:BufferedReader", _keywords,
- &raw, &buffer_size))
+ &raw, &buffer_size)) {
goto exit;
+ }
return_value = _io_BufferedReader___init___impl((buffered *)self, raw, buffer_size);
exit:
@@ -346,8 +361,9 @@
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|n:BufferedWriter", _keywords,
- &raw, &buffer_size))
+ &raw, &buffer_size)) {
goto exit;
+ }
return_value = _io_BufferedWriter___init___impl((buffered *)self, raw, buffer_size);
exit:
@@ -371,14 +387,16 @@
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:write", &buffer))
+ if (!PyArg_Parse(arg, "y*:write", &buffer)) {
goto exit;
+ }
return_value = _io_BufferedWriter_write_impl(self, &buffer);
exit:
/* Cleanup for buffer */
- if (buffer.obj)
+ if (buffer.obj) {
PyBuffer_Release(&buffer);
+ }
return return_value;
}
@@ -410,11 +428,13 @@
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
if ((Py_TYPE(self) == &PyBufferedRWPair_Type) &&
- !_PyArg_NoKeywords("BufferedRWPair", kwargs))
+ !_PyArg_NoKeywords("BufferedRWPair", kwargs)) {
goto exit;
+ }
if (!PyArg_ParseTuple(args, "OO|n:BufferedRWPair",
- &reader, &writer, &buffer_size))
+ &reader, &writer, &buffer_size)) {
goto exit;
+ }
return_value = _io_BufferedRWPair___init___impl((rwpair *)self, reader, writer, buffer_size);
exit:
@@ -444,11 +464,12 @@
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|n:BufferedRandom", _keywords,
- &raw, &buffer_size))
+ &raw, &buffer_size)) {
goto exit;
+ }
return_value = _io_BufferedRandom___init___impl((buffered *)self, raw, buffer_size);
exit:
return return_value;
}
-/*[clinic end generated code: output=2bbb5e239b4ffe6f input=a9049054013a1b77]*/
+/*[clinic end generated code: output=4f6196c756b880c8 input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/bytesio.c.h b/Modules/_io/clinic/bytesio.c.h
index 5f2abb0..1f736fe 100644
--- a/Modules/_io/clinic/bytesio.c.h
+++ b/Modules/_io/clinic/bytesio.c.h
@@ -171,8 +171,9 @@
if (!PyArg_UnpackTuple(args, "read",
0, 1,
- &arg))
+ &arg)) {
goto exit;
+ }
return_value = _io_BytesIO_read_impl(self, arg);
exit:
@@ -215,8 +216,9 @@
if (!PyArg_UnpackTuple(args, "readline",
0, 1,
- &arg))
+ &arg)) {
goto exit;
+ }
return_value = _io_BytesIO_readline_impl(self, arg);
exit:
@@ -247,8 +249,9 @@
if (!PyArg_UnpackTuple(args, "readlines",
0, 1,
- &arg))
+ &arg)) {
goto exit;
+ }
return_value = _io_BytesIO_readlines_impl(self, arg);
exit:
@@ -276,14 +279,16 @@
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
- if (!PyArg_Parse(arg, "w*:readinto", &buffer))
+ if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
goto exit;
+ }
return_value = _io_BytesIO_readinto_impl(self, &buffer);
exit:
/* Cleanup for buffer */
- if (buffer.obj)
+ if (buffer.obj) {
PyBuffer_Release(&buffer);
+ }
return return_value;
}
@@ -311,8 +316,9 @@
if (!PyArg_UnpackTuple(args, "truncate",
0, 1,
- &arg))
+ &arg)) {
goto exit;
+ }
return_value = _io_BytesIO_truncate_impl(self, arg);
exit:
@@ -345,8 +351,9 @@
int whence = 0;
if (!PyArg_ParseTuple(args, "n|i:seek",
- &pos, &whence))
+ &pos, &whence)) {
goto exit;
+ }
return_value = _io_BytesIO_seek_impl(self, pos, whence);
exit:
@@ -412,11 +419,12 @@
PyObject *initvalue = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:BytesIO", _keywords,
- &initvalue))
+ &initvalue)) {
goto exit;
+ }
return_value = _io_BytesIO___init___impl((bytesio *)self, initvalue);
exit:
return return_value;
}
-/*[clinic end generated code: output=60ce2c6272718431 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=3fdb62f3e3b0544d input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/fileio.c.h b/Modules/_io/clinic/fileio.c.h
index 1042008..038836a 100644
--- a/Modules/_io/clinic/fileio.c.h
+++ b/Modules/_io/clinic/fileio.c.h
@@ -56,8 +56,9 @@
PyObject *opener = Py_None;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|siO:FileIO", _keywords,
- &nameobj, &mode, &closefd, &opener))
+ &nameobj, &mode, &closefd, &opener)) {
goto exit;
+ }
return_value = _io_FileIO___init___impl((fileio *)self, nameobj, mode, closefd, opener);
exit:
@@ -154,14 +155,16 @@
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
- if (!PyArg_Parse(arg, "w*:readinto", &buffer))
+ if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
goto exit;
+ }
return_value = _io_FileIO_readinto_impl(self, &buffer);
exit:
/* Cleanup for buffer */
- if (buffer.obj)
+ if (buffer.obj) {
PyBuffer_Release(&buffer);
+ }
return return_value;
}
@@ -210,8 +213,9 @@
Py_ssize_t size = -1;
if (!PyArg_ParseTuple(args, "|O&:read",
- _PyIO_ConvertSsize_t, &size))
+ _PyIO_ConvertSsize_t, &size)) {
goto exit;
+ }
return_value = _io_FileIO_read_impl(self, size);
exit:
@@ -240,14 +244,16 @@
PyObject *return_value = NULL;
Py_buffer b = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:write", &b))
+ if (!PyArg_Parse(arg, "y*:write", &b)) {
goto exit;
+ }
return_value = _io_FileIO_write_impl(self, &b);
exit:
/* Cleanup for b */
- if (b.obj)
+ if (b.obj) {
PyBuffer_Release(&b);
+ }
return return_value;
}
@@ -280,8 +286,9 @@
int whence = 0;
if (!PyArg_ParseTuple(args, "O|i:seek",
- &pos, &whence))
+ &pos, &whence)) {
goto exit;
+ }
return_value = _io_FileIO_seek_impl(self, pos, whence);
exit:
@@ -333,8 +340,9 @@
if (!PyArg_UnpackTuple(args, "truncate",
0, 1,
- &posobj))
+ &posobj)) {
goto exit;
+ }
return_value = _io_FileIO_truncate_impl(self, posobj);
exit:
@@ -364,4 +372,4 @@
#ifndef _IO_FILEIO_TRUNCATE_METHODDEF
#define _IO_FILEIO_TRUNCATE_METHODDEF
#endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */
-/*[clinic end generated code: output=dcbc39b466598492 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=bf4b4bd6b976346d input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/iobase.c.h b/Modules/_io/clinic/iobase.c.h
index 9762f11..edbf73a 100644
--- a/Modules/_io/clinic/iobase.c.h
+++ b/Modules/_io/clinic/iobase.c.h
@@ -186,8 +186,9 @@
Py_ssize_t limit = -1;
if (!PyArg_ParseTuple(args, "|O&:readline",
- _PyIO_ConvertSsize_t, &limit))
+ _PyIO_ConvertSsize_t, &limit)) {
goto exit;
+ }
return_value = _io__IOBase_readline_impl(self, limit);
exit:
@@ -217,8 +218,9 @@
Py_ssize_t hint = -1;
if (!PyArg_ParseTuple(args, "|O&:readlines",
- _PyIO_ConvertSsize_t, &hint))
+ _PyIO_ConvertSsize_t, &hint)) {
goto exit;
+ }
return_value = _io__IOBase_readlines_impl(self, hint);
exit:
@@ -251,8 +253,9 @@
Py_ssize_t n = -1;
if (!PyArg_ParseTuple(args, "|n:read",
- &n))
+ &n)) {
goto exit;
+ }
return_value = _io__RawIOBase_read_impl(self, n);
exit:
@@ -276,4 +279,4 @@
{
return _io__RawIOBase_readall_impl(self);
}
-/*[clinic end generated code: output=b874952f5cc248a4 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=0f53fed928d8e02f input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/stringio.c.h b/Modules/_io/clinic/stringio.c.h
index a8e32a3..ce9f46e 100644
--- a/Modules/_io/clinic/stringio.c.h
+++ b/Modules/_io/clinic/stringio.c.h
@@ -61,8 +61,9 @@
if (!PyArg_UnpackTuple(args, "read",
0, 1,
- &arg))
+ &arg)) {
goto exit;
+ }
return_value = _io_StringIO_read_impl(self, arg);
exit:
@@ -91,8 +92,9 @@
if (!PyArg_UnpackTuple(args, "readline",
0, 1,
- &arg))
+ &arg)) {
goto exit;
+ }
return_value = _io_StringIO_readline_impl(self, arg);
exit:
@@ -123,8 +125,9 @@
if (!PyArg_UnpackTuple(args, "truncate",
0, 1,
- &arg))
+ &arg)) {
goto exit;
+ }
return_value = _io_StringIO_truncate_impl(self, arg);
exit:
@@ -157,8 +160,9 @@
int whence = 0;
if (!PyArg_ParseTuple(args, "n|i:seek",
- &pos, &whence))
+ &pos, &whence)) {
goto exit;
+ }
return_value = _io_StringIO_seek_impl(self, pos, whence);
exit:
@@ -222,8 +226,9 @@
PyObject *newline_obj = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:StringIO", _keywords,
- &value, &newline_obj))
+ &value, &newline_obj)) {
goto exit;
+ }
return_value = _io_StringIO___init___impl((stringio *)self, value, newline_obj);
exit:
@@ -283,4 +288,4 @@
{
return _io_StringIO_seekable_impl(self);
}
-/*[clinic end generated code: output=f061cf3a20cd14ed input=a9049054013a1b77]*/
+/*[clinic end generated code: output=0513219581cbe952 input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/textio.c.h b/Modules/_io/clinic/textio.c.h
index dc7e8c7..f115326 100644
--- a/Modules/_io/clinic/textio.c.h
+++ b/Modules/_io/clinic/textio.c.h
@@ -30,8 +30,9 @@
PyObject *errors = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oi|O:IncrementalNewlineDecoder", _keywords,
- &decoder, &translate, &errors))
+ &decoder, &translate, &errors)) {
goto exit;
+ }
return_value = _io_IncrementalNewlineDecoder___init___impl((nldecoder_object *)self, decoder, translate, errors);
exit:
@@ -59,8 +60,9 @@
int final = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i:decode", _keywords,
- &input, &final))
+ &input, &final)) {
goto exit;
+ }
return_value = _io_IncrementalNewlineDecoder_decode_impl(self, input, final);
exit:
@@ -162,8 +164,9 @@
int write_through = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|zzzii:TextIOWrapper", _keywords,
- &buffer, &encoding, &errors, &newline, &line_buffering, &write_through))
+ &buffer, &encoding, &errors, &newline, &line_buffering, &write_through)) {
goto exit;
+ }
return_value = _io_TextIOWrapper___init___impl((textio *)self, buffer, encoding, errors, newline, line_buffering, write_through);
exit:
@@ -204,8 +207,9 @@
PyObject *return_value = NULL;
PyObject *text;
- if (!PyArg_Parse(arg, "U:write", &text))
+ if (!PyArg_Parse(arg, "U:write", &text)) {
goto exit;
+ }
return_value = _io_TextIOWrapper_write_impl(self, text);
exit:
@@ -230,8 +234,9 @@
Py_ssize_t n = -1;
if (!PyArg_ParseTuple(args, "|O&:read",
- _PyIO_ConvertSsize_t, &n))
+ _PyIO_ConvertSsize_t, &n)) {
goto exit;
+ }
return_value = _io_TextIOWrapper_read_impl(self, n);
exit:
@@ -256,8 +261,9 @@
Py_ssize_t size = -1;
if (!PyArg_ParseTuple(args, "|n:readline",
- &size))
+ &size)) {
goto exit;
+ }
return_value = _io_TextIOWrapper_readline_impl(self, size);
exit:
@@ -283,8 +289,9 @@
int whence = 0;
if (!PyArg_ParseTuple(args, "O|i:seek",
- &cookieObj, &whence))
+ &cookieObj, &whence)) {
goto exit;
+ }
return_value = _io_TextIOWrapper_seek_impl(self, cookieObj, whence);
exit:
@@ -327,8 +334,9 @@
if (!PyArg_UnpackTuple(args, "truncate",
0, 1,
- &pos))
+ &pos)) {
goto exit;
+ }
return_value = _io_TextIOWrapper_truncate_impl(self, pos);
exit:
@@ -453,4 +461,4 @@
{
return _io_TextIOWrapper_close_impl(self);
}
-/*[clinic end generated code: output=690608f85aab8ba5 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=31a39bbbe07ae4e7 input=a9049054013a1b77]*/
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index 919cf50..12e5156 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -92,8 +92,7 @@
if (self->fd >= 0 && self->closefd) {
PyObject *exc, *val, *tb;
PyErr_Fetch(&exc, &val, &tb);
- if (PyErr_WarnFormat(PyExc_ResourceWarning, 1,
- "unclosed file %R", source)) {
+ if (PyErr_ResourceWarning(source, 1, "unclosed file %R", source)) {
/* Spurious errors can appear at shutdown */
if (PyErr_ExceptionMatches(PyExc_Warning))
PyErr_WriteUnraisable((PyObject *) self);
@@ -546,7 +545,7 @@
}
static PyObject *
-err_mode(char *action)
+err_mode(const char *action)
{
_PyIO_State *state = IO_STATE();
if (state != NULL)
@@ -1049,7 +1048,7 @@
}
#endif /* HAVE_FTRUNCATE */
-static char *
+static const char *
mode_string(fileio *self)
{
if (self->created) {
diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c
index 212b0dd..f07a0ca 100644
--- a/Modules/_io/iobase.c
+++ b/Modules/_io/iobase.c
@@ -828,7 +828,7 @@
0, /* tp_weaklist */
0, /* tp_del */
0, /* tp_version_tag */
- (destructor)iobase_finalize, /* tp_finalize */
+ iobase_finalize, /* tp_finalize */
};
diff --git a/Modules/_io/stringio.c b/Modules/_io/stringio.c
index 06b4144..ecf6dc1 100644
--- a/Modules/_io/stringio.c
+++ b/Modules/_io/stringio.c
@@ -438,7 +438,7 @@
_PyIO_str_readline, NULL);
if (line && !PyUnicode_Check(line)) {
PyErr_Format(PyExc_IOError,
- "readline() should have returned an str object, "
+ "readline() should have returned a str object, "
"not '%.200s'", Py_TYPE(line)->tp_name);
Py_DECREF(line);
return NULL;
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index 063caa6..96c8e7b 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -772,7 +772,7 @@
encodefunc_t encodefunc;
} encodefuncentry;
-static encodefuncentry encodefuncs[] = {
+static const encodefuncentry encodefuncs[] = {
{"ascii", (encodefunc_t) ascii_encode},
{"iso8859-1", (encodefunc_t) latin1_encode},
{"utf-8", (encodefunc_t) utf8_encode},
@@ -1021,7 +1021,7 @@
goto error;
}
else if (PyUnicode_Check(res)) {
- encodefuncentry *e = encodefuncs;
+ const encodefuncentry *e = encodefuncs;
while (e->name != NULL) {
if (!PyUnicode_CompareWithASCIIString(res, e->name)) {
self->encodefunc = e->encodefunc;
@@ -1644,8 +1644,8 @@
/* NOTE: `end` must point to the real end of the Py_UCS4 storage,
that is to the NUL character. Otherwise the function will produce
incorrect results. */
-static char *
-find_control_char(int kind, char *s, char *end, Py_UCS4 ch)
+static const char *
+find_control_char(int kind, const char *s, const char *end, Py_UCS4 ch)
{
if (kind == PyUnicode_1BYTE_KIND) {
assert(ch < 256);
@@ -1665,13 +1665,13 @@
Py_ssize_t
_PyIO_find_line_ending(
int translated, int universal, PyObject *readnl,
- int kind, char *start, char *end, Py_ssize_t *consumed)
+ int kind, const char *start, const char *end, Py_ssize_t *consumed)
{
Py_ssize_t len = ((char*)end - (char*)start)/kind;
if (translated) {
/* Newlines are already translated, only search for \n */
- char *pos = find_control_char(kind, start, end, '\n');
+ const char *pos = find_control_char(kind, start, end, '\n');
if (pos != NULL)
return (pos - start)/kind + 1;
else {
@@ -1683,7 +1683,7 @@
/* Universal newline search. Find any of \r, \r\n, \n
* The decoder ensures that \r\n are not split in two pieces
*/
- char *s = start;
+ const char *s = start;
for (;;) {
Py_UCS4 ch;
/* Fast path for non-control chars. The loop always ends
@@ -1713,21 +1713,21 @@
/* Assume that readnl is an ASCII character. */
assert(PyUnicode_KIND(readnl) == PyUnicode_1BYTE_KIND);
if (readnl_len == 1) {
- char *pos = find_control_char(kind, start, end, nl[0]);
+ const char *pos = find_control_char(kind, start, end, nl[0]);
if (pos != NULL)
return (pos - start)/kind + 1;
*consumed = len;
return -1;
}
else {
- char *s = start;
- char *e = end - (readnl_len - 1)*kind;
- char *pos;
+ const char *s = start;
+ const char *e = end - (readnl_len - 1)*kind;
+ const char *pos;
if (e < s)
e = s;
while (s < e) {
Py_ssize_t i;
- char *pos = find_control_char(kind, s, end, nl[0]);
+ const char *pos = find_control_char(kind, s, end, nl[0]);
if (pos == NULL || pos >= e)
break;
for (i = 1; i < readnl_len; i++) {
@@ -2689,7 +2689,7 @@
_PyIO_str_readline, NULL);
if (line && !PyUnicode_Check(line)) {
PyErr_Format(PyExc_IOError,
- "readline() should have returned an str object, "
+ "readline() should have returned a str object, "
"not '%.200s'", Py_TYPE(line)->tp_name);
Py_DECREF(line);
return NULL;
diff --git a/Modules/_json.c b/Modules/_json.c
index f82af34..d3dbf98 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -112,7 +112,7 @@
static PyObject *
_encoded_const(PyObject *obj);
static void
-raise_errmsg(char *msg, PyObject *s, Py_ssize_t end);
+raise_errmsg(const char *msg, PyObject *s, Py_ssize_t end);
static PyObject *
encoder_encode_string(PyEncoderObject *s, PyObject *obj);
static PyObject *
@@ -321,7 +321,7 @@
}
static void
-raise_errmsg(char *msg, PyObject *s, Py_ssize_t end)
+raise_errmsg(const char *msg, PyObject *s, Py_ssize_t end)
{
/* Use JSONDecodeError exception to raise a nice looking ValueError subclass */
static PyObject *JSONDecodeError = NULL;
diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c
index b1d6add..a92fb10 100644
--- a/Modules/_localemodule.c
+++ b/Modules/_localemodule.c
@@ -49,7 +49,7 @@
/* the grouping is terminated by either 0 or CHAR_MAX */
static PyObject*
-copy_grouping(char* s)
+copy_grouping(const char* s)
{
int i;
PyObject *result, *val = NULL;
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c
index 66e534f..ccfb513 100644
--- a/Modules/_lsprof.c
+++ b/Modules/_lsprof.c
@@ -762,7 +762,6 @@
static int
profiler_init(ProfilerObject *pObj, PyObject *args, PyObject *kw)
{
- PyObject *o;
PyObject *timer = NULL;
double timeunit = 0.0;
int subcalls = 1;
@@ -777,11 +776,9 @@
if (setSubcalls(pObj, subcalls) < 0 || setBuiltins(pObj, builtins) < 0)
return -1;
- o = pObj->externalTimer;
- pObj->externalTimer = timer;
- Py_XINCREF(timer);
- Py_XDECREF(o);
pObj->externalTimerUnit = timeunit;
+ Py_XINCREF(timer);
+ Py_XSETREF(pObj->externalTimer, timer);
return 0;
}
diff --git a/Modules/_lzmamodule.c b/Modules/_lzmamodule.c
index 846dc0e..526dcef 100644
--- a/Modules/_lzmamodule.c
+++ b/Modules/_lzmamodule.c
@@ -553,7 +553,6 @@
/*[clinic input]
_lzma.LZMACompressor.compress
- self: self(type="Compressor *")
data: Py_buffer
/
@@ -567,7 +566,7 @@
static PyObject *
_lzma_LZMACompressor_compress_impl(Compressor *self, Py_buffer *data)
-/*[clinic end generated code: output=31f615136963e00f input=8b60cb13e0ce6420]*/
+/*[clinic end generated code: output=31f615136963e00f input=64019eac7f2cc8d0]*/
{
PyObject *result = NULL;
@@ -583,8 +582,6 @@
/*[clinic input]
_lzma.LZMACompressor.flush
- self: self(type="Compressor *")
-
Finish the compression process.
Returns the compressed data left in internal buffers.
@@ -594,7 +591,7 @@
static PyObject *
_lzma_LZMACompressor_flush_impl(Compressor *self)
-/*[clinic end generated code: output=fec21f3e22504f50 input=3060fb26f9b4042c]*/
+/*[clinic end generated code: output=fec21f3e22504f50 input=6b369303f67ad0a8]*/
{
PyObject *result = NULL;
@@ -698,7 +695,6 @@
/*[-clinic input]
_lzma.LZMACompressor.__init__
- self: self(type="Compressor *")
format: int(c_default="FORMAT_XZ") = FORMAT_XZ
The container format to use for the output. This can
be FORMAT_XZ (default), FORMAT_ALONE, or FORMAT_RAW.
@@ -1063,7 +1059,6 @@
/*[clinic input]
_lzma.LZMADecompressor.decompress
- self: self(type="Decompressor *")
data: Py_buffer
max_length: Py_ssize_t=-1
@@ -1086,7 +1081,7 @@
static PyObject *
_lzma_LZMADecompressor_decompress_impl(Decompressor *self, Py_buffer *data,
Py_ssize_t max_length)
-/*[clinic end generated code: output=ef4e20ec7122241d input=f2bb902cc1caf203]*/
+/*[clinic end generated code: output=ef4e20ec7122241d input=60c1f135820e309d]*/
{
PyObject *result = NULL;
@@ -1126,7 +1121,6 @@
/*[clinic input]
_lzma.LZMADecompressor.__init__
- self: self(type="Decompressor *")
format: int(c_default="FORMAT_AUTO") = FORMAT_AUTO
Specifies the container format of the input stream. If this is
FORMAT_AUTO (the default), the decompressor will automatically detect
@@ -1152,7 +1146,7 @@
static int
_lzma_LZMADecompressor___init___impl(Decompressor *self, int format,
PyObject *memlimit, PyObject *filters)
-/*[clinic end generated code: output=3e1821f8aa36564c input=458ca6132ef29801]*/
+/*[clinic end generated code: output=3e1821f8aa36564c input=81fe684a6c2f8a27]*/
{
const uint32_t decoder_flags = LZMA_TELL_ANY_CHECK | LZMA_TELL_NO_CHECK;
uint64_t memlimit_ = UINT64_MAX;
diff --git a/Modules/_multiprocessing/multiprocessing.c b/Modules/_multiprocessing/multiprocessing.c
index 4ae638e..d92a8bf 100644
--- a/Modules/_multiprocessing/multiprocessing.c
+++ b/Modules/_multiprocessing/multiprocessing.c
@@ -128,7 +128,7 @@
{"recv", multiprocessing_recv, METH_VARARGS, ""},
{"send", multiprocessing_send, METH_VARARGS, ""},
#endif
-#ifndef POSIX_SEMAPHORES_NOT_ENABLED
+#if !defined(POSIX_SEMAPHORES_NOT_ENABLED) && !defined(__ANDROID__)
{"sem_unlink", _PyMp_sem_unlink, METH_VARARGS, ""},
#endif
{NULL}
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index e52da37..7121ac8 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -153,6 +153,9 @@
PyObject *codecs_encode;
/* builtins.getattr, used for saving nested names with protocol < 4 */
PyObject *getattr;
+ /* functools.partial, used for implementing __newobj_ex__ with protocols
+ 2 and 3 */
+ PyObject *partial;
} PickleState;
/* Forward declaration of the _pickle module definition. */
@@ -190,6 +193,7 @@
Py_CLEAR(st->import_mapping_3to2);
Py_CLEAR(st->codecs_encode);
Py_CLEAR(st->getattr);
+ Py_CLEAR(st->partial);
}
/* Initialize the given pickle module state. */
@@ -200,6 +204,7 @@
PyObject *copyreg = NULL;
PyObject *compat_pickle = NULL;
PyObject *codecs = NULL;
+ PyObject *functools = NULL;
builtins = PyEval_GetBuiltins();
if (builtins == NULL)
@@ -314,12 +319,21 @@
}
Py_CLEAR(codecs);
+ functools = PyImport_ImportModule("functools");
+ if (!functools)
+ goto error;
+ st->partial = PyObject_GetAttrString(functools, "partial");
+ if (!st->partial)
+ goto error;
+ Py_CLEAR(functools);
+
return 0;
error:
Py_CLEAR(copyreg);
Py_CLEAR(compat_pickle);
Py_CLEAR(codecs);
+ Py_CLEAR(functools);
_Pickle_ClearState(st);
return -1;
}
@@ -356,18 +370,12 @@
/*************************************************************************/
-static int
-stack_underflow(void)
-{
- PickleState *st = _Pickle_GetGlobalState();
- PyErr_SetString(st->UnpicklingError, "unpickling stack underflow");
- return -1;
-}
-
/* Internal data type used as the unpickling stack. */
typedef struct {
PyObject_VAR_HEAD
PyObject **data;
+ int mark_set; /* is MARK set? */
+ Py_ssize_t fence; /* position of top MARK or 0 */
Py_ssize_t allocated; /* number of slots in data allocated */
} Pdata;
@@ -398,6 +406,8 @@
if (!(self = PyObject_New(Pdata, &Pdata_Type)))
return NULL;
Py_SIZE(self) = 0;
+ self->mark_set = 0;
+ self->fence = 0;
self->allocated = 8;
self->data = PyMem_MALLOC(self->allocated * sizeof(PyObject *));
if (self->data)
@@ -415,8 +425,7 @@
{
Py_ssize_t i = Py_SIZE(self);
- if (clearto < 0)
- return stack_underflow();
+ assert(clearto >= self->fence);
if (clearto >= i)
return 0;
@@ -452,6 +461,17 @@
return -1;
}
+static int
+Pdata_stack_underflow(Pdata *self)
+{
+ PickleState *st = _Pickle_GetGlobalState();
+ PyErr_SetString(st->UnpicklingError,
+ self->mark_set ?
+ "unexpected MARK found" :
+ "unpickling stack underflow");
+ return -1;
+}
+
/* D is a Pdata*. Pop the topmost element and store it into V, which
* must be an lvalue holding PyObject*. On stack underflow, UnpicklingError
* is raised and V is set to NULL.
@@ -459,9 +479,8 @@
static PyObject *
Pdata_pop(Pdata *self)
{
- if (Py_SIZE(self) == 0) {
- PickleState *st = _Pickle_GetGlobalState();
- PyErr_SetString(st->UnpicklingError, "bad pickle data");
+ if (Py_SIZE(self) <= self->fence) {
+ Pdata_stack_underflow(self);
return NULL;
}
return self->data[--Py_SIZE(self)];
@@ -493,6 +512,10 @@
PyObject *tuple;
Py_ssize_t len, i, j;
+ if (start < self->fence) {
+ Pdata_stack_underflow(self);
+ return NULL;
+ }
len = Py_SIZE(self) - start;
tuple = PyTuple_New(len);
if (tuple == NULL)
@@ -860,7 +883,7 @@
{
size_t i;
- assert(sizeof(size_t) <= 8);
+ Py_BUILD_ASSERT(sizeof(size_t) <= 8);
for (i = 0; i < sizeof(size_t); i++) {
out[i] = (unsigned char)((value >> (8 * i)) & 0xff);
@@ -1174,21 +1197,9 @@
return read_size;
}
-/* Read `n` bytes from the unpickler's data source, storing the result in `*s`.
-
- This should be used for all data reads, rather than accessing the unpickler's
- input buffer directly. This method deals correctly with reading from input
- streams, which the input buffer doesn't deal with.
-
- Note that when reading from a file-like object, self->next_read_idx won't
- be updated (it should remain at 0 for the entire unpickling process). You
- should use this function's return value to know how many bytes you can
- consume.
-
- Returns -1 (with an exception set) on failure. On success, return the
- number of chars read. */
+/* Don't call it directly: use _Unpickler_Read() */
static Py_ssize_t
-_Unpickler_Read(UnpicklerObject *self, char **s, Py_ssize_t n)
+_Unpickler_ReadImpl(UnpicklerObject *self, char **s, Py_ssize_t n)
{
Py_ssize_t num_read;
@@ -1199,11 +1210,10 @@
"read would overflow (invalid bytecode)");
return -1;
}
- if (self->next_read_idx + n <= self->input_len) {
- *s = self->input_buffer + self->next_read_idx;
- self->next_read_idx += n;
- return n;
- }
+
+ /* This case is handled by the _Unpickler_Read() macro for efficiency */
+ assert(self->next_read_idx + n > self->input_len);
+
if (!self->read) {
PyErr_Format(PyExc_EOFError, "Ran out of input");
return -1;
@@ -1220,6 +1230,26 @@
return n;
}
+/* Read `n` bytes from the unpickler's data source, storing the result in `*s`.
+
+ This should be used for all data reads, rather than accessing the unpickler's
+ input buffer directly. This method deals correctly with reading from input
+ streams, which the input buffer doesn't deal with.
+
+ Note that when reading from a file-like object, self->next_read_idx won't
+ be updated (it should remain at 0 for the entire unpickling process). You
+ should use this function's return value to know how many bytes you can
+ consume.
+
+ Returns -1 (with an exception set) on failure. On success, return the
+ number of chars read. */
+#define _Unpickler_Read(self, s, n) \
+ (((n) <= (self)->input_len - (self)->next_read_idx) \
+ ? (*(s) = (self)->input_buffer + (self)->next_read_idx, \
+ (self)->next_read_idx += (n), \
+ (n)) \
+ : _Unpickler_ReadImpl(self, (s), (n)))
+
static Py_ssize_t
_Unpickler_CopyLine(UnpicklerObject *self, char *line, Py_ssize_t len,
char **result)
@@ -2096,38 +2126,35 @@
static PyObject *
raw_unicode_escape(PyObject *obj)
{
- PyObject *repr;
char *p;
Py_ssize_t i, size;
- size_t expandsize;
void *data;
unsigned int kind;
+ _PyBytesWriter writer;
if (PyUnicode_READY(obj))
return NULL;
+ _PyBytesWriter_Init(&writer);
+
size = PyUnicode_GET_LENGTH(obj);
data = PyUnicode_DATA(obj);
kind = PyUnicode_KIND(obj);
- if (kind == PyUnicode_4BYTE_KIND)
- expandsize = 10;
- else
- expandsize = 6;
- if ((size_t)size > (size_t)PY_SSIZE_T_MAX / expandsize)
- return PyErr_NoMemory();
- repr = PyBytes_FromStringAndSize(NULL, expandsize * size);
- if (repr == NULL)
- return NULL;
- if (size == 0)
- return repr;
- assert(Py_REFCNT(repr) == 1);
+ p = _PyBytesWriter_Alloc(&writer, size);
+ if (p == NULL)
+ goto error;
+ writer.overallocate = 1;
- p = PyBytes_AS_STRING(repr);
for (i=0; i < size; i++) {
Py_UCS4 ch = PyUnicode_READ(kind, data, i);
/* Map 32-bit characters to '\Uxxxxxxxx' */
if (ch >= 0x10000) {
+ /* -1: substract 1 preallocated byte */
+ p = _PyBytesWriter_Prepare(&writer, p, 10-1);
+ if (p == NULL)
+ goto error;
+
*p++ = '\\';
*p++ = 'U';
*p++ = Py_hexdigits[(ch >> 28) & 0xf];
@@ -2139,8 +2166,13 @@
*p++ = Py_hexdigits[(ch >> 4) & 0xf];
*p++ = Py_hexdigits[ch & 15];
}
- /* Map 16-bit characters to '\uxxxx' */
+ /* Map 16-bit characters, '\\' and '\n' to '\uxxxx' */
else if (ch >= 256 || ch == '\\' || ch == '\n') {
+ /* -1: substract 1 preallocated byte */
+ p = _PyBytesWriter_Prepare(&writer, p, 6-1);
+ if (p == NULL)
+ goto error;
+
*p++ = '\\';
*p++ = 'u';
*p++ = Py_hexdigits[(ch >> 12) & 0xf];
@@ -2152,14 +2184,16 @@
else
*p++ = (char) ch;
}
- size = p - PyBytes_AS_STRING(repr);
- if (_PyBytes_Resize(&repr, size) < 0)
- return NULL;
- return repr;
+
+ return _PyBytesWriter_Finish(&writer, p);
+
+error:
+ _PyBytesWriter_Dealloc(&writer);
+ return NULL;
}
static int
-write_utf8(PicklerObject *self, char *data, Py_ssize_t size)
+write_utf8(PicklerObject *self, const char *data, Py_ssize_t size)
{
char header[9];
Py_ssize_t len;
@@ -3531,11 +3565,9 @@
PyErr_Clear();
}
else if (PyUnicode_Check(name)) {
- if (self->proto >= 4) {
- _Py_IDENTIFIER(__newobj_ex__);
- use_newobj_ex = PyUnicode_Compare(
- name, _PyUnicode_FromId(&PyId___newobj_ex__)) == 0;
- }
+ _Py_IDENTIFIER(__newobj_ex__);
+ use_newobj_ex = PyUnicode_Compare(
+ name, _PyUnicode_FromId(&PyId___newobj_ex__)) == 0;
if (!use_newobj_ex) {
_Py_IDENTIFIER(__newobj__);
use_newobj = PyUnicode_Compare(
@@ -3579,11 +3611,58 @@
return -1;
}
- if (save(self, cls, 0) < 0 ||
- save(self, args, 0) < 0 ||
- save(self, kwargs, 0) < 0 ||
- _Pickler_Write(self, &newobj_ex_op, 1) < 0) {
- return -1;
+ if (self->proto >= 4) {
+ if (save(self, cls, 0) < 0 ||
+ save(self, args, 0) < 0 ||
+ save(self, kwargs, 0) < 0 ||
+ _Pickler_Write(self, &newobj_ex_op, 1) < 0) {
+ return -1;
+ }
+ }
+ else {
+ PyObject *newargs;
+ PyObject *cls_new;
+ Py_ssize_t i;
+ _Py_IDENTIFIER(__new__);
+
+ newargs = PyTuple_New(Py_SIZE(args) + 2);
+ if (newargs == NULL)
+ return -1;
+
+ cls_new = _PyObject_GetAttrId(cls, &PyId___new__);
+ if (cls_new == NULL) {
+ Py_DECREF(newargs);
+ return -1;
+ }
+ PyTuple_SET_ITEM(newargs, 0, cls_new);
+ Py_INCREF(cls);
+ PyTuple_SET_ITEM(newargs, 1, cls);
+ for (i = 0; i < Py_SIZE(args); i++) {
+ PyObject *item = PyTuple_GET_ITEM(args, i);
+ Py_INCREF(item);
+ PyTuple_SET_ITEM(newargs, i + 2, item);
+ }
+
+ callable = PyObject_Call(st->partial, newargs, kwargs);
+ Py_DECREF(newargs);
+ if (callable == NULL)
+ return -1;
+
+ newargs = PyTuple_New(0);
+ if (newargs == NULL) {
+ Py_DECREF(callable);
+ return -1;
+ }
+
+ if (save(self, callable, 0) < 0 ||
+ save(self, newargs, 0) < 0 ||
+ _Pickler_Write(self, &reduce_op, 1) < 0) {
+ Py_DECREF(newargs);
+ Py_DECREF(callable);
+ return -1;
+ }
+ Py_DECREF(newargs);
+ Py_DECREF(callable);
}
}
else if (use_newobj) {
@@ -4393,7 +4472,7 @@
}
else {
PyErr_Format(PyExc_TypeError,
- "'memo' attribute must be an PicklerMemoProxy object"
+ "'memo' attribute must be a PicklerMemoProxy object"
"or dict, not %.200s", Py_TYPE(obj)->tp_name);
return -1;
}
@@ -4422,8 +4501,6 @@
static int
Pickler_set_persid(PicklerObject *self, PyObject *value)
{
- PyObject *tmp;
-
if (value == NULL) {
PyErr_SetString(PyExc_TypeError,
"attribute deletion is not supported");
@@ -4435,10 +4512,8 @@
return -1;
}
- tmp = self->pers_func;
Py_INCREF(value);
- self->pers_func = value;
- Py_XDECREF(tmp); /* self->pers_func can be NULL, so be careful. */
+ Py_XSETREF(self->pers_func, value);
return 0;
}
@@ -4520,13 +4595,19 @@
static Py_ssize_t
marker(UnpicklerObject *self)
{
- PickleState *st = _Pickle_GetGlobalState();
+ Py_ssize_t mark;
+
if (self->num_marks < 1) {
+ PickleState *st = _Pickle_GetGlobalState();
PyErr_SetString(st->UnpicklingError, "could not find MARK");
return -1;
}
- return self->marks[--self->num_marks];
+ mark = self->marks[--self->num_marks];
+ self->stack->mark_set = self->num_marks != 0;
+ self->stack->fence = self->num_marks ?
+ self->marks[self->num_marks - 1] : 0;
+ return mark;
}
static int
@@ -4987,7 +5068,7 @@
PyObject *tuple;
if (Py_SIZE(self->stack) < len)
- return stack_underflow();
+ return Pdata_stack_underflow(self->stack);
tuple = Pdata_poptuple(self->stack, Py_SIZE(self->stack) - len);
if (tuple == NULL)
@@ -5069,6 +5150,13 @@
if ((dict = PyDict_New()) == NULL)
return -1;
+ if ((j - i) % 2 != 0) {
+ PickleState *st = _Pickle_GetGlobalState();
+ PyErr_SetString(st->UnpicklingError, "odd number of items for DICT");
+ Py_DECREF(dict);
+ return -1;
+ }
+
for (k = i + 1; k < j; k += 2) {
key = self->stack->data[k - 1];
value = self->stack->data[k];
@@ -5136,7 +5224,7 @@
return -1;
if (Py_SIZE(self->stack) - i < 1)
- return stack_underflow();
+ return Pdata_stack_underflow(self->stack);
args = Pdata_poptuple(self->stack, i + 1);
if (args == NULL)
@@ -5453,12 +5541,15 @@
*/
if (self->num_marks > 0 && self->marks[self->num_marks - 1] == len) {
self->num_marks--;
- } else if (len > 0) {
+ self->stack->mark_set = self->num_marks != 0;
+ self->stack->fence = self->num_marks ?
+ self->marks[self->num_marks - 1] : 0;
+ } else if (len <= self->stack->fence)
+ return Pdata_stack_underflow(self->stack);
+ else {
len--;
Py_DECREF(self->stack->data[len]);
Py_SIZE(self->stack) = len;
- } else {
- return stack_underflow();
}
return 0;
}
@@ -5480,10 +5571,10 @@
load_dup(UnpicklerObject *self)
{
PyObject *last;
- Py_ssize_t len;
+ Py_ssize_t len = Py_SIZE(self->stack);
- if ((len = Py_SIZE(self->stack)) <= 0)
- return stack_underflow();
+ if (len <= self->stack->fence)
+ return Pdata_stack_underflow(self->stack);
last = self->stack->data[len - 1];
PDATA_APPEND(self->stack, last, -1);
return 0;
@@ -5666,8 +5757,8 @@
return -1;
if (len < 2)
return bad_readline();
- if (Py_SIZE(self->stack) <= 0)
- return stack_underflow();
+ if (Py_SIZE(self->stack) <= self->stack->fence)
+ return Pdata_stack_underflow(self->stack);
value = self->stack->data[Py_SIZE(self->stack) - 1];
key = PyLong_FromString(s, NULL, 10);
@@ -5695,8 +5786,8 @@
if (_Unpickler_Read(self, &s, 1) < 0)
return -1;
- if (Py_SIZE(self->stack) <= 0)
- return stack_underflow();
+ if (Py_SIZE(self->stack) <= self->stack->fence)
+ return Pdata_stack_underflow(self->stack);
value = self->stack->data[Py_SIZE(self->stack) - 1];
idx = Py_CHARMASK(s[0]);
@@ -5714,8 +5805,8 @@
if (_Unpickler_Read(self, &s, 4) < 0)
return -1;
- if (Py_SIZE(self->stack) <= 0)
- return stack_underflow();
+ if (Py_SIZE(self->stack) <= self->stack->fence)
+ return Pdata_stack_underflow(self->stack);
value = self->stack->data[Py_SIZE(self->stack) - 1];
idx = calc_binsize(s, 4);
@@ -5733,8 +5824,8 @@
{
PyObject *value;
- if (Py_SIZE(self->stack) <= 0)
- return stack_underflow();
+ if (Py_SIZE(self->stack) <= self->stack->fence)
+ return Pdata_stack_underflow(self->stack);
value = self->stack->data[Py_SIZE(self->stack) - 1];
return _Unpickler_MemoPut(self, self->memo_len, value);
@@ -5748,8 +5839,8 @@
Py_ssize_t len, i;
len = Py_SIZE(self->stack);
- if (x > len || x <= 0)
- return stack_underflow();
+ if (x > len || x <= self->stack->fence)
+ return Pdata_stack_underflow(self->stack);
if (len == x) /* nothing to do */
return 0;
@@ -5798,8 +5889,8 @@
static int
load_append(UnpicklerObject *self)
{
- if (Py_SIZE(self->stack) - 1 <= 0)
- return stack_underflow();
+ if (Py_SIZE(self->stack) - 1 <= self->stack->fence)
+ return Pdata_stack_underflow(self->stack);
return do_append(self, Py_SIZE(self->stack) - 1);
}
@@ -5821,8 +5912,8 @@
int status = 0;
len = Py_SIZE(self->stack);
- if (x > len || x <= 0)
- return stack_underflow();
+ if (x > len || x <= self->stack->fence)
+ return Pdata_stack_underflow(self->stack);
if (len == x) /* nothing to do */
return 0;
if ((len - x) % 2 != 0) {
@@ -5875,8 +5966,8 @@
if (mark < 0)
return -1;
len = Py_SIZE(self->stack);
- if (mark > len || mark <= 0)
- return stack_underflow();
+ if (mark > len || mark <= self->stack->fence)
+ return Pdata_stack_underflow(self->stack);
if (len == mark) /* nothing to do */
return 0;
@@ -5931,8 +6022,8 @@
/* Stack is ... instance, state. We want to leave instance at
* the stack top, possibly mutated via instance.__setstate__(state).
*/
- if (Py_SIZE(self->stack) < 2)
- return stack_underflow();
+ if (Py_SIZE(self->stack) - 2 < self->stack->fence)
+ return Pdata_stack_underflow(self->stack);
PDATA_POP(self->stack, state);
if (state == NULL)
@@ -6068,7 +6159,8 @@
self->marks_size = (Py_ssize_t)alloc;
}
- self->marks[self->num_marks++] = Py_SIZE(self->stack);
+ self->stack->mark_set = 1;
+ self->marks[self->num_marks++] = self->stack->fence = Py_SIZE(self->stack);
return 0;
}
@@ -6151,6 +6243,8 @@
char *s = NULL;
self->num_marks = 0;
+ self->stack->mark_set = 0;
+ self->stack->fence = 0;
self->proto = 0;
if (Py_SIZE(self->stack))
Pdata_clear(self->stack, 0);
@@ -6855,8 +6949,6 @@
static int
Unpickler_set_persload(UnpicklerObject *self, PyObject *value)
{
- PyObject *tmp;
-
if (value == NULL) {
PyErr_SetString(PyExc_TypeError,
"attribute deletion is not supported");
@@ -6869,10 +6961,8 @@
return -1;
}
- tmp = self->pers_func;
Py_INCREF(value);
- self->pers_func = value;
- Py_XDECREF(tmp); /* self->pers_func can be NULL, so be careful. */
+ Py_XSETREF(self->pers_func, value);
return 0;
}
diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
index 8bedab5..0ca0aa5 100644
--- a/Modules/_posixsubprocess.c
+++ b/Modules/_posixsubprocess.c
@@ -21,8 +21,7 @@
#include <dirent.h>
#endif
-#if defined(__ANDROID__) && !defined(SYS_getdents64)
-/* Android doesn't expose syscalls, add the definition manually. */
+#if defined(__ANDROID__) && __ANDROID_API__ < 21 && !defined(SYS_getdents64)
# include <sys/linux-syscalls.h>
# define SYS_getdents64 __NR_getdents64
#endif
@@ -72,7 +71,7 @@
/* Convert ASCII to a positive int, no libc call. no overflow. -1 on error. */
static int
-_pos_int_from_ascii(char *name)
+_pos_int_from_ascii(const char *name)
{
int num = 0;
while (*name >= '0' && *name <= '9') {
diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c
index 95ad4a4..fd6b230 100644
--- a/Modules/_randommodule.c
+++ b/Modules/_randommodule.c
@@ -99,7 +99,7 @@
genrand_int32(RandomObject *self)
{
PY_UINT32_T y;
- static PY_UINT32_T mag01[2]={0x0U, MATRIX_A};
+ static const PY_UINT32_T mag01[2] = {0x0U, MATRIX_A};
/* mag01[x] = x * MATRIX_A for x=0,1 */
PY_UINT32_T *mt;
@@ -136,7 +136,7 @@
* optimize the division away at compile-time. 67108864 is 2**26. In
* effect, a contains 27 random bits shifted left 26, and b fills in the
* lower 26 bits of the 53-bit numerator.
- * The orginal code credited Isaku Wada for this algorithm, 2002/01/09.
+ * The original code credited Isaku Wada for this algorithm, 2002/01/09.
*/
static PyObject *
random_random(RandomObject *self)
diff --git a/Modules/_scproxy.c b/Modules/_scproxy.c
index 66b6e34..68be458 100644
--- a/Modules/_scproxy.c
+++ b/Modules/_scproxy.c
@@ -130,7 +130,7 @@
}
static int
-set_proxy(PyObject* proxies, char* proto, CFDictionaryRef proxyDict,
+set_proxy(PyObject* proxies, const char* proto, CFDictionaryRef proxyDict,
CFStringRef enabledKey,
CFStringRef hostKey, CFStringRef portKey)
{
diff --git a/Modules/_sqlite/cache.c b/Modules/_sqlite/cache.c
index 3689a4e..62c5893 100644
--- a/Modules/_sqlite/cache.c
+++ b/Modules/_sqlite/cache.c
@@ -244,8 +244,7 @@
ptr = ptr->next;
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyMethodDef cache_methods[] = {
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 6aa4764..5349299 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -352,8 +352,7 @@
}
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
/*
@@ -861,8 +860,7 @@
if (PyDict_SetItem(self->function_pinboard, func, Py_None) == -1)
return NULL;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
}
@@ -893,8 +891,7 @@
if (PyDict_SetItem(self->function_pinboard, aggregate_class, Py_None) == -1)
return NULL;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
}
@@ -1029,8 +1026,7 @@
if (PyDict_SetItem(self->function_pinboard, authorizer_cb, Py_None) == -1)
return NULL;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
}
@@ -1059,8 +1055,7 @@
return NULL;
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject* pysqlite_connection_set_trace_callback(pysqlite_Connection* self, PyObject* args, PyObject* kwargs)
@@ -1087,8 +1082,7 @@
sqlite3_trace(self->db, _trace_callback, trace_callback);
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
#ifdef HAVE_LOAD_EXTENSION
@@ -1111,8 +1105,7 @@
PyErr_SetString(pysqlite_OperationalError, "Error enabling load extension");
return NULL;
} else {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
}
@@ -1135,8 +1128,7 @@
PyErr_SetString(pysqlite_OperationalError, errmsg);
return NULL;
} else {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
}
#endif
@@ -1626,7 +1618,7 @@
Py_RETURN_FALSE;
}
-static char connection_doc[] =
+static const char connection_doc[] =
PyDoc_STR("SQLite database connection object.");
static PyGetSetDef connection_getset[] = {
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
index 300da28..9b20678 100644
--- a/Modules/_sqlite/cursor.c
+++ b/Modules/_sqlite/cursor.c
@@ -27,7 +27,7 @@
PyObject* pysqlite_cursor_iternext(pysqlite_Cursor* self);
-static char* errmsg_fetch_across_rollback = "Cursor needed to be reset because of commit/rollback and can no longer be fetched from.";
+static const char errmsg_fetch_across_rollback[] = "Cursor needed to be reset because of commit/rollback and can no longer be fetched from.";
static pysqlite_StatementKind detect_statement_type(const char* statement)
{
@@ -242,8 +242,7 @@
const char* pos;
if (!colname) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
for (pos = colname;; pos++) {
@@ -699,7 +698,9 @@
}
Py_DECREF(self->lastrowid);
- if (!multiple && statement_type == STATEMENT_INSERT) {
+ if (!multiple &&
+ /* REPLACE is an alias for INSERT OR REPLACE */
+ (statement_type == STATEMENT_INSERT || statement_type == STATEMENT_REPLACE)) {
sqlite_int64 lastrowid;
Py_BEGIN_ALLOW_THREADS
lastrowid = sqlite3_last_insert_rowid(self->connection->db);
@@ -914,8 +915,7 @@
row = pysqlite_cursor_iternext(self);
if (!row && !PyErr_Occurred()) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
return row;
@@ -996,8 +996,7 @@
PyObject* pysqlite_noop(pysqlite_Connection* self, PyObject* args)
{
/* don't care, return None */
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
PyObject* pysqlite_cursor_close(pysqlite_Cursor* self, PyObject* args)
@@ -1013,8 +1012,7 @@
self->closed = 1;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyMethodDef cursor_methods[] = {
@@ -1050,7 +1048,7 @@
{NULL}
};
-static char cursor_doc[] =
+static const char cursor_doc[] =
PyDoc_STR("SQLite database cursor class.");
PyTypeObject pysqlite_CursorType = {
diff --git a/Modules/_sqlite/module.c b/Modules/_sqlite/module.c
index 7a7e860..7cd6d2a 100644
--- a/Modules/_sqlite/module.c
+++ b/Modules/_sqlite/module.c
@@ -139,8 +139,7 @@
PyErr_SetString(pysqlite_OperationalError, "Changing the shared_cache flag failed");
return NULL;
} else {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
}
@@ -172,8 +171,7 @@
if (rc == -1)
return NULL;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(module_register_adapter_doc,
@@ -221,8 +219,7 @@
return NULL;
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(enable_callback_tracebacks_doc,
@@ -261,13 +258,13 @@
};
struct _IntConstantPair {
- char* constant_name;
+ const char *constant_name;
int constant_value;
};
typedef struct _IntConstantPair IntConstantPair;
-static IntConstantPair _int_constants[] = {
+static const IntConstantPair _int_constants[] = {
{"PARSE_DECLTYPES", PARSE_DECLTYPES},
{"PARSE_COLNAMES", PARSE_COLNAMES},
diff --git a/Modules/_sre.c b/Modules/_sre.c
index 150229d..d379363 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -35,7 +35,7 @@
* other compatibility work.
*/
-static char copyright[] =
+static const char copyright[] =
" SRE 2.2.2 Copyright (c) 1997-2002 by Secret Labs AB ";
#define PY_SSIZE_T_CLEAN
@@ -62,9 +62,6 @@
/* -------------------------------------------------------------------- */
/* optional features */
-/* enables fast searching */
-#define USE_FAST_SEARCH
-
/* enables copy/deepcopy handling (work in progress) */
#undef USE_BUILTIN_COPY
@@ -717,7 +714,7 @@
}
static PyObject*
-call(char* module, char* function, PyObject* args)
+call(const char* module, const char* function, PyObject* args)
{
PyObject* name;
PyObject* mod;
@@ -2052,8 +2049,9 @@
/* Default value */
return 0;
- if (PyLong_Check(index))
- return PyLong_AsSsize_t(index);
+ if (PyIndex_Check(index)) {
+ return PyNumber_AsSsize_t(index, NULL);
+ }
i = -1;
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 1117b55..ead5b0e 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -378,7 +378,7 @@
}
static PyObject *
-PySSL_SetError(PySSLSocket *obj, int ret, char *filename, int lineno)
+PySSL_SetError(PySSLSocket *obj, int ret, const char *filename, int lineno)
{
PyObject *type = PySSLErrorObject;
char *errstr = NULL;
@@ -460,7 +460,7 @@
}
static PyObject *
-_setSSLError (char *errstr, int errcode, char *filename, int lineno) {
+_setSSLError (const char *errstr, int errcode, const char *filename, int lineno) {
if (errstr == NULL)
errcode = ERR_peek_last_error();
diff --git a/Modules/_struct.c b/Modules/_struct.c
index f965541..df81900 100644
--- a/Modules/_struct.c
+++ b/Modules/_struct.c
@@ -723,7 +723,7 @@
return 0;
}
-static formatdef native_table[] = {
+static const formatdef native_table[] = {
{'x', sizeof(char), 0, NULL},
{'b', sizeof(char), 0, nu_byte, np_byte},
{'B', sizeof(char), 0, nu_ubyte, np_ubyte},
@@ -1189,7 +1189,7 @@
static const formatdef *
-whichtable(char **pfmt)
+whichtable(const char **pfmt)
{
const char *fmt = (*pfmt)++; /* May be backed out of later */
switch (*fmt) {
@@ -1268,7 +1268,7 @@
fmt = PyBytes_AS_STRING(self->s_format);
- f = whichtable((char **)&fmt);
+ f = whichtable(&fmt);
s = fmt;
size = 0;
@@ -1456,7 +1456,7 @@
}
static PyObject *
-s_unpack_internal(PyStructObject *soself, char *startfrom) {
+s_unpack_internal(PyStructObject *soself, const char *startfrom) {
formatcode *code;
Py_ssize_t i = 0;
PyObject *result = PyTuple_New(soself->s_len);
@@ -2279,7 +2279,7 @@
/* Check endian and swap in faster functions */
{
- formatdef *native = native_table;
+ const formatdef *native = native_table;
formatdef *other, *ptr;
#if PY_LITTLE_ENDIAN
other = lilendian_table;
diff --git a/Modules/_testbuffer.c b/Modules/_testbuffer.c
index 43db8a8..13d3ccc 100644
--- a/Modules/_testbuffer.c
+++ b/Modules/_testbuffer.c
@@ -13,7 +13,7 @@
PyObject *calcsize = NULL;
/* cache simple format string */
-static const char *simple_fmt = "B";
+static const char simple_fmt[] = "B";
PyObject *simple_format = NULL;
#define SIMPLE_FORMAT(fmt) (fmt == NULL || strcmp(fmt, "B") == 0)
#define FIX_FORMAT(fmt) (fmt == NULL ? "B" : fmt)
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 3810e94..5d661f7 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -1001,7 +1001,7 @@
getargs_keywords(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *keywords[] = {"arg1","arg2","arg3","arg4","arg5", NULL};
- static char *fmt="(ii)i|(i(ii))(iii)i";
+ static const char fmt[] = "(ii)i|(i(ii))(iii)i";
int int_args[10]={-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, fmt, keywords,
@@ -1028,6 +1028,21 @@
return Py_BuildValue("iii", required, optional, keyword_only);
}
+/* test PyArg_ParseTupleAndKeywords positional-only arguments */
+static PyObject *
+getargs_positional_only_and_keywords(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *keywords[] = {"", "", "keyword", NULL};
+ int required = -1;
+ int optional = -1;
+ int keyword = -1;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|ii", keywords,
+ &required, &optional, &keyword))
+ return NULL;
+ return Py_BuildValue("iii", required, optional, keyword);
+}
+
/* Functions to call PyArg_ParseTuple with integer format codes,
and return the result.
*/
@@ -1161,7 +1176,7 @@
value = PyLong_AsUnsignedLongMask(num);
if (value != ULONG_MAX)
return raiseTestError("test_k_code",
- "PyLong_AsUnsignedLongMask() returned wrong value for long 0xFFF...FFF");
+ "PyLong_AsUnsignedLongMask() returned wrong value for long 0xFFF...FFF");
PyTuple_SET_ITEM(tuple, 0, num);
@@ -1180,7 +1195,7 @@
value = PyLong_AsUnsignedLongMask(num);
if (value != (unsigned long)-0x42)
return raiseTestError("test_k_code",
- "PyLong_AsUnsignedLongMask() returned wrong value for long 0xFFF...FFF");
+ "PyLong_AsUnsignedLongMask() returned wrong value for long 0xFFF...FFF");
PyTuple_SET_ITEM(tuple, 0, num);
@@ -2904,7 +2919,9 @@
static int
check_time_rounding(int round)
{
- if (round != _PyTime_ROUND_FLOOR && round != _PyTime_ROUND_CEILING) {
+ if (round != _PyTime_ROUND_FLOOR
+ && round != _PyTime_ROUND_CEILING
+ && round != _PyTime_ROUND_HALF_EVEN) {
PyErr_SetString(PyExc_ValueError, "invalid rounding");
return -1;
}
@@ -3785,6 +3802,137 @@
return PyLong_FromLong(tstate->recursion_depth - 1);
}
+static PyObject*
+pymem_buffer_overflow(PyObject *self, PyObject *args)
+{
+ char *buffer;
+
+ /* Deliberate buffer overflow to check that PyMem_Free() detects
+ the overflow when debug hooks are installed. */
+ buffer = PyMem_Malloc(16);
+ buffer[16] = 'x';
+ PyMem_Free(buffer);
+
+ Py_RETURN_NONE;
+}
+
+static PyObject*
+pymem_api_misuse(PyObject *self, PyObject *args)
+{
+ char *buffer;
+
+ /* Deliberate misusage of Python allocators:
+ allococate with PyMem but release with PyMem_Raw. */
+ buffer = PyMem_Malloc(16);
+ PyMem_RawFree(buffer);
+
+ Py_RETURN_NONE;
+}
+
+static PyObject*
+pymem_malloc_without_gil(PyObject *self, PyObject *args)
+{
+ char *buffer;
+
+ /* Deliberate bug to test debug hooks on Python memory allocators:
+ call PyMem_Malloc() without holding the GIL */
+ Py_BEGIN_ALLOW_THREADS
+ buffer = PyMem_Malloc(10);
+ Py_END_ALLOW_THREADS
+
+ PyMem_Free(buffer);
+
+ Py_RETURN_NONE;
+}
+
+static PyObject*
+pyobject_malloc_without_gil(PyObject *self, PyObject *args)
+{
+ char *buffer;
+
+ /* Deliberate bug to test debug hooks on Python memory allocators:
+ call PyObject_Malloc() without holding the GIL */
+ Py_BEGIN_ALLOW_THREADS
+ buffer = PyObject_Malloc(10);
+ Py_END_ALLOW_THREADS
+
+ PyObject_Free(buffer);
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+tracemalloc_track(PyObject *self, PyObject *args)
+{
+ unsigned int domain;
+ PyObject *ptr_obj;
+ void *ptr;
+ Py_ssize_t size;
+ int release_gil = 0;
+ int res;
+
+ if (!PyArg_ParseTuple(args, "IOn|i", &domain, &ptr_obj, &size, &release_gil))
+ return NULL;
+ ptr = PyLong_AsVoidPtr(ptr_obj);
+ if (PyErr_Occurred())
+ return NULL;
+
+ if (release_gil) {
+ Py_BEGIN_ALLOW_THREADS
+ res = _PyTraceMalloc_Track(domain, (Py_uintptr_t)ptr, size);
+ Py_END_ALLOW_THREADS
+ }
+ else {
+ res = _PyTraceMalloc_Track(domain, (Py_uintptr_t)ptr, size);
+ }
+
+ if (res < 0) {
+ PyErr_SetString(PyExc_RuntimeError, "_PyTraceMalloc_Track error");
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+tracemalloc_untrack(PyObject *self, PyObject *args)
+{
+ unsigned int domain;
+ PyObject *ptr_obj;
+ void *ptr;
+ int res;
+
+ if (!PyArg_ParseTuple(args, "IO", &domain, &ptr_obj))
+ return NULL;
+ ptr = PyLong_AsVoidPtr(ptr_obj);
+ if (PyErr_Occurred())
+ return NULL;
+
+ res = _PyTraceMalloc_Untrack(domain, (Py_uintptr_t)ptr);
+ if (res < 0) {
+ PyErr_SetString(PyExc_RuntimeError, "_PyTraceMalloc_Track error");
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+tracemalloc_get_traceback(PyObject *self, PyObject *args)
+{
+ unsigned int domain;
+ PyObject *ptr_obj;
+ void *ptr;
+
+ if (!PyArg_ParseTuple(args, "IO", &domain, &ptr_obj))
+ return NULL;
+ ptr = PyLong_AsVoidPtr(ptr_obj);
+ if (PyErr_Occurred())
+ return NULL;
+
+ return _PyTraceMalloc_GetTraceback(domain, (Py_uintptr_t)ptr);
+}
+
static PyMethodDef TestMethods[] = {
{"raise_exception", raise_exception, METH_VARARGS},
@@ -3830,6 +3978,9 @@
METH_VARARGS|METH_KEYWORDS},
{"getargs_keyword_only", (PyCFunction)getargs_keyword_only,
METH_VARARGS|METH_KEYWORDS},
+ {"getargs_positional_only_and_keywords",
+ (PyCFunction)getargs_positional_only_and_keywords,
+ METH_VARARGS|METH_KEYWORDS},
{"getargs_b", getargs_b, METH_VARARGS},
{"getargs_B", getargs_B, METH_VARARGS},
{"getargs_h", getargs_h, METH_VARARGS},
@@ -3976,6 +4127,13 @@
{"PyTime_AsMilliseconds", test_PyTime_AsMilliseconds, METH_VARARGS},
{"PyTime_AsMicroseconds", test_PyTime_AsMicroseconds, METH_VARARGS},
{"get_recursion_depth", get_recursion_depth, METH_NOARGS},
+ {"pymem_buffer_overflow", pymem_buffer_overflow, METH_NOARGS},
+ {"pymem_api_misuse", pymem_api_misuse, METH_NOARGS},
+ {"pymem_malloc_without_gil", pymem_malloc_without_gil, METH_NOARGS},
+ {"pyobject_malloc_without_gil", pyobject_malloc_without_gil, METH_NOARGS},
+ {"tracemalloc_track", tracemalloc_track, METH_VARARGS},
+ {"tracemalloc_untrack", tracemalloc_untrack, METH_VARARGS},
+ {"tracemalloc_get_traceback", tracemalloc_get_traceback, METH_VARARGS},
{NULL, NULL} /* sentinel */
};
@@ -4039,7 +4197,7 @@
"T_LONGLONG", "T_ULONGLONG",
#endif
NULL};
- static char *fmt = "|bbBhHiIlknfds#"
+ static const char fmt[] = "|bbBhHiIlknfds#"
#ifdef HAVE_LONG_LONG
"LK"
#endif
@@ -4394,6 +4552,7 @@
PyModule_AddObject(m, "PY_SSIZE_T_MAX", PyLong_FromSsize_t(PY_SSIZE_T_MAX));
PyModule_AddObject(m, "PY_SSIZE_T_MIN", PyLong_FromSsize_t(PY_SSIZE_T_MIN));
PyModule_AddObject(m, "SIZEOF_PYGC_HEAD", PyLong_FromSsize_t(sizeof(PyGC_Head)));
+ PyModule_AddObject(m, "SIZEOF_TIME_T", PyLong_FromSsize_t(sizeof(time_t)));
Py_INCREF(&PyInstanceMethod_Type);
PyModule_AddObject(m, "instancemethod", (PyObject *)&PyInstanceMethod_Type);
diff --git a/Modules/_testmultiphase.c b/Modules/_testmultiphase.c
index 2005205..03eda27 100644
--- a/Modules/_testmultiphase.c
+++ b/Modules/_testmultiphase.c
@@ -61,7 +61,7 @@
}
static int
-Example_setattr(ExampleObject *self, char *name, PyObject *v)
+Example_setattr(ExampleObject *self, const char *name, PyObject *v)
{
if (self->x_attr == NULL) {
self->x_attr = PyDict_New();
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index cf56fa8..761ec0d 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -462,7 +462,7 @@
v = NULL;
break;
}
- PyTuple_SetItem(v, i, w);
+ PyTuple_SET_ITEM(v, i, w);
}
}
Tcl_Free(FREECAST argv);
@@ -480,13 +480,13 @@
Py_ssize_t i, size;
PyObject *elem, *newelem, *result;
- size = PyTuple_Size(arg);
+ size = PyTuple_GET_SIZE(arg);
result = NULL;
/* Recursively invoke SplitObj for all tuple items.
If this does not return a new object, no action is
needed. */
for(i = 0; i < size; i++) {
- elem = PyTuple_GetItem(arg, i);
+ elem = PyTuple_GET_ITEM(arg, i);
newelem = SplitObj(elem);
if (!newelem) {
Py_XDECREF(result);
@@ -502,12 +502,12 @@
if (!result)
return NULL;
for(k = 0; k < i; k++) {
- elem = PyTuple_GetItem(arg, k);
+ elem = PyTuple_GET_ITEM(arg, k);
Py_INCREF(elem);
- PyTuple_SetItem(result, k, elem);
+ PyTuple_SET_ITEM(result, k, elem);
}
}
- PyTuple_SetItem(result, i, newelem);
+ PyTuple_SET_ITEM(result, i, newelem);
}
if (result)
return result;
@@ -529,7 +529,7 @@
Py_XDECREF(result);
return NULL;
}
- PyTuple_SetItem(result, i, newelem);
+ PyTuple_SET_ITEM(result, i, newelem);
}
return result;
}
@@ -551,7 +551,7 @@
else if (PyBytes_Check(arg)) {
int argc;
const char **argv;
- char *list = PyBytes_AsString(arg);
+ char *list = PyBytes_AS_STRING(arg);
if (Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) {
Py_INCREF(arg);
@@ -559,7 +559,7 @@
}
Tcl_Free(FREECAST argv);
if (argc > 1)
- return Split(PyBytes_AsString(arg));
+ return Split(PyBytes_AS_STRING(arg));
/* Fall through, returning arg. */
}
Py_INCREF(arg);
@@ -758,7 +758,7 @@
}
Tcl_SetVar(v->interp,
"tcl_library",
- PyBytes_AsString(utf8_path),
+ PyBytes_AS_STRING(utf8_path),
TCL_GLOBAL_ONLY);
Py_DECREF(utf8_path);
}
@@ -841,7 +841,7 @@
Py_DECREF(tp);
}
-static char*
+static const char *
PyTclObject_TclString(PyObject *self)
{
return Tcl_GetString(((PyTclObject*)self)->value);
@@ -1306,7 +1306,7 @@
Py_DECREF(result);
return NULL;
}
- PyTuple_SetItem(result, i, elem);
+ PyTuple_SET_ITEM(result, i, elem);
}
return result;
}
@@ -1517,8 +1517,8 @@
int flags = TCL_EVAL_DIRECT | TCL_EVAL_GLOBAL;
/* If args is a single tuple, replace with contents of tuple */
- if (1 == PyTuple_Size(args)){
- PyObject* item = PyTuple_GetItem(args, 0);
+ if (PyTuple_GET_SIZE(args) == 1) {
+ PyObject *item = PyTuple_GET_ITEM(args, 0);
if (PyTuple_Check(item))
args = item;
}
@@ -1726,14 +1726,14 @@
varname_converter(PyObject *in, void *_out)
{
char *s;
- char **out = (char**)_out;
+ const char **out = (const char**)_out;
if (PyBytes_Check(in)) {
- if (PyBytes_Size(in) > INT_MAX) {
+ if (PyBytes_GET_SIZE(in) > INT_MAX) {
PyErr_SetString(PyExc_OverflowError, "bytes object is too long");
return 0;
}
- s = PyBytes_AsString(in);
- if (strlen(s) != (size_t)PyBytes_Size(in)) {
+ s = PyBytes_AS_STRING(in);
+ if (strlen(s) != (size_t)PyBytes_GET_SIZE(in)) {
PyErr_SetString(PyExc_ValueError, "embedded null byte");
return 0;
}
@@ -1846,7 +1846,7 @@
static PyObject *
SetVar(PyObject *self, PyObject *args, int flags)
{
- char *name1, *name2;
+ const char *name1, *name2;
PyObject *newValue;
PyObject *res = NULL;
Tcl_Obj *newval, *ok;
@@ -1915,7 +1915,7 @@
static PyObject *
GetVar(PyObject *self, PyObject *args, int flags)
{
- char *name1, *name2=NULL;
+ const char *name1, *name2=NULL;
PyObject *res = NULL;
Tcl_Obj *tres;
@@ -2274,10 +2274,11 @@
return NULL;
for (i = 0; i < objc; i++) {
PyObject *s = FromObj((PyObject*)self, objv[i]);
- if (!s || PyTuple_SetItem(v, i, s)) {
+ if (!s) {
Py_DECREF(v);
return NULL;
}
+ PyTuple_SET_ITEM(v, i, s);
}
return v;
}
@@ -2304,11 +2305,12 @@
for (i = 0; i < argc; i++) {
PyObject *s = unicodeFromTclString(argv[i]);
- if (!s || PyTuple_SetItem(v, i, s)) {
+ if (!s) {
Py_DECREF(v);
v = NULL;
goto finally;
}
+ PyTuple_SET_ITEM(v, i, s);
}
finally:
@@ -2349,10 +2351,11 @@
return NULL;
for (i = 0; i < objc; i++) {
PyObject *s = FromObj((PyObject*)self, objv[i]);
- if (!s || PyTuple_SetItem(v, i, s)) {
+ if (!s) {
Py_DECREF(v);
return NULL;
}
+ PyTuple_SET_ITEM(v, i, s);
}
return v;
}
@@ -2410,10 +2413,11 @@
for (i = 0; i < (argc - 1); i++) {
PyObject *s = unicodeFromTclString(argv[i + 1]);
- if (!s || PyTuple_SetItem(arg, i, s)) {
+ if (!s) {
Py_DECREF(arg);
return PythonCmd_Error(interp);
}
+ PyTuple_SET_ITEM(arg, i, s);
}
res = PyEval_CallObject(func, arg);
Py_DECREF(arg);
@@ -2485,7 +2489,6 @@
/*[clinic input]
_tkinter.tkapp.createcommand
- self: self(type="TkappObject *")
name: str
func: object
/
@@ -2495,7 +2498,7 @@
static PyObject *
_tkinter_tkapp_createcommand_impl(TkappObject *self, const char *name,
PyObject *func)
-/*[clinic end generated code: output=2a1c79a4ee2af410 input=2bc2c046a0914234]*/
+/*[clinic end generated code: output=2a1c79a4ee2af410 input=255785cb70edc6a0]*/
{
PythonCmd_ClientData *data;
int err;
@@ -2561,7 +2564,6 @@
/*[clinic input]
_tkinter.tkapp.deletecommand
- self: self(type="TkappObject *")
name: str
/
@@ -2569,7 +2571,7 @@
static PyObject *
_tkinter_tkapp_deletecommand_impl(TkappObject *self, const char *name)
-/*[clinic end generated code: output=a67e8cb5845e0d2d input=b6306468f10b219c]*/
+/*[clinic end generated code: output=a67e8cb5845e0d2d input=53e9952eae1f85f5]*/
{
int err;
@@ -2762,13 +2764,11 @@
/*[clinic input]
_tkinter.tktimertoken.deletetimerhandler
- self: self(type="TkttObject *")
-
[clinic start generated code]*/
static PyObject *
_tkinter_tktimertoken_deletetimerhandler_impl(TkttObject *self)
-/*[clinic end generated code: output=bd7fe17f328cfa55 input=25ba5dd594e52084]*/
+/*[clinic end generated code: output=bd7fe17f328cfa55 input=40bd070ff85f5cf3]*/
{
TkttObject *v = self;
PyObject *func = v->func;
@@ -2894,7 +2894,6 @@
/*[clinic input]
_tkinter.tkapp.mainloop
- self: self(type="TkappObject *")
threshold: int = 0
/
@@ -2902,7 +2901,7 @@
static PyObject *
_tkinter_tkapp_mainloop_impl(TkappObject *self, int threshold)
-/*[clinic end generated code: output=0ba8eabbe57841b0 input=ad57c9c1dd2b9470]*/
+/*[clinic end generated code: output=0ba8eabbe57841b0 input=036bcdcf03d5eca0]*/
{
#ifdef WITH_THREAD
PyThreadState *tstate = PyThreadState_Get();
@@ -3072,13 +3071,11 @@
/*[clinic input]
_tkinter.tkapp.willdispatch
- self: self(type="TkappObject *")
-
[clinic start generated code]*/
static PyObject *
_tkinter_tkapp_willdispatch_impl(TkappObject *self)
-/*[clinic end generated code: output=0e3f46d244642155 input=2630699767808970]*/
+/*[clinic end generated code: output=0e3f46d244642155 input=d88f5970843d6dab]*/
{
self->dispatching = 1;
@@ -3629,14 +3626,14 @@
}
}
- Tcl_FindExecutable(PyBytes_AsString(cexe));
+ Tcl_FindExecutable(PyBytes_AS_STRING(cexe));
if (set_var) {
SetEnvironmentVariableW(L"TCL_LIBRARY", NULL);
PyMem_Free(wcs_path);
}
#else
- Tcl_FindExecutable(PyBytes_AsString(cexe));
+ Tcl_FindExecutable(PyBytes_AS_STRING(cexe));
#endif /* MS_WINDOWS */
}
Py_XDECREF(cexe);
diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c
index 796ac0f..e3329c7 100644
--- a/Modules/_tracemalloc.c
+++ b/Modules/_tracemalloc.c
@@ -39,7 +39,11 @@
/* limit of the number of frames in a traceback, 1 by default.
Variable protected by the GIL. */
int max_nframe;
-} tracemalloc_config = {TRACEMALLOC_NOT_INITIALIZED, 0, 1};
+
+ /* use domain in trace key?
+ Variable protected by the GIL. */
+ int use_domain;
+} tracemalloc_config = {TRACEMALLOC_NOT_INITIALIZED, 0, 1, 0};
#if defined(TRACE_RAW_MALLOC) && defined(WITH_THREAD)
/* This lock is needed because tracemalloc_free() is called without
@@ -54,10 +58,21 @@
# define TABLES_UNLOCK()
#endif
+
+#define DEFAULT_DOMAIN 0
+
+/* Pack the frame_t structure to reduce the memory footprint. */
+typedef struct
+#ifdef __GNUC__
+__attribute__((packed))
+#endif
+{
+ Py_uintptr_t ptr;
+ _PyTraceMalloc_domain_t domain;
+} pointer_t;
+
/* Pack the frame_t structure to reduce the memory footprint on 64-bit
- architectures: 12 bytes instead of 16. This optimization might produce
- SIGBUS on architectures not supporting unaligned memory accesses (64-bit
- MIPS CPU?): on such architecture, the structure must not be packed. */
+ architectures: 12 bytes instead of 16. */
typedef struct
#ifdef __GNUC__
__attribute__((packed))
@@ -65,10 +80,13 @@
_declspec(align(4))
#endif
{
+ /* filename cannot be NULL: "<unknown>" is used if the Python frame
+ filename is NULL */
PyObject *filename;
unsigned int lineno;
} frame_t;
+
typedef struct {
Py_uhash_t hash;
int nframe;
@@ -81,6 +99,7 @@
#define MAX_NFRAME \
((INT_MAX - (int)sizeof(traceback_t)) / (int)sizeof(frame_t) + 1)
+
static PyObject *unknown_filename = NULL;
static traceback_t tracemalloc_empty_traceback;
@@ -93,6 +112,7 @@
traceback_t *traceback;
} trace_t;
+
/* Size in bytes of currently traced memory.
Protected by TABLES_LOCK(). */
static size_t tracemalloc_traced_memory = 0;
@@ -119,6 +139,7 @@
Protected by TABLES_LOCK(). */
static _Py_hashtable_t *tracemalloc_traces = NULL;
+
#ifdef TRACE_DEBUG
static void
tracemalloc_error(const char *format, ...)
@@ -133,6 +154,7 @@
}
#endif
+
#if defined(WITH_THREAD) && defined(TRACE_RAW_MALLOC)
#define REENTRANT_THREADLOCAL
@@ -143,7 +165,7 @@
# error "need native thread local storage (TLS)"
#endif
-static int tracemalloc_reentrant_key;
+static int tracemalloc_reentrant_key = -1;
/* Any non-NULL pointer can be used */
#define REENTRANT Py_True
@@ -151,7 +173,10 @@
static int
get_reentrant(void)
{
- void *ptr = PyThread_get_key_value(tracemalloc_reentrant_key);
+ void *ptr;
+
+ assert(tracemalloc_reentrant_key != -1);
+ ptr = PyThread_get_key_value(tracemalloc_reentrant_key);
if (ptr != NULL) {
assert(ptr == REENTRANT);
return 1;
@@ -164,12 +189,14 @@
set_reentrant(int reentrant)
{
assert(reentrant == 0 || reentrant == 1);
+ assert(tracemalloc_reentrant_key != -1);
+
if (reentrant) {
- assert(PyThread_get_key_value(tracemalloc_reentrant_key) == NULL);
+ assert(!get_reentrant());
PyThread_set_key_value(tracemalloc_reentrant_key, REENTRANT);
}
else {
- assert(PyThread_get_key_value(tracemalloc_reentrant_key) == REENTRANT);
+ assert(get_reentrant());
PyThread_set_key_value(tracemalloc_reentrant_key, NULL);
}
}
@@ -194,27 +221,75 @@
}
#endif
-static int
-hashtable_compare_unicode(const void *key, const _Py_hashtable_entry_t *entry)
+
+static Py_uhash_t
+hashtable_hash_pyobject(_Py_hashtable_t *ht, const void *pkey)
{
- if (key != NULL && entry->key != NULL)
- return (PyUnicode_Compare((PyObject *)key, (PyObject *)entry->key) == 0);
- else
- return key == entry->key;
+ PyObject *obj;
+
+ _Py_HASHTABLE_READ_KEY(ht, pkey, obj);
+ return PyObject_Hash(obj);
}
-static _Py_hashtable_allocator_t hashtable_alloc = {malloc, free};
+
+static int
+hashtable_compare_unicode(_Py_hashtable_t *ht, const void *pkey,
+ const _Py_hashtable_entry_t *entry)
+{
+ PyObject *key1, *key2;
+
+ _Py_HASHTABLE_READ_KEY(ht, pkey, key1);
+ _Py_HASHTABLE_ENTRY_READ_KEY(ht, entry, key2);
+
+ if (key1 != NULL && key2 != NULL)
+ return (PyUnicode_Compare(key1, key2) == 0);
+ else
+ return key1 == key2;
+}
+
+
+static Py_uhash_t
+hashtable_hash_pointer_t(_Py_hashtable_t *ht, const void *pkey)
+{
+ pointer_t ptr;
+ Py_uhash_t hash;
+
+ _Py_HASHTABLE_READ_KEY(ht, pkey, ptr);
+
+ hash = (Py_uhash_t)_Py_HashPointer((void*)ptr.ptr);
+ hash ^= ptr.domain;
+ return hash;
+}
+
+
+static int
+hashtable_compare_pointer_t(_Py_hashtable_t *ht, const void *pkey,
+ const _Py_hashtable_entry_t *entry)
+{
+ pointer_t ptr1, ptr2;
+
+ _Py_HASHTABLE_READ_KEY(ht, pkey, ptr1);
+ _Py_HASHTABLE_ENTRY_READ_KEY(ht, entry, ptr2);
+
+ /* compare pointer before domain, because pointer is more likely to be
+ different */
+ return (ptr1.ptr == ptr2.ptr && ptr1.domain == ptr2.domain);
+
+}
+
static _Py_hashtable_t *
-hashtable_new(size_t data_size,
+hashtable_new(size_t key_size, size_t data_size,
_Py_hashtable_hash_func hash_func,
_Py_hashtable_compare_func compare_func)
{
- return _Py_hashtable_new_full(data_size, 0,
+ _Py_hashtable_allocator_t hashtable_alloc = {malloc, free};
+ return _Py_hashtable_new_full(key_size, data_size, 0,
hash_func, compare_func,
- NULL, NULL, NULL, &hashtable_alloc);
+ &hashtable_alloc);
}
+
static void*
raw_malloc(size_t size)
{
@@ -227,21 +302,28 @@
allocators.raw.free(allocators.raw.ctx, ptr);
}
+
static Py_uhash_t
-hashtable_hash_traceback(const void *key)
+hashtable_hash_traceback(_Py_hashtable_t *ht, const void *pkey)
{
- const traceback_t *traceback = key;
+ traceback_t *traceback;
+
+ _Py_HASHTABLE_READ_KEY(ht, pkey, traceback);
return traceback->hash;
}
+
static int
-hashtable_compare_traceback(const traceback_t *traceback1,
- const _Py_hashtable_entry_t *he)
+hashtable_compare_traceback(_Py_hashtable_t *ht, const void *pkey,
+ const _Py_hashtable_entry_t *entry)
{
- const traceback_t *traceback2 = he->key;
+ traceback_t *traceback1, *traceback2;
const frame_t *frame1, *frame2;
int i;
+ _Py_HASHTABLE_READ_KEY(ht, pkey, traceback1);
+ _Py_HASHTABLE_ENTRY_READ_KEY(ht, entry, traceback2);
+
if (traceback1->nframe != traceback2->nframe)
return 0;
@@ -260,6 +342,7 @@
return 1;
}
+
static void
tracemalloc_get_frame(PyFrameObject *pyframe, frame_t *frame)
{
@@ -310,15 +393,15 @@
}
/* intern the filename */
- entry = _Py_hashtable_get_entry(tracemalloc_filenames, filename);
+ entry = _Py_HASHTABLE_GET_ENTRY(tracemalloc_filenames, filename);
if (entry != NULL) {
- filename = (PyObject *)entry->key;
+ _Py_HASHTABLE_ENTRY_READ_KEY(tracemalloc_filenames, entry, filename);
}
else {
/* tracemalloc_filenames is responsible to keep a reference
to the filename */
Py_INCREF(filename);
- if (_Py_hashtable_set(tracemalloc_filenames, filename, NULL, 0) < 0) {
+ if (_Py_HASHTABLE_SET_NODATA(tracemalloc_filenames, filename) < 0) {
Py_DECREF(filename);
#ifdef TRACE_DEBUG
tracemalloc_error("failed to intern the filename");
@@ -331,6 +414,7 @@
frame->filename = filename;
}
+
static Py_uhash_t
traceback_hash(traceback_t *traceback)
{
@@ -355,6 +439,7 @@
return x;
}
+
static void
traceback_get_frames(traceback_t *traceback)
{
@@ -382,6 +467,7 @@
}
}
+
static traceback_t *
traceback_new(void)
{
@@ -401,9 +487,9 @@
traceback->hash = traceback_hash(traceback);
/* intern the traceback */
- entry = _Py_hashtable_get_entry(tracemalloc_tracebacks, traceback);
+ entry = _Py_HASHTABLE_GET_ENTRY(tracemalloc_tracebacks, traceback);
if (entry != NULL) {
- traceback = (traceback_t *)entry->key;
+ _Py_HASHTABLE_ENTRY_READ_KEY(tracemalloc_tracebacks, entry, traceback);
}
else {
traceback_t *copy;
@@ -420,7 +506,7 @@
}
memcpy(copy, traceback, traceback_size);
- if (_Py_hashtable_set(tracemalloc_tracebacks, copy, NULL, 0) < 0) {
+ if (_Py_HASHTABLE_SET_NODATA(tracemalloc_tracebacks, copy) < 0) {
raw_free(copy);
#ifdef TRACE_DEBUG
tracemalloc_error("failed to intern the traceback: putdata failed");
@@ -432,46 +518,154 @@
return traceback;
}
+
static int
-tracemalloc_add_trace(void *ptr, size_t size)
+tracemalloc_use_domain_cb(_Py_hashtable_t *old_traces,
+ _Py_hashtable_entry_t *entry, void *user_data)
{
- traceback_t *traceback;
- trace_t trace;
- int res;
+ Py_uintptr_t ptr;
+ pointer_t key;
+ _Py_hashtable_t *new_traces = (_Py_hashtable_t *)user_data;
+ const void *pdata = _Py_HASHTABLE_ENTRY_PDATA(old_traces, entry);
-#ifdef WITH_THREAD
- assert(PyGILState_Check());
-#endif
+ _Py_HASHTABLE_ENTRY_READ_KEY(old_traces, entry, ptr);
+ key.ptr = ptr;
+ key.domain = DEFAULT_DOMAIN;
- traceback = traceback_new();
- if (traceback == NULL)
+ return _Py_hashtable_set(new_traces,
+ sizeof(key), &key,
+ old_traces->data_size, pdata);
+}
+
+
+/* Convert tracemalloc_traces from compact key (Py_uintptr_t) to pointer_t key.
+ * Return 0 on success, -1 on error. */
+static int
+tracemalloc_use_domain(void)
+{
+ _Py_hashtable_t *new_traces = NULL;
+
+ assert(!tracemalloc_config.use_domain);
+
+ new_traces = hashtable_new(sizeof(pointer_t),
+ sizeof(trace_t),
+ hashtable_hash_pointer_t,
+ hashtable_compare_pointer_t);
+ if (new_traces == NULL) {
return -1;
-
- trace.size = size;
- trace.traceback = traceback;
-
- res = _Py_HASHTABLE_SET(tracemalloc_traces, ptr, trace);
- if (res == 0) {
- assert(tracemalloc_traced_memory <= PY_SIZE_MAX - size);
- tracemalloc_traced_memory += size;
- if (tracemalloc_traced_memory > tracemalloc_peak_traced_memory)
- tracemalloc_peak_traced_memory = tracemalloc_traced_memory;
}
- return res;
+ if (_Py_hashtable_foreach(tracemalloc_traces, tracemalloc_use_domain_cb,
+ new_traces) < 0)
+ {
+ _Py_hashtable_destroy(new_traces);
+ return -1;
+ }
+
+ _Py_hashtable_destroy(tracemalloc_traces);
+ tracemalloc_traces = new_traces;
+
+ tracemalloc_config.use_domain = 1;
+
+ return 0;
}
+
static void
-tracemalloc_remove_trace(void *ptr)
+tracemalloc_remove_trace(_PyTraceMalloc_domain_t domain, Py_uintptr_t ptr)
{
trace_t trace;
+ int removed;
- if (_Py_hashtable_pop(tracemalloc_traces, ptr, &trace, sizeof(trace))) {
+ assert(tracemalloc_config.tracing);
+
+ if (tracemalloc_config.use_domain) {
+ pointer_t key = {ptr, domain};
+ removed = _Py_HASHTABLE_POP(tracemalloc_traces, key, trace);
+ }
+ else {
+ removed = _Py_HASHTABLE_POP(tracemalloc_traces, ptr, trace);
+ }
+ if (!removed) {
+ return;
+ }
+
+ assert(tracemalloc_traced_memory >= trace.size);
+ tracemalloc_traced_memory -= trace.size;
+}
+
+#define REMOVE_TRACE(ptr) \
+ tracemalloc_remove_trace(DEFAULT_DOMAIN, (Py_uintptr_t)(ptr))
+
+
+static int
+tracemalloc_add_trace(_PyTraceMalloc_domain_t domain, Py_uintptr_t ptr,
+ size_t size)
+{
+ pointer_t key = {ptr, domain};
+ traceback_t *traceback;
+ trace_t trace;
+ _Py_hashtable_entry_t* entry;
+ int res;
+
+ assert(tracemalloc_config.tracing);
+
+ traceback = traceback_new();
+ if (traceback == NULL) {
+ return -1;
+ }
+
+ if (!tracemalloc_config.use_domain && domain != DEFAULT_DOMAIN) {
+ /* first trace using a non-zero domain whereas traces use compact
+ (Py_uintptr_t) keys: switch to pointer_t keys. */
+ if (tracemalloc_use_domain() < 0) {
+ return -1;
+ }
+ }
+
+ if (tracemalloc_config.use_domain) {
+ entry = _Py_HASHTABLE_GET_ENTRY(tracemalloc_traces, key);
+ }
+ else {
+ entry = _Py_HASHTABLE_GET_ENTRY(tracemalloc_traces, ptr);
+ }
+
+ if (entry != NULL) {
+ /* the memory block is already tracked */
+ _Py_HASHTABLE_ENTRY_READ_DATA(tracemalloc_traces, entry, trace);
assert(tracemalloc_traced_memory >= trace.size);
tracemalloc_traced_memory -= trace.size;
+
+ trace.size = size;
+ trace.traceback = traceback;
+ _Py_HASHTABLE_ENTRY_WRITE_DATA(tracemalloc_traces, entry, trace);
}
+ else {
+ trace.size = size;
+ trace.traceback = traceback;
+
+ if (tracemalloc_config.use_domain) {
+ res = _Py_HASHTABLE_SET(tracemalloc_traces, key, trace);
+ }
+ else {
+ res = _Py_HASHTABLE_SET(tracemalloc_traces, ptr, trace);
+ }
+ if (res != 0) {
+ return res;
+ }
+ }
+
+ assert(tracemalloc_traced_memory <= PY_SIZE_MAX - size);
+ tracemalloc_traced_memory += size;
+ if (tracemalloc_traced_memory > tracemalloc_peak_traced_memory)
+ tracemalloc_peak_traced_memory = tracemalloc_traced_memory;
+ return 0;
}
+#define ADD_TRACE(ptr, size) \
+ tracemalloc_add_trace(DEFAULT_DOMAIN, (Py_uintptr_t)(ptr), size)
+
+
static void*
tracemalloc_alloc(int use_calloc, void *ctx, size_t nelem, size_t elsize)
{
@@ -488,7 +682,7 @@
return NULL;
TABLES_LOCK();
- if (tracemalloc_add_trace(ptr, nelem * elsize) < 0) {
+ if (ADD_TRACE(ptr, nelem * elsize) < 0) {
/* Failed to allocate a trace for the new memory block */
TABLES_UNLOCK();
alloc->free(alloc->ctx, ptr);
@@ -498,6 +692,7 @@
return ptr;
}
+
static void*
tracemalloc_realloc(void *ctx, void *ptr, size_t new_size)
{
@@ -512,9 +707,14 @@
/* an existing memory block has been resized */
TABLES_LOCK();
- tracemalloc_remove_trace(ptr);
- if (tracemalloc_add_trace(ptr2, new_size) < 0) {
+ /* tracemalloc_add_trace() updates the trace if there is already
+ a trace at address (domain, ptr2) */
+ if (ptr2 != ptr) {
+ REMOVE_TRACE(ptr);
+ }
+
+ if (ADD_TRACE(ptr2, new_size) < 0) {
/* Memory allocation failed. The error cannot be reported to
the caller, because realloc() may already have shrinked the
memory block and so removed bytes.
@@ -532,7 +732,7 @@
/* new allocation */
TABLES_LOCK();
- if (tracemalloc_add_trace(ptr2, new_size) < 0) {
+ if (ADD_TRACE(ptr2, new_size) < 0) {
/* Failed to allocate a trace for the new memory block */
TABLES_UNLOCK();
alloc->free(alloc->ctx, ptr2);
@@ -543,6 +743,7 @@
return ptr2;
}
+
static void
tracemalloc_free(void *ctx, void *ptr)
{
@@ -557,10 +758,11 @@
alloc->free(alloc->ctx, ptr);
TABLES_LOCK();
- tracemalloc_remove_trace(ptr);
+ REMOVE_TRACE(ptr);
TABLES_UNLOCK();
}
+
static void*
tracemalloc_alloc_gil(int use_calloc, void *ctx, size_t nelem, size_t elsize)
{
@@ -585,18 +787,21 @@
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)
{
@@ -612,7 +817,7 @@
ptr2 = alloc->realloc(alloc->ctx, ptr, new_size);
if (ptr2 != NULL && ptr != NULL) {
TABLES_LOCK();
- tracemalloc_remove_trace(ptr);
+ REMOVE_TRACE(ptr);
TABLES_UNLOCK();
}
return ptr2;
@@ -629,6 +834,7 @@
return ptr2;
}
+
#ifdef TRACE_RAW_MALLOC
static void*
tracemalloc_raw_alloc(int use_calloc, void *ctx, size_t nelem, size_t elsize)
@@ -663,18 +869,21 @@
return ptr;
}
+
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)
{
@@ -691,7 +900,7 @@
if (ptr2 != NULL && ptr != NULL) {
TABLES_LOCK();
- tracemalloc_remove_trace(ptr);
+ REMOVE_TRACE(ptr);
TABLES_UNLOCK();
}
return ptr2;
@@ -715,22 +924,31 @@
}
#endif /* TRACE_RAW_MALLOC */
+
static int
-tracemalloc_clear_filename(_Py_hashtable_entry_t *entry, void *user_data)
+tracemalloc_clear_filename(_Py_hashtable_t *ht, _Py_hashtable_entry_t *entry,
+ void *user_data)
{
- PyObject *filename = (PyObject *)entry->key;
+ PyObject *filename;
+
+ _Py_HASHTABLE_ENTRY_READ_KEY(ht, entry, filename);
Py_DECREF(filename);
return 0;
}
+
static int
-traceback_free_traceback(_Py_hashtable_entry_t *entry, void *user_data)
+traceback_free_traceback(_Py_hashtable_t *ht, _Py_hashtable_entry_t *entry,
+ void *user_data)
{
- traceback_t *traceback = (traceback_t *)entry->key;
+ traceback_t *traceback;
+
+ _Py_HASHTABLE_ENTRY_READ_KEY(ht, entry, traceback);
raw_free(traceback);
return 0;
}
+
/* reentrant flag must be set to call this function and GIL must be held */
static void
tracemalloc_clear_traces(void)
@@ -753,6 +971,7 @@
_Py_hashtable_clear(tracemalloc_filenames);
}
+
static int
tracemalloc_init(void)
{
@@ -789,21 +1008,29 @@
}
#endif
- tracemalloc_filenames = hashtable_new(0,
- (_Py_hashtable_hash_func)PyObject_Hash,
+ tracemalloc_filenames = hashtable_new(sizeof(PyObject *), 0,
+ hashtable_hash_pyobject,
hashtable_compare_unicode);
- tracemalloc_tracebacks = hashtable_new(0,
- (_Py_hashtable_hash_func)hashtable_hash_traceback,
- (_Py_hashtable_compare_func)hashtable_compare_traceback);
+ tracemalloc_tracebacks = hashtable_new(sizeof(traceback_t *), 0,
+ hashtable_hash_traceback,
+ hashtable_compare_traceback);
- tracemalloc_traces = hashtable_new(sizeof(trace_t),
- _Py_hashtable_hash_ptr,
- _Py_hashtable_compare_direct);
+ if (tracemalloc_config.use_domain) {
+ tracemalloc_traces = hashtable_new(sizeof(pointer_t),
+ sizeof(trace_t),
+ hashtable_hash_pointer_t,
+ hashtable_compare_pointer_t);
+ }
+ else {
+ tracemalloc_traces = hashtable_new(sizeof(Py_uintptr_t),
+ sizeof(trace_t),
+ _Py_hashtable_hash_ptr,
+ _Py_hashtable_compare_direct);
+ }
if (tracemalloc_filenames == NULL || tracemalloc_tracebacks == NULL
- || tracemalloc_traces == NULL)
- {
+ || tracemalloc_traces == NULL) {
PyErr_NoMemory();
return -1;
}
@@ -823,6 +1050,7 @@
return 0;
}
+
static void
tracemalloc_deinit(void)
{
@@ -833,9 +1061,9 @@
tracemalloc_stop();
/* destroy hash tables */
- _Py_hashtable_destroy(tracemalloc_traces);
_Py_hashtable_destroy(tracemalloc_tracebacks);
_Py_hashtable_destroy(tracemalloc_filenames);
+ _Py_hashtable_destroy(tracemalloc_traces);
#if defined(WITH_THREAD) && defined(TRACE_RAW_MALLOC)
if (tables_lock != NULL) {
@@ -846,11 +1074,13 @@
#ifdef REENTRANT_THREADLOCAL
PyThread_delete_key(tracemalloc_reentrant_key);
+ tracemalloc_reentrant_key = -1;
#endif
Py_XDECREF(unknown_filename);
}
+
static int
tracemalloc_start(int max_nframe)
{
@@ -907,6 +1137,7 @@
return 0;
}
+
static void
tracemalloc_stop(void)
{
@@ -923,8 +1154,9 @@
PyMem_SetAllocator(PYMEM_DOMAIN_MEM, &allocators.mem);
PyMem_SetAllocator(PYMEM_DOMAIN_OBJ, &allocators.obj);
- /* release memory */
tracemalloc_clear_traces();
+
+ /* release memory */
raw_free(tracemalloc_traceback);
tracemalloc_traceback = NULL;
}
@@ -935,6 +1167,7 @@
"True if the tracemalloc module is tracing Python memory allocations,\n"
"False otherwise.");
+
static PyObject*
py_tracemalloc_is_tracing(PyObject *self)
{
@@ -946,6 +1179,7 @@
"\n"
"Clear traces of memory blocks allocated by Python.");
+
static PyObject*
py_tracemalloc_clear_traces(PyObject *self)
{
@@ -959,6 +1193,7 @@
Py_RETURN_NONE;
}
+
static PyObject*
frame_to_pyobject(frame_t *frame)
{
@@ -968,8 +1203,6 @@
if (frame_obj == NULL)
return NULL;
- if (frame->filename == NULL)
- frame->filename = Py_None;
Py_INCREF(frame->filename);
PyTuple_SET_ITEM(frame_obj, 0, frame->filename);
@@ -983,6 +1216,7 @@
return frame_obj;
}
+
static PyObject*
traceback_to_pyobject(traceback_t *traceback, _Py_hashtable_t *intern_table)
{
@@ -1021,33 +1255,43 @@
return frames;
}
+
static PyObject*
-trace_to_pyobject(trace_t *trace, _Py_hashtable_t *intern_tracebacks)
+trace_to_pyobject(_PyTraceMalloc_domain_t domain, trace_t *trace,
+ _Py_hashtable_t *intern_tracebacks)
{
PyObject *trace_obj = NULL;
- PyObject *size, *traceback;
+ PyObject *obj;
- trace_obj = PyTuple_New(2);
+ trace_obj = PyTuple_New(3);
if (trace_obj == NULL)
return NULL;
- size = PyLong_FromSize_t(trace->size);
- if (size == NULL) {
+ obj = PyLong_FromSize_t(domain);
+ if (obj == NULL) {
Py_DECREF(trace_obj);
return NULL;
}
- PyTuple_SET_ITEM(trace_obj, 0, size);
+ PyTuple_SET_ITEM(trace_obj, 0, obj);
- traceback = traceback_to_pyobject(trace->traceback, intern_tracebacks);
- if (traceback == NULL) {
+ obj = PyLong_FromSize_t(trace->size);
+ if (obj == NULL) {
Py_DECREF(trace_obj);
return NULL;
}
- PyTuple_SET_ITEM(trace_obj, 1, traceback);
+ PyTuple_SET_ITEM(trace_obj, 1, obj);
+
+ obj = traceback_to_pyobject(trace->traceback, intern_tracebacks);
+ if (obj == NULL) {
+ Py_DECREF(trace_obj);
+ return NULL;
+ }
+ PyTuple_SET_ITEM(trace_obj, 2, obj);
return trace_obj;
}
+
typedef struct {
_Py_hashtable_t *traces;
_Py_hashtable_t *tracebacks;
@@ -1055,16 +1299,26 @@
} get_traces_t;
static int
-tracemalloc_get_traces_fill(_Py_hashtable_entry_t *entry, void *user_data)
+tracemalloc_get_traces_fill(_Py_hashtable_t *traces, _Py_hashtable_entry_t *entry,
+ void *user_data)
{
get_traces_t *get_traces = user_data;
- trace_t *trace;
+ _PyTraceMalloc_domain_t domain;
+ trace_t trace;
PyObject *tracemalloc_obj;
int res;
- trace = (trace_t *)_Py_HASHTABLE_ENTRY_DATA(entry);
+ if (tracemalloc_config.use_domain) {
+ pointer_t key;
+ _Py_HASHTABLE_ENTRY_READ_KEY(traces, entry, key);
+ domain = key.domain;
+ }
+ else {
+ domain = DEFAULT_DOMAIN;
+ }
+ _Py_HASHTABLE_ENTRY_READ_DATA(traces, entry, trace);
- tracemalloc_obj = trace_to_pyobject(trace, get_traces->tracebacks);
+ tracemalloc_obj = trace_to_pyobject(domain, &trace, get_traces->tracebacks);
if (tracemalloc_obj == NULL)
return 1;
@@ -1076,14 +1330,19 @@
return 0;
}
+
static int
-tracemalloc_pyobject_decref_cb(_Py_hashtable_entry_t *entry, void *user_data)
+tracemalloc_pyobject_decref_cb(_Py_hashtable_t *tracebacks,
+ _Py_hashtable_entry_t *entry,
+ void *user_data)
{
- PyObject *obj = (PyObject *)_Py_HASHTABLE_ENTRY_DATA_AS_VOID_P(entry);
+ PyObject *obj;
+ _Py_HASHTABLE_ENTRY_READ_DATA(tracebacks, entry, obj);
Py_DECREF(obj);
return 0;
}
+
PyDoc_STRVAR(tracemalloc_get_traces_doc,
"_get_traces() -> list\n"
"\n"
@@ -1110,7 +1369,8 @@
/* the traceback hash table is used temporarily to intern traceback tuple
of (filename, lineno) tuples */
- get_traces.tracebacks = hashtable_new(sizeof(PyObject *),
+ get_traces.tracebacks = hashtable_new(sizeof(traceback_t *),
+ sizeof(PyObject *),
_Py_hashtable_hash_ptr,
_Py_hashtable_compare_direct);
if (get_traces.tracebacks == NULL) {
@@ -1142,15 +1402,43 @@
finally:
if (get_traces.tracebacks != NULL) {
_Py_hashtable_foreach(get_traces.tracebacks,
- tracemalloc_pyobject_decref_cb, NULL);
+ tracemalloc_pyobject_decref_cb, NULL);
_Py_hashtable_destroy(get_traces.tracebacks);
}
- if (get_traces.traces != NULL)
+ if (get_traces.traces != NULL) {
_Py_hashtable_destroy(get_traces.traces);
+ }
return get_traces.list;
}
+
+static traceback_t*
+tracemalloc_get_traceback(_PyTraceMalloc_domain_t domain, Py_uintptr_t ptr)
+{
+ trace_t trace;
+ int found;
+
+ if (!tracemalloc_config.tracing)
+ return NULL;
+
+ TABLES_LOCK();
+ if (tracemalloc_config.use_domain) {
+ pointer_t key = {ptr, domain};
+ found = _Py_HASHTABLE_GET(tracemalloc_traces, key, trace);
+ }
+ else {
+ found = _Py_HASHTABLE_GET(tracemalloc_traces, ptr, trace);
+ }
+ TABLES_UNLOCK();
+
+ if (!found)
+ return NULL;
+
+ return trace.traceback;
+}
+
+
PyDoc_STRVAR(tracemalloc_get_object_traceback_doc,
"_get_object_traceback(obj)\n"
"\n"
@@ -1165,11 +1453,7 @@
{
PyTypeObject *type;
void *ptr;
- trace_t trace;
- int found;
-
- if (!tracemalloc_config.tracing)
- Py_RETURN_NONE;
+ traceback_t *traceback;
type = Py_TYPE(obj);
if (PyType_IS_GC(type))
@@ -1177,16 +1461,48 @@
else
ptr = (void *)obj;
- TABLES_LOCK();
- found = _Py_HASHTABLE_GET(tracemalloc_traces, ptr, trace);
- TABLES_UNLOCK();
-
- if (!found)
+ traceback = tracemalloc_get_traceback(DEFAULT_DOMAIN, (Py_uintptr_t)ptr);
+ if (traceback == NULL)
Py_RETURN_NONE;
- return traceback_to_pyobject(trace.traceback, NULL);
+ return traceback_to_pyobject(traceback, NULL);
}
+
+#define PUTS(fd, str) _Py_write_noraise(fd, str, (int)strlen(str))
+
+static void
+_PyMem_DumpFrame(int fd, frame_t * frame)
+{
+ PUTS(fd, " File \"");
+ _Py_DumpASCII(fd, frame->filename);
+ PUTS(fd, "\", line ");
+ _Py_DumpDecimal(fd, frame->lineno);
+ PUTS(fd, "\n");
+}
+
+/* Dump the traceback where a memory block was allocated into file descriptor
+ fd. The function may block on TABLES_LOCK() but it is unlikely. */
+void
+_PyMem_DumpTraceback(int fd, const void *ptr)
+{
+ traceback_t *traceback;
+ int i;
+
+ traceback = tracemalloc_get_traceback(DEFAULT_DOMAIN, (Py_uintptr_t)ptr);
+ if (traceback == NULL)
+ return;
+
+ PUTS(fd, "Memory block allocated at (most recent call first):\n");
+ for (i=0; i < traceback->nframe; i++) {
+ _PyMem_DumpFrame(fd, &traceback->frames[i]);
+ }
+ PUTS(fd, "\n");
+}
+
+#undef PUTS
+
+
PyDoc_STRVAR(tracemalloc_start_doc,
"start(nframe: int=1)\n"
"\n"
@@ -1222,6 +1538,7 @@
"Stop tracing Python memory allocations and clear traces\n"
"of memory blocks allocated by Python.");
+
static PyObject*
py_tracemalloc_stop(PyObject *self)
{
@@ -1229,6 +1546,7 @@
Py_RETURN_NONE;
}
+
PyDoc_STRVAR(tracemalloc_get_traceback_limit_doc,
"get_traceback_limit() -> int\n"
"\n"
@@ -1244,6 +1562,7 @@
return PyLong_FromLong(tracemalloc_config.max_nframe);
}
+
PyDoc_STRVAR(tracemalloc_get_tracemalloc_memory_doc,
"get_tracemalloc_memory() -> int\n"
"\n"
@@ -1267,6 +1586,7 @@
return Py_BuildValue("N", size_obj);
}
+
PyDoc_STRVAR(tracemalloc_get_traced_memory_doc,
"get_traced_memory() -> (int, int)\n"
"\n"
@@ -1292,6 +1612,7 @@
return Py_BuildValue("NN", size_obj, peak_size_obj);
}
+
static PyMethodDef module_methods[] = {
{"is_tracing", (PyCFunction)py_tracemalloc_is_tracing,
METH_NOARGS, tracemalloc_is_tracing_doc},
@@ -1342,6 +1663,7 @@
return m;
}
+
static int
parse_sys_xoptions(PyObject *value)
{
@@ -1370,6 +1692,7 @@
return Py_SAFE_DOWNCAST(nframe, long, int);
}
+
int
_PyTraceMalloc_Init(void)
{
@@ -1428,6 +1751,7 @@
return tracemalloc_start(nframe);
}
+
void
_PyTraceMalloc_Fini(void)
{
@@ -1437,3 +1761,59 @@
tracemalloc_deinit();
}
+int
+_PyTraceMalloc_Track(_PyTraceMalloc_domain_t domain, Py_uintptr_t ptr,
+ size_t size)
+{
+ int res;
+#ifdef WITH_THREAD
+ PyGILState_STATE gil_state;
+#endif
+
+ if (!tracemalloc_config.tracing) {
+ /* tracemalloc is not tracing: do nothing */
+ return -2;
+ }
+
+#ifdef WITH_THREAD
+ gil_state = PyGILState_Ensure();
+#endif
+
+ TABLES_LOCK();
+ res = tracemalloc_add_trace(domain, ptr, size);
+ TABLES_UNLOCK();
+
+#ifdef WITH_THREAD
+ PyGILState_Release(gil_state);
+#endif
+ return res;
+}
+
+
+int
+_PyTraceMalloc_Untrack(_PyTraceMalloc_domain_t domain, Py_uintptr_t ptr)
+{
+ if (!tracemalloc_config.tracing) {
+ /* tracemalloc is not tracing: do nothing */
+ return -2;
+ }
+
+ TABLES_LOCK();
+ tracemalloc_remove_trace(domain, ptr);
+ TABLES_UNLOCK();
+
+ return 0;
+}
+
+
+PyObject*
+_PyTraceMalloc_GetTraceback(_PyTraceMalloc_domain_t domain, Py_uintptr_t ptr)
+{
+ traceback_t *traceback;
+
+ traceback = tracemalloc_get_traceback(domain, ptr);
+ if (traceback == NULL)
+ Py_RETURN_NONE;
+
+ return traceback_to_pyobject(traceback, NULL);
+}
diff --git a/Modules/_winapi.c b/Modules/_winapi.c
index 3e7f187..2396fe2 100644
--- a/Modules/_winapi.c
+++ b/Modules/_winapi.c
@@ -175,7 +175,7 @@
self.declare(data)
self.err_occurred_if("_return_value == INVALID_HANDLE_VALUE", data)
data.return_conversion.append(
- 'if (_return_value == NULL)\n Py_RETURN_NONE;\n')
+ 'if (_return_value == NULL) {\n Py_RETURN_NONE;\n}\n')
data.return_conversion.append(
'return_value = HANDLE_TO_PYNUM(_return_value);\n')
@@ -188,7 +188,7 @@
data.return_conversion.append(
'return_value = Py_BuildValue("k", _return_value);\n')
[python start generated code]*/
-/*[python end generated code: output=da39a3ee5e6b4b0d input=374076979596ebba]*/
+/*[python end generated code: output=da39a3ee5e6b4b0d input=94819e72d2c6d558]*/
#include "clinic/_winapi.c.h"
@@ -675,7 +675,7 @@
/* helpers for createprocess */
static unsigned long
-getulong(PyObject* obj, char* name)
+getulong(PyObject* obj, const char* name)
{
PyObject* value;
unsigned long ret;
@@ -691,7 +691,7 @@
}
static HANDLE
-gethandle(PyObject* obj, char* name)
+gethandle(PyObject* obj, const char* name)
{
PyObject* value;
HANDLE ret;
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index 2803177..cac23bf 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -31,7 +31,7 @@
int itemsize;
PyObject * (*getitem)(struct arrayobject *, Py_ssize_t);
int (*setitem)(struct arrayobject *, Py_ssize_t, PyObject *);
- char *formats;
+ const char *formats;
int is_integer_type;
int is_signed;
};
@@ -40,7 +40,7 @@
PyObject_VAR_HEAD
char *ob_item;
Py_ssize_t allocated;
- struct arraydescr *ob_descr;
+ const struct arraydescr *ob_descr;
PyObject *weakreflist; /* List of weak references */
int ob_exports; /* Number of exported buffers */
} arrayobject;
@@ -511,7 +511,7 @@
* Don't forget to update typecode_to_mformat_code() if you add a new
* typecode.
*/
-static struct arraydescr descriptors[] = {
+static const struct arraydescr descriptors[] = {
{'b', 1, b_getitem, b_setitem, "b", 1, 1},
{'B', 1, BB_getitem, BB_setitem, "B", 1, 0},
{'u', sizeof(Py_UNICODE), u_getitem, u_setitem, "u", 0, 0},
@@ -539,7 +539,7 @@
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=ad43d37e942a8854]*/
static PyObject *
-newarrayobject(PyTypeObject *type, Py_ssize_t size, struct arraydescr *descr)
+newarrayobject(PyTypeObject *type, Py_ssize_t size, const struct arraydescr *descr)
{
arrayobject *op;
size_t nbytes;
@@ -1946,7 +1946,7 @@
{
PyObject *converted_items;
PyObject *result;
- struct arraydescr *descr;
+ const struct arraydescr *descr;
if (!PyType_Check(arraytype)) {
PyErr_Format(PyExc_TypeError,
@@ -2084,7 +2084,7 @@
Py_ssize_t itemcount = Py_SIZE(items) / mf_descr.size;
const unsigned char *memstr =
(unsigned char *)PyBytes_AS_STRING(items);
- struct arraydescr *descr;
+ const struct arraydescr *descr;
/* If possible, try to pack array's items using a data type
* that fits better. This may result in an array with narrower
@@ -2554,7 +2554,7 @@
view->format = NULL;
view->internal = NULL;
if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) {
- view->format = self->ob_descr->formats;
+ view->format = (char *)self->ob_descr->formats;
#ifdef Py_UNICODE_WIDE
if (self->ob_descr->typecode == 'u') {
view->format = "w";
@@ -2595,7 +2595,7 @@
{
int c;
PyObject *initial = NULL, *it = NULL;
- struct arraydescr *descr;
+ const struct arraydescr *descr;
if (type == &Arraytype && !_PyArg_NoKeywords("array.array()", kwds))
return NULL;
@@ -2875,9 +2875,20 @@
static PyObject *
arrayiter_next(arrayiterobject *it)
{
+ arrayobject *ao;
+
+ assert(it != NULL);
assert(PyArrayIter_Check(it));
- if (it->index < Py_SIZE(it->ao))
- return (*it->getitem)(it->ao, it->index++);
+ ao = it->ao;
+ if (ao == NULL) {
+ return NULL;
+ }
+ assert(array_Check(ao));
+ if (it->index < Py_SIZE(ao)) {
+ return (*it->getitem)(ao, it->index++);
+ }
+ it->ao = NULL;
+ Py_DECREF(ao);
return NULL;
}
@@ -2906,8 +2917,11 @@
array_arrayiterator___reduce___impl(arrayiterobject *self)
/*[clinic end generated code: output=7898a52e8e66e016 input=a062ea1e9951417a]*/
{
- return Py_BuildValue("N(O)n", _PyObject_GetBuiltin("iter"),
- self->ao, self->index);
+ PyObject *func = _PyObject_GetBuiltin("iter");
+ if (self->ao == NULL) {
+ return Py_BuildValue("N(())", func);
+ }
+ return Py_BuildValue("N(O)n", func, self->ao, self->index);
}
/*[clinic input]
@@ -2987,7 +3001,7 @@
char buffer[Py_ARRAY_LENGTH(descriptors)], *p;
PyObject *typecodes;
Py_ssize_t size = 0;
- struct arraydescr *descr;
+ const struct arraydescr *descr;
if (PyType_Ready(&Arraytype) < 0)
return -1;
diff --git a/Modules/audioop.c b/Modules/audioop.c
index 306937e..9a96eea 100644
--- a/Modules/audioop.c
+++ b/Modules/audioop.c
@@ -51,13 +51,15 @@
#define SEG_SHIFT (4) /* Left shift for segment number. */
#define SEG_MASK (0x70) /* Segment field mask. */
-static PyInt16 seg_aend[8] = {0x1F, 0x3F, 0x7F, 0xFF,
- 0x1FF, 0x3FF, 0x7FF, 0xFFF};
-static PyInt16 seg_uend[8] = {0x3F, 0x7F, 0xFF, 0x1FF,
- 0x3FF, 0x7FF, 0xFFF, 0x1FFF};
+static const PyInt16 seg_aend[8] = {
+ 0x1F, 0x3F, 0x7F, 0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF
+};
+static const PyInt16 seg_uend[8] = {
+ 0x3F, 0x7F, 0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF
+};
static PyInt16
-search(PyInt16 val, PyInt16 *table, int size)
+search(PyInt16 val, const PyInt16 *table, int size)
{
int i;
@@ -70,7 +72,7 @@
#define st_ulaw2linear16(uc) (_st_ulaw2linear16[uc])
#define st_alaw2linear16(uc) (_st_alaw2linear16[uc])
-static PyInt16 _st_ulaw2linear16[256] = {
+static const PyInt16 _st_ulaw2linear16[256] = {
-32124, -31100, -30076, -29052, -28028, -27004, -25980,
-24956, -23932, -22908, -21884, -20860, -19836, -18812,
-17788, -16764, -15996, -15484, -14972, -14460, -13948,
@@ -176,7 +178,7 @@
}
-static PyInt16 _st_alaw2linear16[256] = {
+static const PyInt16 _st_alaw2linear16[256] = {
-5504, -5248, -6016, -5760, -4480, -4224, -4992,
-4736, -7552, -7296, -8064, -7808, -6528, -6272,
-7040, -6784, -2752, -2624, -3008, -2880, -2240,
@@ -270,12 +272,12 @@
/* End of code taken from sox */
/* Intel ADPCM step variation table */
-static int indexTable[16] = {
+static const int indexTable[16] = {
-1, -1, -1, -1, 2, 4, 6, 8,
-1, -1, -1, -1, 2, 4, 6, 8,
};
-static int stepsizeTable[89] = {
+static const int stepsizeTable[89] = {
7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
diff --git a/Modules/binascii.c b/Modules/binascii.c
index d920d23..a306acd 100644
--- a/Modules/binascii.c
+++ b/Modules/binascii.c
@@ -74,7 +74,7 @@
#define SKIP 0x7E
#define FAIL 0x7D
-static unsigned char table_a2b_hqx[256] = {
+static const unsigned char table_a2b_hqx[256] = {
/* ^@ ^A ^B ^C ^D ^E ^F ^G */
/* 0*/ FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL,
/* \b \t \n ^K ^L \r ^N ^O */
@@ -125,10 +125,10 @@
FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL,
};
-static unsigned char table_b2a_hqx[] =
+static const unsigned char table_b2a_hqx[] =
"!\"#$%&'()*+,-012345689@ABCDEFGHIJKLMNPQRSTUVXYZ[`abcdefhijklmpqr";
-static char table_a2b_base64[] = {
+static const char table_a2b_base64[] = {
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63,
@@ -144,12 +144,12 @@
/* Max binary chunk size; limited only by available memory */
#define BASE64_MAXBIN ((PY_SSIZE_T_MAX - 3) / 2)
-static unsigned char table_b2a_base64[] =
+static const unsigned char table_b2a_base64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-static unsigned short crctab_hqx[256] = {
+static const unsigned short crctab_hqx[256] = {
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
@@ -256,7 +256,8 @@
binascii_a2b_uu_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=5779f39b0b48459f input=7cafeaf73df63d1c]*/
{
- unsigned char *ascii_data, *bin_data;
+ const unsigned char *ascii_data;
+ unsigned char *bin_data;
int leftbits = 0;
unsigned char this_ch;
unsigned int leftchar = 0;
@@ -342,13 +343,15 @@
binascii_b2a_uu_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=181021b69bb9a414 input=00fdf458ce8b465b]*/
{
- unsigned char *ascii_data, *bin_data;
+ unsigned char *ascii_data;
+ const unsigned char *bin_data;
int leftbits = 0;
unsigned char this_ch;
unsigned int leftchar = 0;
- PyObject *rv;
- Py_ssize_t bin_len;
+ Py_ssize_t bin_len, out_len;
+ _PyBytesWriter writer;
+ _PyBytesWriter_Init(&writer);
bin_data = data->buf;
bin_len = data->len;
if ( bin_len > 45 ) {
@@ -358,9 +361,10 @@
}
/* We're lazy and allocate to much (fixed up later) */
- if ( (rv=PyBytes_FromStringAndSize(NULL, 2 + (bin_len+2)/3*4)) == NULL )
+ out_len = 2 + (bin_len + 2) / 3 * 4;
+ ascii_data = _PyBytesWriter_Alloc(&writer, out_len);
+ if (ascii_data == NULL)
return NULL;
- ascii_data = (unsigned char *)PyBytes_AS_STRING(rv);
/* Store the length */
*ascii_data++ = ' ' + (bin_len & 077);
@@ -382,17 +386,12 @@
}
*ascii_data++ = '\n'; /* Append a courtesy newline */
- if (_PyBytes_Resize(&rv,
- (ascii_data -
- (unsigned char *)PyBytes_AS_STRING(rv))) < 0) {
- Py_CLEAR(rv);
- }
- return rv;
+ return _PyBytesWriter_Finish(&writer, ascii_data);
}
static int
-binascii_find_valid(unsigned char *s, Py_ssize_t slen, int num)
+binascii_find_valid(const unsigned char *s, Py_ssize_t slen, int num)
{
/* Finds & returns the (num+1)th
** valid character for base64, or -1 if none.
@@ -429,13 +428,14 @@
binascii_a2b_base64_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=3e351b702bed56d2 input=5872acf6e1cac243]*/
{
- unsigned char *ascii_data, *bin_data;
+ const unsigned char *ascii_data;
+ unsigned char *bin_data;
int leftbits = 0;
unsigned char this_ch;
unsigned int leftchar = 0;
- PyObject *rv;
Py_ssize_t ascii_len, bin_len;
int quad_pos = 0;
+ _PyBytesWriter writer;
ascii_data = data->buf;
ascii_len = data->len;
@@ -447,11 +447,12 @@
bin_len = ((ascii_len+3)/4)*3; /* Upper bound, corrected later */
+ _PyBytesWriter_Init(&writer);
+
/* Allocate the buffer */
- if ( (rv=PyBytes_FromStringAndSize(NULL, bin_len)) == NULL )
+ bin_data = _PyBytesWriter_Alloc(&writer, bin_len);
+ if (bin_data == NULL)
return NULL;
- bin_data = (unsigned char *)PyBytes_AS_STRING(rv);
- bin_len = 0;
for( ; ascii_len > 0; ascii_len--, ascii_data++) {
this_ch = *ascii_data;
@@ -496,31 +497,17 @@
if ( leftbits >= 8 ) {
leftbits -= 8;
*bin_data++ = (leftchar >> leftbits) & 0xff;
- bin_len++;
leftchar &= ((1 << leftbits) - 1);
}
}
if (leftbits != 0) {
PyErr_SetString(Error, "Incorrect padding");
- Py_DECREF(rv);
+ _PyBytesWriter_Dealloc(&writer);
return NULL;
}
- /* And set string size correctly. If the result string is empty
- ** (because the input was all invalid) return the shared empty
- ** string instead; _PyBytes_Resize() won't do this for us.
- */
- if (bin_len > 0) {
- if (_PyBytes_Resize(&rv, bin_len) < 0) {
- Py_CLEAR(rv);
- }
- }
- else {
- Py_DECREF(rv);
- rv = PyBytes_FromStringAndSize("", 0);
- }
- return rv;
+ return _PyBytesWriter_Finish(&writer, bin_data);
}
@@ -528,24 +515,27 @@
binascii.b2a_base64
data: Py_buffer
- /
+ *
+ newline: int(c_default="1") = True
Base64-code line of data.
[clinic start generated code]*/
static PyObject *
-binascii_b2a_base64_impl(PyModuleDef *module, Py_buffer *data)
-/*[clinic end generated code: output=3cd61fbee2913285 input=14ec4e47371174a9]*/
+binascii_b2a_base64_impl(PyModuleDef *module, Py_buffer *data, int newline)
+/*[clinic end generated code: output=19e1dd719a890b50 input=7b2ea6fa38d8924c]*/
{
- unsigned char *ascii_data, *bin_data;
+ unsigned char *ascii_data;
+ const unsigned char *bin_data;
int leftbits = 0;
unsigned char this_ch;
unsigned int leftchar = 0;
- PyObject *rv;
- Py_ssize_t bin_len;
+ Py_ssize_t bin_len, out_len;
+ _PyBytesWriter writer;
bin_data = data->buf;
bin_len = data->len;
+ _PyBytesWriter_Init(&writer);
assert(bin_len >= 0);
@@ -555,11 +545,14 @@
}
/* We're lazy and allocate too much (fixed up later).
- "+3" leaves room for up to two pad characters and a trailing
- newline. Note that 'b' gets encoded as 'Yg==\n' (1 in, 5 out). */
- if ( (rv=PyBytes_FromStringAndSize(NULL, bin_len*2 + 3)) == NULL )
+ "+2" leaves room for up to two pad characters.
+ Note that 'b' gets encoded as 'Yg==\n' (1 in, 5 out). */
+ out_len = bin_len*2 + 2;
+ if (newline)
+ out_len++;
+ ascii_data = _PyBytesWriter_Alloc(&writer, out_len);
+ if (ascii_data == NULL)
return NULL;
- ascii_data = (unsigned char *)PyBytes_AS_STRING(rv);
for( ; bin_len > 0 ; bin_len--, bin_data++ ) {
/* Shift the data into our buffer */
@@ -581,14 +574,10 @@
*ascii_data++ = table_b2a_base64[(leftchar&0xf) << 2];
*ascii_data++ = BASE64_PAD;
}
- *ascii_data++ = '\n'; /* Append a courtesy newline */
+ if (newline)
+ *ascii_data++ = '\n'; /* Append a courtesy newline */
- if (_PyBytes_Resize(&rv,
- (ascii_data -
- (unsigned char *)PyBytes_AS_STRING(rv))) < 0) {
- Py_CLEAR(rv);
- }
- return rv;
+ return _PyBytesWriter_Finish(&writer, ascii_data);
}
/*[clinic input]
@@ -604,16 +593,19 @@
binascii_a2b_hqx_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=60bcdbbd28b105cd input=0d914c680e0eed55]*/
{
- unsigned char *ascii_data, *bin_data;
+ const unsigned char *ascii_data;
+ unsigned char *bin_data;
int leftbits = 0;
unsigned char this_ch;
unsigned int leftchar = 0;
- PyObject *rv;
+ PyObject *res;
Py_ssize_t len;
int done = 0;
+ _PyBytesWriter writer;
ascii_data = data->buf;
len = data->len;
+ _PyBytesWriter_Init(&writer);
assert(len >= 0);
@@ -623,9 +615,9 @@
/* Allocate a string that is too big (fixed later)
Add two to the initial length to prevent interning which
would preclude subsequent resizing. */
- if ( (rv=PyBytes_FromStringAndSize(NULL, len+2)) == NULL )
+ bin_data = _PyBytesWriter_Alloc(&writer, len + 2);
+ if (bin_data == NULL)
return NULL;
- bin_data = (unsigned char *)PyBytes_AS_STRING(rv);
for( ; len > 0 ; len--, ascii_data++ ) {
/* Get the byte and look it up */
@@ -634,7 +626,7 @@
continue;
if ( this_ch == FAIL ) {
PyErr_SetString(Error, "Illegal char");
- Py_DECREF(rv);
+ _PyBytesWriter_Dealloc(&writer);
return NULL;
}
if ( this_ch == DONE ) {
@@ -656,21 +648,14 @@
if ( leftbits && !done ) {
PyErr_SetString(Incomplete,
"String has incomplete number of bytes");
- Py_DECREF(rv);
+ _PyBytesWriter_Dealloc(&writer);
return NULL;
}
- if (_PyBytes_Resize(&rv,
- (bin_data -
- (unsigned char *)PyBytes_AS_STRING(rv))) < 0) {
- Py_CLEAR(rv);
- }
- if (rv) {
- PyObject *rrv = Py_BuildValue("Oi", rv, done);
- Py_DECREF(rv);
- return rrv;
- }
- return NULL;
+ res = _PyBytesWriter_Finish(&writer, bin_data);
+ if (res == NULL)
+ return NULL;
+ return Py_BuildValue("Ni", res, done);
}
@@ -687,11 +672,13 @@
binascii_rlecode_hqx_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=0905da344dbf0648 input=e1f1712447a82b09]*/
{
- unsigned char *in_data, *out_data;
- PyObject *rv;
+ const unsigned char *in_data;
+ unsigned char *out_data;
unsigned char ch;
Py_ssize_t in, inend, len;
+ _PyBytesWriter writer;
+ _PyBytesWriter_Init(&writer);
in_data = data->buf;
len = data->len;
@@ -701,9 +688,9 @@
return PyErr_NoMemory();
/* Worst case: output is twice as big as input (fixed later) */
- if ( (rv=PyBytes_FromStringAndSize(NULL, len*2+2)) == NULL )
+ out_data = _PyBytesWriter_Alloc(&writer, len * 2 + 2);
+ if (out_data == NULL)
return NULL;
- out_data = (unsigned char *)PyBytes_AS_STRING(rv);
for( in=0; in<len; in++) {
ch = in_data[in];
@@ -729,12 +716,8 @@
}
}
}
- if (_PyBytes_Resize(&rv,
- (out_data -
- (unsigned char *)PyBytes_AS_STRING(rv))) < 0) {
- Py_CLEAR(rv);
- }
- return rv;
+
+ return _PyBytesWriter_Finish(&writer, out_data);
}
@@ -751,15 +734,17 @@
binascii_b2a_hqx_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=5a987810d5e3cdbb input=9596ebe019fe12ba]*/
{
- unsigned char *ascii_data, *bin_data;
+ unsigned char *ascii_data;
+ const unsigned char *bin_data;
int leftbits = 0;
unsigned char this_ch;
unsigned int leftchar = 0;
- PyObject *rv;
Py_ssize_t len;
+ _PyBytesWriter writer;
bin_data = data->buf;
len = data->len;
+ _PyBytesWriter_Init(&writer);
assert(len >= 0);
@@ -767,9 +752,9 @@
return PyErr_NoMemory();
/* Allocate a buffer that is at least large enough */
- if ( (rv=PyBytes_FromStringAndSize(NULL, len*2+2)) == NULL )
+ ascii_data = _PyBytesWriter_Alloc(&writer, len * 2 + 2);
+ if (ascii_data == NULL)
return NULL;
- ascii_data = (unsigned char *)PyBytes_AS_STRING(rv);
for( ; len > 0 ; len--, bin_data++ ) {
/* Shift into our buffer, and output any 6bits ready */
@@ -786,12 +771,8 @@
leftchar <<= (6-leftbits);
*ascii_data++ = table_b2a_hqx[leftchar & 0x3f];
}
- if (_PyBytes_Resize(&rv,
- (ascii_data -
- (unsigned char *)PyBytes_AS_STRING(rv))) < 0) {
- Py_CLEAR(rv);
- }
- return rv;
+
+ return _PyBytesWriter_Finish(&writer, ascii_data);
}
@@ -808,13 +789,15 @@
binascii_rledecode_hqx_impl(PyModuleDef *module, Py_buffer *data)
/*[clinic end generated code: output=f7afd89b789946ab input=54cdd49fc014402c]*/
{
- unsigned char *in_data, *out_data;
+ const unsigned char *in_data;
+ unsigned char *out_data;
unsigned char in_byte, in_repeat;
- PyObject *rv;
- Py_ssize_t in_len, out_len, out_len_left;
+ Py_ssize_t in_len;
+ _PyBytesWriter writer;
in_data = data->buf;
in_len = data->len;
+ _PyBytesWriter_Init(&writer);
assert(in_len >= 0);
@@ -825,59 +808,48 @@
return PyErr_NoMemory();
/* Allocate a buffer of reasonable size. Resized when needed */
- out_len = in_len*2;
- if ( (rv=PyBytes_FromStringAndSize(NULL, out_len)) == NULL )
+ out_data = _PyBytesWriter_Alloc(&writer, in_len);
+ if (out_data == NULL)
return NULL;
- out_len_left = out_len;
- out_data = (unsigned char *)PyBytes_AS_STRING(rv);
+
+ /* Use overallocation */
+ writer.overallocate = 1;
/*
** We need two macros here to get/put bytes and handle
** end-of-buffer for input and output strings.
*/
-#define INBYTE(b) \
- do { \
- if ( --in_len < 0 ) { \
- PyErr_SetString(Incomplete, ""); \
- Py_DECREF(rv); \
- return NULL; \
- } \
- b = *in_data++; \
+#define INBYTE(b) \
+ do { \
+ if ( --in_len < 0 ) { \
+ PyErr_SetString(Incomplete, ""); \
+ goto error; \
+ } \
+ b = *in_data++; \
} while(0)
-#define OUTBYTE(b) \
- do { \
- if ( --out_len_left < 0 ) { \
- if ( out_len > PY_SSIZE_T_MAX / 2) return PyErr_NoMemory(); \
- if (_PyBytes_Resize(&rv, 2*out_len) < 0) \
- { Py_XDECREF(rv); return NULL; } \
- out_data = (unsigned char *)PyBytes_AS_STRING(rv) \
- + out_len; \
- out_len_left = out_len-1; \
- out_len = out_len * 2; \
- } \
- *out_data++ = b; \
- } while(0)
-
- /*
- ** Handle first byte separately (since we have to get angry
- ** in case of an orphaned RLE code).
- */
- INBYTE(in_byte);
+ /*
+ ** Handle first byte separately (since we have to get angry
+ ** in case of an orphaned RLE code).
+ */
+ INBYTE(in_byte);
if (in_byte == RUNCHAR) {
INBYTE(in_repeat);
+ /* only 1 byte will be written, but 2 bytes were preallocated:
+ substract 1 byte to prevent overallocation */
+ writer.min_size--;
+
if (in_repeat != 0) {
/* Note Error, not Incomplete (which is at the end
** of the string only). This is a programmer error.
*/
PyErr_SetString(Error, "Orphaned RLE code at start");
- Py_DECREF(rv);
- return NULL;
+ goto error;
}
- OUTBYTE(RUNCHAR);
+ *out_data++ = RUNCHAR;
} else {
- OUTBYTE(in_byte);
+ *out_data++ = in_byte;
}
while( in_len > 0 ) {
@@ -885,26 +857,39 @@
if (in_byte == RUNCHAR) {
INBYTE(in_repeat);
+ /* only 1 byte will be written, but 2 bytes were preallocated:
+ substract 1 byte to prevent overallocation */
+ writer.min_size--;
+
if ( in_repeat == 0 ) {
/* Just an escaped RUNCHAR value */
- OUTBYTE(RUNCHAR);
+ *out_data++ = RUNCHAR;
} else {
/* Pick up value and output a sequence of it */
in_byte = out_data[-1];
+
+ /* enlarge the buffer if needed */
+ if (in_repeat > 1) {
+ /* -1 because we already preallocated 1 byte */
+ out_data = _PyBytesWriter_Prepare(&writer, out_data,
+ in_repeat - 1);
+ if (out_data == NULL)
+ goto error;
+ }
+
while ( --in_repeat > 0 )
- OUTBYTE(in_byte);
+ *out_data++ = in_byte;
}
} else {
/* Normal byte */
- OUTBYTE(in_byte);
+ *out_data++ = in_byte;
}
}
- if (_PyBytes_Resize(&rv,
- (out_data -
- (unsigned char *)PyBytes_AS_STRING(rv))) < 0) {
- Py_CLEAR(rv);
- }
- return rv;
+ return _PyBytesWriter_Finish(&writer, out_data);
+
+error:
+ _PyBytesWriter_Dealloc(&writer);
+ return NULL;
}
@@ -922,7 +907,7 @@
binascii_crc_hqx_impl(PyModuleDef *module, Py_buffer *data, unsigned int crc)
/*[clinic end generated code: output=167c2dac62625717 input=add8c53712ccceda]*/
{
- unsigned char *bin_data;
+ const unsigned char *bin_data;
Py_ssize_t len;
crc &= 0xffff;
@@ -1000,7 +985,7 @@
using byte-swap instructions.
********************************************************************/
-static unsigned int crc_32_tab[256] = {
+static const unsigned int crc_32_tab[256] = {
0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U,
0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U,
0xe0d5e91eU, 0x97d2d988U, 0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U,
@@ -1073,7 +1058,7 @@
#ifdef USE_ZLIB_CRC32
/* This was taken from zlibmodule.c PyZlib_crc32 (but is PY_SSIZE_T_CLEAN) */
{
- Byte *buf;
+ const Byte *buf;
Py_ssize_t len;
int signed_val;
@@ -1084,7 +1069,7 @@
}
#else /* USE_ZLIB_CRC32 */
{ /* By Jim Ahlstrom; All rights transferred to CNRI */
- unsigned char *bin_data;
+ const unsigned char *bin_data;
Py_ssize_t len;
unsigned int result;
@@ -1167,7 +1152,7 @@
binascii_a2b_hex_impl(PyModuleDef *module, Py_buffer *hexstr)
/*[clinic end generated code: output=d61da452b5c6d290 input=9e1e7f2f94db24fd]*/
{
- char* argbuf;
+ const char* argbuf;
Py_ssize_t arglen;
PyObject *retval;
char* retbuf;
@@ -1224,7 +1209,7 @@
return binascii_a2b_hex_impl(module, hexstr);
}
-static int table_hex[128] = {
+static const int table_hex[128] = {
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
@@ -1255,7 +1240,8 @@
{
Py_ssize_t in, out;
char ch;
- unsigned char *ascii_data, *odata;
+ const unsigned char *ascii_data;
+ unsigned char *odata;
Py_ssize_t datalen = 0;
PyObject *rv;
@@ -1361,13 +1347,14 @@
/*[clinic end generated code: output=a87ca9ccb94e2a9f input=7f2a9aaa008e92b2]*/
{
Py_ssize_t in, out;
- unsigned char *databuf, *odata;
+ const unsigned char *databuf;
+ unsigned char *odata;
Py_ssize_t datalen = 0, odatalen = 0;
PyObject *rv;
unsigned int linelen = 0;
unsigned char ch;
int crlf = 0;
- unsigned char *p;
+ const unsigned char *p;
databuf = data->buf;
datalen = data->len;
@@ -1376,7 +1363,7 @@
/* XXX: this function has the side effect of converting all of
* the end of lines to be the same depending on this detection
* here */
- p = (unsigned char *) memchr(databuf, '\n', datalen);
+ p = (const unsigned char *) memchr(databuf, '\n', datalen);
if ((p != NULL) && (p > databuf) && (*(p-1) == '\r'))
crlf = 1;
diff --git a/Modules/cjkcodecs/clinic/multibytecodec.c.h b/Modules/cjkcodecs/clinic/multibytecodec.c.h
index 8a47ff8..0d8a3e0 100644
--- a/Modules/cjkcodecs/clinic/multibytecodec.c.h
+++ b/Modules/cjkcodecs/clinic/multibytecodec.c.h
@@ -30,8 +30,9 @@
const char *errors = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|z:encode", _keywords,
- &input, &errors))
+ &input, &errors)) {
goto exit;
+ }
return_value = _multibytecodec_MultibyteCodec_encode_impl(self, input, errors);
exit:
@@ -66,14 +67,16 @@
const char *errors = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|z:decode", _keywords,
- &input, &errors))
+ &input, &errors)) {
goto exit;
+ }
return_value = _multibytecodec_MultibyteCodec_decode_impl(self, &input, errors);
exit:
/* Cleanup for input */
- if (input.obj)
+ if (input.obj) {
PyBuffer_Release(&input);
+ }
return return_value;
}
@@ -100,8 +103,9 @@
int final = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i:encode", _keywords,
- &input, &final))
+ &input, &final)) {
goto exit;
+ }
return_value = _multibytecodec_MultibyteIncrementalEncoder_encode_impl(self, input, final);
exit:
@@ -147,14 +151,16 @@
int final = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|i:decode", _keywords,
- &input, &final))
+ &input, &final)) {
goto exit;
+ }
return_value = _multibytecodec_MultibyteIncrementalDecoder_decode_impl(self, &input, final);
exit:
/* Cleanup for input */
- if (input.obj)
+ if (input.obj) {
PyBuffer_Release(&input);
+ }
return return_value;
}
@@ -196,8 +202,9 @@
if (!PyArg_UnpackTuple(args, "read",
0, 1,
- &sizeobj))
+ &sizeobj)) {
goto exit;
+ }
return_value = _multibytecodec_MultibyteStreamReader_read_impl(self, sizeobj);
exit:
@@ -224,8 +231,9 @@
if (!PyArg_UnpackTuple(args, "readline",
0, 1,
- &sizeobj))
+ &sizeobj)) {
goto exit;
+ }
return_value = _multibytecodec_MultibyteStreamReader_readline_impl(self, sizeobj);
exit:
@@ -252,8 +260,9 @@
if (!PyArg_UnpackTuple(args, "readlines",
0, 1,
- &sizehintobj))
+ &sizehintobj)) {
goto exit;
+ }
return_value = _multibytecodec_MultibyteStreamReader_readlines_impl(self, sizehintobj);
exit:
@@ -317,4 +326,4 @@
#define _MULTIBYTECODEC___CREATE_CODEC_METHODDEF \
{"__create_codec", (PyCFunction)_multibytecodec___create_codec, METH_O, _multibytecodec___create_codec__doc__},
-/*[clinic end generated code: output=eebb21e18c3043d1 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=f837bc56b2fa2a4e input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_bz2module.c.h b/Modules/clinic/_bz2module.c.h
index 3ed8303..9451fd3 100644
--- a/Modules/clinic/_bz2module.c.h
+++ b/Modules/clinic/_bz2module.c.h
@@ -25,14 +25,16 @@
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:compress", &data))
+ if (!PyArg_Parse(arg, "y*:compress", &data)) {
goto exit;
+ }
return_value = _bz2_BZ2Compressor_compress_impl(self, &data);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -80,11 +82,13 @@
int compresslevel = 9;
if ((Py_TYPE(self) == &BZ2Compressor_Type) &&
- !_PyArg_NoKeywords("BZ2Compressor", kwargs))
+ !_PyArg_NoKeywords("BZ2Compressor", kwargs)) {
goto exit;
+ }
if (!PyArg_ParseTuple(args, "|i:BZ2Compressor",
- &compresslevel))
+ &compresslevel)) {
goto exit;
+ }
return_value = _bz2_BZ2Compressor___init___impl((BZ2Compressor *)self, compresslevel);
exit:
@@ -126,14 +130,16 @@
Py_ssize_t max_length = -1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|n:decompress", _keywords,
- &data, &max_length))
+ &data, &max_length)) {
goto exit;
+ }
return_value = _bz2_BZ2Decompressor_decompress_impl(self, &data, max_length);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -155,14 +161,16 @@
int return_value = -1;
if ((Py_TYPE(self) == &BZ2Decompressor_Type) &&
- !_PyArg_NoPositional("BZ2Decompressor", args))
+ !_PyArg_NoPositional("BZ2Decompressor", args)) {
goto exit;
+ }
if ((Py_TYPE(self) == &BZ2Decompressor_Type) &&
- !_PyArg_NoKeywords("BZ2Decompressor", kwargs))
+ !_PyArg_NoKeywords("BZ2Decompressor", kwargs)) {
goto exit;
+ }
return_value = _bz2_BZ2Decompressor___init___impl((BZ2Decompressor *)self);
exit:
return return_value;
}
-/*[clinic end generated code: output=fef29b76b3314fc7 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=71be22f38224fe84 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_codecsmodule.c.h b/Modules/clinic/_codecsmodule.c.h
index e94be11..a7ca79e 100644
--- a/Modules/clinic/_codecsmodule.c.h
+++ b/Modules/clinic/_codecsmodule.c.h
@@ -33,8 +33,9 @@
PyObject *return_value = NULL;
const char *encoding;
- if (!PyArg_Parse(arg, "s:lookup", &encoding))
+ if (!PyArg_Parse(arg, "s:lookup", &encoding)) {
goto exit;
+ }
return_value = _codecs_lookup_impl(module, encoding);
exit:
@@ -70,8 +71,9 @@
const char *errors = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|ss:encode", _keywords,
- &obj, &encoding, &errors))
+ &obj, &encoding, &errors)) {
goto exit;
+ }
return_value = _codecs_encode_impl(module, obj, encoding, errors);
exit:
@@ -107,8 +109,9 @@
const char *errors = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|ss:decode", _keywords,
- &obj, &encoding, &errors))
+ &obj, &encoding, &errors)) {
goto exit;
+ }
return_value = _codecs_decode_impl(module, obj, encoding, errors);
exit:
@@ -133,8 +136,9 @@
PyObject *return_value = NULL;
const char *encoding;
- if (!PyArg_Parse(arg, "s:_forget_codec", &encoding))
+ if (!PyArg_Parse(arg, "s:_forget_codec", &encoding)) {
goto exit;
+ }
return_value = _codecs__forget_codec_impl(module, encoding);
exit:
@@ -161,14 +165,16 @@
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "s*|z:escape_decode",
- &data, &errors))
+ &data, &errors)) {
goto exit;
+ }
return_value = _codecs_escape_decode_impl(module, &data, errors);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -193,8 +199,9 @@
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "O!|z:escape_encode",
- &PyBytes_Type, &data, &errors))
+ &PyBytes_Type, &data, &errors)) {
goto exit;
+ }
return_value = _codecs_escape_encode_impl(module, data, errors);
exit:
@@ -221,8 +228,9 @@
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "O|z:unicode_internal_decode",
- &obj, &errors))
+ &obj, &errors)) {
goto exit;
+ }
return_value = _codecs_unicode_internal_decode_impl(module, obj, errors);
exit:
@@ -250,14 +258,16 @@
int final = 0;
if (!PyArg_ParseTuple(args, "y*|zi:utf_7_decode",
- &data, &errors, &final))
+ &data, &errors, &final)) {
goto exit;
+ }
return_value = _codecs_utf_7_decode_impl(module, &data, errors, final);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -283,14 +293,16 @@
int final = 0;
if (!PyArg_ParseTuple(args, "y*|zi:utf_8_decode",
- &data, &errors, &final))
+ &data, &errors, &final)) {
goto exit;
+ }
return_value = _codecs_utf_8_decode_impl(module, &data, errors, final);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -316,14 +328,16 @@
int final = 0;
if (!PyArg_ParseTuple(args, "y*|zi:utf_16_decode",
- &data, &errors, &final))
+ &data, &errors, &final)) {
goto exit;
+ }
return_value = _codecs_utf_16_decode_impl(module, &data, errors, final);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -349,14 +363,16 @@
int final = 0;
if (!PyArg_ParseTuple(args, "y*|zi:utf_16_le_decode",
- &data, &errors, &final))
+ &data, &errors, &final)) {
goto exit;
+ }
return_value = _codecs_utf_16_le_decode_impl(module, &data, errors, final);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -382,14 +398,16 @@
int final = 0;
if (!PyArg_ParseTuple(args, "y*|zi:utf_16_be_decode",
- &data, &errors, &final))
+ &data, &errors, &final)) {
goto exit;
+ }
return_value = _codecs_utf_16_be_decode_impl(module, &data, errors, final);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -417,14 +435,16 @@
int final = 0;
if (!PyArg_ParseTuple(args, "y*|zii:utf_16_ex_decode",
- &data, &errors, &byteorder, &final))
+ &data, &errors, &byteorder, &final)) {
goto exit;
+ }
return_value = _codecs_utf_16_ex_decode_impl(module, &data, errors, byteorder, final);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -450,14 +470,16 @@
int final = 0;
if (!PyArg_ParseTuple(args, "y*|zi:utf_32_decode",
- &data, &errors, &final))
+ &data, &errors, &final)) {
goto exit;
+ }
return_value = _codecs_utf_32_decode_impl(module, &data, errors, final);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -483,14 +505,16 @@
int final = 0;
if (!PyArg_ParseTuple(args, "y*|zi:utf_32_le_decode",
- &data, &errors, &final))
+ &data, &errors, &final)) {
goto exit;
+ }
return_value = _codecs_utf_32_le_decode_impl(module, &data, errors, final);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -516,14 +540,16 @@
int final = 0;
if (!PyArg_ParseTuple(args, "y*|zi:utf_32_be_decode",
- &data, &errors, &final))
+ &data, &errors, &final)) {
goto exit;
+ }
return_value = _codecs_utf_32_be_decode_impl(module, &data, errors, final);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -551,14 +577,16 @@
int final = 0;
if (!PyArg_ParseTuple(args, "y*|zii:utf_32_ex_decode",
- &data, &errors, &byteorder, &final))
+ &data, &errors, &byteorder, &final)) {
goto exit;
+ }
return_value = _codecs_utf_32_ex_decode_impl(module, &data, errors, byteorder, final);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -583,14 +611,16 @@
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "s*|z:unicode_escape_decode",
- &data, &errors))
+ &data, &errors)) {
goto exit;
+ }
return_value = _codecs_unicode_escape_decode_impl(module, &data, errors);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -615,14 +645,16 @@
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "s*|z:raw_unicode_escape_decode",
- &data, &errors))
+ &data, &errors)) {
goto exit;
+ }
return_value = _codecs_raw_unicode_escape_decode_impl(module, &data, errors);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -647,14 +679,16 @@
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "y*|z:latin_1_decode",
- &data, &errors))
+ &data, &errors)) {
goto exit;
+ }
return_value = _codecs_latin_1_decode_impl(module, &data, errors);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -679,14 +713,16 @@
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "y*|z:ascii_decode",
- &data, &errors))
+ &data, &errors)) {
goto exit;
+ }
return_value = _codecs_ascii_decode_impl(module, &data, errors);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -712,14 +748,16 @@
PyObject *mapping = NULL;
if (!PyArg_ParseTuple(args, "y*|zO:charmap_decode",
- &data, &errors, &mapping))
+ &data, &errors, &mapping)) {
goto exit;
+ }
return_value = _codecs_charmap_decode_impl(module, &data, errors, mapping);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -747,14 +785,16 @@
int final = 0;
if (!PyArg_ParseTuple(args, "y*|zi:mbcs_decode",
- &data, &errors, &final))
+ &data, &errors, &final)) {
goto exit;
+ }
return_value = _codecs_mbcs_decode_impl(module, &data, errors, final);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -785,14 +825,16 @@
int final = 0;
if (!PyArg_ParseTuple(args, "iy*|zi:code_page_decode",
- &codepage, &data, &errors, &final))
+ &codepage, &data, &errors, &final)) {
goto exit;
+ }
return_value = _codecs_code_page_decode_impl(module, codepage, &data, errors, final);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -819,14 +861,16 @@
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "s*|z:readbuffer_encode",
- &data, &errors))
+ &data, &errors)) {
goto exit;
+ }
return_value = _codecs_readbuffer_encode_impl(module, &data, errors);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -851,8 +895,9 @@
const char *errors = NULL;
if (!PyArg_ParseTuple(args, "O|z:unicode_internal_encode",
- &obj, &errors))
+ &obj, &errors)) {
goto exit;
+ }
return_value = _codecs_unicode_internal_encode_impl(module, obj, errors);
exit:
@@ -878,9 +923,10 @@
PyObject *str;
const char *errors = NULL;
- if (!PyArg_ParseTuple(args, "O|z:utf_7_encode",
- &str, &errors))
+ if (!PyArg_ParseTuple(args, "U|z:utf_7_encode",
+ &str, &errors)) {
goto exit;
+ }
return_value = _codecs_utf_7_encode_impl(module, str, errors);
exit:
@@ -906,9 +952,10 @@
PyObject *str;
const char *errors = NULL;
- if (!PyArg_ParseTuple(args, "O|z:utf_8_encode",
- &str, &errors))
+ if (!PyArg_ParseTuple(args, "U|z:utf_8_encode",
+ &str, &errors)) {
goto exit;
+ }
return_value = _codecs_utf_8_encode_impl(module, str, errors);
exit:
@@ -935,9 +982,10 @@
const char *errors = NULL;
int byteorder = 0;
- if (!PyArg_ParseTuple(args, "O|zi:utf_16_encode",
- &str, &errors, &byteorder))
+ if (!PyArg_ParseTuple(args, "U|zi:utf_16_encode",
+ &str, &errors, &byteorder)) {
goto exit;
+ }
return_value = _codecs_utf_16_encode_impl(module, str, errors, byteorder);
exit:
@@ -963,9 +1011,10 @@
PyObject *str;
const char *errors = NULL;
- if (!PyArg_ParseTuple(args, "O|z:utf_16_le_encode",
- &str, &errors))
+ if (!PyArg_ParseTuple(args, "U|z:utf_16_le_encode",
+ &str, &errors)) {
goto exit;
+ }
return_value = _codecs_utf_16_le_encode_impl(module, str, errors);
exit:
@@ -991,9 +1040,10 @@
PyObject *str;
const char *errors = NULL;
- if (!PyArg_ParseTuple(args, "O|z:utf_16_be_encode",
- &str, &errors))
+ if (!PyArg_ParseTuple(args, "U|z:utf_16_be_encode",
+ &str, &errors)) {
goto exit;
+ }
return_value = _codecs_utf_16_be_encode_impl(module, str, errors);
exit:
@@ -1020,9 +1070,10 @@
const char *errors = NULL;
int byteorder = 0;
- if (!PyArg_ParseTuple(args, "O|zi:utf_32_encode",
- &str, &errors, &byteorder))
+ if (!PyArg_ParseTuple(args, "U|zi:utf_32_encode",
+ &str, &errors, &byteorder)) {
goto exit;
+ }
return_value = _codecs_utf_32_encode_impl(module, str, errors, byteorder);
exit:
@@ -1048,9 +1099,10 @@
PyObject *str;
const char *errors = NULL;
- if (!PyArg_ParseTuple(args, "O|z:utf_32_le_encode",
- &str, &errors))
+ if (!PyArg_ParseTuple(args, "U|z:utf_32_le_encode",
+ &str, &errors)) {
goto exit;
+ }
return_value = _codecs_utf_32_le_encode_impl(module, str, errors);
exit:
@@ -1076,9 +1128,10 @@
PyObject *str;
const char *errors = NULL;
- if (!PyArg_ParseTuple(args, "O|z:utf_32_be_encode",
- &str, &errors))
+ if (!PyArg_ParseTuple(args, "U|z:utf_32_be_encode",
+ &str, &errors)) {
goto exit;
+ }
return_value = _codecs_utf_32_be_encode_impl(module, str, errors);
exit:
@@ -1104,9 +1157,10 @@
PyObject *str;
const char *errors = NULL;
- if (!PyArg_ParseTuple(args, "O|z:unicode_escape_encode",
- &str, &errors))
+ if (!PyArg_ParseTuple(args, "U|z:unicode_escape_encode",
+ &str, &errors)) {
goto exit;
+ }
return_value = _codecs_unicode_escape_encode_impl(module, str, errors);
exit:
@@ -1132,9 +1186,10 @@
PyObject *str;
const char *errors = NULL;
- if (!PyArg_ParseTuple(args, "O|z:raw_unicode_escape_encode",
- &str, &errors))
+ if (!PyArg_ParseTuple(args, "U|z:raw_unicode_escape_encode",
+ &str, &errors)) {
goto exit;
+ }
return_value = _codecs_raw_unicode_escape_encode_impl(module, str, errors);
exit:
@@ -1160,9 +1215,10 @@
PyObject *str;
const char *errors = NULL;
- if (!PyArg_ParseTuple(args, "O|z:latin_1_encode",
- &str, &errors))
+ if (!PyArg_ParseTuple(args, "U|z:latin_1_encode",
+ &str, &errors)) {
goto exit;
+ }
return_value = _codecs_latin_1_encode_impl(module, str, errors);
exit:
@@ -1188,9 +1244,10 @@
PyObject *str;
const char *errors = NULL;
- if (!PyArg_ParseTuple(args, "O|z:ascii_encode",
- &str, &errors))
+ if (!PyArg_ParseTuple(args, "U|z:ascii_encode",
+ &str, &errors)) {
goto exit;
+ }
return_value = _codecs_ascii_encode_impl(module, str, errors);
exit:
@@ -1217,9 +1274,10 @@
const char *errors = NULL;
PyObject *mapping = NULL;
- if (!PyArg_ParseTuple(args, "O|zO:charmap_encode",
- &str, &errors, &mapping))
+ if (!PyArg_ParseTuple(args, "U|zO:charmap_encode",
+ &str, &errors, &mapping)) {
goto exit;
+ }
return_value = _codecs_charmap_encode_impl(module, str, errors, mapping);
exit:
@@ -1243,8 +1301,9 @@
PyObject *return_value = NULL;
PyObject *map;
- if (!PyArg_Parse(arg, "U:charmap_build", &map))
+ if (!PyArg_Parse(arg, "U:charmap_build", &map)) {
goto exit;
+ }
return_value = _codecs_charmap_build_impl(module, map);
exit:
@@ -1272,9 +1331,10 @@
PyObject *str;
const char *errors = NULL;
- if (!PyArg_ParseTuple(args, "O|z:mbcs_encode",
- &str, &errors))
+ if (!PyArg_ParseTuple(args, "U|z:mbcs_encode",
+ &str, &errors)) {
goto exit;
+ }
return_value = _codecs_mbcs_encode_impl(module, str, errors);
exit:
@@ -1305,9 +1365,10 @@
PyObject *str;
const char *errors = NULL;
- if (!PyArg_ParseTuple(args, "iO|z:code_page_encode",
- &code_page, &str, &errors))
+ if (!PyArg_ParseTuple(args, "iU|z:code_page_encode",
+ &code_page, &str, &errors)) {
goto exit;
+ }
return_value = _codecs_code_page_encode_impl(module, code_page, str, errors);
exit:
@@ -1341,8 +1402,9 @@
PyObject *handler;
if (!PyArg_ParseTuple(args, "sO:register_error",
- &errors, &handler))
+ &errors, &handler)) {
goto exit;
+ }
return_value = _codecs_register_error_impl(module, errors, handler);
exit:
@@ -1370,8 +1432,9 @@
PyObject *return_value = NULL;
const char *name;
- if (!PyArg_Parse(arg, "s:lookup_error", &name))
+ if (!PyArg_Parse(arg, "s:lookup_error", &name)) {
goto exit;
+ }
return_value = _codecs_lookup_error_impl(module, name);
exit:
@@ -1393,4 +1456,4 @@
#ifndef _CODECS_CODE_PAGE_ENCODE_METHODDEF
#define _CODECS_CODE_PAGE_ENCODE_METHODDEF
#endif /* !defined(_CODECS_CODE_PAGE_ENCODE_METHODDEF) */
-/*[clinic end generated code: output=9c9967048027c1c7 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=120320fe2ac32085 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_cryptmodule.c.h b/Modules/clinic/_cryptmodule.c.h
index b8ec31e..664cba8 100644
--- a/Modules/clinic/_cryptmodule.c.h
+++ b/Modules/clinic/_cryptmodule.c.h
@@ -27,11 +27,12 @@
const char *salt;
if (!PyArg_ParseTuple(args, "ss:crypt",
- &word, &salt))
+ &word, &salt)) {
goto exit;
+ }
return_value = crypt_crypt_impl(module, word, salt);
exit:
return return_value;
}
-/*[clinic end generated code: output=22c295c9bce018c4 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=6977cf9917d9a684 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_cursesmodule.c.h b/Modules/clinic/_cursesmodule.c.h
index 5e11742..62ff1c8 100644
--- a/Modules/clinic/_cursesmodule.c.h
+++ b/Modules/clinic/_cursesmodule.c.h
@@ -40,22 +40,26 @@
switch (PyTuple_GET_SIZE(args)) {
case 1:
- if (!PyArg_ParseTuple(args, "O:addch", &ch))
+ if (!PyArg_ParseTuple(args, "O:addch", &ch)) {
goto exit;
+ }
break;
case 2:
- if (!PyArg_ParseTuple(args, "Ol:addch", &ch, &attr))
+ if (!PyArg_ParseTuple(args, "Ol:addch", &ch, &attr)) {
goto exit;
+ }
group_right_1 = 1;
break;
case 3:
- if (!PyArg_ParseTuple(args, "iiO:addch", &y, &x, &ch))
+ if (!PyArg_ParseTuple(args, "iiO:addch", &y, &x, &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", &y, &x, &ch, &attr)) {
goto exit;
+ }
group_right_1 = 1;
group_left_1 = 1;
break;
@@ -68,4 +72,4 @@
exit:
return return_value;
}
-/*[clinic end generated code: output=982b1e709577f3ec input=a9049054013a1b77]*/
+/*[clinic end generated code: output=13ffc5f8d79cbfbf input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_datetimemodule.c.h b/Modules/clinic/_datetimemodule.c.h
index 688c903..cf9860b 100644
--- a/Modules/clinic/_datetimemodule.c.h
+++ b/Modules/clinic/_datetimemodule.c.h
@@ -27,11 +27,12 @@
PyObject *tz = Py_None;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:now", _keywords,
- &tz))
+ &tz)) {
goto exit;
+ }
return_value = datetime_datetime_now_impl(type, tz);
exit:
return return_value;
}
-/*[clinic end generated code: output=7f45c670d6e4953a input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a82e6bd057a5dab9 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_dbmmodule.c.h b/Modules/clinic/_dbmmodule.c.h
index 8474e02..b31da71 100644
--- a/Modules/clinic/_dbmmodule.c.h
+++ b/Modules/clinic/_dbmmodule.c.h
@@ -60,8 +60,9 @@
PyObject *default_value = NULL;
if (!PyArg_ParseTuple(args, "s#|O:get",
- &key, &key_length, &default_value))
+ &key, &key_length, &default_value)) {
goto exit;
+ }
return_value = _dbm_dbm_get_impl(self, key, key_length, default_value);
exit:
@@ -93,8 +94,9 @@
PyObject *default_value = NULL;
if (!PyArg_ParseTuple(args, "s#|O:setdefault",
- &key, &key_length, &default_value))
+ &key, &key_length, &default_value)) {
goto exit;
+ }
return_value = _dbm_dbm_setdefault_impl(self, key, key_length, default_value);
exit:
@@ -131,11 +133,12 @@
int mode = 438;
if (!PyArg_ParseTuple(args, "s|si:open",
- &filename, &flags, &mode))
+ &filename, &flags, &mode)) {
goto exit;
+ }
return_value = dbmopen_impl(module, filename, flags, mode);
exit:
return return_value;
}
-/*[clinic end generated code: output=1d92e81b28c558d0 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=97f8b6f542973b71 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_elementtree.c.h b/Modules/clinic/_elementtree.c.h
index 86b4c4c..266b92f 100644
--- a/Modules/clinic/_elementtree.c.h
+++ b/Modules/clinic/_elementtree.c.h
@@ -19,8 +19,9 @@
PyObject *return_value = NULL;
PyObject *subelement;
- if (!PyArg_Parse(arg, "O!:append", &Element_Type, &subelement))
+ if (!PyArg_Parse(arg, "O!:append", &Element_Type, &subelement)) {
goto exit;
+ }
return_value = _elementtree_Element_append_impl(self, subelement);
exit:
@@ -87,8 +88,9 @@
Py_ssize_t _return_value;
_return_value = _elementtree_Element___sizeof___impl(self);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromSsize_t(_return_value);
exit:
@@ -149,8 +151,9 @@
PyObject *namespaces = Py_None;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:find", _keywords,
- &path, &namespaces))
+ &path, &namespaces)) {
goto exit;
+ }
return_value = _elementtree_Element_find_impl(self, path, namespaces);
exit:
@@ -180,8 +183,9 @@
PyObject *namespaces = Py_None;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OO:findtext", _keywords,
- &path, &default_value, &namespaces))
+ &path, &default_value, &namespaces)) {
goto exit;
+ }
return_value = _elementtree_Element_findtext_impl(self, path, default_value, namespaces);
exit:
@@ -209,8 +213,9 @@
PyObject *namespaces = Py_None;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:findall", _keywords,
- &path, &namespaces))
+ &path, &namespaces)) {
goto exit;
+ }
return_value = _elementtree_Element_findall_impl(self, path, namespaces);
exit:
@@ -238,8 +243,9 @@
PyObject *namespaces = Py_None;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:iterfind", _keywords,
- &path, &namespaces))
+ &path, &namespaces)) {
goto exit;
+ }
return_value = _elementtree_Element_iterfind_impl(self, path, namespaces);
exit:
@@ -267,8 +273,9 @@
PyObject *default_value = Py_None;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:get", _keywords,
- &key, &default_value))
+ &key, &default_value)) {
goto exit;
+ }
return_value = _elementtree_Element_get_impl(self, key, default_value);
exit:
@@ -311,8 +318,9 @@
PyObject *tag = Py_None;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:iter", _keywords,
- &tag))
+ &tag)) {
goto exit;
+ }
return_value = _elementtree_Element_iter_impl(self, tag);
exit:
@@ -356,8 +364,9 @@
PyObject *subelement;
if (!PyArg_ParseTuple(args, "nO!:insert",
- &index, &Element_Type, &subelement))
+ &index, &Element_Type, &subelement)) {
goto exit;
+ }
return_value = _elementtree_Element_insert_impl(self, index, subelement);
exit:
@@ -419,8 +428,9 @@
if (!PyArg_UnpackTuple(args, "makeelement",
2, 2,
- &tag, &attrib))
+ &tag, &attrib)) {
goto exit;
+ }
return_value = _elementtree_Element_makeelement_impl(self, tag, attrib);
exit:
@@ -444,8 +454,9 @@
PyObject *return_value = NULL;
PyObject *subelement;
- if (!PyArg_Parse(arg, "O!:remove", &Element_Type, &subelement))
+ if (!PyArg_Parse(arg, "O!:remove", &Element_Type, &subelement)) {
goto exit;
+ }
return_value = _elementtree_Element_remove_impl(self, subelement);
exit:
@@ -473,8 +484,9 @@
if (!PyArg_UnpackTuple(args, "set",
2, 2,
- &key, &value))
+ &key, &value)) {
goto exit;
+ }
return_value = _elementtree_Element_set_impl(self, key, value);
exit:
@@ -493,8 +505,9 @@
PyObject *element_factory = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:TreeBuilder", _keywords,
- &element_factory))
+ &element_factory)) {
goto exit;
+ }
return_value = _elementtree_TreeBuilder___init___impl((TreeBuilderObject *)self, element_factory);
exit:
@@ -555,8 +568,9 @@
if (!PyArg_UnpackTuple(args, "start",
1, 2,
- &tag, &attrs))
+ &tag, &attrs)) {
goto exit;
+ }
return_value = _elementtree_TreeBuilder_start_impl(self, tag, attrs);
exit:
@@ -577,8 +591,9 @@
const char *encoding = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOz:XMLParser", _keywords,
- &html, &target, &encoding))
+ &html, &target, &encoding)) {
goto exit;
+ }
return_value = _elementtree_XMLParser___init___impl((XMLParserObject *)self, html, target, encoding);
exit:
@@ -640,8 +655,9 @@
if (!PyArg_UnpackTuple(args, "doctype",
3, 3,
- &name, &pubid, &system))
+ &name, &pubid, &system)) {
goto exit;
+ }
return_value = _elementtree_XMLParser_doctype_impl(self, name, pubid, system);
exit:
@@ -668,12 +684,14 @@
PyObject *events_queue;
PyObject *events_to_report = Py_None;
- if (!PyArg_ParseTuple(args, "O!|O:_setevents",
- &PyList_Type, &events_queue, &events_to_report))
+ if (!PyArg_UnpackTuple(args, "_setevents",
+ 1, 2,
+ &events_queue, &events_to_report)) {
goto exit;
+ }
return_value = _elementtree_XMLParser__setevents_impl(self, events_queue, events_to_report);
exit:
return return_value;
}
-/*[clinic end generated code: output=25b8bf7e7f2151ca input=a9049054013a1b77]*/
+/*[clinic end generated code: output=491eb5718c1ae64b input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_gdbmmodule.c.h b/Modules/clinic/_gdbmmodule.c.h
index 110ad9a..23182c8 100644
--- a/Modules/clinic/_gdbmmodule.c.h
+++ b/Modules/clinic/_gdbmmodule.c.h
@@ -23,8 +23,9 @@
if (!PyArg_UnpackTuple(args, "get",
1, 2,
- &key, &default_value))
+ &key, &default_value)) {
goto exit;
+ }
return_value = _gdbm_gdbm_get_impl(self, key, default_value);
exit:
@@ -53,8 +54,9 @@
if (!PyArg_UnpackTuple(args, "setdefault",
1, 2,
- &key, &default_value))
+ &key, &default_value)) {
goto exit;
+ }
return_value = _gdbm_gdbm_setdefault_impl(self, key, default_value);
exit:
@@ -147,8 +149,9 @@
const char *key;
Py_ssize_clean_t key_length;
- if (!PyArg_Parse(arg, "s#:nextkey", &key, &key_length))
+ if (!PyArg_Parse(arg, "s#:nextkey", &key, &key_length)) {
goto exit;
+ }
return_value = _gdbm_gdbm_nextkey_impl(self, key, key_length);
exit:
@@ -243,11 +246,12 @@
int mode = 438;
if (!PyArg_ParseTuple(args, "s|si:open",
- &name, &flags, &mode))
+ &name, &flags, &mode)) {
goto exit;
+ }
return_value = dbmopen_impl(module, name, flags, mode);
exit:
return return_value;
}
-/*[clinic end generated code: output=d3d8d871bcccb68a input=a9049054013a1b77]*/
+/*[clinic end generated code: output=418849fb5dbe69a5 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_lzmamodule.c.h b/Modules/clinic/_lzmamodule.c.h
index 59d9d51..b78dbcd 100644
--- a/Modules/clinic/_lzmamodule.c.h
+++ b/Modules/clinic/_lzmamodule.c.h
@@ -25,14 +25,16 @@
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:compress", &data))
+ if (!PyArg_Parse(arg, "y*:compress", &data)) {
goto exit;
+ }
return_value = _lzma_LZMACompressor_compress_impl(self, &data);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -94,14 +96,16 @@
Py_ssize_t max_length = -1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|n:decompress", _keywords,
- &data, &max_length))
+ &data, &max_length)) {
goto exit;
+ }
return_value = _lzma_LZMADecompressor_decompress_impl(self, &data, max_length);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -143,8 +147,9 @@
PyObject *filters = Py_None;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iOO:LZMADecompressor", _keywords,
- &format, &memlimit, &filters))
+ &format, &memlimit, &filters)) {
goto exit;
+ }
return_value = _lzma_LZMADecompressor___init___impl((Decompressor *)self, format, memlimit, filters);
exit:
@@ -171,8 +176,9 @@
PyObject *return_value = NULL;
int check_id;
- if (!PyArg_Parse(arg, "i:is_check_supported", &check_id))
+ if (!PyArg_Parse(arg, "i:is_check_supported", &check_id)) {
goto exit;
+ }
return_value = _lzma_is_check_supported_impl(module, check_id);
exit:
@@ -199,8 +205,9 @@
PyObject *return_value = NULL;
lzma_filter filter = {LZMA_VLI_UNKNOWN, NULL};
- if (!PyArg_Parse(arg, "O&:_encode_filter_properties", lzma_filter_converter, &filter))
+ if (!PyArg_Parse(arg, "O&:_encode_filter_properties", lzma_filter_converter, &filter)) {
goto exit;
+ }
return_value = _lzma__encode_filter_properties_impl(module, filter);
exit:
@@ -234,15 +241,17 @@
Py_buffer encoded_props = {NULL, NULL};
if (!PyArg_ParseTuple(args, "O&y*:_decode_filter_properties",
- lzma_vli_converter, &filter_id, &encoded_props))
+ lzma_vli_converter, &filter_id, &encoded_props)) {
goto exit;
+ }
return_value = _lzma__decode_filter_properties_impl(module, filter_id, &encoded_props);
exit:
/* Cleanup for encoded_props */
- if (encoded_props.obj)
+ if (encoded_props.obj) {
PyBuffer_Release(&encoded_props);
+ }
return return_value;
}
-/*[clinic end generated code: output=2d3e0842be3d3fe1 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=804aed7d196ba52e input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_opcode.c.h b/Modules/clinic/_opcode.c.h
index 196a2ee..68652b0 100644
--- a/Modules/clinic/_opcode.c.h
+++ b/Modules/clinic/_opcode.c.h
@@ -23,14 +23,16 @@
int _return_value;
if (!PyArg_ParseTuple(args, "i|O:stack_effect",
- &opcode, &oparg))
+ &opcode, &oparg)) {
goto exit;
+ }
_return_value = _opcode_stack_effect_impl(module, opcode, oparg);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong((long)_return_value);
exit:
return return_value;
}
-/*[clinic end generated code: output=8ee7cb735705e8b3 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=5bd7c1c113e6526a input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_pickle.c.h b/Modules/clinic/_pickle.c.h
index ab4d205..11299e9 100644
--- a/Modules/clinic/_pickle.c.h
+++ b/Modules/clinic/_pickle.c.h
@@ -53,8 +53,9 @@
Py_ssize_t _return_value;
_return_value = _pickle_Pickler___sizeof___impl(self);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromSsize_t(_return_value);
exit:
@@ -98,8 +99,9 @@
int fix_imports = 1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|Op:Pickler", _keywords,
- &file, &protocol, &fix_imports))
+ &file, &protocol, &fix_imports)) {
goto exit;
+ }
return_value = _pickle_Pickler___init___impl((PicklerObject *)self, file, protocol, fix_imports);
exit:
@@ -212,8 +214,9 @@
if (!PyArg_UnpackTuple(args, "find_class",
2, 2,
- &module_name, &global_name))
+ &module_name, &global_name)) {
goto exit;
+ }
return_value = _pickle_Unpickler_find_class_impl(self, module_name, global_name);
exit:
@@ -239,8 +242,9 @@
Py_ssize_t _return_value;
_return_value = _pickle_Unpickler___sizeof___impl(self);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromSsize_t(_return_value);
exit:
@@ -288,8 +292,9 @@
const char *errors = "strict";
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|$pss:Unpickler", _keywords,
- &file, &fix_imports, &encoding, &errors))
+ &file, &fix_imports, &encoding, &errors)) {
goto exit;
+ }
return_value = _pickle_Unpickler___init___impl((UnpicklerObject *)self, file, fix_imports, encoding, errors);
exit:
@@ -394,8 +399,9 @@
int fix_imports = 1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|O$p:dump", _keywords,
- &obj, &file, &protocol, &fix_imports))
+ &obj, &file, &protocol, &fix_imports)) {
goto exit;
+ }
return_value = _pickle_dump_impl(module, obj, file, protocol, fix_imports);
exit:
@@ -437,8 +443,9 @@
int fix_imports = 1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O$p:dumps", _keywords,
- &obj, &protocol, &fix_imports))
+ &obj, &protocol, &fix_imports)) {
goto exit;
+ }
return_value = _pickle_dumps_impl(module, obj, protocol, fix_imports);
exit:
@@ -492,8 +499,9 @@
const char *errors = "strict";
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|$pss:load", _keywords,
- &file, &fix_imports, &encoding, &errors))
+ &file, &fix_imports, &encoding, &errors)) {
goto exit;
+ }
return_value = _pickle_load_impl(module, file, fix_imports, encoding, errors);
exit:
@@ -538,11 +546,12 @@
const char *errors = "strict";
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|$pss:loads", _keywords,
- &data, &fix_imports, &encoding, &errors))
+ &data, &fix_imports, &encoding, &errors)) {
goto exit;
+ }
return_value = _pickle_loads_impl(module, data, fix_imports, encoding, errors);
exit:
return return_value;
}
-/*[clinic end generated code: output=a7169d4fbbeef827 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=5e972f339d197760 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_sre.c.h b/Modules/clinic/_sre.c.h
index 6de4708..448d8af 100644
--- a/Modules/clinic/_sre.c.h
+++ b/Modules/clinic/_sre.c.h
@@ -20,8 +20,9 @@
int _return_value;
_return_value = _sre_getcodesize_impl(module);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong((long)_return_value);
exit:
@@ -48,11 +49,13 @@
int _return_value;
if (!PyArg_ParseTuple(args, "ii:getlower",
- &character, &flags))
+ &character, &flags)) {
goto exit;
+ }
_return_value = _sre_getlower_impl(module, character, flags);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong((long)_return_value);
exit:
@@ -84,8 +87,9 @@
PyObject *pattern = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Onn$O:match", _keywords,
- &string, &pos, &endpos, &pattern))
+ &string, &pos, &endpos, &pattern)) {
goto exit;
+ }
return_value = _sre_SRE_Pattern_match_impl(self, string, pos, endpos, pattern);
exit:
@@ -118,8 +122,9 @@
PyObject *pattern = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Onn$O:fullmatch", _keywords,
- &string, &pos, &endpos, &pattern))
+ &string, &pos, &endpos, &pattern)) {
goto exit;
+ }
return_value = _sre_SRE_Pattern_fullmatch_impl(self, string, pos, endpos, pattern);
exit:
@@ -154,8 +159,9 @@
PyObject *pattern = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Onn$O:search", _keywords,
- &string, &pos, &endpos, &pattern))
+ &string, &pos, &endpos, &pattern)) {
goto exit;
+ }
return_value = _sre_SRE_Pattern_search_impl(self, string, pos, endpos, pattern);
exit:
@@ -188,8 +194,9 @@
PyObject *source = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Onn$O:findall", _keywords,
- &string, &pos, &endpos, &source))
+ &string, &pos, &endpos, &source)) {
goto exit;
+ }
return_value = _sre_SRE_Pattern_findall_impl(self, string, pos, endpos, source);
exit:
@@ -221,8 +228,9 @@
Py_ssize_t endpos = PY_SSIZE_T_MAX;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|nn:finditer", _keywords,
- &string, &pos, &endpos))
+ &string, &pos, &endpos)) {
goto exit;
+ }
return_value = _sre_SRE_Pattern_finditer_impl(self, string, pos, endpos);
exit:
@@ -251,8 +259,9 @@
Py_ssize_t endpos = PY_SSIZE_T_MAX;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|nn:scanner", _keywords,
- &string, &pos, &endpos))
+ &string, &pos, &endpos)) {
goto exit;
+ }
return_value = _sre_SRE_Pattern_scanner_impl(self, string, pos, endpos);
exit:
@@ -282,8 +291,9 @@
PyObject *source = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|On$O:split", _keywords,
- &string, &maxsplit, &source))
+ &string, &maxsplit, &source)) {
goto exit;
+ }
return_value = _sre_SRE_Pattern_split_impl(self, string, maxsplit, source);
exit:
@@ -313,8 +323,9 @@
Py_ssize_t count = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|n:sub", _keywords,
- &repl, &string, &count))
+ &repl, &string, &count)) {
goto exit;
+ }
return_value = _sre_SRE_Pattern_sub_impl(self, repl, string, count);
exit:
@@ -344,8 +355,9 @@
Py_ssize_t count = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|n:subn", _keywords,
- &repl, &string, &count))
+ &repl, &string, &count)) {
goto exit;
+ }
return_value = _sre_SRE_Pattern_subn_impl(self, repl, string, count);
exit:
@@ -388,8 +400,9 @@
PyObject *memo;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:__deepcopy__", _keywords,
- &memo))
+ &memo)) {
goto exit;
+ }
return_value = _sre_SRE_Pattern___deepcopy___impl(self, memo);
exit:
@@ -423,8 +436,9 @@
PyObject *indexgroup;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OiO!nOO:compile", _keywords,
- &pattern, &flags, &PyList_Type, &code, &groups, &groupindex, &indexgroup))
+ &pattern, &flags, &PyList_Type, &code, &groups, &groupindex, &indexgroup)) {
goto exit;
+ }
return_value = _sre_compile_impl(module, pattern, flags, code, groups, groupindex, indexgroup);
exit:
@@ -451,8 +465,9 @@
PyObject *template;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:expand", _keywords,
- &template))
+ &template)) {
goto exit;
+ }
return_value = _sre_SRE_Match_expand_impl(self, template);
exit:
@@ -482,8 +497,9 @@
PyObject *default_value = Py_None;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:groups", _keywords,
- &default_value))
+ &default_value)) {
goto exit;
+ }
return_value = _sre_SRE_Match_groups_impl(self, default_value);
exit:
@@ -513,8 +529,9 @@
PyObject *default_value = Py_None;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:groupdict", _keywords,
- &default_value))
+ &default_value)) {
goto exit;
+ }
return_value = _sre_SRE_Match_groupdict_impl(self, default_value);
exit:
@@ -542,11 +559,13 @@
if (!PyArg_UnpackTuple(args, "start",
0, 1,
- &group))
+ &group)) {
goto exit;
+ }
_return_value = _sre_SRE_Match_start_impl(self, group);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromSsize_t(_return_value);
exit:
@@ -574,11 +593,13 @@
if (!PyArg_UnpackTuple(args, "end",
0, 1,
- &group))
+ &group)) {
goto exit;
+ }
_return_value = _sre_SRE_Match_end_impl(self, group);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromSsize_t(_return_value);
exit:
@@ -605,8 +626,9 @@
if (!PyArg_UnpackTuple(args, "span",
0, 1,
- &group))
+ &group)) {
goto exit;
+ }
return_value = _sre_SRE_Match_span_impl(self, group);
exit:
@@ -649,8 +671,9 @@
PyObject *memo;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:__deepcopy__", _keywords,
- &memo))
+ &memo)) {
goto exit;
+ }
return_value = _sre_SRE_Match___deepcopy___impl(self, memo);
exit:
@@ -690,4 +713,4 @@
{
return _sre_SRE_Scanner_search_impl(self);
}
-/*[clinic end generated code: output=d1d73ab2c5008bd4 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=00f7bf869b3283bc input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_ssl.c.h b/Modules/clinic/_ssl.c.h
index 4dbc5d0..2bf46b5 100644
--- a/Modules/clinic/_ssl.c.h
+++ b/Modules/clinic/_ssl.c.h
@@ -36,8 +36,9 @@
PyObject *return_value = NULL;
PyObject *path;
- if (!PyArg_Parse(arg, "O&:_test_decode_cert", PyUnicode_FSConverter, &path))
+ if (!PyArg_Parse(arg, "O&:_test_decode_cert", PyUnicode_FSConverter, &path)) {
goto exit;
+ }
return_value = _ssl__test_decode_cert_impl(module, path);
exit:
@@ -71,8 +72,9 @@
int binary_mode = 0;
if (!PyArg_ParseTuple(args, "|p:peer_certificate",
- &binary_mode))
+ &binary_mode)) {
goto exit;
+ }
return_value = _ssl__SSLSocket_peer_certificate_impl(self, binary_mode);
exit:
@@ -209,14 +211,16 @@
PyObject *return_value = NULL;
Py_buffer b = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:write", &b))
+ if (!PyArg_Parse(arg, "y*:write", &b)) {
goto exit;
+ }
return_value = _ssl__SSLSocket_write_impl(self, &b);
exit:
/* Cleanup for b */
- if (b.obj)
+ if (b.obj) {
PyBuffer_Release(&b);
+ }
return return_value;
}
@@ -260,12 +264,14 @@
switch (PyTuple_GET_SIZE(args)) {
case 1:
- if (!PyArg_ParseTuple(args, "i:read", &len))
+ if (!PyArg_ParseTuple(args, "i:read", &len)) {
goto exit;
+ }
break;
case 2:
- if (!PyArg_ParseTuple(args, "iw*:read", &len, &buffer))
+ if (!PyArg_ParseTuple(args, "iw*:read", &len, &buffer)) {
goto exit;
+ }
group_right_1 = 1;
break;
default:
@@ -276,8 +282,9 @@
exit:
/* Cleanup for buffer */
- if (buffer.obj)
+ if (buffer.obj) {
PyBuffer_Release(&buffer);
+ }
return return_value;
}
@@ -332,11 +339,13 @@
int proto_version;
if ((type == &PySSLContext_Type) &&
- !_PyArg_NoKeywords("_SSLContext", kwargs))
+ !_PyArg_NoKeywords("_SSLContext", kwargs)) {
goto exit;
+ }
if (!PyArg_ParseTuple(args, "i:_SSLContext",
- &proto_version))
+ &proto_version)) {
goto exit;
+ }
return_value = _ssl__SSLContext_impl(type, proto_version);
exit:
@@ -360,8 +369,9 @@
PyObject *return_value = NULL;
const char *cipherlist;
- if (!PyArg_Parse(arg, "s:set_ciphers", &cipherlist))
+ if (!PyArg_Parse(arg, "s:set_ciphers", &cipherlist)) {
goto exit;
+ }
return_value = _ssl__SSLContext_set_ciphers_impl(self, cipherlist);
exit:
@@ -386,14 +396,16 @@
PyObject *return_value = NULL;
Py_buffer protos = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:_set_npn_protocols", &protos))
+ if (!PyArg_Parse(arg, "y*:_set_npn_protocols", &protos)) {
goto exit;
+ }
return_value = _ssl__SSLContext__set_npn_protocols_impl(self, &protos);
exit:
/* Cleanup for protos */
- if (protos.obj)
+ if (protos.obj) {
PyBuffer_Release(&protos);
+ }
return return_value;
}
@@ -416,14 +428,16 @@
PyObject *return_value = NULL;
Py_buffer protos = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:_set_alpn_protocols", &protos))
+ if (!PyArg_Parse(arg, "y*:_set_alpn_protocols", &protos)) {
goto exit;
+ }
return_value = _ssl__SSLContext__set_alpn_protocols_impl(self, &protos);
exit:
/* Cleanup for protos */
- if (protos.obj)
+ if (protos.obj) {
PyBuffer_Release(&protos);
+ }
return return_value;
}
@@ -450,8 +464,9 @@
PyObject *password = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OO:load_cert_chain", _keywords,
- &certfile, &keyfile, &password))
+ &certfile, &keyfile, &password)) {
goto exit;
+ }
return_value = _ssl__SSLContext_load_cert_chain_impl(self, certfile, keyfile, password);
exit:
@@ -482,8 +497,9 @@
PyObject *cadata = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOO:load_verify_locations", _keywords,
- &cafile, &capath, &cadata))
+ &cafile, &capath, &cadata)) {
goto exit;
+ }
return_value = _ssl__SSLContext_load_verify_locations_impl(self, cafile, capath, cadata);
exit:
@@ -520,8 +536,9 @@
PyObject *hostname_obj = Py_None;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!i|O:_wrap_socket", _keywords,
- PySocketModule.Sock_Type, &sock, &server_side, &hostname_obj))
+ PySocketModule.Sock_Type, &sock, &server_side, &hostname_obj)) {
goto exit;
+ }
return_value = _ssl__SSLContext__wrap_socket_impl(self, sock, server_side, hostname_obj);
exit:
@@ -553,8 +570,9 @@
PyObject *hostname_obj = Py_None;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!i|O:_wrap_bio", _keywords,
- &PySSLMemoryBIO_Type, &incoming, &PySSLMemoryBIO_Type, &outgoing, &server_side, &hostname_obj))
+ &PySSLMemoryBIO_Type, &incoming, &PySSLMemoryBIO_Type, &outgoing, &server_side, &hostname_obj)) {
goto exit;
+ }
return_value = _ssl__SSLContext__wrap_bio_impl(self, incoming, outgoing, server_side, hostname_obj);
exit:
@@ -670,8 +688,9 @@
int binary_form = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|p:get_ca_certs", _keywords,
- &binary_form))
+ &binary_form)) {
goto exit;
+ }
return_value = _ssl__SSLContext_get_ca_certs_impl(self, binary_form);
exit:
@@ -687,11 +706,13 @@
PyObject *return_value = NULL;
if ((type == &PySSLMemoryBIO_Type) &&
- !_PyArg_NoPositional("MemoryBIO", args))
+ !_PyArg_NoPositional("MemoryBIO", args)) {
goto exit;
+ }
if ((type == &PySSLMemoryBIO_Type) &&
- !_PyArg_NoKeywords("MemoryBIO", kwargs))
+ !_PyArg_NoKeywords("MemoryBIO", kwargs)) {
goto exit;
+ }
return_value = _ssl_MemoryBIO_impl(type);
exit:
@@ -722,8 +743,9 @@
int len = -1;
if (!PyArg_ParseTuple(args, "|i:read",
- &len))
+ &len)) {
goto exit;
+ }
return_value = _ssl_MemoryBIO_read_impl(self, len);
exit:
@@ -750,14 +772,16 @@
PyObject *return_value = NULL;
Py_buffer b = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:write", &b))
+ if (!PyArg_Parse(arg, "y*:write", &b)) {
goto exit;
+ }
return_value = _ssl_MemoryBIO_write_impl(self, &b);
exit:
/* Cleanup for b */
- if (b.obj)
+ if (b.obj) {
PyBuffer_Release(&b);
+ }
return return_value;
}
@@ -805,14 +829,16 @@
double entropy;
if (!PyArg_ParseTuple(args, "s*d:RAND_add",
- &view, &entropy))
+ &view, &entropy)) {
goto exit;
+ }
return_value = _ssl_RAND_add_impl(module, &view, entropy);
exit:
/* Cleanup for view */
- if (view.obj)
+ if (view.obj) {
PyBuffer_Release(&view);
+ }
return return_value;
}
@@ -835,8 +861,9 @@
PyObject *return_value = NULL;
int n;
- if (!PyArg_Parse(arg, "i:RAND_bytes", &n))
+ if (!PyArg_Parse(arg, "i:RAND_bytes", &n)) {
goto exit;
+ }
return_value = _ssl_RAND_bytes_impl(module, n);
exit:
@@ -864,8 +891,9 @@
PyObject *return_value = NULL;
int n;
- if (!PyArg_Parse(arg, "i:RAND_pseudo_bytes", &n))
+ if (!PyArg_Parse(arg, "i:RAND_pseudo_bytes", &n)) {
goto exit;
+ }
return_value = _ssl_RAND_pseudo_bytes_impl(module, n);
exit:
@@ -916,8 +944,9 @@
PyObject *return_value = NULL;
PyObject *path;
- if (!PyArg_Parse(arg, "O&:RAND_egd", PyUnicode_FSConverter, &path))
+ if (!PyArg_Parse(arg, "O&:RAND_egd", PyUnicode_FSConverter, &path)) {
goto exit;
+ }
return_value = _ssl_RAND_egd_impl(module, path);
exit:
@@ -970,8 +999,9 @@
int name = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|p:txt2obj", _keywords,
- &txt, &name))
+ &txt, &name)) {
goto exit;
+ }
return_value = _ssl_txt2obj_impl(module, txt, name);
exit:
@@ -996,8 +1026,9 @@
PyObject *return_value = NULL;
int nid;
- if (!PyArg_Parse(arg, "i:nid2obj", &nid))
+ if (!PyArg_Parse(arg, "i:nid2obj", &nid)) {
goto exit;
+ }
return_value = _ssl_nid2obj_impl(module, nid);
exit:
@@ -1032,8 +1063,9 @@
const char *store_name;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:enum_certificates", _keywords,
- &store_name))
+ &store_name)) {
goto exit;
+ }
return_value = _ssl_enum_certificates_impl(module, store_name);
exit:
@@ -1069,8 +1101,9 @@
const char *store_name;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:enum_crls", _keywords,
- &store_name))
+ &store_name)) {
goto exit;
+ }
return_value = _ssl_enum_crls_impl(module, store_name);
exit:
@@ -1102,4 +1135,4 @@
#ifndef _SSL_ENUM_CRLS_METHODDEF
#define _SSL_ENUM_CRLS_METHODDEF
#endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */
-/*[clinic end generated code: output=a14999cb565a69a2 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=c6fe203099a5aa89 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_tkinter.c.h b/Modules/clinic/_tkinter.c.h
index 7917dec..73527fc 100644
--- a/Modules/clinic/_tkinter.c.h
+++ b/Modules/clinic/_tkinter.c.h
@@ -19,8 +19,9 @@
PyObject *return_value = NULL;
const char *script;
- if (!PyArg_Parse(arg, "s:eval", &script))
+ if (!PyArg_Parse(arg, "s:eval", &script)) {
goto exit;
+ }
return_value = _tkinter_tkapp_eval_impl(self, script);
exit:
@@ -44,8 +45,9 @@
PyObject *return_value = NULL;
const char *fileName;
- if (!PyArg_Parse(arg, "s:evalfile", &fileName))
+ if (!PyArg_Parse(arg, "s:evalfile", &fileName)) {
goto exit;
+ }
return_value = _tkinter_tkapp_evalfile_impl(self, fileName);
exit:
@@ -69,8 +71,9 @@
PyObject *return_value = NULL;
const char *script;
- if (!PyArg_Parse(arg, "s:record", &script))
+ if (!PyArg_Parse(arg, "s:record", &script)) {
goto exit;
+ }
return_value = _tkinter_tkapp_record_impl(self, script);
exit:
@@ -94,8 +97,9 @@
PyObject *return_value = NULL;
const char *msg;
- if (!PyArg_Parse(arg, "s:adderrinfo", &msg))
+ if (!PyArg_Parse(arg, "s:adderrinfo", &msg)) {
goto exit;
+ }
return_value = _tkinter_tkapp_adderrinfo_impl(self, msg);
exit:
@@ -143,8 +147,9 @@
PyObject *return_value = NULL;
const char *s;
- if (!PyArg_Parse(arg, "s:exprstring", &s))
+ if (!PyArg_Parse(arg, "s:exprstring", &s)) {
goto exit;
+ }
return_value = _tkinter_tkapp_exprstring_impl(self, s);
exit:
@@ -168,8 +173,9 @@
PyObject *return_value = NULL;
const char *s;
- if (!PyArg_Parse(arg, "s:exprlong", &s))
+ if (!PyArg_Parse(arg, "s:exprlong", &s)) {
goto exit;
+ }
return_value = _tkinter_tkapp_exprlong_impl(self, s);
exit:
@@ -193,8 +199,9 @@
PyObject *return_value = NULL;
const char *s;
- if (!PyArg_Parse(arg, "s:exprdouble", &s))
+ if (!PyArg_Parse(arg, "s:exprdouble", &s)) {
goto exit;
+ }
return_value = _tkinter_tkapp_exprdouble_impl(self, s);
exit:
@@ -218,8 +225,9 @@
PyObject *return_value = NULL;
const char *s;
- if (!PyArg_Parse(arg, "s:exprboolean", &s))
+ if (!PyArg_Parse(arg, "s:exprboolean", &s)) {
goto exit;
+ }
return_value = _tkinter_tkapp_exprboolean_impl(self, s);
exit:
@@ -262,8 +270,9 @@
PyObject *func;
if (!PyArg_ParseTuple(args, "sO:createcommand",
- &name, &func))
+ &name, &func)) {
goto exit;
+ }
return_value = _tkinter_tkapp_createcommand_impl(self, name, func);
exit:
@@ -287,8 +296,9 @@
PyObject *return_value = NULL;
const char *name;
- if (!PyArg_Parse(arg, "s:deletecommand", &name))
+ if (!PyArg_Parse(arg, "s:deletecommand", &name)) {
goto exit;
+ }
return_value = _tkinter_tkapp_deletecommand_impl(self, name);
exit:
@@ -318,8 +328,9 @@
PyObject *func;
if (!PyArg_ParseTuple(args, "OiO:createfilehandler",
- &file, &mask, &func))
+ &file, &mask, &func)) {
goto exit;
+ }
return_value = _tkinter_tkapp_createfilehandler_impl(self, file, mask, func);
exit:
@@ -377,8 +388,9 @@
PyObject *func;
if (!PyArg_ParseTuple(args, "iO:createtimerhandler",
- &milliseconds, &func))
+ &milliseconds, &func)) {
goto exit;
+ }
return_value = _tkinter_tkapp_createtimerhandler_impl(self, milliseconds, func);
exit:
@@ -403,8 +415,9 @@
int threshold = 0;
if (!PyArg_ParseTuple(args, "|i:mainloop",
- &threshold))
+ &threshold)) {
goto exit;
+ }
return_value = _tkinter_tkapp_mainloop_impl(self, threshold);
exit:
@@ -429,8 +442,9 @@
int flags = 0;
if (!PyArg_ParseTuple(args, "|i:dooneevent",
- &flags))
+ &flags)) {
goto exit;
+ }
return_value = _tkinter_tkapp_dooneevent_impl(self, flags);
exit:
@@ -551,8 +565,9 @@
const char *use = NULL;
if (!PyArg_ParseTuple(args, "|zssiiiiz:create",
- &screenName, &baseName, &className, &interactive, &wantobjects, &wantTk, &sync, &use))
+ &screenName, &baseName, &className, &interactive, &wantobjects, &wantTk, &sync, &use)) {
goto exit;
+ }
return_value = _tkinter_create_impl(module, screenName, baseName, className, interactive, wantobjects, wantTk, sync, use);
exit:
@@ -579,8 +594,9 @@
PyObject *return_value = NULL;
int new_val;
- if (!PyArg_Parse(arg, "i:setbusywaitinterval", &new_val))
+ if (!PyArg_Parse(arg, "i:setbusywaitinterval", &new_val)) {
goto exit;
+ }
return_value = _tkinter_setbusywaitinterval_impl(module, new_val);
exit:
@@ -606,8 +622,9 @@
int _return_value;
_return_value = _tkinter_getbusywaitinterval_impl(module);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong((long)_return_value);
exit:
@@ -621,4 +638,4 @@
#ifndef _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF
#define _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF
#endif /* !defined(_TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF) */
-/*[clinic end generated code: output=6dd667b91cf8addd input=a9049054013a1b77]*/
+/*[clinic end generated code: output=13be3f8313bba3c7 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_weakref.c.h b/Modules/clinic/_weakref.c.h
index 87c701c..b93343b 100644
--- a/Modules/clinic/_weakref.c.h
+++ b/Modules/clinic/_weakref.c.h
@@ -21,11 +21,12 @@
Py_ssize_t _return_value;
_return_value = _weakref_getweakrefcount_impl(module, object);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromSsize_t(_return_value);
exit:
return return_value;
}
-/*[clinic end generated code: output=4da9aade63eed77f input=a9049054013a1b77]*/
+/*[clinic end generated code: output=00e317cda5359ea3 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_winapi.c.h b/Modules/clinic/_winapi.c.h
index 34518e8..2b8deea 100644
--- a/Modules/clinic/_winapi.c.h
+++ b/Modules/clinic/_winapi.c.h
@@ -19,8 +19,9 @@
PyObject *return_value = NULL;
int wait;
- if (!PyArg_Parse(arg, "p:GetOverlappedResult", &wait))
+ if (!PyArg_Parse(arg, "p:GetOverlappedResult", &wait)) {
goto exit;
+ }
return_value = _winapi_Overlapped_GetOverlappedResult_impl(self, wait);
exit:
@@ -79,8 +80,9 @@
PyObject *return_value = NULL;
HANDLE handle;
- if (!PyArg_Parse(arg, "" F_HANDLE ":CloseHandle", &handle))
+ if (!PyArg_Parse(arg, "" F_HANDLE ":CloseHandle", &handle)) {
goto exit;
+ }
return_value = _winapi_CloseHandle_impl(module, handle);
exit:
@@ -108,8 +110,9 @@
int use_overlapped = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "" F_HANDLE "|i:ConnectNamedPipe", _keywords,
- &handle, &use_overlapped))
+ &handle, &use_overlapped)) {
goto exit;
+ }
return_value = _winapi_ConnectNamedPipe_impl(module, handle, use_overlapped);
exit:
@@ -147,13 +150,16 @@
HANDLE _return_value;
if (!PyArg_ParseTuple(args, "skk" F_POINTER "kk" F_HANDLE ":CreateFile",
- &file_name, &desired_access, &share_mode, &security_attributes, &creation_disposition, &flags_and_attributes, &template_file))
+ &file_name, &desired_access, &share_mode, &security_attributes, &creation_disposition, &flags_and_attributes, &template_file)) {
goto exit;
+ }
_return_value = _winapi_CreateFile_impl(module, file_name, desired_access, share_mode, security_attributes, creation_disposition, flags_and_attributes, template_file);
- if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred())
+ if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
goto exit;
- if (_return_value == NULL)
+ }
+ if (_return_value == NULL) {
Py_RETURN_NONE;
+ }
return_value = HANDLE_TO_PYNUM(_return_value);
exit:
@@ -180,8 +186,9 @@
LPWSTR dst_path;
if (!PyArg_ParseTuple(args, "uu:CreateJunction",
- &src_path, &dst_path))
+ &src_path, &dst_path)) {
goto exit;
+ }
return_value = _winapi_CreateJunction_impl(module, src_path, dst_path);
exit:
@@ -220,13 +227,16 @@
HANDLE _return_value;
if (!PyArg_ParseTuple(args, "skkkkkk" F_POINTER ":CreateNamedPipe",
- &name, &open_mode, &pipe_mode, &max_instances, &out_buffer_size, &in_buffer_size, &default_timeout, &security_attributes))
+ &name, &open_mode, &pipe_mode, &max_instances, &out_buffer_size, &in_buffer_size, &default_timeout, &security_attributes)) {
goto exit;
+ }
_return_value = _winapi_CreateNamedPipe_impl(module, name, open_mode, pipe_mode, max_instances, out_buffer_size, in_buffer_size, default_timeout, security_attributes);
- if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred())
+ if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
goto exit;
- if (_return_value == NULL)
+ }
+ if (_return_value == NULL) {
Py_RETURN_NONE;
+ }
return_value = HANDLE_TO_PYNUM(_return_value);
exit:
@@ -259,8 +269,9 @@
DWORD size;
if (!PyArg_ParseTuple(args, "Ok:CreatePipe",
- &pipe_attrs, &size))
+ &pipe_attrs, &size)) {
goto exit;
+ }
return_value = _winapi_CreatePipe_impl(module, pipe_attrs, size);
exit:
@@ -309,8 +320,9 @@
PyObject *startup_info;
if (!PyArg_ParseTuple(args, "ZZOOikOZO:CreateProcess",
- &application_name, &command_line, &proc_attrs, &thread_attrs, &inherit_handles, &creation_flags, &env_mapping, ¤t_directory, &startup_info))
+ &application_name, &command_line, &proc_attrs, &thread_attrs, &inherit_handles, &creation_flags, &env_mapping, ¤t_directory, &startup_info)) {
goto exit;
+ }
return_value = _winapi_CreateProcess_impl(module, application_name, command_line, proc_attrs, thread_attrs, inherit_handles, creation_flags, env_mapping, current_directory, startup_info);
exit:
@@ -353,13 +365,16 @@
HANDLE _return_value;
if (!PyArg_ParseTuple(args, "" F_HANDLE "" F_HANDLE "" F_HANDLE "ki|k:DuplicateHandle",
- &source_process_handle, &source_handle, &target_process_handle, &desired_access, &inherit_handle, &options))
+ &source_process_handle, &source_handle, &target_process_handle, &desired_access, &inherit_handle, &options)) {
goto exit;
+ }
_return_value = _winapi_DuplicateHandle_impl(module, source_process_handle, source_handle, target_process_handle, desired_access, inherit_handle, options);
- if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred())
+ if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
goto exit;
- if (_return_value == NULL)
+ }
+ if (_return_value == NULL) {
Py_RETURN_NONE;
+ }
return_value = HANDLE_TO_PYNUM(_return_value);
exit:
@@ -383,8 +398,9 @@
PyObject *return_value = NULL;
UINT ExitCode;
- if (!PyArg_Parse(arg, "I:ExitProcess", &ExitCode))
+ if (!PyArg_Parse(arg, "I:ExitProcess", &ExitCode)) {
goto exit;
+ }
return_value = _winapi_ExitProcess_impl(module, ExitCode);
exit:
@@ -410,10 +426,12 @@
HANDLE _return_value;
_return_value = _winapi_GetCurrentProcess_impl(module);
- if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred())
+ if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
goto exit;
- if (_return_value == NULL)
+ }
+ if (_return_value == NULL) {
Py_RETURN_NONE;
+ }
return_value = HANDLE_TO_PYNUM(_return_value);
exit:
@@ -439,11 +457,13 @@
HANDLE process;
DWORD _return_value;
- if (!PyArg_Parse(arg, "" F_HANDLE ":GetExitCodeProcess", &process))
+ if (!PyArg_Parse(arg, "" F_HANDLE ":GetExitCodeProcess", &process)) {
goto exit;
+ }
_return_value = _winapi_GetExitCodeProcess_impl(module, process);
- if ((_return_value == DWORD_MAX) && PyErr_Occurred())
+ if ((_return_value == DWORD_MAX) && PyErr_Occurred()) {
goto exit;
+ }
return_value = Py_BuildValue("k", _return_value);
exit:
@@ -468,8 +488,9 @@
DWORD _return_value;
_return_value = _winapi_GetLastError_impl(module);
- if ((_return_value == DWORD_MAX) && PyErr_Occurred())
+ if ((_return_value == DWORD_MAX) && PyErr_Occurred()) {
goto exit;
+ }
return_value = Py_BuildValue("k", _return_value);
exit:
@@ -501,8 +522,9 @@
PyObject *return_value = NULL;
HMODULE module_handle;
- if (!PyArg_Parse(arg, "" F_HANDLE ":GetModuleFileName", &module_handle))
+ if (!PyArg_Parse(arg, "" F_HANDLE ":GetModuleFileName", &module_handle)) {
goto exit;
+ }
return_value = _winapi_GetModuleFileName_impl(module, module_handle);
exit:
@@ -533,13 +555,16 @@
DWORD std_handle;
HANDLE _return_value;
- if (!PyArg_Parse(arg, "k:GetStdHandle", &std_handle))
+ if (!PyArg_Parse(arg, "k:GetStdHandle", &std_handle)) {
goto exit;
+ }
_return_value = _winapi_GetStdHandle_impl(module, std_handle);
- if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred())
+ if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
goto exit;
- if (_return_value == NULL)
+ }
+ if (_return_value == NULL) {
Py_RETURN_NONE;
+ }
return_value = HANDLE_TO_PYNUM(_return_value);
exit:
@@ -565,8 +590,9 @@
long _return_value;
_return_value = _winapi_GetVersion_impl(module);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong(_return_value);
exit:
@@ -595,13 +621,16 @@
HANDLE _return_value;
if (!PyArg_ParseTuple(args, "kik:OpenProcess",
- &desired_access, &inherit_handle, &process_id))
+ &desired_access, &inherit_handle, &process_id)) {
goto exit;
+ }
_return_value = _winapi_OpenProcess_impl(module, desired_access, inherit_handle, process_id);
- if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred())
+ if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
goto exit;
- if (_return_value == NULL)
+ }
+ if (_return_value == NULL) {
Py_RETURN_NONE;
+ }
return_value = HANDLE_TO_PYNUM(_return_value);
exit:
@@ -627,8 +656,9 @@
int size = 0;
if (!PyArg_ParseTuple(args, "" F_HANDLE "|i:PeekNamedPipe",
- &handle, &size))
+ &handle, &size)) {
goto exit;
+ }
return_value = _winapi_PeekNamedPipe_impl(module, handle, size);
exit:
@@ -657,8 +687,9 @@
int use_overlapped = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "" F_HANDLE "i|i:ReadFile", _keywords,
- &handle, &size, &use_overlapped))
+ &handle, &size, &use_overlapped)) {
goto exit;
+ }
return_value = _winapi_ReadFile_impl(module, handle, size, use_overlapped);
exit:
@@ -690,8 +721,9 @@
PyObject *collect_data_timeout;
if (!PyArg_ParseTuple(args, "" F_HANDLE "OOO:SetNamedPipeHandleState",
- &named_pipe, &mode, &max_collection_count, &collect_data_timeout))
+ &named_pipe, &mode, &max_collection_count, &collect_data_timeout)) {
goto exit;
+ }
return_value = _winapi_SetNamedPipeHandleState_impl(module, named_pipe, mode, max_collection_count, collect_data_timeout);
exit:
@@ -719,8 +751,9 @@
UINT exit_code;
if (!PyArg_ParseTuple(args, "" F_HANDLE "I:TerminateProcess",
- &handle, &exit_code))
+ &handle, &exit_code)) {
goto exit;
+ }
return_value = _winapi_TerminateProcess_impl(module, handle, exit_code);
exit:
@@ -746,8 +779,9 @@
DWORD timeout;
if (!PyArg_ParseTuple(args, "sk:WaitNamedPipe",
- &name, &timeout))
+ &name, &timeout)) {
goto exit;
+ }
return_value = _winapi_WaitNamedPipe_impl(module, name, timeout);
exit:
@@ -777,8 +811,9 @@
DWORD milliseconds = INFINITE;
if (!PyArg_ParseTuple(args, "Oi|k:WaitForMultipleObjects",
- &handle_seq, &wait_flag, &milliseconds))
+ &handle_seq, &wait_flag, &milliseconds)) {
goto exit;
+ }
return_value = _winapi_WaitForMultipleObjects_impl(module, handle_seq, wait_flag, milliseconds);
exit:
@@ -811,11 +846,13 @@
long _return_value;
if (!PyArg_ParseTuple(args, "" F_HANDLE "k:WaitForSingleObject",
- &handle, &milliseconds))
+ &handle, &milliseconds)) {
goto exit;
+ }
_return_value = _winapi_WaitForSingleObject_impl(module, handle, milliseconds);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong(_return_value);
exit:
@@ -844,11 +881,12 @@
int use_overlapped = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "" F_HANDLE "O|i:WriteFile", _keywords,
- &handle, &buffer, &use_overlapped))
+ &handle, &buffer, &use_overlapped)) {
goto exit;
+ }
return_value = _winapi_WriteFile_impl(module, handle, buffer, use_overlapped);
exit:
return return_value;
}
-/*[clinic end generated code: output=98771c6584056d19 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=d099ee4fbcdd5bc0 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/arraymodule.c.h b/Modules/clinic/arraymodule.c.h
index fdf247e..ced17aa 100644
--- a/Modules/clinic/arraymodule.c.h
+++ b/Modules/clinic/arraymodule.c.h
@@ -77,8 +77,9 @@
Py_ssize_t i = -1;
if (!PyArg_ParseTuple(args, "|n:pop",
- &i))
+ &i)) {
goto exit;
+ }
return_value = array_array_pop_impl(self, i);
exit:
@@ -114,8 +115,9 @@
PyObject *v;
if (!PyArg_ParseTuple(args, "nO:insert",
- &i, &v))
+ &i, &v)) {
goto exit;
+ }
return_value = array_array_insert_impl(self, i, v);
exit:
@@ -211,8 +213,9 @@
Py_ssize_t n;
if (!PyArg_ParseTuple(args, "On:fromfile",
- &f, &n))
+ &f, &n)) {
goto exit;
+ }
return_value = array_array_fromfile_impl(self, f, n);
exit:
@@ -275,14 +278,16 @@
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
- if (!PyArg_Parse(arg, "s*:fromstring", &buffer))
+ if (!PyArg_Parse(arg, "s*:fromstring", &buffer)) {
goto exit;
+ }
return_value = array_array_fromstring_impl(self, &buffer);
exit:
/* Cleanup for buffer */
- if (buffer.obj)
+ if (buffer.obj) {
PyBuffer_Release(&buffer);
+ }
return return_value;
}
@@ -305,14 +310,16 @@
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:frombytes", &buffer))
+ if (!PyArg_Parse(arg, "y*:frombytes", &buffer)) {
goto exit;
+ }
return_value = array_array_frombytes_impl(self, &buffer);
exit:
/* Cleanup for buffer */
- if (buffer.obj)
+ if (buffer.obj) {
PyBuffer_Release(&buffer);
+ }
return return_value;
}
@@ -379,8 +386,9 @@
Py_UNICODE *ustr;
Py_ssize_clean_t ustr_length;
- if (!PyArg_Parse(arg, "u#:fromunicode", &ustr, &ustr_length))
+ if (!PyArg_Parse(arg, "u#:fromunicode", &ustr, &ustr_length)) {
goto exit;
+ }
return_value = array_array_fromunicode_impl(self, ustr, ustr_length);
exit:
@@ -453,8 +461,9 @@
PyObject *items;
if (!PyArg_ParseTuple(args, "OCiO:_array_reconstructor",
- &arraytype, &typecode, &mformat_code, &items))
+ &arraytype, &typecode, &mformat_code, &items)) {
goto exit;
+ }
return_value = array__array_reconstructor_impl(module, arraytype, typecode, mformat_code, items);
exit:
@@ -496,4 +505,4 @@
#define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \
{"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
-/*[clinic end generated code: output=d2e82c65ea841cfc input=a9049054013a1b77]*/
+/*[clinic end generated code: output=0b99c89275eda265 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/audioop.c.h b/Modules/clinic/audioop.c.h
index 3ee2966..4baba27 100644
--- a/Modules/clinic/audioop.c.h
+++ b/Modules/clinic/audioop.c.h
@@ -24,14 +24,16 @@
Py_ssize_t index;
if (!PyArg_ParseTuple(args, "y*in:getsample",
- &fragment, &width, &index))
+ &fragment, &width, &index)) {
goto exit;
+ }
return_value = audioop_getsample_impl(module, &fragment, width, index);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -56,14 +58,16 @@
int width;
if (!PyArg_ParseTuple(args, "y*i:max",
- &fragment, &width))
+ &fragment, &width)) {
goto exit;
+ }
return_value = audioop_max_impl(module, &fragment, width);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -88,14 +92,16 @@
int width;
if (!PyArg_ParseTuple(args, "y*i:minmax",
- &fragment, &width))
+ &fragment, &width)) {
goto exit;
+ }
return_value = audioop_minmax_impl(module, &fragment, width);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -120,14 +126,16 @@
int width;
if (!PyArg_ParseTuple(args, "y*i:avg",
- &fragment, &width))
+ &fragment, &width)) {
goto exit;
+ }
return_value = audioop_avg_impl(module, &fragment, width);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -152,14 +160,16 @@
int width;
if (!PyArg_ParseTuple(args, "y*i:rms",
- &fragment, &width))
+ &fragment, &width)) {
goto exit;
+ }
return_value = audioop_rms_impl(module, &fragment, width);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -185,17 +195,20 @@
Py_buffer reference = {NULL, NULL};
if (!PyArg_ParseTuple(args, "y*y*:findfit",
- &fragment, &reference))
+ &fragment, &reference)) {
goto exit;
+ }
return_value = audioop_findfit_impl(module, &fragment, &reference);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
/* Cleanup for reference */
- if (reference.obj)
+ if (reference.obj) {
PyBuffer_Release(&reference);
+ }
return return_value;
}
@@ -221,17 +234,20 @@
Py_buffer reference = {NULL, NULL};
if (!PyArg_ParseTuple(args, "y*y*:findfactor",
- &fragment, &reference))
+ &fragment, &reference)) {
goto exit;
+ }
return_value = audioop_findfactor_impl(module, &fragment, &reference);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
/* Cleanup for reference */
- if (reference.obj)
+ if (reference.obj) {
PyBuffer_Release(&reference);
+ }
return return_value;
}
@@ -257,14 +273,16 @@
Py_ssize_t length;
if (!PyArg_ParseTuple(args, "y*n:findmax",
- &fragment, &length))
+ &fragment, &length)) {
goto exit;
+ }
return_value = audioop_findmax_impl(module, &fragment, length);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -289,14 +307,16 @@
int width;
if (!PyArg_ParseTuple(args, "y*i:avgpp",
- &fragment, &width))
+ &fragment, &width)) {
goto exit;
+ }
return_value = audioop_avgpp_impl(module, &fragment, width);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -321,14 +341,16 @@
int width;
if (!PyArg_ParseTuple(args, "y*i:maxpp",
- &fragment, &width))
+ &fragment, &width)) {
goto exit;
+ }
return_value = audioop_maxpp_impl(module, &fragment, width);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -353,14 +375,16 @@
int width;
if (!PyArg_ParseTuple(args, "y*i:cross",
- &fragment, &width))
+ &fragment, &width)) {
goto exit;
+ }
return_value = audioop_cross_impl(module, &fragment, width);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -387,14 +411,16 @@
double factor;
if (!PyArg_ParseTuple(args, "y*id:mul",
- &fragment, &width, &factor))
+ &fragment, &width, &factor)) {
goto exit;
+ }
return_value = audioop_mul_impl(module, &fragment, width, factor);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -422,14 +448,16 @@
double rfactor;
if (!PyArg_ParseTuple(args, "y*idd:tomono",
- &fragment, &width, &lfactor, &rfactor))
+ &fragment, &width, &lfactor, &rfactor)) {
goto exit;
+ }
return_value = audioop_tomono_impl(module, &fragment, width, lfactor, rfactor);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -457,14 +485,16 @@
double rfactor;
if (!PyArg_ParseTuple(args, "y*idd:tostereo",
- &fragment, &width, &lfactor, &rfactor))
+ &fragment, &width, &lfactor, &rfactor)) {
goto exit;
+ }
return_value = audioop_tostereo_impl(module, &fragment, width, lfactor, rfactor);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -491,17 +521,20 @@
int width;
if (!PyArg_ParseTuple(args, "y*y*i:add",
- &fragment1, &fragment2, &width))
+ &fragment1, &fragment2, &width)) {
goto exit;
+ }
return_value = audioop_add_impl(module, &fragment1, &fragment2, width);
exit:
/* Cleanup for fragment1 */
- if (fragment1.obj)
+ if (fragment1.obj) {
PyBuffer_Release(&fragment1);
+ }
/* Cleanup for fragment2 */
- if (fragment2.obj)
+ if (fragment2.obj) {
PyBuffer_Release(&fragment2);
+ }
return return_value;
}
@@ -528,14 +561,16 @@
int bias;
if (!PyArg_ParseTuple(args, "y*ii:bias",
- &fragment, &width, &bias))
+ &fragment, &width, &bias)) {
goto exit;
+ }
return_value = audioop_bias_impl(module, &fragment, width, bias);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -560,14 +595,16 @@
int width;
if (!PyArg_ParseTuple(args, "y*i:reverse",
- &fragment, &width))
+ &fragment, &width)) {
goto exit;
+ }
return_value = audioop_reverse_impl(module, &fragment, width);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -592,14 +629,16 @@
int width;
if (!PyArg_ParseTuple(args, "y*i:byteswap",
- &fragment, &width))
+ &fragment, &width)) {
goto exit;
+ }
return_value = audioop_byteswap_impl(module, &fragment, width);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -626,14 +665,16 @@
int newwidth;
if (!PyArg_ParseTuple(args, "y*ii:lin2lin",
- &fragment, &width, &newwidth))
+ &fragment, &width, &newwidth)) {
goto exit;
+ }
return_value = audioop_lin2lin_impl(module, &fragment, width, newwidth);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -667,14 +708,16 @@
int weightB = 0;
if (!PyArg_ParseTuple(args, "y*iiiiO|ii:ratecv",
- &fragment, &width, &nchannels, &inrate, &outrate, &state, &weightA, &weightB))
+ &fragment, &width, &nchannels, &inrate, &outrate, &state, &weightA, &weightB)) {
goto exit;
+ }
return_value = audioop_ratecv_impl(module, &fragment, width, nchannels, inrate, outrate, state, weightA, weightB);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -699,14 +742,16 @@
int width;
if (!PyArg_ParseTuple(args, "y*i:lin2ulaw",
- &fragment, &width))
+ &fragment, &width)) {
goto exit;
+ }
return_value = audioop_lin2ulaw_impl(module, &fragment, width);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -731,14 +776,16 @@
int width;
if (!PyArg_ParseTuple(args, "y*i:ulaw2lin",
- &fragment, &width))
+ &fragment, &width)) {
goto exit;
+ }
return_value = audioop_ulaw2lin_impl(module, &fragment, width);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -763,14 +810,16 @@
int width;
if (!PyArg_ParseTuple(args, "y*i:lin2alaw",
- &fragment, &width))
+ &fragment, &width)) {
goto exit;
+ }
return_value = audioop_lin2alaw_impl(module, &fragment, width);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -795,14 +844,16 @@
int width;
if (!PyArg_ParseTuple(args, "y*i:alaw2lin",
- &fragment, &width))
+ &fragment, &width)) {
goto exit;
+ }
return_value = audioop_alaw2lin_impl(module, &fragment, width);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -829,14 +880,16 @@
PyObject *state;
if (!PyArg_ParseTuple(args, "y*iO:lin2adpcm",
- &fragment, &width, &state))
+ &fragment, &width, &state)) {
goto exit;
+ }
return_value = audioop_lin2adpcm_impl(module, &fragment, width, state);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
@@ -863,15 +916,17 @@
PyObject *state;
if (!PyArg_ParseTuple(args, "y*iO:adpcm2lin",
- &fragment, &width, &state))
+ &fragment, &width, &state)) {
goto exit;
+ }
return_value = audioop_adpcm2lin_impl(module, &fragment, width, state);
exit:
/* Cleanup for fragment */
- if (fragment.obj)
+ if (fragment.obj) {
PyBuffer_Release(&fragment);
+ }
return return_value;
}
-/*[clinic end generated code: output=a076e1b213a8727b input=a9049054013a1b77]*/
+/*[clinic end generated code: output=af5b025f0241fee2 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/binascii.c.h b/Modules/clinic/binascii.c.h
index e348bee..e297f1d 100644
--- a/Modules/clinic/binascii.c.h
+++ b/Modules/clinic/binascii.c.h
@@ -20,8 +20,9 @@
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
- if (!PyArg_Parse(arg, "O&:a2b_uu", ascii_buffer_converter, &data))
+ if (!PyArg_Parse(arg, "O&:a2b_uu", ascii_buffer_converter, &data)) {
goto exit;
+ }
return_value = binascii_a2b_uu_impl(module, &data);
exit:
@@ -50,14 +51,16 @@
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:b2a_uu", &data))
+ if (!PyArg_Parse(arg, "y*:b2a_uu", &data)) {
goto exit;
+ }
return_value = binascii_b2a_uu_impl(module, &data);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -80,8 +83,9 @@
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
- if (!PyArg_Parse(arg, "O&:a2b_base64", ascii_buffer_converter, &data))
+ if (!PyArg_Parse(arg, "O&:a2b_base64", ascii_buffer_converter, &data)) {
goto exit;
+ }
return_value = binascii_a2b_base64_impl(module, &data);
exit:
@@ -93,31 +97,36 @@
}
PyDoc_STRVAR(binascii_b2a_base64__doc__,
-"b2a_base64($module, data, /)\n"
+"b2a_base64($module, /, data, *, newline=True)\n"
"--\n"
"\n"
"Base64-code line of data.");
#define BINASCII_B2A_BASE64_METHODDEF \
- {"b2a_base64", (PyCFunction)binascii_b2a_base64, METH_O, binascii_b2a_base64__doc__},
+ {"b2a_base64", (PyCFunction)binascii_b2a_base64, METH_VARARGS|METH_KEYWORDS, binascii_b2a_base64__doc__},
static PyObject *
-binascii_b2a_base64_impl(PyModuleDef *module, Py_buffer *data);
+binascii_b2a_base64_impl(PyModuleDef *module, Py_buffer *data, int newline);
static PyObject *
-binascii_b2a_base64(PyModuleDef *module, PyObject *arg)
+binascii_b2a_base64(PyModuleDef *module, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
+ static char *_keywords[] = {"data", "newline", NULL};
Py_buffer data = {NULL, NULL};
+ int newline = 1;
- if (!PyArg_Parse(arg, "y*:b2a_base64", &data))
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|$i:b2a_base64", _keywords,
+ &data, &newline)) {
goto exit;
- return_value = binascii_b2a_base64_impl(module, &data);
+ }
+ return_value = binascii_b2a_base64_impl(module, &data, newline);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -140,8 +149,9 @@
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
- if (!PyArg_Parse(arg, "O&:a2b_hqx", ascii_buffer_converter, &data))
+ if (!PyArg_Parse(arg, "O&:a2b_hqx", ascii_buffer_converter, &data)) {
goto exit;
+ }
return_value = binascii_a2b_hqx_impl(module, &data);
exit:
@@ -170,14 +180,16 @@
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:rlecode_hqx", &data))
+ if (!PyArg_Parse(arg, "y*:rlecode_hqx", &data)) {
goto exit;
+ }
return_value = binascii_rlecode_hqx_impl(module, &data);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -200,14 +212,16 @@
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:b2a_hqx", &data))
+ if (!PyArg_Parse(arg, "y*:b2a_hqx", &data)) {
goto exit;
+ }
return_value = binascii_b2a_hqx_impl(module, &data);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -230,14 +244,16 @@
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:rledecode_hqx", &data))
+ if (!PyArg_Parse(arg, "y*:rledecode_hqx", &data)) {
goto exit;
+ }
return_value = binascii_rledecode_hqx_impl(module, &data);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -263,17 +279,20 @@
unsigned int _return_value;
if (!PyArg_ParseTuple(args, "y*I:crc_hqx",
- &data, &crc))
+ &data, &crc)) {
goto exit;
+ }
_return_value = binascii_crc_hqx_impl(module, &data, crc);
- if ((_return_value == (unsigned int)-1) && PyErr_Occurred())
+ if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromUnsignedLong((unsigned long)_return_value);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -299,17 +318,20 @@
unsigned int _return_value;
if (!PyArg_ParseTuple(args, "y*|I:crc32",
- &data, &crc))
+ &data, &crc)) {
goto exit;
+ }
_return_value = binascii_crc32_impl(module, &data, crc);
- if ((_return_value == (unsigned int)-1) && PyErr_Occurred())
+ if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromUnsignedLong((unsigned long)_return_value);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -335,14 +357,16 @@
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:b2a_hex", &data))
+ if (!PyArg_Parse(arg, "y*:b2a_hex", &data)) {
goto exit;
+ }
return_value = binascii_b2a_hex_impl(module, &data);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -367,14 +391,16 @@
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:hexlify", &data))
+ if (!PyArg_Parse(arg, "y*:hexlify", &data)) {
goto exit;
+ }
return_value = binascii_hexlify_impl(module, &data);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -400,8 +426,9 @@
PyObject *return_value = NULL;
Py_buffer hexstr = {NULL, NULL};
- if (!PyArg_Parse(arg, "O&:a2b_hex", ascii_buffer_converter, &hexstr))
+ if (!PyArg_Parse(arg, "O&:a2b_hex", ascii_buffer_converter, &hexstr)) {
goto exit;
+ }
return_value = binascii_a2b_hex_impl(module, &hexstr);
exit:
@@ -432,8 +459,9 @@
PyObject *return_value = NULL;
Py_buffer hexstr = {NULL, NULL};
- if (!PyArg_Parse(arg, "O&:unhexlify", ascii_buffer_converter, &hexstr))
+ if (!PyArg_Parse(arg, "O&:unhexlify", ascii_buffer_converter, &hexstr)) {
goto exit;
+ }
return_value = binascii_unhexlify_impl(module, &hexstr);
exit:
@@ -465,8 +493,9 @@
int header = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|i:a2b_qp", _keywords,
- ascii_buffer_converter, &data, &header))
+ ascii_buffer_converter, &data, &header)) {
goto exit;
+ }
return_value = binascii_a2b_qp_impl(module, &data, header);
exit:
@@ -505,15 +534,17 @@
int header = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|iii:b2a_qp", _keywords,
- &data, "etabs, &istext, &header))
+ &data, "etabs, &istext, &header)) {
goto exit;
+ }
return_value = binascii_b2a_qp_impl(module, &data, quotetabs, istext, header);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
-/*[clinic end generated code: output=b1a3cbf7660ebaa5 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=7fb420392d78ac4d input=a9049054013a1b77]*/
diff --git a/Modules/clinic/cmathmodule.c.h b/Modules/clinic/cmathmodule.c.h
index 7d61649..5899348 100644
--- a/Modules/clinic/cmathmodule.c.h
+++ b/Modules/clinic/cmathmodule.c.h
@@ -21,8 +21,9 @@
Py_complex z;
Py_complex _return_value;
- if (!PyArg_Parse(arg, "D:acos", &z))
+ if (!PyArg_Parse(arg, "D:acos", &z)) {
goto exit;
+ }
/* modifications for z */
errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
_return_value = cmath_acos_impl(module, z);
@@ -62,8 +63,9 @@
Py_complex z;
Py_complex _return_value;
- if (!PyArg_Parse(arg, "D:acosh", &z))
+ if (!PyArg_Parse(arg, "D:acosh", &z)) {
goto exit;
+ }
/* modifications for z */
errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
_return_value = cmath_acosh_impl(module, z);
@@ -103,8 +105,9 @@
Py_complex z;
Py_complex _return_value;
- if (!PyArg_Parse(arg, "D:asin", &z))
+ if (!PyArg_Parse(arg, "D:asin", &z)) {
goto exit;
+ }
/* modifications for z */
errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
_return_value = cmath_asin_impl(module, z);
@@ -144,8 +147,9 @@
Py_complex z;
Py_complex _return_value;
- if (!PyArg_Parse(arg, "D:asinh", &z))
+ if (!PyArg_Parse(arg, "D:asinh", &z)) {
goto exit;
+ }
/* modifications for z */
errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
_return_value = cmath_asinh_impl(module, z);
@@ -185,8 +189,9 @@
Py_complex z;
Py_complex _return_value;
- if (!PyArg_Parse(arg, "D:atan", &z))
+ if (!PyArg_Parse(arg, "D:atan", &z)) {
goto exit;
+ }
/* modifications for z */
errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
_return_value = cmath_atan_impl(module, z);
@@ -226,8 +231,9 @@
Py_complex z;
Py_complex _return_value;
- if (!PyArg_Parse(arg, "D:atanh", &z))
+ if (!PyArg_Parse(arg, "D:atanh", &z)) {
goto exit;
+ }
/* modifications for z */
errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
_return_value = cmath_atanh_impl(module, z);
@@ -267,8 +273,9 @@
Py_complex z;
Py_complex _return_value;
- if (!PyArg_Parse(arg, "D:cos", &z))
+ if (!PyArg_Parse(arg, "D:cos", &z)) {
goto exit;
+ }
/* modifications for z */
errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
_return_value = cmath_cos_impl(module, z);
@@ -308,8 +315,9 @@
Py_complex z;
Py_complex _return_value;
- if (!PyArg_Parse(arg, "D:cosh", &z))
+ if (!PyArg_Parse(arg, "D:cosh", &z)) {
goto exit;
+ }
/* modifications for z */
errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
_return_value = cmath_cosh_impl(module, z);
@@ -349,8 +357,9 @@
Py_complex z;
Py_complex _return_value;
- if (!PyArg_Parse(arg, "D:exp", &z))
+ if (!PyArg_Parse(arg, "D:exp", &z)) {
goto exit;
+ }
/* modifications for z */
errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
_return_value = cmath_exp_impl(module, z);
@@ -390,8 +399,9 @@
Py_complex z;
Py_complex _return_value;
- if (!PyArg_Parse(arg, "D:log10", &z))
+ if (!PyArg_Parse(arg, "D:log10", &z)) {
goto exit;
+ }
/* modifications for z */
errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
_return_value = cmath_log10_impl(module, z);
@@ -431,8 +441,9 @@
Py_complex z;
Py_complex _return_value;
- if (!PyArg_Parse(arg, "D:sin", &z))
+ if (!PyArg_Parse(arg, "D:sin", &z)) {
goto exit;
+ }
/* modifications for z */
errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
_return_value = cmath_sin_impl(module, z);
@@ -472,8 +483,9 @@
Py_complex z;
Py_complex _return_value;
- if (!PyArg_Parse(arg, "D:sinh", &z))
+ if (!PyArg_Parse(arg, "D:sinh", &z)) {
goto exit;
+ }
/* modifications for z */
errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
_return_value = cmath_sinh_impl(module, z);
@@ -513,8 +525,9 @@
Py_complex z;
Py_complex _return_value;
- if (!PyArg_Parse(arg, "D:sqrt", &z))
+ if (!PyArg_Parse(arg, "D:sqrt", &z)) {
goto exit;
+ }
/* modifications for z */
errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
_return_value = cmath_sqrt_impl(module, z);
@@ -554,8 +567,9 @@
Py_complex z;
Py_complex _return_value;
- if (!PyArg_Parse(arg, "D:tan", &z))
+ if (!PyArg_Parse(arg, "D:tan", &z)) {
goto exit;
+ }
/* modifications for z */
errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
_return_value = cmath_tan_impl(module, z);
@@ -595,8 +609,9 @@
Py_complex z;
Py_complex _return_value;
- if (!PyArg_Parse(arg, "D:tanh", &z))
+ if (!PyArg_Parse(arg, "D:tanh", &z)) {
goto exit;
+ }
/* modifications for z */
errno = 0; PyFPE_START_PROTECT("complex function", goto exit);
_return_value = cmath_tanh_impl(module, z);
@@ -639,8 +654,9 @@
PyObject *y_obj = NULL;
if (!PyArg_ParseTuple(args, "D|O:log",
- &x, &y_obj))
+ &x, &y_obj)) {
goto exit;
+ }
return_value = cmath_log_impl(module, x, y_obj);
exit:
@@ -665,8 +681,9 @@
PyObject *return_value = NULL;
Py_complex z;
- if (!PyArg_Parse(arg, "D:phase", &z))
+ if (!PyArg_Parse(arg, "D:phase", &z)) {
goto exit;
+ }
return_value = cmath_phase_impl(module, z);
exit:
@@ -693,8 +710,9 @@
PyObject *return_value = NULL;
Py_complex z;
- if (!PyArg_Parse(arg, "D:polar", &z))
+ if (!PyArg_Parse(arg, "D:polar", &z)) {
goto exit;
+ }
return_value = cmath_polar_impl(module, z);
exit:
@@ -721,8 +739,9 @@
double phi;
if (!PyArg_ParseTuple(args, "dd:rect",
- &r, &phi))
+ &r, &phi)) {
goto exit;
+ }
return_value = cmath_rect_impl(module, r, phi);
exit:
@@ -747,8 +766,9 @@
PyObject *return_value = NULL;
Py_complex z;
- if (!PyArg_Parse(arg, "D:isfinite", &z))
+ if (!PyArg_Parse(arg, "D:isfinite", &z)) {
goto exit;
+ }
return_value = cmath_isfinite_impl(module, z);
exit:
@@ -773,8 +793,9 @@
PyObject *return_value = NULL;
Py_complex z;
- if (!PyArg_Parse(arg, "D:isnan", &z))
+ if (!PyArg_Parse(arg, "D:isnan", &z)) {
goto exit;
+ }
return_value = cmath_isnan_impl(module, z);
exit:
@@ -799,8 +820,9 @@
PyObject *return_value = NULL;
Py_complex z;
- if (!PyArg_Parse(arg, "D:isinf", &z))
+ if (!PyArg_Parse(arg, "D:isinf", &z)) {
goto exit;
+ }
return_value = cmath_isinf_impl(module, z);
exit:
@@ -847,14 +869,16 @@
int _return_value;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "DD|$dd:isclose", _keywords,
- &a, &b, &rel_tol, &abs_tol))
+ &a, &b, &rel_tol, &abs_tol)) {
goto exit;
+ }
_return_value = cmath_isclose_impl(module, a, b, rel_tol, abs_tol);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyBool_FromLong((long)_return_value);
exit:
return return_value;
}
-/*[clinic end generated code: output=229e9c48c9d27362 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=f166205b4beb1826 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/fcntlmodule.c.h b/Modules/clinic/fcntlmodule.c.h
index d9a1517..104b482 100644
--- a/Modules/clinic/fcntlmodule.c.h
+++ b/Modules/clinic/fcntlmodule.c.h
@@ -33,8 +33,9 @@
PyObject *arg = NULL;
if (!PyArg_ParseTuple(args, "O&i|O:fcntl",
- conv_descriptor, &fd, &code, &arg))
+ conv_descriptor, &fd, &code, &arg)) {
goto exit;
+ }
return_value = fcntl_fcntl_impl(module, fd, code, arg);
exit:
@@ -91,8 +92,9 @@
int mutate_arg = 1;
if (!PyArg_ParseTuple(args, "O&I|Op:ioctl",
- conv_descriptor, &fd, &code, &ob_arg, &mutate_arg))
+ conv_descriptor, &fd, &code, &ob_arg, &mutate_arg)) {
goto exit;
+ }
return_value = fcntl_ioctl_impl(module, fd, code, ob_arg, mutate_arg);
exit:
@@ -122,8 +124,9 @@
int code;
if (!PyArg_ParseTuple(args, "O&i:flock",
- conv_descriptor, &fd, &code))
+ conv_descriptor, &fd, &code)) {
goto exit;
+ }
return_value = fcntl_flock_impl(module, fd, code);
exit:
@@ -175,11 +178,12 @@
int whence = 0;
if (!PyArg_ParseTuple(args, "O&i|OOi:lockf",
- conv_descriptor, &fd, &code, &lenobj, &startobj, &whence))
+ conv_descriptor, &fd, &code, &lenobj, &startobj, &whence)) {
goto exit;
+ }
return_value = fcntl_lockf_impl(module, fd, code, lenobj, startobj, whence);
exit:
return return_value;
}
-/*[clinic end generated code: output=b7d6e8fc2ad09c48 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=b08537e9adc04ca2 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/grpmodule.c.h b/Modules/clinic/grpmodule.c.h
index eb5b59d..cd111aa 100644
--- a/Modules/clinic/grpmodule.c.h
+++ b/Modules/clinic/grpmodule.c.h
@@ -24,8 +24,9 @@
PyObject *id;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:getgrgid", _keywords,
- &id))
+ &id)) {
goto exit;
+ }
return_value = grp_getgrgid_impl(module, id);
exit:
@@ -54,8 +55,9 @@
PyObject *name;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "U:getgrnam", _keywords,
- &name))
+ &name)) {
goto exit;
+ }
return_value = grp_getgrnam_impl(module, name);
exit:
@@ -82,4 +84,4 @@
{
return grp_getgrall_impl(module);
}
-/*[clinic end generated code: output=5191c25600afb1bd input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a8a097520206ccd6 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/md5module.c.h b/Modules/clinic/md5module.c.h
index f5a3117..9c8987e 100644
--- a/Modules/clinic/md5module.c.h
+++ b/Modules/clinic/md5module.c.h
@@ -85,11 +85,12 @@
PyObject *string = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:md5", _keywords,
- &string))
+ &string)) {
goto exit;
+ }
return_value = _md5_md5_impl(module, string);
exit:
return return_value;
}
-/*[clinic end generated code: output=0f803ded701aca54 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=d701d041d387b081 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h
index 9ef702a..33621d8 100644
--- a/Modules/clinic/posixmodule.c.h
+++ b/Modules/clinic/posixmodule.c.h
@@ -43,8 +43,9 @@
int follow_symlinks = 1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|$O&p:stat", _keywords,
- path_converter, &path, FSTATAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks))
+ path_converter, &path, FSTATAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) {
goto exit;
+ }
return_value = os_stat_impl(module, &path, dir_fd, follow_symlinks);
exit:
@@ -78,8 +79,9 @@
int dir_fd = DEFAULT_DIR_FD;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|$O&:lstat", _keywords,
- path_converter, &path, FSTATAT_DIR_FD_CONVERTER, &dir_fd))
+ path_converter, &path, FSTATAT_DIR_FD_CONVERTER, &dir_fd)) {
goto exit;
+ }
return_value = os_lstat_impl(module, &path, dir_fd);
exit:
@@ -141,11 +143,13 @@
int _return_value;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&i|$O&pp:access", _keywords,
- path_converter, &path, &mode, FACCESSAT_DIR_FD_CONVERTER, &dir_fd, &effective_ids, &follow_symlinks))
+ path_converter, &path, &mode, FACCESSAT_DIR_FD_CONVERTER, &dir_fd, &effective_ids, &follow_symlinks)) {
goto exit;
+ }
_return_value = os_access_impl(module, &path, mode, dir_fd, effective_ids, follow_symlinks);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyBool_FromLong((long)_return_value);
exit:
@@ -179,11 +183,13 @@
int fd;
char *_return_value;
- if (!PyArg_Parse(arg, "i:ttyname", &fd))
+ if (!PyArg_Parse(arg, "i:ttyname", &fd)) {
goto exit;
+ }
_return_value = os_ttyname_impl(module, fd);
- if (_return_value == NULL)
+ if (_return_value == NULL) {
goto exit;
+ }
return_value = PyUnicode_DecodeFSDefault(_return_value);
exit:
@@ -238,8 +244,9 @@
path_t path = PATH_T_INITIALIZE("chdir", "path", 0, PATH_HAVE_FCHDIR);
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&:chdir", _keywords,
- path_converter, &path))
+ path_converter, &path)) {
goto exit;
+ }
return_value = os_chdir_impl(module, &path);
exit:
@@ -274,8 +281,9 @@
int fd;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&:fchdir", _keywords,
- fildes_converter, &fd))
+ fildes_converter, &fd)) {
goto exit;
+ }
return_value = os_fchdir_impl(module, fd);
exit:
@@ -328,8 +336,9 @@
int follow_symlinks = 1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&i|$O&p:chmod", _keywords,
- path_converter, &path, &mode, FCHMODAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks))
+ path_converter, &path, &mode, FCHMODAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) {
goto exit;
+ }
return_value = os_chmod_impl(module, &path, mode, dir_fd, follow_symlinks);
exit:
@@ -364,8 +373,9 @@
int mode;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:fchmod", _keywords,
- &fd, &mode))
+ &fd, &mode)) {
goto exit;
+ }
return_value = os_fchmod_impl(module, fd, mode);
exit:
@@ -400,8 +410,9 @@
int mode;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&i:lchmod", _keywords,
- path_converter, &path, &mode))
+ path_converter, &path, &mode)) {
goto exit;
+ }
return_value = os_lchmod_impl(module, &path, mode);
exit:
@@ -444,8 +455,9 @@
int follow_symlinks = 1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&k|p:chflags", _keywords,
- path_converter, &path, &flags, &follow_symlinks))
+ path_converter, &path, &flags, &follow_symlinks)) {
goto exit;
+ }
return_value = os_chflags_impl(module, &path, flags, follow_symlinks);
exit:
@@ -483,8 +495,9 @@
unsigned long flags;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&k:lchflags", _keywords,
- path_converter, &path, &flags))
+ path_converter, &path, &flags)) {
goto exit;
+ }
return_value = os_lchflags_impl(module, &path, flags);
exit:
@@ -518,8 +531,9 @@
path_t path = PATH_T_INITIALIZE("chroot", "path", 0, 0);
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&:chroot", _keywords,
- path_converter, &path))
+ path_converter, &path)) {
goto exit;
+ }
return_value = os_chroot_impl(module, &path);
exit:
@@ -553,8 +567,9 @@
int fd;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&:fsync", _keywords,
- fildes_converter, &fd))
+ fildes_converter, &fd)) {
goto exit;
+ }
return_value = os_fsync_impl(module, fd);
exit:
@@ -607,8 +622,9 @@
int fd;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&:fdatasync", _keywords,
- fildes_converter, &fd))
+ fildes_converter, &fd)) {
goto exit;
+ }
return_value = os_fdatasync_impl(module, fd);
exit:
@@ -668,8 +684,9 @@
int follow_symlinks = 1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&O&|$O&p:chown", _keywords,
- path_converter, &path, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid, FCHOWNAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks))
+ path_converter, &path, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid, FCHOWNAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) {
goto exit;
+ }
return_value = os_chown_impl(module, &path, uid, gid, dir_fd, follow_symlinks);
exit:
@@ -707,8 +724,9 @@
gid_t gid;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iO&O&:fchown", _keywords,
- &fd, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid))
+ &fd, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid)) {
goto exit;
+ }
return_value = os_fchown_impl(module, fd, uid, gid);
exit:
@@ -744,8 +762,9 @@
gid_t gid;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&O&:lchown", _keywords,
- path_converter, &path, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid))
+ path_converter, &path, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid)) {
goto exit;
+ }
return_value = os_lchown_impl(module, &path, uid, gid);
exit:
@@ -831,8 +850,9 @@
int follow_symlinks = 1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&|$O&O&p:link", _keywords,
- path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd, &follow_symlinks))
+ path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd, &follow_symlinks)) {
goto exit;
+ }
return_value = os_link_impl(module, &src, &dst, src_dir_fd, dst_dir_fd, follow_symlinks);
exit:
@@ -877,8 +897,9 @@
path_t path = PATH_T_INITIALIZE("listdir", "path", 1, PATH_HAVE_FDOPENDIR);
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O&:listdir", _keywords,
- path_converter, &path))
+ path_converter, &path)) {
goto exit;
+ }
return_value = os_listdir_impl(module, &path);
exit:
@@ -907,8 +928,9 @@
PyObject *return_value = NULL;
path_t path = PATH_T_INITIALIZE("_getfullpathname", "path", 0, 0);
- if (!PyArg_Parse(arg, "O&:_getfullpathname", path_converter, &path))
+ if (!PyArg_Parse(arg, "O&:_getfullpathname", path_converter, &path)) {
goto exit;
+ }
return_value = os__getfullpathname_impl(module, &path);
exit:
@@ -940,8 +962,9 @@
PyObject *return_value = NULL;
PyObject *path;
- if (!PyArg_Parse(arg, "U:_getfinalpathname", &path))
+ if (!PyArg_Parse(arg, "U:_getfinalpathname", &path)) {
goto exit;
+ }
return_value = os__getfinalpathname_impl(module, path);
exit:
@@ -969,8 +992,9 @@
PyObject *return_value = NULL;
path_t path = PATH_T_INITIALIZE("_isdir", "path", 0, 0);
- if (!PyArg_Parse(arg, "O&:_isdir", path_converter, &path))
+ if (!PyArg_Parse(arg, "O&:_isdir", path_converter, &path)) {
goto exit;
+ }
return_value = os__isdir_impl(module, &path);
exit:
@@ -1004,8 +1028,9 @@
PyObject *path;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "U:_getvolumepathname", _keywords,
- &path))
+ &path)) {
goto exit;
+ }
return_value = os__getvolumepathname_impl(module, path);
exit:
@@ -1043,8 +1068,9 @@
int dir_fd = DEFAULT_DIR_FD;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|i$O&:mkdir", _keywords,
- path_converter, &path, &mode, MKDIRAT_DIR_FD_CONVERTER, &dir_fd))
+ path_converter, &path, &mode, MKDIRAT_DIR_FD_CONVERTER, &dir_fd)) {
goto exit;
+ }
return_value = os_mkdir_impl(module, &path, mode, dir_fd);
exit:
@@ -1074,8 +1100,9 @@
PyObject *return_value = NULL;
int increment;
- if (!PyArg_Parse(arg, "i:nice", &increment))
+ if (!PyArg_Parse(arg, "i:nice", &increment)) {
goto exit;
+ }
return_value = os_nice_impl(module, increment);
exit:
@@ -1107,8 +1134,9 @@
int who;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:getpriority", _keywords,
- &which, &who))
+ &which, &who)) {
goto exit;
+ }
return_value = os_getpriority_impl(module, which, who);
exit:
@@ -1141,8 +1169,9 @@
int priority;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iii:setpriority", _keywords,
- &which, &who, &priority))
+ &which, &who, &priority)) {
goto exit;
+ }
return_value = os_setpriority_impl(module, which, who, priority);
exit:
@@ -1181,8 +1210,9 @@
int dst_dir_fd = DEFAULT_DIR_FD;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&|$O&O&:rename", _keywords,
- path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd))
+ path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd)) {
goto exit;
+ }
return_value = os_rename_impl(module, &src, &dst, src_dir_fd, dst_dir_fd);
exit:
@@ -1224,8 +1254,9 @@
int dst_dir_fd = DEFAULT_DIR_FD;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&|$O&O&:replace", _keywords,
- path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd))
+ path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd)) {
goto exit;
+ }
return_value = os_replace_impl(module, &src, &dst, src_dir_fd, dst_dir_fd);
exit:
@@ -1263,8 +1294,9 @@
int dir_fd = DEFAULT_DIR_FD;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|$O&:rmdir", _keywords,
- path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd))
+ path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd)) {
goto exit;
+ }
return_value = os_rmdir_impl(module, &path, dir_fd);
exit:
@@ -1297,11 +1329,13 @@
long _return_value;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "u:system", _keywords,
- &command))
+ &command)) {
goto exit;
+ }
_return_value = os_system_impl(module, command);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong(_return_value);
exit:
@@ -1333,11 +1367,13 @@
long _return_value;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&:system", _keywords,
- PyUnicode_FSConverter, &command))
+ PyUnicode_FSConverter, &command)) {
goto exit;
+ }
_return_value = os_system_impl(module, command);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong(_return_value);
exit:
@@ -1367,8 +1403,9 @@
PyObject *return_value = NULL;
int mask;
- if (!PyArg_Parse(arg, "i:umask", &mask))
+ if (!PyArg_Parse(arg, "i:umask", &mask)) {
goto exit;
+ }
return_value = os_umask_impl(module, mask);
exit:
@@ -1401,8 +1438,9 @@
int dir_fd = DEFAULT_DIR_FD;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|$O&:unlink", _keywords,
- path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd))
+ path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd)) {
goto exit;
+ }
return_value = os_unlink_impl(module, &path, dir_fd);
exit:
@@ -1438,8 +1476,9 @@
int dir_fd = DEFAULT_DIR_FD;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|$O&:remove", _keywords,
- path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd))
+ path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd)) {
goto exit;
+ }
return_value = os_remove_impl(module, &path, dir_fd);
exit:
@@ -1522,8 +1561,9 @@
int follow_symlinks = 1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|O$OO&p:utime", _keywords,
- path_converter, &path, ×, &ns, FUTIMENSAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks))
+ path_converter, &path, ×, &ns, FUTIMENSAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) {
goto exit;
+ }
return_value = os_utime_impl(module, &path, times, ns, dir_fd, follow_symlinks);
exit:
@@ -1553,8 +1593,9 @@
int status;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:_exit", _keywords,
- &status))
+ &status)) {
goto exit;
+ }
return_value = os__exit_impl(module, status);
exit:
@@ -1588,8 +1629,9 @@
PyObject *argv;
if (!PyArg_ParseTuple(args, "O&O:execv",
- PyUnicode_FSConverter, &path, &argv))
+ PyUnicode_FSConverter, &path, &argv)) {
goto exit;
+ }
return_value = os_execv_impl(module, path, argv);
exit:
@@ -1633,8 +1675,9 @@
PyObject *env;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&OO:execve", _keywords,
- path_converter, &path, &argv, &env))
+ path_converter, &path, &argv, &env)) {
goto exit;
+ }
return_value = os_execve_impl(module, &path, argv, env);
exit:
@@ -1676,8 +1719,9 @@
PyObject *argv;
if (!PyArg_ParseTuple(args, "iO&O:spawnv",
- &mode, PyUnicode_FSConverter, &path, &argv))
+ &mode, PyUnicode_FSConverter, &path, &argv)) {
goto exit;
+ }
return_value = os_spawnv_impl(module, mode, path, argv);
exit:
@@ -1723,8 +1767,9 @@
PyObject *env;
if (!PyArg_ParseTuple(args, "iO&OO:spawnve",
- &mode, PyUnicode_FSConverter, &path, &argv, &env))
+ &mode, PyUnicode_FSConverter, &path, &argv, &env)) {
goto exit;
+ }
return_value = os_spawnve_impl(module, mode, path, argv, env);
exit:
@@ -1806,8 +1851,9 @@
int policy;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:sched_get_priority_max", _keywords,
- &policy))
+ &policy)) {
goto exit;
+ }
return_value = os_sched_get_priority_max_impl(module, policy);
exit:
@@ -1838,8 +1884,9 @@
int policy;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:sched_get_priority_min", _keywords,
- &policy))
+ &policy)) {
goto exit;
+ }
return_value = os_sched_get_priority_min_impl(module, policy);
exit:
@@ -1870,8 +1917,9 @@
PyObject *return_value = NULL;
pid_t pid;
- if (!PyArg_Parse(arg, "" _Py_PARSE_PID ":sched_getscheduler", &pid))
+ if (!PyArg_Parse(arg, "" _Py_PARSE_PID ":sched_getscheduler", &pid)) {
goto exit;
+ }
return_value = os_sched_getscheduler_impl(module, pid);
exit:
@@ -1902,8 +1950,9 @@
PyObject *sched_priority;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:sched_param", _keywords,
- &sched_priority))
+ &sched_priority)) {
goto exit;
+ }
return_value = os_sched_param_impl(type, sched_priority);
exit:
@@ -1939,8 +1988,9 @@
struct sched_param param;
if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "iO&:sched_setscheduler",
- &pid, &policy, convert_sched_param, ¶m))
+ &pid, &policy, convert_sched_param, ¶m)) {
goto exit;
+ }
return_value = os_sched_setscheduler_impl(module, pid, policy, ¶m);
exit:
@@ -1972,8 +2022,9 @@
PyObject *return_value = NULL;
pid_t pid;
- if (!PyArg_Parse(arg, "" _Py_PARSE_PID ":sched_getparam", &pid))
+ if (!PyArg_Parse(arg, "" _Py_PARSE_PID ":sched_getparam", &pid)) {
goto exit;
+ }
return_value = os_sched_getparam_impl(module, pid);
exit:
@@ -2008,8 +2059,9 @@
struct sched_param param;
if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "O&:sched_setparam",
- &pid, convert_sched_param, ¶m))
+ &pid, convert_sched_param, ¶m)) {
goto exit;
+ }
return_value = os_sched_setparam_impl(module, pid, ¶m);
exit:
@@ -2041,11 +2093,13 @@
pid_t pid;
double _return_value;
- if (!PyArg_Parse(arg, "" _Py_PARSE_PID ":sched_rr_get_interval", &pid))
+ if (!PyArg_Parse(arg, "" _Py_PARSE_PID ":sched_rr_get_interval", &pid)) {
goto exit;
+ }
_return_value = os_sched_rr_get_interval_impl(module, pid);
- if ((_return_value == -1.0) && PyErr_Occurred())
+ if ((_return_value == -1.0) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyFloat_FromDouble(_return_value);
exit:
@@ -2100,8 +2154,9 @@
PyObject *mask;
if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "O:sched_setaffinity",
- &pid, &mask))
+ &pid, &mask)) {
goto exit;
+ }
return_value = os_sched_setaffinity_impl(module, pid, mask);
exit:
@@ -2116,7 +2171,7 @@
"sched_getaffinity($module, pid, /)\n"
"--\n"
"\n"
-"Return the affinity of the process identified by pid.\n"
+"Return the affinity of the process identified by pid (or the current process if zero).\n"
"\n"
"The affinity is returned as a set of CPU identifiers.");
@@ -2132,8 +2187,9 @@
PyObject *return_value = NULL;
pid_t pid;
- if (!PyArg_Parse(arg, "" _Py_PARSE_PID ":sched_getaffinity", &pid))
+ if (!PyArg_Parse(arg, "" _Py_PARSE_PID ":sched_getaffinity", &pid)) {
goto exit;
+ }
return_value = os_sched_getaffinity_impl(module, pid);
exit:
@@ -2322,8 +2378,9 @@
pid_t pid;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "" _Py_PARSE_PID ":getpgid", _keywords,
- &pid))
+ &pid)) {
goto exit;
+ }
return_value = os_getpgid_impl(module, pid);
exit:
@@ -2467,8 +2524,9 @@
Py_ssize_t signal;
if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "n:kill",
- &pid, &signal))
+ &pid, &signal)) {
goto exit;
+ }
return_value = os_kill_impl(module, pid, signal);
exit:
@@ -2499,8 +2557,9 @@
int signal;
if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "i:killpg",
- &pgid, &signal))
+ &pgid, &signal)) {
goto exit;
+ }
return_value = os_killpg_impl(module, pgid, signal);
exit:
@@ -2529,8 +2588,9 @@
PyObject *return_value = NULL;
int op;
- if (!PyArg_Parse(arg, "i:plock", &op))
+ if (!PyArg_Parse(arg, "i:plock", &op)) {
goto exit;
+ }
return_value = os_plock_impl(module, op);
exit:
@@ -2559,8 +2619,9 @@
PyObject *return_value = NULL;
uid_t uid;
- if (!PyArg_Parse(arg, "O&:setuid", _Py_Uid_Converter, &uid))
+ if (!PyArg_Parse(arg, "O&:setuid", _Py_Uid_Converter, &uid)) {
goto exit;
+ }
return_value = os_setuid_impl(module, uid);
exit:
@@ -2589,8 +2650,9 @@
PyObject *return_value = NULL;
uid_t euid;
- if (!PyArg_Parse(arg, "O&:seteuid", _Py_Uid_Converter, &euid))
+ if (!PyArg_Parse(arg, "O&:seteuid", _Py_Uid_Converter, &euid)) {
goto exit;
+ }
return_value = os_seteuid_impl(module, euid);
exit:
@@ -2619,8 +2681,9 @@
PyObject *return_value = NULL;
gid_t egid;
- if (!PyArg_Parse(arg, "O&:setegid", _Py_Gid_Converter, &egid))
+ if (!PyArg_Parse(arg, "O&:setegid", _Py_Gid_Converter, &egid)) {
goto exit;
+ }
return_value = os_setegid_impl(module, egid);
exit:
@@ -2651,8 +2714,9 @@
uid_t euid;
if (!PyArg_ParseTuple(args, "O&O&:setreuid",
- _Py_Uid_Converter, &ruid, _Py_Uid_Converter, &euid))
+ _Py_Uid_Converter, &ruid, _Py_Uid_Converter, &euid)) {
goto exit;
+ }
return_value = os_setreuid_impl(module, ruid, euid);
exit:
@@ -2683,8 +2747,9 @@
gid_t egid;
if (!PyArg_ParseTuple(args, "O&O&:setregid",
- _Py_Gid_Converter, &rgid, _Py_Gid_Converter, &egid))
+ _Py_Gid_Converter, &rgid, _Py_Gid_Converter, &egid)) {
goto exit;
+ }
return_value = os_setregid_impl(module, rgid, egid);
exit:
@@ -2713,8 +2778,9 @@
PyObject *return_value = NULL;
gid_t gid;
- if (!PyArg_Parse(arg, "O&:setgid", _Py_Gid_Converter, &gid))
+ if (!PyArg_Parse(arg, "O&:setgid", _Py_Gid_Converter, &gid)) {
goto exit;
+ }
return_value = os_setgid_impl(module, gid);
exit:
@@ -2761,8 +2827,9 @@
int options;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:wait3", _keywords,
- &options))
+ &options)) {
goto exit;
+ }
return_value = os_wait3_impl(module, options);
exit:
@@ -2797,8 +2864,9 @@
int options;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "" _Py_PARSE_PID "i:wait4", _keywords,
- &pid, &options))
+ &pid, &options)) {
goto exit;
+ }
return_value = os_wait4_impl(module, pid, options);
exit:
@@ -2841,8 +2909,9 @@
int options;
if (!PyArg_ParseTuple(args, "i" _Py_PARSE_PID "i:waitid",
- &idtype, &id, &options))
+ &idtype, &id, &options)) {
goto exit;
+ }
return_value = os_waitid_impl(module, idtype, id, options);
exit:
@@ -2878,8 +2947,9 @@
int options;
if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "i:waitpid",
- &pid, &options))
+ &pid, &options)) {
goto exit;
+ }
return_value = os_waitpid_impl(module, pid, options);
exit:
@@ -2915,8 +2985,9 @@
int options;
if (!PyArg_ParseTuple(args, "" _Py_PARSE_INTPTR "i:waitpid",
- &pid, &options))
+ &pid, &options)) {
goto exit;
+ }
return_value = os_waitpid_impl(module, pid, options);
exit:
@@ -2986,8 +3057,9 @@
int dir_fd = DEFAULT_DIR_FD;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&|p$O&:symlink", _keywords,
- path_converter, &src, path_converter, &dst, &target_is_directory, SYMLINKAT_DIR_FD_CONVERTER, &dir_fd))
+ path_converter, &src, path_converter, &dst, &target_is_directory, SYMLINKAT_DIR_FD_CONVERTER, &dir_fd)) {
goto exit;
+ }
return_value = os_symlink_impl(module, &src, &dst, target_is_directory, dir_fd);
exit:
@@ -3047,8 +3119,9 @@
PyObject *return_value = NULL;
pid_t pid;
- if (!PyArg_Parse(arg, "" _Py_PARSE_PID ":getsid", &pid))
+ if (!PyArg_Parse(arg, "" _Py_PARSE_PID ":getsid", &pid)) {
goto exit;
+ }
return_value = os_getsid_impl(module, pid);
exit:
@@ -3101,8 +3174,9 @@
pid_t pgrp;
if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "" _Py_PARSE_PID ":setpgid",
- &pid, &pgrp))
+ &pid, &pgrp)) {
goto exit;
+ }
return_value = os_setpgid_impl(module, pid, pgrp);
exit:
@@ -3131,8 +3205,9 @@
PyObject *return_value = NULL;
int fd;
- if (!PyArg_Parse(arg, "i:tcgetpgrp", &fd))
+ if (!PyArg_Parse(arg, "i:tcgetpgrp", &fd)) {
goto exit;
+ }
return_value = os_tcgetpgrp_impl(module, fd);
exit:
@@ -3163,8 +3238,9 @@
pid_t pgid;
if (!PyArg_ParseTuple(args, "i" _Py_PARSE_PID ":tcsetpgrp",
- &fd, &pgid))
+ &fd, &pgid)) {
goto exit;
+ }
return_value = os_tcsetpgrp_impl(module, fd, pgid);
exit:
@@ -3203,11 +3279,13 @@
int _return_value;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&i|i$O&:open", _keywords,
- path_converter, &path, &flags, &mode, OPENAT_DIR_FD_CONVERTER, &dir_fd))
+ path_converter, &path, &flags, &mode, OPENAT_DIR_FD_CONVERTER, &dir_fd)) {
goto exit;
+ }
_return_value = os_open_impl(module, &path, flags, mode, dir_fd);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong((long)_return_value);
exit:
@@ -3237,8 +3315,9 @@
int fd;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:close", _keywords,
- &fd))
+ &fd)) {
goto exit;
+ }
return_value = os_close_impl(module, fd);
exit:
@@ -3265,8 +3344,9 @@
int fd_high;
if (!PyArg_ParseTuple(args, "ii:closerange",
- &fd_low, &fd_high))
+ &fd_low, &fd_high)) {
goto exit;
+ }
return_value = os_closerange_impl(module, fd_low, fd_high);
exit:
@@ -3292,11 +3372,13 @@
int fd;
int _return_value;
- if (!PyArg_Parse(arg, "i:dup", &fd))
+ if (!PyArg_Parse(arg, "i:dup", &fd)) {
goto exit;
+ }
_return_value = os_dup_impl(module, fd);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong((long)_return_value);
exit:
@@ -3325,8 +3407,9 @@
int inheritable = 1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|p:dup2", _keywords,
- &fd, &fd2, &inheritable))
+ &fd, &fd2, &inheritable)) {
goto exit;
+ }
return_value = os_dup2_impl(module, fd, fd2, inheritable);
exit:
@@ -3363,8 +3446,9 @@
Py_off_t length;
if (!PyArg_ParseTuple(args, "iiO&:lockf",
- &fd, &command, Py_off_t_converter, &length))
+ &fd, &command, Py_off_t_converter, &length)) {
goto exit;
+ }
return_value = os_lockf_impl(module, fd, command, length);
exit:
@@ -3398,11 +3482,13 @@
Py_off_t _return_value;
if (!PyArg_ParseTuple(args, "iO&i:lseek",
- &fd, Py_off_t_converter, &position, &how))
+ &fd, Py_off_t_converter, &position, &how)) {
goto exit;
+ }
_return_value = os_lseek_impl(module, fd, position, how);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromPy_off_t(_return_value);
exit:
@@ -3429,8 +3515,9 @@
Py_ssize_t length;
if (!PyArg_ParseTuple(args, "in:read",
- &fd, &length))
+ &fd, &length)) {
goto exit;
+ }
return_value = os_read_impl(module, fd, length);
exit:
@@ -3468,11 +3555,13 @@
Py_ssize_t _return_value;
if (!PyArg_ParseTuple(args, "iO:readv",
- &fd, &buffers))
+ &fd, &buffers)) {
goto exit;
+ }
_return_value = os_readv_impl(module, fd, buffers);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromSsize_t(_return_value);
exit:
@@ -3507,8 +3596,9 @@
Py_off_t offset;
if (!PyArg_ParseTuple(args, "iiO&:pread",
- &fd, &length, Py_off_t_converter, &offset))
+ &fd, &length, Py_off_t_converter, &offset)) {
goto exit;
+ }
return_value = os_pread_impl(module, fd, length, offset);
exit:
@@ -3538,17 +3628,20 @@
Py_ssize_t _return_value;
if (!PyArg_ParseTuple(args, "iy*:write",
- &fd, &data))
+ &fd, &data)) {
goto exit;
+ }
_return_value = os_write_impl(module, fd, &data);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromSsize_t(_return_value);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -3576,8 +3669,9 @@
int fd;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:fstat", _keywords,
- &fd))
+ &fd)) {
goto exit;
+ }
return_value = os_fstat_impl(module, fd);
exit:
@@ -3606,11 +3700,13 @@
int fd;
int _return_value;
- if (!PyArg_Parse(arg, "i:isatty", &fd))
+ if (!PyArg_Parse(arg, "i:isatty", &fd)) {
goto exit;
+ }
_return_value = os_isatty_impl(module, fd);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyBool_FromLong((long)_return_value);
exit:
@@ -3668,8 +3764,9 @@
PyObject *return_value = NULL;
int flags;
- if (!PyArg_Parse(arg, "i:pipe2", &flags))
+ if (!PyArg_Parse(arg, "i:pipe2", &flags)) {
goto exit;
+ }
return_value = os_pipe2_impl(module, flags);
exit:
@@ -3704,11 +3801,13 @@
Py_ssize_t _return_value;
if (!PyArg_ParseTuple(args, "iO:writev",
- &fd, &buffers))
+ &fd, &buffers)) {
goto exit;
+ }
_return_value = os_writev_impl(module, fd, buffers);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromSsize_t(_return_value);
exit:
@@ -3746,17 +3845,20 @@
Py_ssize_t _return_value;
if (!PyArg_ParseTuple(args, "iy*O&:pwrite",
- &fd, &buffer, Py_off_t_converter, &offset))
+ &fd, &buffer, Py_off_t_converter, &offset)) {
goto exit;
+ }
_return_value = os_pwrite_impl(module, fd, &buffer, offset);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromSsize_t(_return_value);
exit:
/* Cleanup for buffer */
- if (buffer.obj)
+ if (buffer.obj) {
PyBuffer_Release(&buffer);
+ }
return return_value;
}
@@ -3792,8 +3894,9 @@
int dir_fd = DEFAULT_DIR_FD;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|i$O&:mkfifo", _keywords,
- path_converter, &path, &mode, MKFIFOAT_DIR_FD_CONVERTER, &dir_fd))
+ path_converter, &path, &mode, MKFIFOAT_DIR_FD_CONVERTER, &dir_fd)) {
goto exit;
+ }
return_value = os_mkfifo_impl(module, &path, mode, dir_fd);
exit:
@@ -3843,8 +3946,9 @@
int dir_fd = DEFAULT_DIR_FD;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|iO&$O&:mknod", _keywords,
- path_converter, &path, &mode, _Py_Dev_Converter, &device, MKNODAT_DIR_FD_CONVERTER, &dir_fd))
+ path_converter, &path, &mode, _Py_Dev_Converter, &device, MKNODAT_DIR_FD_CONVERTER, &dir_fd)) {
goto exit;
+ }
return_value = os_mknod_impl(module, &path, mode, device, dir_fd);
exit:
@@ -3877,11 +3981,13 @@
dev_t device;
unsigned int _return_value;
- if (!PyArg_Parse(arg, "O&:major", _Py_Dev_Converter, &device))
+ if (!PyArg_Parse(arg, "O&:major", _Py_Dev_Converter, &device)) {
goto exit;
+ }
_return_value = os_major_impl(module, device);
- if ((_return_value == (unsigned int)-1) && PyErr_Occurred())
+ if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromUnsignedLong((unsigned long)_return_value);
exit:
@@ -3911,11 +4017,13 @@
dev_t device;
unsigned int _return_value;
- if (!PyArg_Parse(arg, "O&:minor", _Py_Dev_Converter, &device))
+ if (!PyArg_Parse(arg, "O&:minor", _Py_Dev_Converter, &device)) {
goto exit;
+ }
_return_value = os_minor_impl(module, device);
- if ((_return_value == (unsigned int)-1) && PyErr_Occurred())
+ if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromUnsignedLong((unsigned long)_return_value);
exit:
@@ -3947,11 +4055,13 @@
dev_t _return_value;
if (!PyArg_ParseTuple(args, "ii:makedev",
- &major, &minor))
+ &major, &minor)) {
goto exit;
+ }
_return_value = os_makedev_impl(module, major, minor);
- if ((_return_value == (dev_t)-1) && PyErr_Occurred())
+ if ((_return_value == (dev_t)-1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = _PyLong_FromDev(_return_value);
exit:
@@ -3982,8 +4092,9 @@
Py_off_t length;
if (!PyArg_ParseTuple(args, "iO&:ftruncate",
- &fd, Py_off_t_converter, &length))
+ &fd, Py_off_t_converter, &length)) {
goto exit;
+ }
return_value = os_ftruncate_impl(module, fd, length);
exit:
@@ -4018,8 +4129,9 @@
Py_off_t length;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&:truncate", _keywords,
- path_converter, &path, Py_off_t_converter, &length))
+ path_converter, &path, Py_off_t_converter, &length)) {
goto exit;
+ }
return_value = os_truncate_impl(module, &path, length);
exit:
@@ -4058,8 +4170,9 @@
Py_off_t length;
if (!PyArg_ParseTuple(args, "iO&O&:posix_fallocate",
- &fd, Py_off_t_converter, &offset, Py_off_t_converter, &length))
+ &fd, Py_off_t_converter, &offset, Py_off_t_converter, &length)) {
goto exit;
+ }
return_value = os_posix_fallocate_impl(module, fd, offset, length);
exit:
@@ -4101,8 +4214,9 @@
int advice;
if (!PyArg_ParseTuple(args, "iO&O&i:posix_fadvise",
- &fd, Py_off_t_converter, &offset, Py_off_t_converter, &length, &advice))
+ &fd, Py_off_t_converter, &offset, Py_off_t_converter, &length, &advice)) {
goto exit;
+ }
return_value = os_posix_fadvise_impl(module, fd, offset, length, advice);
exit:
@@ -4133,8 +4247,9 @@
PyObject *value;
if (!PyArg_ParseTuple(args, "UU:putenv",
- &name, &value))
+ &name, &value)) {
goto exit;
+ }
return_value = os_putenv_impl(module, name, value);
exit:
@@ -4165,8 +4280,9 @@
PyObject *value = NULL;
if (!PyArg_ParseTuple(args, "O&O&:putenv",
- PyUnicode_FSConverter, &name, PyUnicode_FSConverter, &value))
+ PyUnicode_FSConverter, &name, PyUnicode_FSConverter, &value)) {
goto exit;
+ }
return_value = os_putenv_impl(module, name, value);
exit:
@@ -4200,8 +4316,9 @@
PyObject *return_value = NULL;
PyObject *name = NULL;
- if (!PyArg_Parse(arg, "O&:unsetenv", PyUnicode_FSConverter, &name))
+ if (!PyArg_Parse(arg, "O&:unsetenv", PyUnicode_FSConverter, &name)) {
goto exit;
+ }
return_value = os_unsetenv_impl(module, name);
exit:
@@ -4231,8 +4348,9 @@
PyObject *return_value = NULL;
int code;
- if (!PyArg_Parse(arg, "i:strerror", &code))
+ if (!PyArg_Parse(arg, "i:strerror", &code)) {
goto exit;
+ }
return_value = os_strerror_impl(module, code);
exit:
@@ -4260,11 +4378,13 @@
int status;
int _return_value;
- if (!PyArg_Parse(arg, "i:WCOREDUMP", &status))
+ if (!PyArg_Parse(arg, "i:WCOREDUMP", &status)) {
goto exit;
+ }
_return_value = os_WCOREDUMP_impl(module, status);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyBool_FromLong((long)_return_value);
exit:
@@ -4299,11 +4419,13 @@
int _return_value;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:WIFCONTINUED", _keywords,
- &status))
+ &status)) {
goto exit;
+ }
_return_value = os_WIFCONTINUED_impl(module, status);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyBool_FromLong((long)_return_value);
exit:
@@ -4335,11 +4457,13 @@
int _return_value;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:WIFSTOPPED", _keywords,
- &status))
+ &status)) {
goto exit;
+ }
_return_value = os_WIFSTOPPED_impl(module, status);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyBool_FromLong((long)_return_value);
exit:
@@ -4371,11 +4495,13 @@
int _return_value;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:WIFSIGNALED", _keywords,
- &status))
+ &status)) {
goto exit;
+ }
_return_value = os_WIFSIGNALED_impl(module, status);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyBool_FromLong((long)_return_value);
exit:
@@ -4407,11 +4533,13 @@
int _return_value;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:WIFEXITED", _keywords,
- &status))
+ &status)) {
goto exit;
+ }
_return_value = os_WIFEXITED_impl(module, status);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyBool_FromLong((long)_return_value);
exit:
@@ -4443,11 +4571,13 @@
int _return_value;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:WEXITSTATUS", _keywords,
- &status))
+ &status)) {
goto exit;
+ }
_return_value = os_WEXITSTATUS_impl(module, status);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong((long)_return_value);
exit:
@@ -4479,11 +4609,13 @@
int _return_value;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:WTERMSIG", _keywords,
- &status))
+ &status)) {
goto exit;
+ }
_return_value = os_WTERMSIG_impl(module, status);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong((long)_return_value);
exit:
@@ -4515,11 +4647,13 @@
int _return_value;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:WSTOPSIG", _keywords,
- &status))
+ &status)) {
goto exit;
+ }
_return_value = os_WSTOPSIG_impl(module, status);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong((long)_return_value);
exit:
@@ -4550,8 +4684,9 @@
PyObject *return_value = NULL;
int fd;
- if (!PyArg_Parse(arg, "i:fstatvfs", &fd))
+ if (!PyArg_Parse(arg, "i:fstatvfs", &fd)) {
goto exit;
+ }
return_value = os_fstatvfs_impl(module, fd);
exit:
@@ -4586,8 +4721,9 @@
path_t path = PATH_T_INITIALIZE("statvfs", "path", 0, PATH_HAVE_FSTATVFS);
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&:statvfs", _keywords,
- path_converter, &path))
+ path_converter, &path)) {
goto exit;
+ }
return_value = os_statvfs_impl(module, &path);
exit:
@@ -4621,8 +4757,9 @@
Py_UNICODE *path;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "u:_getdiskusage", _keywords,
- &path))
+ &path)) {
goto exit;
+ }
return_value = os__getdiskusage_impl(module, path);
exit:
@@ -4656,11 +4793,13 @@
long _return_value;
if (!PyArg_ParseTuple(args, "iO&:fpathconf",
- &fd, conv_path_confname, &name))
+ &fd, conv_path_confname, &name)) {
goto exit;
+ }
_return_value = os_fpathconf_impl(module, fd, name);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong(_return_value);
exit:
@@ -4697,11 +4836,13 @@
long _return_value;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&:pathconf", _keywords,
- path_converter, &path, conv_path_confname, &name))
+ path_converter, &path, conv_path_confname, &name)) {
goto exit;
+ }
_return_value = os_pathconf_impl(module, &path, name);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong(_return_value);
exit:
@@ -4733,8 +4874,9 @@
PyObject *return_value = NULL;
int name;
- if (!PyArg_Parse(arg, "O&:confstr", conv_confstr_confname, &name))
+ if (!PyArg_Parse(arg, "O&:confstr", conv_confstr_confname, &name)) {
goto exit;
+ }
return_value = os_confstr_impl(module, name);
exit:
@@ -4764,11 +4906,13 @@
int name;
long _return_value;
- if (!PyArg_Parse(arg, "O&:sysconf", conv_sysconf_confname, &name))
+ if (!PyArg_Parse(arg, "O&:sysconf", conv_sysconf_confname, &name)) {
goto exit;
+ }
_return_value = os_sysconf_impl(module, name);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong(_return_value);
exit:
@@ -4847,8 +4991,9 @@
int fd;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:device_encoding", _keywords,
- &fd))
+ &fd)) {
goto exit;
+ }
return_value = os_device_encoding_impl(module, fd);
exit:
@@ -4878,8 +5023,9 @@
uid_t suid;
if (!PyArg_ParseTuple(args, "O&O&O&:setresuid",
- _Py_Uid_Converter, &ruid, _Py_Uid_Converter, &euid, _Py_Uid_Converter, &suid))
+ _Py_Uid_Converter, &ruid, _Py_Uid_Converter, &euid, _Py_Uid_Converter, &suid)) {
goto exit;
+ }
return_value = os_setresuid_impl(module, ruid, euid, suid);
exit:
@@ -4911,8 +5057,9 @@
gid_t sgid;
if (!PyArg_ParseTuple(args, "O&O&O&:setresgid",
- _Py_Gid_Converter, &rgid, _Py_Gid_Converter, &egid, _Py_Gid_Converter, &sgid))
+ _Py_Gid_Converter, &rgid, _Py_Gid_Converter, &egid, _Py_Gid_Converter, &sgid)) {
goto exit;
+ }
return_value = os_setresgid_impl(module, rgid, egid, sgid);
exit:
@@ -4995,8 +5142,9 @@
int follow_symlinks = 1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&|$p:getxattr", _keywords,
- path_converter, &path, path_converter, &attribute, &follow_symlinks))
+ path_converter, &path, path_converter, &attribute, &follow_symlinks)) {
goto exit;
+ }
return_value = os_getxattr_impl(module, &path, &attribute, follow_symlinks);
exit:
@@ -5043,8 +5191,9 @@
int follow_symlinks = 1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&y*|i$p:setxattr", _keywords,
- path_converter, &path, path_converter, &attribute, &value, &flags, &follow_symlinks))
+ path_converter, &path, path_converter, &attribute, &value, &flags, &follow_symlinks)) {
goto exit;
+ }
return_value = os_setxattr_impl(module, &path, &attribute, &value, flags, follow_symlinks);
exit:
@@ -5053,8 +5202,9 @@
/* Cleanup for attribute */
path_cleanup(&attribute);
/* Cleanup for value */
- if (value.obj)
+ if (value.obj) {
PyBuffer_Release(&value);
+ }
return return_value;
}
@@ -5091,8 +5241,9 @@
int follow_symlinks = 1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&|$p:removexattr", _keywords,
- path_converter, &path, path_converter, &attribute, &follow_symlinks))
+ path_converter, &path, path_converter, &attribute, &follow_symlinks)) {
goto exit;
+ }
return_value = os_removexattr_impl(module, &path, &attribute, follow_symlinks);
exit:
@@ -5135,8 +5286,9 @@
int follow_symlinks = 1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O&$p:listxattr", _keywords,
- path_converter, &path, &follow_symlinks))
+ path_converter, &path, &follow_symlinks)) {
goto exit;
+ }
return_value = os_listxattr_impl(module, &path, follow_symlinks);
exit:
@@ -5166,8 +5318,9 @@
PyObject *return_value = NULL;
Py_ssize_t size;
- if (!PyArg_Parse(arg, "n:urandom", &size))
+ if (!PyArg_Parse(arg, "n:urandom", &size)) {
goto exit;
+ }
return_value = os_urandom_impl(module, size);
exit:
@@ -5178,7 +5331,11 @@
"cpu_count($module, /)\n"
"--\n"
"\n"
-"Return the number of CPUs in the system; return None if indeterminable.");
+"Return the number of CPUs in the system; return None if indeterminable.\n"
+"\n"
+"This number is not equivalent to the number of CPUs the current process can\n"
+"use. The number of usable CPUs can be obtained with\n"
+"``len(os.sched_getaffinity(0))``");
#define OS_CPU_COUNT_METHODDEF \
{"cpu_count", (PyCFunction)os_cpu_count, METH_NOARGS, os_cpu_count__doc__},
@@ -5211,11 +5368,13 @@
int fd;
int _return_value;
- if (!PyArg_Parse(arg, "i:get_inheritable", &fd))
+ if (!PyArg_Parse(arg, "i:get_inheritable", &fd)) {
goto exit;
+ }
_return_value = os_get_inheritable_impl(module, fd);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyBool_FromLong((long)_return_value);
exit:
@@ -5242,8 +5401,9 @@
int inheritable;
if (!PyArg_ParseTuple(args, "ii:set_inheritable",
- &fd, &inheritable))
+ &fd, &inheritable)) {
goto exit;
+ }
return_value = os_set_inheritable_impl(module, fd, inheritable);
exit:
@@ -5271,11 +5431,13 @@
Py_intptr_t handle;
int _return_value;
- if (!PyArg_Parse(arg, "" _Py_PARSE_INTPTR ":get_handle_inheritable", &handle))
+ if (!PyArg_Parse(arg, "" _Py_PARSE_INTPTR ":get_handle_inheritable", &handle)) {
goto exit;
+ }
_return_value = os_get_handle_inheritable_impl(module, handle);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyBool_FromLong((long)_return_value);
exit:
@@ -5307,8 +5469,9 @@
int inheritable;
if (!PyArg_ParseTuple(args, "" _Py_PARSE_INTPTR "p:set_handle_inheritable",
- &handle, &inheritable))
+ &handle, &inheritable)) {
goto exit;
+ }
return_value = os_set_handle_inheritable_impl(module, handle, inheritable);
exit:
@@ -5317,6 +5480,39 @@
#endif /* defined(MS_WINDOWS) */
+PyDoc_STRVAR(os_fspath__doc__,
+"fspath($module, /, path)\n"
+"--\n"
+"\n"
+"Return the file system path representation of the object.\n"
+"\n"
+"If the object is str or bytes, then allow it to pass through as-is. If the\n"
+"object defines __fspath__(), then return the result of that method. All other\n"
+"types raise a TypeError.");
+
+#define OS_FSPATH_METHODDEF \
+ {"fspath", (PyCFunction)os_fspath, METH_VARARGS|METH_KEYWORDS, os_fspath__doc__},
+
+static PyObject *
+os_fspath_impl(PyModuleDef *module, PyObject *path);
+
+static PyObject *
+os_fspath(PyModuleDef *module, PyObject *args, PyObject *kwargs)
+{
+ PyObject *return_value = NULL;
+ static char *_keywords[] = {"path", NULL};
+ PyObject *path;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:fspath", _keywords,
+ &path)) {
+ goto exit;
+ }
+ return_value = os_fspath_impl(module, path);
+
+exit:
+ return return_value;
+}
+
#ifndef OS_TTYNAME_METHODDEF
#define OS_TTYNAME_METHODDEF
#endif /* !defined(OS_TTYNAME_METHODDEF) */
@@ -5788,4 +5984,4 @@
#ifndef OS_SET_HANDLE_INHERITABLE_METHODDEF
#define OS_SET_HANDLE_INHERITABLE_METHODDEF
#endif /* !defined(OS_SET_HANDLE_INHERITABLE_METHODDEF) */
-/*[clinic end generated code: output=95824c52fd034654 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=1b91c3a100e75a4d input=a9049054013a1b77]*/
diff --git a/Modules/clinic/pwdmodule.c.h b/Modules/clinic/pwdmodule.c.h
index 9de2e4f..6b50464 100644
--- a/Modules/clinic/pwdmodule.c.h
+++ b/Modules/clinic/pwdmodule.c.h
@@ -33,8 +33,9 @@
PyObject *return_value = NULL;
PyObject *arg;
- if (!PyArg_Parse(arg_, "U:getpwnam", &arg))
+ if (!PyArg_Parse(arg_, "U:getpwnam", &arg)) {
goto exit;
+ }
return_value = pwd_getpwnam_impl(module, arg);
exit:
@@ -68,4 +69,4 @@
#ifndef PWD_GETPWALL_METHODDEF
#define PWD_GETPWALL_METHODDEF
#endif /* !defined(PWD_GETPWALL_METHODDEF) */
-/*[clinic end generated code: output=2ed0ecf34fd3f98f input=a9049054013a1b77]*/
+/*[clinic end generated code: output=f807c89b44be0fde input=a9049054013a1b77]*/
diff --git a/Modules/clinic/pyexpat.c.h b/Modules/clinic/pyexpat.c.h
index 379c5db..0c1f3fc 100644
--- a/Modules/clinic/pyexpat.c.h
+++ b/Modules/clinic/pyexpat.c.h
@@ -25,8 +25,9 @@
int isfinal = 0;
if (!PyArg_ParseTuple(args, "O|i:Parse",
- &data, &isfinal))
+ &data, &isfinal)) {
goto exit;
+ }
return_value = pyexpat_xmlparser_Parse_impl(self, data, isfinal);
exit:
@@ -60,8 +61,9 @@
PyObject *return_value = NULL;
const char *base;
- if (!PyArg_Parse(arg, "s:SetBase", &base))
+ if (!PyArg_Parse(arg, "s:SetBase", &base)) {
goto exit;
+ }
return_value = pyexpat_xmlparser_SetBase_impl(self, base);
exit:
@@ -129,8 +131,9 @@
const char *encoding = NULL;
if (!PyArg_ParseTuple(args, "z|s:ExternalEntityParserCreate",
- &context, &encoding))
+ &context, &encoding)) {
goto exit;
+ }
return_value = pyexpat_xmlparser_ExternalEntityParserCreate_impl(self, context, encoding);
exit:
@@ -160,8 +163,9 @@
PyObject *return_value = NULL;
int flag;
- if (!PyArg_Parse(arg, "i:SetParamEntityParsing", &flag))
+ if (!PyArg_Parse(arg, "i:SetParamEntityParsing", &flag)) {
goto exit;
+ }
return_value = pyexpat_xmlparser_SetParamEntityParsing_impl(self, flag);
exit:
@@ -193,8 +197,9 @@
int flag = 1;
if (!PyArg_ParseTuple(args, "|p:UseForeignDTD",
- &flag))
+ &flag)) {
goto exit;
+ }
return_value = pyexpat_xmlparser_UseForeignDTD_impl(self, flag);
exit:
@@ -244,8 +249,9 @@
PyObject *intern = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|zzO:ParserCreate", _keywords,
- &encoding, &namespace_separator, &intern))
+ &encoding, &namespace_separator, &intern)) {
goto exit;
+ }
return_value = pyexpat_ParserCreate_impl(module, encoding, namespace_separator, intern);
exit:
@@ -270,8 +276,9 @@
PyObject *return_value = NULL;
long code;
- if (!PyArg_Parse(arg, "l:ErrorString", &code))
+ if (!PyArg_Parse(arg, "l:ErrorString", &code)) {
goto exit;
+ }
return_value = pyexpat_ErrorString_impl(module, code);
exit:
@@ -281,4 +288,4 @@
#ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
#define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
#endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */
-/*[clinic end generated code: output=bf4d99c9702d8a6c input=a9049054013a1b77]*/
+/*[clinic end generated code: output=71a60d709647fbe3 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/sha1module.c.h b/Modules/clinic/sha1module.c.h
index fa865ba..6d3fa64 100644
--- a/Modules/clinic/sha1module.c.h
+++ b/Modules/clinic/sha1module.c.h
@@ -85,11 +85,12 @@
PyObject *string = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:sha1", _keywords,
- &string))
+ &string)) {
goto exit;
+ }
return_value = _sha1_sha1_impl(module, string);
exit:
return return_value;
}
-/*[clinic end generated code: output=be19102f3120490a input=a9049054013a1b77]*/
+/*[clinic end generated code: output=40df3f8955919e72 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/sha256module.c.h b/Modules/clinic/sha256module.c.h
index c5fe188..c429800 100644
--- a/Modules/clinic/sha256module.c.h
+++ b/Modules/clinic/sha256module.c.h
@@ -85,8 +85,9 @@
PyObject *string = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:sha256", _keywords,
- &string))
+ &string)) {
goto exit;
+ }
return_value = _sha256_sha256_impl(module, string);
exit:
@@ -113,11 +114,12 @@
PyObject *string = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:sha224", _keywords,
- &string))
+ &string)) {
goto exit;
+ }
return_value = _sha256_sha224_impl(module, string);
exit:
return return_value;
}
-/*[clinic end generated code: output=354cedf3b632c7b2 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=e85cc4a223371d84 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/sha512module.c.h b/Modules/clinic/sha512module.c.h
index c308739..94fb15c 100644
--- a/Modules/clinic/sha512module.c.h
+++ b/Modules/clinic/sha512module.c.h
@@ -103,8 +103,9 @@
PyObject *string = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:sha512", _keywords,
- &string))
+ &string)) {
goto exit;
+ }
return_value = _sha512_sha512_impl(module, string);
exit:
@@ -135,8 +136,9 @@
PyObject *string = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:sha384", _keywords,
- &string))
+ &string)) {
goto exit;
+ }
return_value = _sha512_sha384_impl(module, string);
exit:
@@ -168,4 +170,4 @@
#ifndef _SHA512_SHA384_METHODDEF
#define _SHA512_SHA384_METHODDEF
#endif /* !defined(_SHA512_SHA384_METHODDEF) */
-/*[clinic end generated code: output=1c7d385731fee7c0 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=845af47cea22e2a1 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/signalmodule.c.h b/Modules/clinic/signalmodule.c.h
index ec07ef1..e0aaab6 100644
--- a/Modules/clinic/signalmodule.c.h
+++ b/Modules/clinic/signalmodule.c.h
@@ -23,11 +23,13 @@
int seconds;
long _return_value;
- if (!PyArg_Parse(arg, "i:alarm", &seconds))
+ if (!PyArg_Parse(arg, "i:alarm", &seconds)) {
goto exit;
+ }
_return_value = signal_alarm_impl(module, seconds);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong(_return_value);
exit:
@@ -85,8 +87,9 @@
PyObject *handler;
if (!PyArg_ParseTuple(args, "iO:signal",
- &signalnum, &handler))
+ &signalnum, &handler)) {
goto exit;
+ }
return_value = signal_signal_impl(module, signalnum, handler);
exit:
@@ -117,8 +120,9 @@
PyObject *return_value = NULL;
int signalnum;
- if (!PyArg_Parse(arg, "i:getsignal", &signalnum))
+ if (!PyArg_Parse(arg, "i:getsignal", &signalnum)) {
goto exit;
+ }
return_value = signal_getsignal_impl(module, signalnum);
exit:
@@ -150,8 +154,9 @@
int flag;
if (!PyArg_ParseTuple(args, "ii:siginterrupt",
- &signalnum, &flag))
+ &signalnum, &flag)) {
goto exit;
+ }
return_value = signal_siginterrupt_impl(module, signalnum, flag);
exit:
@@ -189,8 +194,9 @@
double interval = 0.0;
if (!PyArg_ParseTuple(args, "id|d:setitimer",
- &which, &seconds, &interval))
+ &which, &seconds, &interval)) {
goto exit;
+ }
return_value = signal_setitimer_impl(module, which, seconds, interval);
exit:
@@ -219,8 +225,9 @@
PyObject *return_value = NULL;
int which;
- if (!PyArg_Parse(arg, "i:getitimer", &which))
+ if (!PyArg_Parse(arg, "i:getitimer", &which)) {
goto exit;
+ }
return_value = signal_getitimer_impl(module, which);
exit:
@@ -251,8 +258,9 @@
PyObject *mask;
if (!PyArg_ParseTuple(args, "iO:pthread_sigmask",
- &how, &mask))
+ &how, &mask)) {
goto exit;
+ }
return_value = signal_pthread_sigmask_impl(module, how, mask);
exit:
@@ -344,8 +352,9 @@
if (!PyArg_UnpackTuple(args, "sigtimedwait",
2, 2,
- &sigset, &timeout_obj))
+ &sigset, &timeout_obj)) {
goto exit;
+ }
return_value = signal_sigtimedwait_impl(module, sigset, timeout_obj);
exit:
@@ -376,8 +385,9 @@
int signalnum;
if (!PyArg_ParseTuple(args, "li:pthread_kill",
- &thread_id, &signalnum))
+ &thread_id, &signalnum)) {
goto exit;
+ }
return_value = signal_pthread_kill_impl(module, thread_id, signalnum);
exit:
@@ -429,4 +439,4 @@
#ifndef SIGNAL_PTHREAD_KILL_METHODDEF
#define SIGNAL_PTHREAD_KILL_METHODDEF
#endif /* !defined(SIGNAL_PTHREAD_KILL_METHODDEF) */
-/*[clinic end generated code: output=b99278c16c40ea43 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=4b9519180a091536 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/spwdmodule.c.h b/Modules/clinic/spwdmodule.c.h
index c0d18db..51bda96 100644
--- a/Modules/clinic/spwdmodule.c.h
+++ b/Modules/clinic/spwdmodule.c.h
@@ -24,8 +24,9 @@
PyObject *return_value = NULL;
PyObject *arg;
- if (!PyArg_Parse(arg_, "U:getspnam", &arg))
+ if (!PyArg_Parse(arg_, "U:getspnam", &arg)) {
goto exit;
+ }
return_value = spwd_getspnam_impl(module, arg);
exit:
@@ -65,4 +66,4 @@
#ifndef SPWD_GETSPALL_METHODDEF
#define SPWD_GETSPALL_METHODDEF
#endif /* !defined(SPWD_GETSPALL_METHODDEF) */
-/*[clinic end generated code: output=6c178830413f7763 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=2b7a384447e5f1e3 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/unicodedata.c.h b/Modules/clinic/unicodedata.c.h
index d520c1e..d481ccb 100644
--- a/Modules/clinic/unicodedata.c.h
+++ b/Modules/clinic/unicodedata.c.h
@@ -27,8 +27,9 @@
PyObject *default_value = NULL;
if (!PyArg_ParseTuple(args, "C|O:decimal",
- &chr, &default_value))
+ &chr, &default_value)) {
goto exit;
+ }
return_value = unicodedata_UCD_decimal_impl(self, chr, default_value);
exit:
@@ -59,8 +60,9 @@
PyObject *default_value = NULL;
if (!PyArg_ParseTuple(args, "C|O:digit",
- &chr, &default_value))
+ &chr, &default_value)) {
goto exit;
+ }
return_value = unicodedata_UCD_digit_impl(self, chr, default_value);
exit:
@@ -92,8 +94,9 @@
PyObject *default_value = NULL;
if (!PyArg_ParseTuple(args, "C|O:numeric",
- &chr, &default_value))
+ &chr, &default_value)) {
goto exit;
+ }
return_value = unicodedata_UCD_numeric_impl(self, chr, default_value);
exit:
@@ -118,8 +121,9 @@
PyObject *return_value = NULL;
int chr;
- if (!PyArg_Parse(arg, "C:category", &chr))
+ if (!PyArg_Parse(arg, "C:category", &chr)) {
goto exit;
+ }
return_value = unicodedata_UCD_category_impl(self, chr);
exit:
@@ -146,8 +150,9 @@
PyObject *return_value = NULL;
int chr;
- if (!PyArg_Parse(arg, "C:bidirectional", &chr))
+ if (!PyArg_Parse(arg, "C:bidirectional", &chr)) {
goto exit;
+ }
return_value = unicodedata_UCD_bidirectional_impl(self, chr);
exit:
@@ -175,11 +180,13 @@
int chr;
int _return_value;
- if (!PyArg_Parse(arg, "C:combining", &chr))
+ if (!PyArg_Parse(arg, "C:combining", &chr)) {
goto exit;
+ }
_return_value = unicodedata_UCD_combining_impl(self, chr);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong((long)_return_value);
exit:
@@ -208,11 +215,13 @@
int chr;
int _return_value;
- if (!PyArg_Parse(arg, "C:mirrored", &chr))
+ if (!PyArg_Parse(arg, "C:mirrored", &chr)) {
goto exit;
+ }
_return_value = unicodedata_UCD_mirrored_impl(self, chr);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong((long)_return_value);
exit:
@@ -237,8 +246,9 @@
PyObject *return_value = NULL;
int chr;
- if (!PyArg_Parse(arg, "C:east_asian_width", &chr))
+ if (!PyArg_Parse(arg, "C:east_asian_width", &chr)) {
goto exit;
+ }
return_value = unicodedata_UCD_east_asian_width_impl(self, chr);
exit:
@@ -265,8 +275,9 @@
PyObject *return_value = NULL;
int chr;
- if (!PyArg_Parse(arg, "C:decomposition", &chr))
+ if (!PyArg_Parse(arg, "C:decomposition", &chr)) {
goto exit;
+ }
return_value = unicodedata_UCD_decomposition_impl(self, chr);
exit:
@@ -296,8 +307,9 @@
PyObject *input;
if (!PyArg_ParseTuple(args, "sO!:normalize",
- &form, &PyUnicode_Type, &input))
+ &form, &PyUnicode_Type, &input)) {
goto exit;
+ }
return_value = unicodedata_UCD_normalize_impl(self, form, input);
exit:
@@ -327,8 +339,9 @@
PyObject *default_value = NULL;
if (!PyArg_ParseTuple(args, "C|O:name",
- &chr, &default_value))
+ &chr, &default_value)) {
goto exit;
+ }
return_value = unicodedata_UCD_name_impl(self, chr, default_value);
exit:
@@ -358,11 +371,12 @@
const char *name;
Py_ssize_clean_t name_length;
- if (!PyArg_Parse(arg, "s#:lookup", &name, &name_length))
+ if (!PyArg_Parse(arg, "s#:lookup", &name, &name_length)) {
goto exit;
+ }
return_value = unicodedata_UCD_lookup_impl(self, name, name_length);
exit:
return return_value;
}
-/*[clinic end generated code: output=4f8da33c6bc6efc9 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=5313ce129da87b2f input=a9049054013a1b77]*/
diff --git a/Modules/clinic/zlibmodule.c.h b/Modules/clinic/zlibmodule.c.h
index 602ae1d..dcaeef8 100644
--- a/Modules/clinic/zlibmodule.c.h
+++ b/Modules/clinic/zlibmodule.c.h
@@ -3,38 +3,41 @@
[clinic start generated code]*/
PyDoc_STRVAR(zlib_compress__doc__,
-"compress($module, bytes, level=Z_DEFAULT_COMPRESSION, /)\n"
+"compress($module, data, /, level=Z_DEFAULT_COMPRESSION)\n"
"--\n"
"\n"
"Returns a bytes object containing compressed data.\n"
"\n"
-" bytes\n"
+" data\n"
" Binary data to be compressed.\n"
" level\n"
-" Compression level, in 0-9.");
+" Compression level, in 0-9 or -1.");
#define ZLIB_COMPRESS_METHODDEF \
- {"compress", (PyCFunction)zlib_compress, METH_VARARGS, zlib_compress__doc__},
+ {"compress", (PyCFunction)zlib_compress, METH_VARARGS|METH_KEYWORDS, zlib_compress__doc__},
static PyObject *
-zlib_compress_impl(PyModuleDef *module, Py_buffer *bytes, int level);
+zlib_compress_impl(PyModuleDef *module, Py_buffer *data, int level);
static PyObject *
-zlib_compress(PyModuleDef *module, PyObject *args)
+zlib_compress(PyModuleDef *module, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
- Py_buffer bytes = {NULL, NULL};
+ static char *_keywords[] = {"", "level", NULL};
+ Py_buffer data = {NULL, NULL};
int level = Z_DEFAULT_COMPRESSION;
- if (!PyArg_ParseTuple(args, "y*|i:compress",
- &bytes, &level))
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|i:compress", _keywords,
+ &data, &level)) {
goto exit;
- return_value = zlib_compress_impl(module, &bytes, level);
+ }
+ return_value = zlib_compress_impl(module, &data, level);
exit:
- /* Cleanup for bytes */
- if (bytes.obj)
- PyBuffer_Release(&bytes);
+ /* Cleanup for data */
+ if (data.obj) {
+ PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -68,14 +71,16 @@
unsigned int bufsize = DEF_BUF_SIZE;
if (!PyArg_ParseTuple(args, "y*|iO&:decompress",
- &data, &wbits, capped_uint_converter, &bufsize))
+ &data, &wbits, capped_uint_converter, &bufsize)) {
goto exit;
+ }
return_value = zlib_decompress_impl(module, &data, wbits, bufsize);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -130,14 +135,16 @@
Py_buffer zdict = {NULL, NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iiiiiy*:compressobj", _keywords,
- &level, &method, &wbits, &memLevel, &strategy, &zdict))
+ &level, &method, &wbits, &memLevel, &strategy, &zdict)) {
goto exit;
+ }
return_value = zlib_compressobj_impl(module, level, method, wbits, memLevel, strategy, &zdict);
exit:
/* Cleanup for zdict */
- if (zdict.obj)
+ if (zdict.obj) {
PyBuffer_Release(&zdict);
+ }
return return_value;
}
@@ -169,8 +176,9 @@
PyObject *zdict = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iO:decompressobj", _keywords,
- &wbits, &zdict))
+ &wbits, &zdict)) {
goto exit;
+ }
return_value = zlib_decompressobj_impl(module, wbits, zdict);
exit:
@@ -202,14 +210,16 @@
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:compress", &data))
+ if (!PyArg_Parse(arg, "y*:compress", &data)) {
goto exit;
+ }
return_value = zlib_Compress_compress_impl(self, &data);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -246,14 +256,16 @@
unsigned int max_length = 0;
if (!PyArg_ParseTuple(args, "y*|O&:decompress",
- &data, capped_uint_converter, &max_length))
+ &data, capped_uint_converter, &max_length)) {
goto exit;
+ }
return_value = zlib_Decompress_decompress_impl(self, &data, max_length);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -283,8 +295,9 @@
int mode = Z_FINISH;
if (!PyArg_ParseTuple(args, "|i:flush",
- &mode))
+ &mode)) {
goto exit;
+ }
return_value = zlib_Compress_flush_impl(self, mode);
exit:
@@ -357,8 +370,9 @@
unsigned int length = DEF_BUF_SIZE;
if (!PyArg_ParseTuple(args, "|O&:flush",
- capped_uint_converter, &length))
+ capped_uint_converter, &length)) {
goto exit;
+ }
return_value = zlib_Decompress_flush_impl(self, length);
exit:
@@ -390,14 +404,16 @@
unsigned int value = 1;
if (!PyArg_ParseTuple(args, "y*|I:adler32",
- &data, &value))
+ &data, &value)) {
goto exit;
+ }
return_value = zlib_adler32_impl(module, &data, value);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -427,14 +443,16 @@
unsigned int value = 0;
if (!PyArg_ParseTuple(args, "y*|I:crc32",
- &data, &value))
+ &data, &value)) {
goto exit;
+ }
return_value = zlib_crc32_impl(module, &data, value);
exit:
/* Cleanup for data */
- if (data.obj)
+ if (data.obj) {
PyBuffer_Release(&data);
+ }
return return_value;
}
@@ -442,4 +460,4 @@
#ifndef ZLIB_COMPRESS_COPY_METHODDEF
#define ZLIB_COMPRESS_COPY_METHODDEF
#endif /* !defined(ZLIB_COMPRESS_COPY_METHODDEF) */
-/*[clinic end generated code: output=f31627b314a7bd2f input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ba904dec30cc1a1a input=a9049054013a1b77]*/
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
index f1fda48..d6322d0 100644
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -119,7 +119,7 @@
handler fails in faulthandler_fatal_error() */
{SIGSEGV, 0, "Segmentation fault", }
};
-static const unsigned char faulthandler_nsignals = \
+static const size_t faulthandler_nsignals = \
Py_ARRAY_LENGTH(faulthandler_handlers);
#ifdef HAVE_SIGALTSTACK
@@ -202,8 +202,9 @@
static PyThreadState*
get_thread_state(void)
{
- PyThreadState *tstate = PyThreadState_Get();
+ PyThreadState *tstate = _PyThreadState_UncheckedGet();
if (tstate == NULL) {
+ /* just in case but very unlikely... */
PyErr_SetString(PyExc_RuntimeError,
"unable to get the current thread state");
return NULL;
@@ -234,11 +235,12 @@
PyGILState_GetThisThreadState(). */
tstate = PyGILState_GetThisThreadState();
#else
- tstate = PyThreadState_Get();
+ tstate = _PyThreadState_UncheckedGet();
#endif
- if (all_threads)
- _Py_DumpTracebackThreads(fd, interp, tstate);
+ if (all_threads) {
+ (void)_Py_DumpTracebackThreads(fd, NULL, tstate);
+ }
else {
if (tstate != NULL)
_Py_DumpTraceback(fd, tstate);
@@ -272,7 +274,7 @@
return NULL;
if (all_threads) {
- errmsg = _Py_DumpTracebackThreads(fd, tstate->interp, tstate);
+ errmsg = _Py_DumpTracebackThreads(fd, NULL, tstate);
if (errmsg != NULL) {
PyErr_SetString(PyExc_RuntimeError, errmsg);
return NULL;
@@ -288,6 +290,19 @@
Py_RETURN_NONE;
}
+static void
+faulthandler_disable_fatal_handler(fault_handler_t *handler)
+{
+ if (!handler->enabled)
+ return;
+ handler->enabled = 0;
+#ifdef HAVE_SIGACTION
+ (void)sigaction(handler->signum, &handler->previous, NULL);
+#else
+ (void)signal(handler->signum, handler->previous);
+#endif
+}
+
/* Handler for SIGSEGV, SIGFPE, SIGABRT, SIGBUS and SIGILL signals.
@@ -306,7 +321,7 @@
faulthandler_fatal_error(int signum)
{
const int fd = fatal_error.fd;
- unsigned int i;
+ size_t i;
fault_handler_t *handler = NULL;
int save_errno = errno;
@@ -324,12 +339,7 @@
}
/* restore the previous handler */
-#ifdef HAVE_SIGACTION
- (void)sigaction(signum, &handler->previous, NULL);
-#else
- (void)signal(signum, handler->previous);
-#endif
- handler->enabled = 0;
+ faulthandler_disable_fatal_handler(handler);
PUTS(fd, "Fatal Python error: ");
PUTS(fd, handler->name);
@@ -351,20 +361,117 @@
raise(signum);
}
+#ifdef MS_WINDOWS
+static LONG WINAPI
+faulthandler_exc_handler(struct _EXCEPTION_POINTERS *exc_info)
+{
+ const int fd = fatal_error.fd;
+ DWORD code = exc_info->ExceptionRecord->ExceptionCode;
+ DWORD flags = exc_info->ExceptionRecord->ExceptionFlags;
+
+ /* only log fatal exceptions */
+ if (flags & EXCEPTION_NONCONTINUABLE) {
+ /* call the next exception handler */
+ return EXCEPTION_CONTINUE_SEARCH;
+ }
+
+ PUTS(fd, "Windows fatal exception: ");
+ switch (code)
+ {
+ /* only format most common errors */
+ case EXCEPTION_ACCESS_VIOLATION: PUTS(fd, "access violation"); break;
+ case EXCEPTION_FLT_DIVIDE_BY_ZERO: PUTS(fd, "float divide by zero"); break;
+ case EXCEPTION_FLT_OVERFLOW: PUTS(fd, "float overflow"); break;
+ case EXCEPTION_INT_DIVIDE_BY_ZERO: PUTS(fd, "int divide by zero"); break;
+ case EXCEPTION_INT_OVERFLOW: PUTS(fd, "integer overflow"); break;
+ case EXCEPTION_IN_PAGE_ERROR: PUTS(fd, "page error"); break;
+ case EXCEPTION_STACK_OVERFLOW: PUTS(fd, "stack overflow"); break;
+ default:
+ PUTS(fd, "code ");
+ _Py_DumpDecimal(fd, code);
+ }
+ PUTS(fd, "\n\n");
+
+ if (code == EXCEPTION_ACCESS_VIOLATION) {
+ /* disable signal handler for SIGSEGV */
+ size_t i;
+ for (i=0; i < faulthandler_nsignals; i++) {
+ fault_handler_t *handler = &faulthandler_handlers[i];
+ if (handler->signum == SIGSEGV) {
+ faulthandler_disable_fatal_handler(handler);
+ break;
+ }
+ }
+ }
+
+ faulthandler_dump_traceback(fd, fatal_error.all_threads,
+ fatal_error.interp);
+
+ /* call the next exception handler */
+ return EXCEPTION_CONTINUE_SEARCH;
+}
+#endif
+
/* Install the handler for fatal signals, faulthandler_fatal_error(). */
+static int
+faulthandler_enable(void)
+{
+ size_t i;
+
+ if (fatal_error.enabled) {
+ return 0;
+ }
+ fatal_error.enabled = 1;
+
+ for (i=0; i < faulthandler_nsignals; i++) {
+ fault_handler_t *handler;
+#ifdef HAVE_SIGACTION
+ struct sigaction action;
+#endif
+ int err;
+
+ handler = &faulthandler_handlers[i];
+ assert(!handler->enabled);
+#ifdef HAVE_SIGACTION
+ action.sa_handler = faulthandler_fatal_error;
+ sigemptyset(&action.sa_mask);
+ /* Do not prevent the signal from being received from within
+ its own signal handler */
+ action.sa_flags = SA_NODEFER;
+#ifdef HAVE_SIGALTSTACK
+ if (stack.ss_sp != NULL) {
+ /* Call the signal handler on an alternate signal stack
+ provided by sigaltstack() */
+ action.sa_flags |= SA_ONSTACK;
+ }
+#endif
+ err = sigaction(handler->signum, &action, &handler->previous);
+#else
+ handler->previous = signal(handler->signum,
+ faulthandler_fatal_error);
+ err = (handler->previous == SIG_ERR);
+#endif
+ if (err) {
+ PyErr_SetFromErrno(PyExc_RuntimeError);
+ return -1;
+ }
+
+ handler->enabled = 1;
+ }
+
+#ifdef MS_WINDOWS
+ AddVectoredExceptionHandler(1, faulthandler_exc_handler);
+#endif
+ return 0;
+}
+
static PyObject*
-faulthandler_enable(PyObject *self, PyObject *args, PyObject *kwargs)
+faulthandler_py_enable(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = {"file", "all_threads", NULL};
PyObject *file = NULL;
int all_threads = 1;
- unsigned int i;
- fault_handler_t *handler;
-#ifdef HAVE_SIGACTION
- struct sigaction action;
-#endif
- int err;
int fd;
PyThreadState *tstate;
@@ -386,37 +493,10 @@
fatal_error.all_threads = all_threads;
fatal_error.interp = tstate->interp;
- if (!fatal_error.enabled) {
- fatal_error.enabled = 1;
-
- for (i=0; i < faulthandler_nsignals; i++) {
- handler = &faulthandler_handlers[i];
-#ifdef HAVE_SIGACTION
- action.sa_handler = faulthandler_fatal_error;
- sigemptyset(&action.sa_mask);
- /* Do not prevent the signal from being received from within
- its own signal handler */
- action.sa_flags = SA_NODEFER;
-#ifdef HAVE_SIGALTSTACK
- if (stack.ss_sp != NULL) {
- /* Call the signal handler on an alternate signal stack
- provided by sigaltstack() */
- action.sa_flags |= SA_ONSTACK;
- }
-#endif
- err = sigaction(handler->signum, &action, &handler->previous);
-#else
- handler->previous = signal(handler->signum,
- faulthandler_fatal_error);
- err = (handler->previous == SIG_ERR);
-#endif
- if (err) {
- PyErr_SetFromErrno(PyExc_RuntimeError);
- return NULL;
- }
- handler->enabled = 1;
- }
+ if (faulthandler_enable() < 0) {
+ return NULL;
}
+
Py_RETURN_NONE;
}
@@ -430,14 +510,7 @@
fatal_error.enabled = 0;
for (i=0; i < faulthandler_nsignals; i++) {
handler = &faulthandler_handlers[i];
- if (!handler->enabled)
- continue;
-#ifdef HAVE_SIGACTION
- (void)sigaction(handler->signum, &handler->previous, NULL);
-#else
- (void)signal(handler->signum, handler->previous);
-#endif
- handler->enabled = 0;
+ faulthandler_disable_fatal_handler(handler);
}
}
@@ -469,7 +542,6 @@
{
PyLockStatus st;
const char* errmsg;
- PyThreadState *current;
int ok;
#if defined(HAVE_PTHREAD_SIGMASK) && !defined(HAVE_BROKEN_PTHREAD_SIGMASK)
sigset_t set;
@@ -489,12 +561,9 @@
/* Timeout => dump traceback */
assert(st == PY_LOCK_FAILURE);
- /* get the thread holding the GIL, NULL if no thread hold the GIL */
- current = _PyThreadState_UncheckedGet();
-
_Py_write_noraise(thread.fd, thread.header, (int)thread.header_len);
- errmsg = _Py_DumpTracebackThreads(thread.fd, thread.interp, current);
+ errmsg = _Py_DumpTracebackThreads(thread.fd, thread.interp, NULL);
ok = (errmsg == NULL);
if (thread.exit)
@@ -894,7 +963,7 @@
faulthandler_sigsegv(PyObject *self, PyObject *args)
{
int release_gil = 0;
- if (!PyArg_ParseTuple(args, "|i:_read_null", &release_gil))
+ if (!PyArg_ParseTuple(args, "|i:_sigsegv", &release_gil))
return NULL;
if (release_gil) {
@@ -907,6 +976,49 @@
Py_RETURN_NONE;
}
+#ifdef WITH_THREAD
+static void
+faulthandler_fatal_error_thread(void *plock)
+{
+ PyThread_type_lock *lock = (PyThread_type_lock *)plock;
+
+ Py_FatalError("in new thread");
+
+ /* notify the caller that we are done */
+ PyThread_release_lock(lock);
+}
+
+static PyObject *
+faulthandler_fatal_error_c_thread(PyObject *self, PyObject *args)
+{
+ long thread;
+ PyThread_type_lock lock;
+
+ faulthandler_suppress_crash_report();
+
+ lock = PyThread_allocate_lock();
+ if (lock == NULL)
+ return PyErr_NoMemory();
+
+ PyThread_acquire_lock(lock, WAIT_LOCK);
+
+ thread = PyThread_start_new_thread(faulthandler_fatal_error_thread, lock);
+ if (thread == -1) {
+ PyThread_free_lock(lock);
+ PyErr_SetString(PyExc_RuntimeError, "unable to start the thread");
+ return NULL;
+ }
+
+ /* wait until the thread completes: it will never occur, since Py_FatalError()
+ exits the process immedialty. */
+ PyThread_acquire_lock(lock, WAIT_LOCK);
+ PyThread_release_lock(lock);
+ PyThread_free_lock(lock);
+
+ Py_RETURN_NONE;
+}
+#endif
+
static PyObject *
faulthandler_sigfpe(PyObject *self, PyObject *args)
{
@@ -951,6 +1063,8 @@
}
#if defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGACTION)
+#define FAULTHANDLER_STACK_OVERFLOW
+
#ifdef __INTEL_COMPILER
/* Issue #23654: Turn off ICC's tail call optimization for the
* stack_overflow generator. ICC turns the recursive tail call into
@@ -994,7 +1108,7 @@
size, depth);
return NULL;
}
-#endif
+#endif /* defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGACTION) */
static int
@@ -1017,12 +1131,25 @@
return 0;
}
+#ifdef MS_WINDOWS
+static PyObject *
+faulthandler_raise_exception(PyObject *self, PyObject *args)
+{
+ unsigned int code, flags = 0;
+ if (!PyArg_ParseTuple(args, "I|I:_raise_exception", &code, &flags))
+ return NULL;
+ faulthandler_suppress_crash_report();
+ RaiseException(code, flags, 0, NULL);
+ Py_RETURN_NONE;
+}
+#endif
+
PyDoc_STRVAR(module_doc,
"faulthandler module.");
static PyMethodDef module_methods[] = {
{"enable",
- (PyCFunction)faulthandler_enable, METH_VARARGS|METH_KEYWORDS,
+ (PyCFunction)faulthandler_py_enable, METH_VARARGS|METH_KEYWORDS,
PyDoc_STR("enable(file=sys.stderr, all_threads=True): "
"enable the fault handler")},
{"disable", (PyCFunction)faulthandler_disable_py, METH_NOARGS,
@@ -1065,16 +1192,25 @@
"a SIGSEGV or SIGBUS signal depending on the platform")},
{"_sigsegv", faulthandler_sigsegv, METH_VARARGS,
PyDoc_STR("_sigsegv(release_gil=False): raise a SIGSEGV signal")},
+#ifdef WITH_THREAD
+ {"_fatal_error_c_thread", faulthandler_fatal_error_c_thread, METH_NOARGS,
+ PyDoc_STR("fatal_error_c_thread(): "
+ "call Py_FatalError() in a new C thread.")},
+#endif
{"_sigabrt", faulthandler_sigabrt, METH_NOARGS,
PyDoc_STR("_sigabrt(): raise a SIGABRT signal")},
{"_sigfpe", (PyCFunction)faulthandler_sigfpe, METH_NOARGS,
PyDoc_STR("_sigfpe(): raise a SIGFPE signal")},
{"_fatal_error", faulthandler_fatal_error_py, METH_VARARGS,
PyDoc_STR("_fatal_error(message): call Py_FatalError(message)")},
-#if defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGACTION)
+#ifdef FAULTHANDLER_STACK_OVERFLOW
{"_stack_overflow", (PyCFunction)faulthandler_stack_overflow, METH_NOARGS,
PyDoc_STR("_stack_overflow(): recursive call to raise a stack overflow")},
#endif
+#ifdef MS_WINDOWS
+ {"_raise_exception", faulthandler_raise_exception, METH_VARARGS,
+ PyDoc_STR("raise_exception(code, flags=0): Call RaiseException(code, flags).")},
+#endif
{NULL, NULL} /* sentinel */
};
@@ -1093,7 +1229,33 @@
PyMODINIT_FUNC
PyInit_faulthandler(void)
{
- return PyModule_Create(&module_def);
+ PyObject *m = PyModule_Create(&module_def);
+ if (m == NULL)
+ return NULL;
+
+ /* Add constants for unit tests */
+#ifdef MS_WINDOWS
+ /* RaiseException() codes (prefixed by an underscore) */
+ if (PyModule_AddIntConstant(m, "_EXCEPTION_ACCESS_VIOLATION",
+ EXCEPTION_ACCESS_VIOLATION))
+ return NULL;
+ if (PyModule_AddIntConstant(m, "_EXCEPTION_INT_DIVIDE_BY_ZERO",
+ EXCEPTION_INT_DIVIDE_BY_ZERO))
+ return NULL;
+ if (PyModule_AddIntConstant(m, "_EXCEPTION_STACK_OVERFLOW",
+ EXCEPTION_STACK_OVERFLOW))
+ return NULL;
+
+ /* RaiseException() flags (prefixed by an underscore) */
+ if (PyModule_AddIntConstant(m, "_EXCEPTION_NONCONTINUABLE",
+ EXCEPTION_NONCONTINUABLE))
+ return NULL;
+ if (PyModule_AddIntConstant(m, "_EXCEPTION_NONCONTINUABLE_EXCEPTION",
+ EXCEPTION_NONCONTINUABLE_EXCEPTION))
+ return NULL;
+#endif
+
+ return m;
}
/* Call faulthandler.enable() if the PYTHONFAULTHANDLER environment variable
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index cb7222d..0c6f444 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -738,7 +738,7 @@
}
static void
-debug_cycle(char *msg, PyObject *op)
+debug_cycle(const char *msg, PyObject *op)
{
PySys_FormatStderr("gc: %s <%s %p>\n",
msg, Py_TYPE(op)->tp_name, op);
diff --git a/Modules/getaddrinfo.c b/Modules/getaddrinfo.c
index d8167ea..b6fb53c 100644
--- a/Modules/getaddrinfo.c
+++ b/Modules/getaddrinfo.c
@@ -136,7 +136,7 @@
struct addrinfo *, int);
static int str_isnumber(const char *);
-static char *ai_errlist[] = {
+static const char * const ai_errlist[] = {
"success.",
"address family for hostname not supported.", /* EAI_ADDRFAMILY */
"temporary failure in name resolution.", /* EAI_AGAIN */
@@ -198,7 +198,7 @@
#define ERR(err) { error = (err); goto bad; }
-char *
+const char *
gai_strerror(int ecode)
{
if (ecode < 0 || ecode > EAI_MAX)
diff --git a/Modules/getpath.c b/Modules/getpath.c
index 18deb60..65b47a3 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -460,8 +460,8 @@
{
extern wchar_t *Py_GetProgramName(void);
- static wchar_t delimiter[2] = {DELIM, '\0'};
- static wchar_t separator[2] = {SEP, '\0'};
+ static const wchar_t delimiter[2] = {DELIM, '\0'};
+ static const wchar_t separator[2] = {SEP, '\0'};
char *_rtpypath = Py_GETENV("PYTHONPATH"); /* XXX use wide version on Windows */
wchar_t *rtpypath = NULL;
wchar_t *home = Py_GetPythonHome();
diff --git a/Modules/grpmodule.c b/Modules/grpmodule.c
index 403e434..5ad87f1 100644
--- a/Modules/grpmodule.c
+++ b/Modules/grpmodule.c
@@ -100,14 +100,25 @@
gid_t gid;
struct group *p;
- py_int_id = PyNumber_Long(id);
- if (!py_int_id)
+ if (!_Py_Gid_Converter(id, &gid)) {
+ if (!PyErr_ExceptionMatches(PyExc_TypeError)) {
return NULL;
- if (!_Py_Gid_Converter(py_int_id, &gid)) {
+ }
+ PyErr_Clear();
+ if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
+ "group id must be int, not %.200",
+ id->ob_type->tp_name) < 0) {
+ return NULL;
+ }
+ py_int_id = PyNumber_Long(id);
+ if (!py_int_id)
+ return NULL;
+ if (!_Py_Gid_Converter(py_int_id, &gid)) {
+ Py_DECREF(py_int_id);
+ return NULL;
+ }
Py_DECREF(py_int_id);
- return NULL;
}
- Py_DECREF(py_int_id);
if ((p = getgrgid(gid)) == NULL) {
PyObject *gid_obj = _PyLong_FromGid(gid);
diff --git a/Modules/hashtable.c b/Modules/hashtable.c
index 133f313..b53cc24 100644
--- a/Modules/hashtable.c
+++ b/Modules/hashtable.c
@@ -1,5 +1,5 @@
-/* The implementation of the hash table (_Py_hashtable_t) is based on the cfuhash
- project:
+/* The implementation of the hash table (_Py_hashtable_t) is based on the
+ cfuhash project:
http://sourceforge.net/projects/libcfu/
Copyright of cfuhash:
@@ -59,7 +59,21 @@
#define ENTRY_NEXT(ENTRY) \
((_Py_hashtable_entry_t *)_Py_SLIST_ITEM_NEXT(ENTRY))
#define HASHTABLE_ITEM_SIZE(HT) \
- (sizeof(_Py_hashtable_entry_t) + (HT)->data_size)
+ (sizeof(_Py_hashtable_entry_t) + (HT)->key_size + (HT)->data_size)
+
+#define ENTRY_READ_PDATA(TABLE, ENTRY, DATA_SIZE, PDATA) \
+ do { \
+ assert((DATA_SIZE) == (TABLE)->data_size); \
+ Py_MEMCPY((PDATA), _Py_HASHTABLE_ENTRY_PDATA(TABLE, (ENTRY)), \
+ (DATA_SIZE)); \
+ } while (0)
+
+#define ENTRY_WRITE_PDATA(TABLE, ENTRY, DATA_SIZE, PDATA) \
+ do { \
+ assert((DATA_SIZE) == (TABLE)->data_size); \
+ Py_MEMCPY((void *)_Py_HASHTABLE_ENTRY_PDATA((TABLE), (ENTRY)), \
+ (PDATA), (DATA_SIZE)); \
+ } while (0)
/* Forward declaration */
static void hashtable_rehash(_Py_hashtable_t *ht);
@@ -70,6 +84,7 @@
list->head = NULL;
}
+
static void
_Py_slist_prepend(_Py_slist_t *list, _Py_slist_item_t *item)
{
@@ -77,6 +92,7 @@
list->head = item;
}
+
static void
_Py_slist_remove(_Py_slist_t *list, _Py_slist_item_t *previous,
_Py_slist_item_t *item)
@@ -87,24 +103,26 @@
list->head = item->next;
}
-Py_uhash_t
-_Py_hashtable_hash_int(const void *key)
-{
- return (Py_uhash_t)key;
-}
Py_uhash_t
-_Py_hashtable_hash_ptr(const void *key)
+_Py_hashtable_hash_ptr(struct _Py_hashtable_t *ht, const void *pkey)
{
- return (Py_uhash_t)_Py_HashPointer((void *)key);
+ void *key;
+
+ _Py_HASHTABLE_READ_KEY(ht, pkey, key);
+ return (Py_uhash_t)_Py_HashPointer(key);
}
+
int
-_Py_hashtable_compare_direct(const void *key, const _Py_hashtable_entry_t *entry)
+_Py_hashtable_compare_direct(_Py_hashtable_t *ht, const void *pkey,
+ const _Py_hashtable_entry_t *entry)
{
- return entry->key == key;
+ const void *pkey2 = _Py_HASHTABLE_ENTRY_PKEY(entry);
+ return (memcmp(pkey, pkey2, ht->key_size) == 0);
}
+
/* makes sure the real size of the buckets array is a power of 2 */
static size_t
round_size(size_t s)
@@ -118,13 +136,12 @@
return i;
}
+
_Py_hashtable_t *
-_Py_hashtable_new_full(size_t data_size, size_t init_size,
+_Py_hashtable_new_full(size_t key_size, size_t data_size,
+ size_t init_size,
_Py_hashtable_hash_func hash_func,
_Py_hashtable_compare_func compare_func,
- _Py_hashtable_copy_data_func copy_data_func,
- _Py_hashtable_free_data_func free_data_func,
- _Py_hashtable_get_data_size_func get_data_size_func,
_Py_hashtable_allocator_t *allocator)
{
_Py_hashtable_t *ht;
@@ -144,6 +161,7 @@
ht->num_buckets = round_size(init_size);
ht->entries = 0;
+ ht->key_size = key_size;
ht->data_size = data_size;
buckets_size = ht->num_buckets * sizeof(ht->buckets[0]);
@@ -156,28 +174,27 @@
ht->hash_func = hash_func;
ht->compare_func = compare_func;
- ht->copy_data_func = copy_data_func;
- ht->free_data_func = free_data_func;
- ht->get_data_size_func = get_data_size_func;
ht->alloc = alloc;
return ht;
}
+
_Py_hashtable_t *
-_Py_hashtable_new(size_t data_size,
+_Py_hashtable_new(size_t key_size, size_t data_size,
_Py_hashtable_hash_func hash_func,
_Py_hashtable_compare_func compare_func)
{
- return _Py_hashtable_new_full(data_size, HASHTABLE_MIN_SIZE,
+ return _Py_hashtable_new_full(key_size, data_size,
+ HASHTABLE_MIN_SIZE,
hash_func, compare_func,
- NULL, NULL, NULL, NULL);
+ NULL);
}
+
size_t
_Py_hashtable_size(_Py_hashtable_t *ht)
{
size_t size;
- size_t hv;
size = sizeof(_Py_hashtable_t);
@@ -187,22 +204,10 @@
/* entries */
size += ht->entries * HASHTABLE_ITEM_SIZE(ht);
- /* data linked from entries */
- if (ht->get_data_size_func) {
- for (hv = 0; hv < ht->num_buckets; hv++) {
- _Py_hashtable_entry_t *entry;
-
- for (entry = TABLE_HEAD(ht, hv); entry; entry = ENTRY_NEXT(entry)) {
- void *data;
-
- data = _Py_HASHTABLE_ENTRY_DATA_AS_VOID_P(entry);
- size += ht->get_data_size_func(data);
- }
- }
- }
return size;
}
+
#ifdef Py_DEBUG
void
_Py_hashtable_print_stats(_Py_hashtable_t *ht)
@@ -243,38 +248,45 @@
}
#endif
-/* Get an entry. Return NULL if the key does not exist. */
+
_Py_hashtable_entry_t *
-_Py_hashtable_get_entry(_Py_hashtable_t *ht, const void *key)
+_Py_hashtable_get_entry(_Py_hashtable_t *ht,
+ size_t key_size, const void *pkey)
{
Py_uhash_t key_hash;
size_t index;
_Py_hashtable_entry_t *entry;
- key_hash = ht->hash_func(key);
+ assert(key_size == ht->key_size);
+
+ key_hash = ht->hash_func(ht, pkey);
index = key_hash & (ht->num_buckets - 1);
for (entry = TABLE_HEAD(ht, index); entry != NULL; entry = ENTRY_NEXT(entry)) {
- if (entry->key_hash == key_hash && ht->compare_func(key, entry))
+ if (entry->key_hash == key_hash && ht->compare_func(ht, pkey, entry))
break;
}
return entry;
}
+
static int
-_hashtable_pop_entry(_Py_hashtable_t *ht, const void *key, void *data, size_t data_size)
+_Py_hashtable_pop_entry(_Py_hashtable_t *ht, size_t key_size, const void *pkey,
+ void *data, size_t data_size)
{
Py_uhash_t key_hash;
size_t index;
_Py_hashtable_entry_t *entry, *previous;
- key_hash = ht->hash_func(key);
+ assert(key_size == ht->key_size);
+
+ key_hash = ht->hash_func(ht, pkey);
index = key_hash & (ht->num_buckets - 1);
previous = NULL;
for (entry = TABLE_HEAD(ht, index); entry != NULL; entry = ENTRY_NEXT(entry)) {
- if (entry->key_hash == key_hash && ht->compare_func(key, entry))
+ if (entry->key_hash == key_hash && ht->compare_func(ht, pkey, entry))
break;
previous = entry;
}
@@ -287,7 +299,7 @@
ht->entries--;
if (data != NULL)
- _Py_HASHTABLE_ENTRY_READ_DATA(ht, data, data_size, entry);
+ ENTRY_READ_PDATA(ht, entry, data_size, data);
ht->alloc.free(entry);
if ((float)ht->entries / (float)ht->num_buckets < HASHTABLE_LOW)
@@ -295,26 +307,27 @@
return 1;
}
-/* Add a new entry to the hash. The key must not be present in the hash table.
- Return 0 on success, -1 on memory error. */
+
int
-_Py_hashtable_set(_Py_hashtable_t *ht, const void *key,
- void *data, size_t data_size)
+_Py_hashtable_set(_Py_hashtable_t *ht, size_t key_size, const void *pkey,
+ size_t data_size, const void *data)
{
Py_uhash_t key_hash;
size_t index;
_Py_hashtable_entry_t *entry;
+ assert(key_size == ht->key_size);
+
assert(data != NULL || data_size == 0);
#ifndef NDEBUG
/* Don't write the assertion on a single line because it is interesting
to know the duplicated entry if the assertion failed. The entry can
be read using a debugger. */
- entry = _Py_hashtable_get_entry(ht, key);
+ entry = _Py_hashtable_get_entry(ht, key_size, pkey);
assert(entry == NULL);
#endif
- key_hash = ht->hash_func(key);
+ key_hash = ht->hash_func(ht, pkey);
index = key_hash & (ht->num_buckets - 1);
entry = ht->alloc.malloc(HASHTABLE_ITEM_SIZE(ht));
@@ -323,11 +336,9 @@
return -1;
}
- entry->key = (void *)key;
entry->key_hash = key_hash;
-
- assert(data_size == ht->data_size);
- memcpy(_Py_HASHTABLE_ENTRY_DATA(entry), data, data_size);
+ Py_MEMCPY((void *)_Py_HASHTABLE_ENTRY_PKEY(entry), pkey, ht->key_size);
+ ENTRY_WRITE_PDATA(ht, entry, data_size, data);
_Py_slist_prepend(&ht->buckets[index], (_Py_slist_item_t*)entry);
ht->entries++;
@@ -337,48 +348,50 @@
return 0;
}
-/* Get data from an entry. Copy entry data into data and return 1 if the entry
- exists, return 0 if the entry does not exist. */
+
int
-_Py_hashtable_get(_Py_hashtable_t *ht, const void *key, void *data, size_t data_size)
+_Py_hashtable_get(_Py_hashtable_t *ht, size_t key_size,const void *pkey,
+ size_t data_size, void *data)
{
_Py_hashtable_entry_t *entry;
assert(data != NULL);
- entry = _Py_hashtable_get_entry(ht, key);
+ entry = _Py_hashtable_get_entry(ht, key_size, pkey);
if (entry == NULL)
return 0;
- _Py_HASHTABLE_ENTRY_READ_DATA(ht, data, data_size, entry);
+ ENTRY_READ_PDATA(ht, entry, data_size, data);
return 1;
}
+
int
-_Py_hashtable_pop(_Py_hashtable_t *ht, const void *key, void *data, size_t data_size)
+_Py_hashtable_pop(_Py_hashtable_t *ht, size_t key_size, const void *pkey,
+ size_t data_size, void *data)
{
assert(data != NULL);
- assert(ht->free_data_func == NULL);
- return _hashtable_pop_entry(ht, key, data, data_size);
+ return _Py_hashtable_pop_entry(ht, key_size, pkey, data, data_size);
}
-/* Delete an entry. The entry must exist. */
+
+/* Code commented since the function is not needed in Python */
+#if 0
void
-_Py_hashtable_delete(_Py_hashtable_t *ht, const void *key)
+_Py_hashtable_delete(_Py_hashtable_t *ht, size_t key_size, const void *pkey)
{
#ifndef NDEBUG
- int found = _hashtable_pop_entry(ht, key, NULL, 0);
+ int found = _Py_hashtable_pop_entry(ht, key_size, pkey, NULL, 0);
assert(found);
#else
- (void)_hashtable_pop_entry(ht, key, NULL, 0);
+ (void)_Py_hashtable_pop_entry(ht, key_size, pkey, NULL, 0);
#endif
}
+#endif
-/* Prototype for a pointer to a function to be called foreach
- key/value pair in the hash by hashtable_foreach(). Iteration
- stops if a non-zero value is returned. */
+
int
_Py_hashtable_foreach(_Py_hashtable_t *ht,
- int (*func) (_Py_hashtable_entry_t *entry, void *arg),
+ _Py_hashtable_foreach_func func,
void *arg)
{
_Py_hashtable_entry_t *entry;
@@ -386,7 +399,7 @@
for (hv = 0; hv < ht->num_buckets; hv++) {
for (entry = TABLE_HEAD(ht, hv); entry; entry = ENTRY_NEXT(entry)) {
- int res = func(entry, arg);
+ int res = func(ht, entry, arg);
if (res)
return res;
}
@@ -394,6 +407,7 @@
return 0;
}
+
static void
hashtable_rehash(_Py_hashtable_t *ht)
{
@@ -425,7 +439,8 @@
for (entry = BUCKETS_HEAD(old_buckets[bucket]); entry != NULL; entry = next) {
size_t entry_index;
- assert(ht->hash_func(entry->key) == entry->key_hash);
+
+ assert(ht->hash_func(ht, _Py_HASHTABLE_ENTRY_PKEY(entry)) == entry->key_hash);
next = ENTRY_NEXT(entry);
entry_index = entry->key_hash & (new_size - 1);
@@ -436,6 +451,7 @@
ht->alloc.free(old_buckets);
}
+
void
_Py_hashtable_clear(_Py_hashtable_t *ht)
{
@@ -445,8 +461,6 @@
for (i=0; i < ht->num_buckets; i++) {
for (entry = TABLE_HEAD(ht, i); entry != NULL; entry = next) {
next = ENTRY_NEXT(entry);
- if (ht->free_data_func)
- ht->free_data_func(_Py_HASHTABLE_ENTRY_DATA_AS_VOID_P(entry));
ht->alloc.free(entry);
}
_Py_slist_init(&ht->buckets[i]);
@@ -455,6 +469,7 @@
hashtable_rehash(ht);
}
+
void
_Py_hashtable_destroy(_Py_hashtable_t *ht)
{
@@ -464,8 +479,6 @@
_Py_slist_item_t *entry = ht->buckets[i].head;
while (entry) {
_Py_slist_item_t *entry_next = entry->next;
- if (ht->free_data_func)
- ht->free_data_func(_Py_HASHTABLE_ENTRY_DATA_AS_VOID_P(entry));
ht->alloc.free(entry);
entry = entry_next;
}
@@ -475,39 +488,31 @@
ht->alloc.free(ht);
}
-/* Return a copy of the hash table */
+
_Py_hashtable_t *
_Py_hashtable_copy(_Py_hashtable_t *src)
{
+ const size_t key_size = src->key_size;
+ const size_t data_size = src->data_size;
_Py_hashtable_t *dst;
_Py_hashtable_entry_t *entry;
size_t bucket;
int err;
- void *data, *new_data;
- dst = _Py_hashtable_new_full(src->data_size, src->num_buckets,
- src->hash_func, src->compare_func,
- src->copy_data_func, src->free_data_func,
- src->get_data_size_func, &src->alloc);
+ dst = _Py_hashtable_new_full(key_size, data_size,
+ src->num_buckets,
+ src->hash_func,
+ src->compare_func,
+ &src->alloc);
if (dst == NULL)
return NULL;
for (bucket=0; bucket < src->num_buckets; bucket++) {
entry = TABLE_HEAD(src, bucket);
for (; entry; entry = ENTRY_NEXT(entry)) {
- if (src->copy_data_func) {
- data = _Py_HASHTABLE_ENTRY_DATA_AS_VOID_P(entry);
- new_data = src->copy_data_func(data);
- if (new_data != NULL)
- err = _Py_hashtable_set(dst, entry->key,
- &new_data, src->data_size);
- else
- err = 1;
- }
- else {
- data = _Py_HASHTABLE_ENTRY_DATA(entry);
- err = _Py_hashtable_set(dst, entry->key, data, src->data_size);
- }
+ const void *pkey = _Py_HASHTABLE_ENTRY_PKEY(entry);
+ const void *pdata = _Py_HASHTABLE_ENTRY_PDATA(src, entry);
+ err = _Py_hashtable_set(dst, key_size, pkey, data_size, pdata);
if (err) {
_Py_hashtable_destroy(dst);
return NULL;
@@ -516,4 +521,3 @@
}
return dst;
}
-
diff --git a/Modules/hashtable.h b/Modules/hashtable.h
index a9f9993..18fed09 100644
--- a/Modules/hashtable.h
+++ b/Modules/hashtable.h
@@ -1,9 +1,10 @@
#ifndef Py_HASHTABLE_H
#define Py_HASHTABLE_H
-
/* The whole API is private */
#ifndef Py_LIMITED_API
+/* Single linked list */
+
typedef struct _Py_slist_item_s {
struct _Py_slist_item_s *next;
} _Py_slist_item_t;
@@ -16,33 +17,66 @@
#define _Py_SLIST_HEAD(SLIST) (((_Py_slist_t *)SLIST)->head)
+
+/* _Py_hashtable: table entry */
+
typedef struct {
/* used by _Py_hashtable_t.buckets to link entries */
_Py_slist_item_t _Py_slist_item;
- const void *key;
Py_uhash_t key_hash;
- /* data follows */
+ /* key (key_size bytes) and then data (data_size bytes) follows */
} _Py_hashtable_entry_t;
-#define _Py_HASHTABLE_ENTRY_DATA(ENTRY) \
- ((char *)(ENTRY) + sizeof(_Py_hashtable_entry_t))
+#define _Py_HASHTABLE_ENTRY_PKEY(ENTRY) \
+ ((const void *)((char *)(ENTRY) \
+ + sizeof(_Py_hashtable_entry_t)))
-#define _Py_HASHTABLE_ENTRY_DATA_AS_VOID_P(ENTRY) \
- (*(void **)_Py_HASHTABLE_ENTRY_DATA(ENTRY))
+#define _Py_HASHTABLE_ENTRY_PDATA(TABLE, ENTRY) \
+ ((const void *)((char *)(ENTRY) \
+ + sizeof(_Py_hashtable_entry_t) \
+ + (TABLE)->key_size))
-#define _Py_HASHTABLE_ENTRY_READ_DATA(TABLE, DATA, DATA_SIZE, ENTRY) \
+/* Get a key value from pkey: use memcpy() rather than a pointer dereference
+ to avoid memory alignment issues. */
+#define _Py_HASHTABLE_READ_KEY(TABLE, PKEY, DST_KEY) \
do { \
- assert((DATA_SIZE) == (TABLE)->data_size); \
- memcpy(DATA, _Py_HASHTABLE_ENTRY_DATA(ENTRY), DATA_SIZE); \
+ assert(sizeof(DST_KEY) == (TABLE)->key_size); \
+ Py_MEMCPY(&(DST_KEY), (PKEY), sizeof(DST_KEY)); \
} while (0)
-typedef Py_uhash_t (*_Py_hashtable_hash_func) (const void *key);
-typedef int (*_Py_hashtable_compare_func) (const void *key, const _Py_hashtable_entry_t *he);
-typedef void* (*_Py_hashtable_copy_data_func)(void *data);
-typedef void (*_Py_hashtable_free_data_func)(void *data);
-typedef size_t (*_Py_hashtable_get_data_size_func)(void *data);
+#define _Py_HASHTABLE_ENTRY_READ_KEY(TABLE, ENTRY, KEY) \
+ do { \
+ assert(sizeof(KEY) == (TABLE)->key_size); \
+ Py_MEMCPY(&(KEY), _Py_HASHTABLE_ENTRY_PKEY(ENTRY), sizeof(KEY)); \
+ } while (0)
+
+#define _Py_HASHTABLE_ENTRY_READ_DATA(TABLE, ENTRY, DATA) \
+ do { \
+ assert(sizeof(DATA) == (TABLE)->data_size); \
+ Py_MEMCPY(&(DATA), _Py_HASHTABLE_ENTRY_PDATA(TABLE, (ENTRY)), \
+ sizeof(DATA)); \
+ } while (0)
+
+#define _Py_HASHTABLE_ENTRY_WRITE_DATA(TABLE, ENTRY, DATA) \
+ do { \
+ assert(sizeof(DATA) == (TABLE)->data_size); \
+ Py_MEMCPY((void *)_Py_HASHTABLE_ENTRY_PDATA((TABLE), (ENTRY)), \
+ &(DATA), sizeof(DATA)); \
+ } while (0)
+
+
+/* _Py_hashtable: prototypes */
+
+/* Forward declaration */
+struct _Py_hashtable_t;
+
+typedef Py_uhash_t (*_Py_hashtable_hash_func) (struct _Py_hashtable_t *ht,
+ const void *pkey);
+typedef int (*_Py_hashtable_compare_func) (struct _Py_hashtable_t *ht,
+ const void *pkey,
+ const _Py_hashtable_entry_t *he);
typedef struct {
/* allocate a memory block */
@@ -52,77 +86,126 @@
void (*free) (void *ptr);
} _Py_hashtable_allocator_t;
-typedef struct {
+
+/* _Py_hashtable: table */
+
+typedef struct _Py_hashtable_t {
size_t num_buckets;
size_t entries; /* Total number of entries in the table. */
_Py_slist_t *buckets;
+ size_t key_size;
size_t data_size;
_Py_hashtable_hash_func hash_func;
_Py_hashtable_compare_func compare_func;
- _Py_hashtable_copy_data_func copy_data_func;
- _Py_hashtable_free_data_func free_data_func;
- _Py_hashtable_get_data_size_func get_data_size_func;
_Py_hashtable_allocator_t alloc;
} _Py_hashtable_t;
-/* hash and compare functions for integers and pointers */
-PyAPI_FUNC(Py_uhash_t) _Py_hashtable_hash_ptr(const void *key);
-PyAPI_FUNC(Py_uhash_t) _Py_hashtable_hash_int(const void *key);
-PyAPI_FUNC(int) _Py_hashtable_compare_direct(const void *key, const _Py_hashtable_entry_t *entry);
+/* hash a pointer (void*) */
+PyAPI_FUNC(Py_uhash_t) _Py_hashtable_hash_ptr(
+ struct _Py_hashtable_t *ht,
+ const void *pkey);
+
+/* comparison using memcmp() */
+PyAPI_FUNC(int) _Py_hashtable_compare_direct(
+ _Py_hashtable_t *ht,
+ const void *pkey,
+ const _Py_hashtable_entry_t *entry);
PyAPI_FUNC(_Py_hashtable_t *) _Py_hashtable_new(
+ size_t key_size,
size_t data_size,
_Py_hashtable_hash_func hash_func,
_Py_hashtable_compare_func compare_func);
+
PyAPI_FUNC(_Py_hashtable_t *) _Py_hashtable_new_full(
+ size_t key_size,
size_t data_size,
size_t init_size,
_Py_hashtable_hash_func hash_func,
_Py_hashtable_compare_func compare_func,
- _Py_hashtable_copy_data_func copy_data_func,
- _Py_hashtable_free_data_func free_data_func,
- _Py_hashtable_get_data_size_func get_data_size_func,
_Py_hashtable_allocator_t *allocator);
-PyAPI_FUNC(_Py_hashtable_t *) _Py_hashtable_copy(_Py_hashtable_t *src);
-PyAPI_FUNC(void) _Py_hashtable_clear(_Py_hashtable_t *ht);
+
PyAPI_FUNC(void) _Py_hashtable_destroy(_Py_hashtable_t *ht);
-typedef int (*_Py_hashtable_foreach_func) (_Py_hashtable_entry_t *entry, void *arg);
+/* Return a copy of the hash table */
+PyAPI_FUNC(_Py_hashtable_t *) _Py_hashtable_copy(_Py_hashtable_t *src);
+PyAPI_FUNC(void) _Py_hashtable_clear(_Py_hashtable_t *ht);
+
+typedef int (*_Py_hashtable_foreach_func) (_Py_hashtable_t *ht,
+ _Py_hashtable_entry_t *entry,
+ void *arg);
+
+/* Call func() on each entry of the hashtable.
+ Iteration stops if func() result is non-zero, in this case it's the result
+ of the call. Otherwise, the function returns 0. */
PyAPI_FUNC(int) _Py_hashtable_foreach(
_Py_hashtable_t *ht,
- _Py_hashtable_foreach_func func, void *arg);
+ _Py_hashtable_foreach_func func,
+ void *arg);
+
PyAPI_FUNC(size_t) _Py_hashtable_size(_Py_hashtable_t *ht);
-PyAPI_FUNC(_Py_hashtable_entry_t*) _Py_hashtable_get_entry(
- _Py_hashtable_t *ht,
- const void *key);
+/* Add a new entry to the hash. The key must not be present in the hash table.
+ Return 0 on success, -1 on memory error.
+
+ Don't call directly this function,
+ but use _Py_HASHTABLE_SET() and _Py_HASHTABLE_SET_NODATA() macros */
PyAPI_FUNC(int) _Py_hashtable_set(
_Py_hashtable_t *ht,
- const void *key,
- void *data,
- size_t data_size);
-PyAPI_FUNC(int) _Py_hashtable_get(
- _Py_hashtable_t *ht,
- const void *key,
- void *data,
- size_t data_size);
-PyAPI_FUNC(int) _Py_hashtable_pop(
- _Py_hashtable_t *ht,
- const void *key,
- void *data,
- size_t data_size);
-PyAPI_FUNC(void) _Py_hashtable_delete(
- _Py_hashtable_t *ht,
- const void *key);
+ size_t key_size,
+ const void *pkey,
+ size_t data_size,
+ const void *data);
#define _Py_HASHTABLE_SET(TABLE, KEY, DATA) \
- _Py_hashtable_set(TABLE, KEY, &(DATA), sizeof(DATA))
+ _Py_hashtable_set(TABLE, sizeof(KEY), &(KEY), sizeof(DATA), &(DATA))
+
+#define _Py_HASHTABLE_SET_NODATA(TABLE, KEY) \
+ _Py_hashtable_set(TABLE, sizeof(KEY), &(KEY), 0, NULL)
+
+
+/* Get an entry.
+ Return NULL if the key does not exist.
+
+ Don't call directly this function, but use _Py_HASHTABLE_GET_ENTRY()
+ macro */
+PyAPI_FUNC(_Py_hashtable_entry_t*) _Py_hashtable_get_entry(
+ _Py_hashtable_t *ht,
+ size_t key_size,
+ const void *pkey);
+
+#define _Py_HASHTABLE_GET_ENTRY(TABLE, KEY) \
+ _Py_hashtable_get_entry(TABLE, sizeof(KEY), &(KEY))
+
+
+/* Get data from an entry. Copy entry data into data and return 1 if the entry
+ exists, return 0 if the entry does not exist.
+
+ Don't call directly this function, but use _Py_HASHTABLE_GET() macro */
+PyAPI_FUNC(int) _Py_hashtable_get(
+ _Py_hashtable_t *ht,
+ size_t key_size,
+ const void *pkey,
+ size_t data_size,
+ void *data);
#define _Py_HASHTABLE_GET(TABLE, KEY, DATA) \
- _Py_hashtable_get(TABLE, KEY, &(DATA), sizeof(DATA))
+ _Py_hashtable_get(TABLE, sizeof(KEY), &(KEY), sizeof(DATA), &(DATA))
+
+
+/* Don't call directly this function, but use _Py_HASHTABLE_POP() macro */
+PyAPI_FUNC(int) _Py_hashtable_pop(
+ _Py_hashtable_t *ht,
+ size_t key_size,
+ const void *pkey,
+ size_t data_size,
+ void *data);
+
+#define _Py_HASHTABLE_POP(TABLE, KEY, DATA) \
+ _Py_hashtable_pop(TABLE, sizeof(KEY), &(KEY), sizeof(DATA), &(DATA))
+
#endif /* Py_LIMITED_API */
-
#endif
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index 409922a..c82ad7a 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -1,4 +1,5 @@
+#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
@@ -7,7 +8,7 @@
*/
-/* groupby object ***********************************************************/
+/* groupby object ************************************************************/
typedef struct {
PyObject_HEAD
@@ -74,7 +75,7 @@
static PyObject *
groupby_next(groupbyobject *gbo)
{
- PyObject *newvalue, *newkey, *r, *grouper, *tmp;
+ PyObject *newvalue, *newkey, *r, *grouper;
/* skip to next iteration group */
for (;;) {
@@ -85,8 +86,7 @@
else {
int rcmp;
- rcmp = PyObject_RichCompareBool(gbo->tgtkey,
- gbo->currkey, Py_EQ);
+ rcmp = PyObject_RichCompareBool(gbo->tgtkey, gbo->currkey, Py_EQ);
if (rcmp == -1)
return NULL;
else if (rcmp == 0)
@@ -101,27 +101,19 @@
newkey = newvalue;
Py_INCREF(newvalue);
} else {
- newkey = PyObject_CallFunctionObjArgs(gbo->keyfunc,
- newvalue, NULL);
+ newkey = PyObject_CallFunctionObjArgs(gbo->keyfunc, newvalue, NULL);
if (newkey == NULL) {
Py_DECREF(newvalue);
return NULL;
}
}
- tmp = gbo->currkey;
- gbo->currkey = newkey;
- Py_XDECREF(tmp);
-
- tmp = gbo->currvalue;
- gbo->currvalue = newvalue;
- Py_XDECREF(tmp);
+ Py_XSETREF(gbo->currkey, newkey);
+ Py_XSETREF(gbo->currvalue, newvalue);
}
Py_INCREF(gbo->currkey);
- tmp = gbo->tgtkey;
- gbo->tgtkey = gbo->currkey;
- Py_XDECREF(tmp);
+ Py_XSETREF(gbo->tgtkey, gbo->currkey);
grouper = _grouper_create(gbo, gbo->tgtkey);
if (grouper == NULL)
@@ -173,7 +165,7 @@
reduce_doc},
{"__setstate__", (PyCFunction)groupby_setstate, METH_O,
setstate_doc},
- {NULL, NULL} /* sentinel */
+ {NULL, NULL} /* sentinel */
};
PyDoc_STRVAR(groupby_doc,
@@ -296,8 +288,7 @@
newkey = newvalue;
Py_INCREF(newvalue);
} else {
- newkey = PyObject_CallFunctionObjArgs(gbo->keyfunc,
- newvalue, NULL);
+ newkey = PyObject_CallFunctionObjArgs(gbo->keyfunc, newvalue, NULL);
if (newkey == NULL) {
Py_DECREF(newvalue);
return NULL;
@@ -325,8 +316,7 @@
static PyObject *
_grouper_reduce(_grouperobject *lz)
{
- return Py_BuildValue("O(OO)", Py_TYPE(lz),
- lz->parent, lz->tgtkey);
+ return Py_BuildValue("O(OO)", Py_TYPE(lz), lz->parent, lz->tgtkey);
}
static PyMethodDef _grouper_methods[] = {
@@ -359,7 +349,7 @@
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
0, /* tp_doc */
- (traverseproc)_grouper_traverse,/* tp_traverse */
+ (traverseproc)_grouper_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
@@ -380,8 +370,7 @@
};
-
-/* tee object and with supporting function and objects ***************/
+/* tee object and with supporting function and objects ***********************/
/* The teedataobject pre-allocates space for LINKCELLS number of objects.
To help the object fit neatly inside cache lines (space for 16 to 32
@@ -396,7 +385,7 @@
typedef struct {
PyObject_HEAD
PyObject *it;
- int numread; /* 0 <= numread <= LINKCELLS */
+ int numread; /* 0 <= numread <= LINKCELLS */
PyObject *nextlink;
PyObject *(values[LINKCELLS]);
} teedataobject;
@@ -404,7 +393,7 @@
typedef struct {
PyObject_HEAD
teedataobject *dataobj;
- int index; /* 0 <= index <= LINKCELLS */
+ int index; /* 0 <= index <= LINKCELLS */
PyObject *weakreflist;
} teeobject;
@@ -461,6 +450,7 @@
teedataobject_traverse(teedataobject *tdo, visitproc visit, void * arg)
{
int i;
+
Py_VISIT(tdo->it);
for (i = 0; i < tdo->numread; i++)
Py_VISIT(tdo->values[i]);
@@ -510,6 +500,7 @@
int i;
/* create a temporary list of already iterated values */
PyObject *values = PyList_New(tdo->numread);
+
if (!values)
return NULL;
for (i=0 ; i<tdo->numread ; i++) {
@@ -577,7 +568,7 @@
PyDoc_STRVAR(teedataobject_doc, "Data container common to multiple tee objects.");
static PyTypeObject teedataobject_type = {
- PyVarObject_HEAD_INIT(0, 0) /* Must fill in type value later */
+ PyVarObject_HEAD_INIT(0, 0) /* Must fill in type value later */
"itertools._tee_dataobject", /* tp_name */
sizeof(teedataobject), /* tp_basicsize */
0, /* tp_itemsize */
@@ -597,7 +588,7 @@
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
teedataobject_doc, /* tp_doc */
(traverseproc)teedataobject_traverse, /* tp_traverse */
(inquiry)teedataobject_clear, /* tp_clear */
@@ -752,9 +743,9 @@
"Iterator wrapped to make it copyable");
static PyMethodDef tee_methods[] = {
- {"__copy__", (PyCFunction)tee_copy, METH_NOARGS, teecopy_doc},
- {"__reduce__", (PyCFunction)tee_reduce, METH_NOARGS, reduce_doc},
- {"__setstate__", (PyCFunction)tee_setstate, METH_O, setstate_doc},
+ {"__copy__", (PyCFunction)tee_copy, METH_NOARGS, teecopy_doc},
+ {"__reduce__", (PyCFunction)tee_reduce, METH_NOARGS, reduce_doc},
+ {"__setstate__", (PyCFunction)tee_setstate, METH_O, setstate_doc},
{NULL, NULL} /* sentinel */
};
@@ -784,7 +775,7 @@
(traverseproc)tee_traverse, /* tp_traverse */
(inquiry)tee_clear, /* tp_clear */
0, /* tp_richcompare */
- offsetof(teeobject, weakreflist), /* tp_weaklistoffset */
+ offsetof(teeobject, weakreflist), /* tp_weaklistoffset */
PyObject_SelfIter, /* tp_iter */
(iternextfunc)tee_next, /* tp_iternext */
tee_methods, /* tp_methods */
@@ -850,12 +841,13 @@
"tee(iterable, n=2) --> tuple of n independent iterators.");
-/* cycle object **********************************************************/
+/* cycle object **************************************************************/
typedef struct {
PyObject_HEAD
PyObject *it;
PyObject *saved;
+ Py_ssize_t index;
int firstpass;
} cycleobject;
@@ -895,6 +887,7 @@
}
lz->it = it;
lz->saved = saved;
+ lz->index = 0;
lz->firstpass = 0;
return (PyObject *)lz;
@@ -904,15 +897,16 @@
cycle_dealloc(cycleobject *lz)
{
PyObject_GC_UnTrack(lz);
- Py_XDECREF(lz->saved);
Py_XDECREF(lz->it);
+ Py_XDECREF(lz->saved);
Py_TYPE(lz)->tp_free(lz);
}
static int
cycle_traverse(cycleobject *lz, visitproc visit, void *arg)
{
- Py_VISIT(lz->it);
+ if (lz->it)
+ Py_VISIT(lz->it);
Py_VISIT(lz->saved);
return 0;
}
@@ -921,56 +915,69 @@
cycle_next(cycleobject *lz)
{
PyObject *item;
- PyObject *it;
- PyObject *tmp;
- while (1) {
+ if (lz->it != NULL) {
item = PyIter_Next(lz->it);
if (item != NULL) {
- if (!lz->firstpass && PyList_Append(lz->saved, item)) {
+ if (lz->firstpass)
+ return item;
+ if (PyList_Append(lz->saved, item)) {
Py_DECREF(item);
return NULL;
}
return item;
}
- if (PyErr_Occurred()) {
- if (PyErr_ExceptionMatches(PyExc_StopIteration))
- PyErr_Clear();
- else
- return NULL;
- }
- if (PyList_Size(lz->saved) == 0)
+ /* Note: StopIteration is already cleared by PyIter_Next() */
+ if (PyErr_Occurred())
return NULL;
- it = PyObject_GetIter(lz->saved);
- if (it == NULL)
- return NULL;
- tmp = lz->it;
- lz->it = it;
- lz->firstpass = 1;
- Py_DECREF(tmp);
+ Py_CLEAR(lz->it);
}
+ if (Py_SIZE(lz->saved) == 0)
+ return NULL;
+ item = PyList_GET_ITEM(lz->saved, lz->index);
+ lz->index++;
+ if (lz->index >= Py_SIZE(lz->saved))
+ lz->index = 0;
+ Py_INCREF(item);
+ return item;
}
static PyObject *
cycle_reduce(cycleobject *lz)
{
- /* Create a new cycle with the iterator tuple, then set
- * the saved state on it.
- */
- return Py_BuildValue("O(O)(Oi)", Py_TYPE(lz),
- lz->it, lz->saved, lz->firstpass);
+ /* Create a new cycle with the iterator tuple, then set the saved state */
+ if (lz->it == NULL) {
+ PyObject *it = PyObject_GetIter(lz->saved);
+ if (it == NULL)
+ return NULL;
+ if (lz->index != 0) {
+ _Py_IDENTIFIER(__setstate__);
+ PyObject *res = _PyObject_CallMethodId(it, &PyId___setstate__,
+ "n", lz->index);
+ if (res == NULL) {
+ Py_DECREF(it);
+ return NULL;
+ }
+ Py_DECREF(res);
+ }
+ return Py_BuildValue("O(N)(Oi)", Py_TYPE(lz), it, lz->saved, 1);
}
+ return Py_BuildValue("O(O)(Oi)", Py_TYPE(lz), lz->it, lz->saved,
+ lz->firstpass);
+}
static PyObject *
cycle_setstate(cycleobject *lz, PyObject *state)
{
PyObject *saved=NULL;
int firstpass;
- if (!PyArg_ParseTuple(state, "Oi", &saved, &firstpass))
+
+ if (!PyArg_ParseTuple(state, "O!i", &PyList_Type, &saved, &firstpass))
return NULL;
- Py_XINCREF(saved);
+ Py_INCREF(saved);
Py_XSETREF(lz->saved, saved);
lz->firstpass = firstpass != 0;
+ lz->index = 0;
Py_RETURN_NONE;
}
@@ -1039,7 +1046,7 @@
PyObject_HEAD
PyObject *func;
PyObject *it;
- long start;
+ long start;
} dropwhileobject;
static PyTypeObject dropwhile_type;
@@ -1129,8 +1136,7 @@
static PyObject *
dropwhile_reduce(dropwhileobject *lz)
{
- return Py_BuildValue("O(OO)l", Py_TYPE(lz),
- lz->func, lz->it, lz->start);
+ return Py_BuildValue("O(OO)l", Py_TYPE(lz), lz->func, lz->it, lz->start);
}
static PyObject *
@@ -1181,13 +1187,13 @@
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_BASETYPE, /* tp_flags */
dropwhile_doc, /* tp_doc */
- (traverseproc)dropwhile_traverse, /* tp_traverse */
+ (traverseproc)dropwhile_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
PyObject_SelfIter, /* tp_iter */
(iternextfunc)dropwhile_next, /* tp_iternext */
- dropwhile_methods, /* tp_methods */
+ dropwhile_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
@@ -1208,7 +1214,7 @@
PyObject_HEAD
PyObject *func;
PyObject *it;
- long stop;
+ long stop;
} takewhileobject;
static PyTypeObject takewhile_type;
@@ -1283,7 +1289,7 @@
}
ok = PyObject_IsTrue(good);
Py_DECREF(good);
- if (ok == 1)
+ if (ok > 0)
return item;
Py_DECREF(item);
if (ok == 0)
@@ -1294,14 +1300,14 @@
static PyObject *
takewhile_reduce(takewhileobject *lz)
{
- return Py_BuildValue("O(OO)l", Py_TYPE(lz),
- lz->func, lz->it, lz->stop);
+ return Py_BuildValue("O(OO)l", Py_TYPE(lz), lz->func, lz->it, lz->stop);
}
static PyObject *
takewhile_reduce_setstate(takewhileobject *lz, PyObject *state)
{
int stop = PyObject_IsTrue(state);
+
if (stop < 0)
return NULL;
lz->stop = stop;
@@ -1345,7 +1351,7 @@
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_BASETYPE, /* tp_flags */
takewhile_doc, /* tp_doc */
- (traverseproc)takewhile_traverse, /* tp_traverse */
+ (traverseproc)takewhile_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
@@ -1366,7 +1372,7 @@
};
-/* islice object ************************************************************/
+/* islice object *************************************************************/
typedef struct {
PyObject_HEAD
@@ -1402,7 +1408,8 @@
if (PyErr_Occurred())
PyErr_Clear();
PyErr_SetString(PyExc_ValueError,
- "Stop argument for islice() must be None or an integer: 0 <= x <= sys.maxsize.");
+ "Stop argument for islice() must be None or "
+ "an integer: 0 <= x <= sys.maxsize.");
return NULL;
}
}
@@ -1417,14 +1424,16 @@
if (PyErr_Occurred())
PyErr_Clear();
PyErr_SetString(PyExc_ValueError,
- "Stop argument for islice() must be None or an integer: 0 <= x <= sys.maxsize.");
+ "Stop argument for islice() must be None or "
+ "an integer: 0 <= x <= sys.maxsize.");
return NULL;
}
}
}
if (start<0 || stop<-1) {
PyErr_SetString(PyExc_ValueError,
- "Indices for islice() must be None or an integer: 0 <= x <= sys.maxsize.");
+ "Indices for islice() must be None or "
+ "an integer: 0 <= x <= sys.maxsize.");
return NULL;
}
@@ -1521,6 +1530,7 @@
* then 'setstate' with the next and count
*/
PyObject *stop;
+
if (lz->it == NULL) {
PyObject *empty_list;
PyObject *empty_it;
@@ -1550,6 +1560,7 @@
islice_setstate(isliceobject *lz, PyObject *state)
{
Py_ssize_t cnt = PyLong_AsSsize_t(state);
+
if (cnt == -1 && PyErr_Occurred())
return NULL;
lz->cnt = cnt;
@@ -1764,7 +1775,7 @@
};
-/* chain object ************************************************************/
+/* chain object **************************************************************/
typedef struct {
PyObject_HEAD
@@ -1840,32 +1851,32 @@
PyObject *item;
if (lz->source == NULL)
- return NULL; /* already stopped */
+ return NULL; /* already stopped */
if (lz->active == NULL) {
PyObject *iterable = PyIter_Next(lz->source);
if (iterable == NULL) {
Py_CLEAR(lz->source);
- return NULL; /* no more input sources */
+ return NULL; /* no more input sources */
}
lz->active = PyObject_GetIter(iterable);
Py_DECREF(iterable);
if (lz->active == NULL) {
Py_CLEAR(lz->source);
- return NULL; /* input not iterable */
+ return NULL; /* input not iterable */
}
}
- item = PyIter_Next(lz->active);
+ item = (*Py_TYPE(lz->active)->tp_iternext)(lz->active);
if (item != NULL)
return item;
if (PyErr_Occurred()) {
if (PyErr_ExceptionMatches(PyExc_StopIteration))
PyErr_Clear();
else
- return NULL; /* input raised an exception */
+ return NULL; /* input raised an exception */
}
Py_CLEAR(lz->active);
- return chain_next(lz); /* recurse and use next active */
+ return chain_next(lz); /* recurse and use next active */
}
static PyObject *
@@ -1891,6 +1902,7 @@
chain_setstate(chainobject *lz, PyObject *state)
{
PyObject *source, *active=NULL;
+
if (! PyArg_ParseTuple(state, "O|O", &source, &active))
return NULL;
@@ -1915,13 +1927,13 @@
that evaluates lazily.");
static PyMethodDef chain_methods[] = {
- {"from_iterable", (PyCFunction) chain_new_from_iterable, METH_O | METH_CLASS,
- chain_from_iterable_doc},
+ {"from_iterable", (PyCFunction) chain_new_from_iterable, METH_O | METH_CLASS,
+ chain_from_iterable_doc},
{"__reduce__", (PyCFunction)chain_reduce, METH_NOARGS,
reduce_doc},
{"__setstate__", (PyCFunction)chain_setstate, METH_O,
setstate_doc},
- {NULL, NULL} /* sentinel */
+ {NULL, NULL} /* sentinel */
};
static PyTypeObject chain_type = {
@@ -1973,10 +1985,10 @@
typedef struct {
PyObject_HEAD
- PyObject *pools; /* tuple of pool tuples */
- Py_ssize_t *indices; /* one index per pool */
- PyObject *result; /* most recently returned result tuple */
- int stopped; /* set to 1 when the product iterator is exhausted */
+ PyObject *pools; /* tuple of pool tuples */
+ Py_ssize_t *indices; /* one index per pool */
+ PyObject *result; /* most recently returned result tuple */
+ int stopped; /* set to 1 when the iterator is exhausted */
} productobject;
static PyTypeObject product_type;
@@ -1995,7 +2007,8 @@
PyObject *tmpargs = PyTuple_New(0);
if (tmpargs == NULL)
return NULL;
- if (!PyArg_ParseTupleAndKeywords(tmpargs, kwds, "|n:product", kwlist, &repeat)) {
+ if (!PyArg_ParseTupleAndKeywords(tmpargs, kwds, "|n:product",
+ kwlist, &repeat)) {
Py_DECREF(tmpargs);
return NULL;
}
@@ -2284,7 +2297,7 @@
static PyTypeObject product_type = {
PyVarObject_HEAD_INIT(NULL, 0)
"itertools.product", /* tp_name */
- sizeof(productobject), /* tp_basicsize */
+ sizeof(productobject), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)product_dealloc, /* tp_dealloc */
@@ -2326,15 +2339,15 @@
};
-/* combinations object ************************************************************/
+/* combinations object *******************************************************/
typedef struct {
PyObject_HEAD
- PyObject *pool; /* input converted to a tuple */
- Py_ssize_t *indices; /* one index per result element */
- PyObject *result; /* most recently returned result tuple */
- Py_ssize_t r; /* size of result tuple */
- int stopped; /* set to 1 when the combinations iterator is exhausted */
+ PyObject *pool; /* input converted to a tuple */
+ Py_ssize_t *indices; /* one index per result element */
+ PyObject *result; /* most recently returned result tuple */
+ Py_ssize_t r; /* size of result tuple */
+ int stopped; /* set to 1 when the iterator is exhausted */
} combinationsobject;
static PyTypeObject combinations_type;
@@ -2544,17 +2557,16 @@
Py_ssize_t i;
Py_ssize_t n = PyTuple_GET_SIZE(lz->pool);
- if (!PyTuple_Check(state) || PyTuple_GET_SIZE(state) != lz->r)
- {
+ if (!PyTuple_Check(state) || PyTuple_GET_SIZE(state) != lz->r) {
PyErr_SetString(PyExc_ValueError, "invalid arguments");
return NULL;
}
- for (i=0; i<lz->r; i++)
- {
+ for (i=0; i<lz->r; i++) {
Py_ssize_t max;
PyObject* indexObject = PyTuple_GET_ITEM(state, i);
Py_ssize_t index = PyLong_AsSsize_t(indexObject);
+
if (index == -1 && PyErr_Occurred())
return NULL; /* not an integer */
max = i + n - lz->r;
@@ -2640,7 +2652,7 @@
};
-/* combinations with replacement object *******************************************/
+/* combinations with replacement object **************************************/
/* Equivalent to:
@@ -2670,11 +2682,11 @@
*/
typedef struct {
PyObject_HEAD
- PyObject *pool; /* input converted to a tuple */
+ PyObject *pool; /* input converted to a tuple */
Py_ssize_t *indices; /* one index per result element */
PyObject *result; /* most recently returned result tuple */
- Py_ssize_t r; /* size of result tuple */
- int stopped; /* set to 1 when the cwr iterator is exhausted */
+ Py_ssize_t r; /* size of result tuple */
+ int stopped; /* set to 1 when the cwr iterator is exhausted */
} cwrobject;
static PyTypeObject cwr_type;
@@ -2691,8 +2703,9 @@
Py_ssize_t i;
static char *kwargs[] = {"iterable", "r", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "On:combinations_with_replacement", kwargs,
- &iterable, &r))
+ if (!PyArg_ParseTupleAndKeywords(args, kwds,
+ "On:combinations_with_replacement",
+ kwargs, &iterable, &r))
return NULL;
pool = PySequence_Tuple(iterable);
@@ -2857,8 +2870,7 @@
indices = PyTuple_New(lz->r);
if (!indices)
return NULL;
- for (i=0; i<lz->r; i++)
- {
+ for (i=0; i<lz->r; i++) {
PyObject* index = PyLong_FromSsize_t(lz->indices[i]);
if (!index) {
Py_DECREF(indices);
@@ -2884,10 +2896,10 @@
}
n = PyTuple_GET_SIZE(lz->pool);
- for (i=0; i<lz->r; i++)
- {
+ for (i=0; i<lz->r; i++) {
PyObject* indexObject = PyTuple_GET_ITEM(state, i);
Py_ssize_t index = PyLong_AsSsize_t(indexObject);
+
if (index < 0 && PyErr_Occurred())
return NULL; /* not an integer */
/* clamp the index */
@@ -2971,7 +2983,7 @@
};
-/* permutations object ************************************************************
+/* permutations object ********************************************************
def permutations(iterable, r=None):
'permutations(range(3), 2) --> (0,1) (0,2) (1,0) (1,2) (2,0) (2,1)'
@@ -2998,12 +3010,12 @@
typedef struct {
PyObject_HEAD
- PyObject *pool; /* input converted to a tuple */
- Py_ssize_t *indices; /* one index per element in the pool */
- Py_ssize_t *cycles; /* one rollover counter per element in the result */
- PyObject *result; /* most recently returned result tuple */
- Py_ssize_t r; /* size of result tuple */
- int stopped; /* set to 1 when the permutations iterator is exhausted */
+ PyObject *pool; /* input converted to a tuple */
+ Py_ssize_t *indices; /* one index per element in the pool */
+ Py_ssize_t *cycles; /* one rollover counter per element in the result */
+ PyObject *result; /* most recently returned result tuple */
+ Py_ssize_t r; /* size of result tuple */
+ int stopped; /* set to 1 when the iterator is exhausted */
} permutationsobject;
static PyTypeObject permutations_type;
@@ -3218,7 +3230,7 @@
indices = PyTuple_New(n);
if (indices == NULL)
goto err;
- for (i=0; i<n; i++){
+ for (i=0; i<n; i++) {
PyObject* index = PyLong_FromSsize_t(po->indices[i]);
if (!index)
goto err;
@@ -3228,8 +3240,7 @@
cycles = PyTuple_New(po->r);
if (cycles == NULL)
goto err;
- for (i=0; i<po->r; i++)
- {
+ for (i=0 ; i<po->r ; i++) {
PyObject* index = PyLong_FromSsize_t(po->cycles[i]);
if (!index)
goto err;
@@ -3257,15 +3268,12 @@
return NULL;
n = PyTuple_GET_SIZE(po->pool);
- if (PyTuple_GET_SIZE(indices) != n ||
- PyTuple_GET_SIZE(cycles) != po->r)
- {
+ if (PyTuple_GET_SIZE(indices) != n || PyTuple_GET_SIZE(cycles) != po->r) {
PyErr_SetString(PyExc_ValueError, "invalid arguments");
return NULL;
}
- for (i=0; i<n; i++)
- {
+ for (i=0; i<n; i++) {
PyObject* indexObject = PyTuple_GET_ITEM(indices, i);
Py_ssize_t index = PyLong_AsSsize_t(indexObject);
if (index < 0 && PyErr_Occurred())
@@ -3278,8 +3286,7 @@
po->indices[i] = index;
}
- for (i=0; i<po->r; i++)
- {
+ for (i=0; i<po->r; i++) {
PyObject* indexObject = PyTuple_GET_ITEM(cycles, i);
Py_ssize_t index = PyLong_AsSsize_t(indexObject);
if (index < 0 && PyErr_Occurred())
@@ -3320,11 +3327,11 @@
static PyTypeObject permutations_type = {
PyVarObject_HEAD_INIT(NULL, 0)
- "itertools.permutations", /* tp_name */
+ "itertools.permutations", /* tp_name */
sizeof(permutationsobject), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
- (destructor)permutations_dealloc, /* tp_dealloc */
+ (destructor)permutations_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
@@ -3341,13 +3348,13 @@
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_BASETYPE, /* tp_flags */
- permutations_doc, /* tp_doc */
- (traverseproc)permutations_traverse, /* tp_traverse */
+ permutations_doc, /* tp_doc */
+ (traverseproc)permutations_traverse,/* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
PyObject_SelfIter, /* tp_iter */
- (iternextfunc)permutations_next, /* tp_iternext */
+ (iternextfunc)permutations_next, /* tp_iternext */
permuations_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
@@ -3358,11 +3365,11 @@
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
- permutations_new, /* tp_new */
+ permutations_new, /* tp_new */
PyObject_GC_Del, /* tp_free */
};
-/* accumulate object ************************************************************/
+/* accumulate object ********************************************************/
typedef struct {
PyObject_HEAD
@@ -3429,9 +3436,9 @@
static PyObject *
accumulate_next(accumulateobject *lz)
{
- PyObject *val, *oldtotal, *newtotal;
+ PyObject *val, *newtotal;
- val = PyIter_Next(lz->it);
+ val = (*Py_TYPE(lz->it)->tp_iternext)(lz->it);
if (val == NULL)
return NULL;
@@ -3449,11 +3456,8 @@
if (newtotal == NULL)
return NULL;
- oldtotal = lz->total;
- lz->total = newtotal;
- Py_DECREF(oldtotal);
-
Py_INCREF(newtotal);
+ Py_SETREF(lz->total, newtotal);
return newtotal;
}
@@ -3480,7 +3484,7 @@
return Py_BuildValue("O(OO)O", Py_TYPE(lz),
lz->it, lz->binop?lz->binop:Py_None,
lz->total?lz->total:Py_None);
- }
+}
static PyObject *
accumulate_setstate(accumulateobject *lz, PyObject *state)
@@ -3642,7 +3646,7 @@
ok = PyObject_IsTrue(selector);
Py_DECREF(selector);
- if (ok == 1)
+ if (ok > 0)
return datum;
Py_DECREF(datum);
if (ok < 0)
@@ -3655,7 +3659,7 @@
{
return Py_BuildValue("O(OO)", Py_TYPE(lz),
lz->data, lz->selectors);
- }
+}
static PyMethodDef compress_methods[] = {
{"__reduce__", (PyCFunction)compress_reduce, METH_NOARGS,
@@ -3674,44 +3678,44 @@
PyVarObject_HEAD_INIT(NULL, 0)
"itertools.compress", /* tp_name */
sizeof(compressobject), /* tp_basicsize */
- 0, /* tp_itemsize */
+ 0, /* tp_itemsize */
/* methods */
(destructor)compress_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- PyObject_GenericGetAttr, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
- Py_TPFLAGS_BASETYPE, /* tp_flags */
- compress_doc, /* tp_doc */
- (traverseproc)compress_traverse, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- PyObject_SelfIter, /* tp_iter */
+ Py_TPFLAGS_BASETYPE, /* tp_flags */
+ compress_doc, /* tp_doc */
+ (traverseproc)compress_traverse, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ PyObject_SelfIter, /* tp_iter */
(iternextfunc)compress_next, /* tp_iternext */
- compress_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- compress_new, /* tp_new */
- PyObject_GC_Del, /* tp_free */
+ compress_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ compress_new, /* tp_new */
+ PyObject_GC_Del, /* tp_free */
};
@@ -3792,8 +3796,7 @@
ok = PyObject_IsTrue(item);
} else {
PyObject *good;
- good = PyObject_CallFunctionObjArgs(lz->func,
- item, NULL);
+ good = PyObject_CallFunctionObjArgs(lz->func, item, NULL);
if (good == NULL) {
Py_DECREF(item);
return NULL;
@@ -3812,9 +3815,8 @@
static PyObject *
filterfalse_reduce(filterfalseobject *lz)
{
- return Py_BuildValue("O(OO)", Py_TYPE(lz),
- lz->func, lz->it);
- }
+ return Py_BuildValue("O(OO)", Py_TYPE(lz), lz->func, lz->it);
+}
static PyMethodDef filterfalse_methods[] = {
{"__reduce__", (PyCFunction)filterfalse_reduce, METH_NOARGS,
@@ -3834,7 +3836,7 @@
sizeof(filterfalseobject), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
- (destructor)filterfalse_dealloc, /* tp_dealloc */
+ (destructor)filterfalse_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
@@ -3852,7 +3854,7 @@
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_BASETYPE, /* tp_flags */
filterfalse_doc, /* tp_doc */
- (traverseproc)filterfalse_traverse, /* tp_traverse */
+ (traverseproc)filterfalse_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
@@ -4091,15 +4093,15 @@
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
- Py_TPFLAGS_BASETYPE, /* tp_flags */
+ Py_TPFLAGS_BASETYPE, /* tp_flags */
count_doc, /* tp_doc */
- (traverseproc)count_traverse, /* tp_traverse */
+ (traverseproc)count_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
PyObject_SelfIter, /* tp_iter */
(iternextfunc)count_next, /* tp_iternext */
- count_methods, /* tp_methods */
+ count_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
@@ -4265,9 +4267,7 @@
PyObject_GC_Del, /* tp_free */
};
-/* ziplongest object ************************************************************/
-
-#include "Python.h"
+/* ziplongest object *********************************************************/
typedef struct {
PyObject_HEAD
@@ -4306,7 +4306,7 @@
ittuple = PyTuple_New(tuplesize);
if (ittuple == NULL)
return NULL;
- for (i=0; i < tuplesize; ++i) {
+ for (i=0; i < tuplesize; i++) {
PyObject *item = PyTuple_GET_ITEM(args, i);
PyObject *it = PyObject_GetIter(item);
if (it == NULL) {
@@ -4447,6 +4447,7 @@
*/
int i;
PyObject *args = PyTuple_New(PyTuple_GET_SIZE(lz->ittuple));
+
if (args == NULL)
return NULL;
for (i=0; i<PyTuple_GET_SIZE(lz->ittuple); i++) {
@@ -4497,7 +4498,7 @@
sizeof(ziplongestobject), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
- (destructor)zip_longest_dealloc, /* tp_dealloc */
+ (destructor)zip_longest_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
@@ -4514,8 +4515,8 @@
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_BASETYPE, /* tp_flags */
- zip_longest_doc, /* tp_doc */
- (traverseproc)zip_longest_traverse, /* tp_traverse */
+ zip_longest_doc, /* tp_doc */
+ (traverseproc)zip_longest_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
@@ -4531,7 +4532,7 @@
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
- zip_longest_new, /* tp_new */
+ zip_longest_new, /* tp_new */
PyObject_GC_Del, /* tp_free */
};
diff --git a/Modules/main.c b/Modules/main.c
index e4c955e..b6dcdd0 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -42,11 +42,11 @@
#define PROGRAM_OPTS BASE_OPTS
/* Short usage message (with %s for argv0) */
-static char *usage_line =
+static const char usage_line[] =
"usage: %ls [option] ... [-c cmd | -m mod | file | -] [arg] ...\n";
/* Long usage message, split into parts < 512 bytes */
-static char *usage_1 = "\
+static const char usage_1[] = "\
Options and arguments (and corresponding environment variables):\n\
-b : issue warnings about str(bytes_instance), str(bytearray_instance)\n\
and comparing bytes/bytearray with str. (-bb: issue errors)\n\
@@ -56,7 +56,7 @@
-E : ignore PYTHON* environment variables (such as PYTHONPATH)\n\
-h : print this help message and exit (also --help)\n\
";
-static char *usage_2 = "\
+static const char usage_2[] = "\
-i : inspect interactively after running script; forces a prompt even\n\
if stdin does not appear to be a terminal; also PYTHONINSPECT=x\n\
-I : isolate Python from the user's environment (implies -E and -s)\n\
@@ -67,7 +67,7 @@
-s : don't add user site directory to sys.path; also PYTHONNOUSERSITE\n\
-S : don't imply 'import site' on initialization\n\
";
-static char *usage_3 = "\
+static const char usage_3[] = "\
-u : unbuffered binary stdout and stderr, stdin always buffered;\n\
also PYTHONUNBUFFERED=x\n\
see man page for details on internal buffering relating to '-u'\n\
@@ -79,7 +79,7 @@
-x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\
-X opt : set implementation-specific option\n\
";
-static char *usage_4 = "\
+static const char usage_4[] = "\
file : program read from script file\n\
- : program read from stdin (default; interactive mode if a tty)\n\
arg ...: arguments passed to program in sys.argv[1:]\n\n\
@@ -88,22 +88,23 @@
PYTHONPATH : '%lc'-separated list of directories prefixed to the\n\
default module search path. The result is sys.path.\n\
";
-static char *usage_5 =
+static const char usage_5[] =
"PYTHONHOME : alternate <prefix> directory (or <prefix>%lc<exec_prefix>).\n"
" The default module search path uses %s.\n"
"PYTHONCASEOK : ignore case in 'import' statements (Windows).\n"
"PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.\n"
-"PYTHONFAULTHANDLER: dump the Python traceback on fatal errors.\n\
-";
-static char *usage_6 = "\
-PYTHONHASHSEED: if this variable is set to 'random', a random value is used\n\
- to seed the hashes of str, bytes and datetime objects. It can also be\n\
- set to an integer in the range [0,4294967295] to get hash values with a\n\
- predictable seed.\n\
-";
+"PYTHONFAULTHANDLER: dump the Python traceback on fatal errors.\n";
+static const char usage_6[] =
+"PYTHONHASHSEED: if this variable is set to 'random', a random value is used\n"
+" to seed the hashes of str, bytes and datetime objects. It can also be\n"
+" set to an integer in the range [0,4294967295] to get hash values with a\n"
+" predictable seed.\n"
+"PYTHONMALLOC: set the Python memory allocators and/or install debug hooks\n"
+" on Python memory allocators. Use PYTHONMALLOC=debug to install debug\n"
+" hooks.\n";
static int
-usage(int exitcode, wchar_t* program)
+usage(int exitcode, const wchar_t* program)
{
FILE *f = exitcode ? stderr : stdout;
@@ -341,6 +342,7 @@
int help = 0;
int version = 0;
int saw_unbuffered_flag = 0;
+ char *opt;
PyCompilerFlags cf;
PyObject *warning_option = NULL;
PyObject *warning_options = NULL;
@@ -365,6 +367,13 @@
}
}
+ opt = Py_GETENV("PYTHONMALLOC");
+ if (_PyMem_SetupAllocators(opt) < 0) {
+ fprintf(stderr,
+ "Error in PYTHONMALLOC: unknown allocator \"%s\"!\n", opt);
+ exit(1);
+ }
+
Py_HashRandomizationFlag = 1;
_PyRandom_Init();
@@ -654,7 +663,7 @@
Py_SetProgramName(wbuf);
/* Don't free wbuf, the argument to Py_SetProgramName
- * must remain valid until the Py_Finalize is called.
+ * must remain valid until Py_FinalizeEx is called.
*/
} else {
Py_SetProgramName(argv[0]);
@@ -785,7 +794,11 @@
sts = PyRun_AnyFileFlags(stdin, "<stdin>", &cf) != 0;
}
- Py_Finalize();
+ if (Py_FinalizeEx() < 0) {
+ /* Value unlikely to be confused with a non-error exit status or
+ other special meaning */
+ sts = 120;
+ }
#ifdef __INSURE__
/* Insure++ is a memory analysis tool that aids in discovering
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index 7ebf8e8..cf04901 100644
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -875,7 +875,7 @@
}
static PyObject *
-math_2(PyObject *args, double (*func) (double, double), char *funcname)
+math_2(PyObject *args, double (*func) (double, double), const char *funcname)
{
PyObject *ox, *oy;
double x, y, r;
@@ -1672,7 +1672,7 @@
in that int is larger than PY_SSIZE_T_MAX. */
static PyObject*
-loghelper(PyObject* arg, double (*func)(double), char *funcname)
+loghelper(PyObject* arg, double (*func)(double), const char *funcname)
{
/* If it is int, do it ourselves. */
if (PyLong_Check(arg)) {
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index bb98a99..50cec24 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -389,6 +389,7 @@
PyObject *args)
{
Py_buffer data;
+ PyObject *result;
CHECK_VALID(NULL);
if (!PyArg_ParseTuple(args, "y*:write", &data))
@@ -406,9 +407,9 @@
}
memcpy(self->data + self->pos, data.buf, data.len);
self->pos = self->pos + data.len;
+ result = PyLong_FromSsize_t(data.len);
PyBuffer_Release(&data);
- Py_INCREF(Py_None);
- return Py_None;
+ return result;
}
static PyObject *
diff --git a/Modules/nismodule.c b/Modules/nismodule.c
index 64eb5db..b6a855c 100644
--- a/Modules/nismodule.c
+++ b/Modules/nismodule.c
@@ -76,11 +76,7 @@
*pfix = 0;
for (i=0; aliases[i].alias != 0L; i++) {
- if (!strcmp (aliases[i].alias, map)) {
- *pfix = aliases[i].fix;
- return aliases[i].map;
- }
- if (!strcmp (aliases[i].map, map)) {
+ if (!strcmp (aliases[i].alias, map) || !strcmp (aliases[i].map, map)) {
*pfix = aliases[i].fix;
return aliases[i].map;
}
diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c
index d2fd5c8..2b7d71f 100644
--- a/Modules/ossaudiodev.c
+++ b/Modules/ossaudiodev.c
@@ -31,7 +31,11 @@
#endif
#include <sys/ioctl.h>
+#ifdef __ANDROID__
+#include <linux/soundcard.h>
+#else
#include <sys/soundcard.h>
+#endif
#if defined(linux)
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
index 6471b8e..82770a5 100644
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -53,7 +53,7 @@
/* String constants used to initialize module attributes.
*
*/
-static char parser_copyright_string[] =
+static const char parser_copyright_string[] =
"Copyright 1995-1996 by Virginia Polytechnic Institute & State\n\
University, Blacksburg, Virginia, USA, and Fred L. Drake, Jr., Reston,\n\
Virginia, USA. Portions copyright 1991-1995 by Stichting Mathematisch\n\
@@ -63,7 +63,7 @@
PyDoc_STRVAR(parser_doc_string,
"This is an interface to Python's internal parser.");
-static char parser_version_string[] = "0.5";
+static const char parser_version_string[] = "0.5";
typedef PyObject* (*SeqMaker) (Py_ssize_t length);
@@ -578,13 +578,13 @@
}
-/* err_string(char* message)
+/* err_string(const char* message)
*
* Sets the error string for an exception of type ParserError.
*
*/
static void
-err_string(char *message)
+err_string(const char *message)
{
PyErr_SetString(parser_error, message);
}
@@ -597,7 +597,7 @@
*
*/
static PyObject*
-parser_do_parse(PyObject *args, PyObject *kw, char *argspec, int type)
+parser_do_parse(PyObject *args, PyObject *kw, const char *argspec, int type)
{
char* string = 0;
PyObject* res = 0;
@@ -670,9 +670,75 @@
static node* build_node_tree(PyObject *tuple);
-static int validate_expr_tree(node *tree);
-static int validate_file_input(node *tree);
-static int validate_encoding_decl(node *tree);
+
+static int
+validate_node(node *tree)
+{
+ int type = TYPE(tree);
+ int nch = NCH(tree);
+ dfa *nt_dfa;
+ state *dfa_state;
+ int pos, arc;
+
+ assert(ISNONTERMINAL(type));
+ type -= NT_OFFSET;
+ if (type >= _PyParser_Grammar.g_ndfas) {
+ PyErr_Format(parser_error, "Unrecognized node type %d.", TYPE(tree));
+ return 0;
+ }
+ nt_dfa = &_PyParser_Grammar.g_dfa[type];
+ REQ(tree, nt_dfa->d_type);
+
+ /* Run the DFA for this nonterminal. */
+ dfa_state = &nt_dfa->d_state[nt_dfa->d_initial];
+ for (pos = 0; pos < nch; ++pos) {
+ node *ch = CHILD(tree, pos);
+ int ch_type = TYPE(ch);
+ for (arc = 0; arc < dfa_state->s_narcs; ++arc) {
+ short a_label = dfa_state->s_arc[arc].a_lbl;
+ assert(a_label < _PyParser_Grammar.g_ll.ll_nlabels);
+ if (_PyParser_Grammar.g_ll.ll_label[a_label].lb_type == ch_type) {
+ /* The child is acceptable; if non-terminal, validate it recursively. */
+ if (ISNONTERMINAL(ch_type) && !validate_node(ch))
+ return 0;
+
+ /* Update the state, and move on to the next child. */
+ dfa_state = &nt_dfa->d_state[dfa_state->s_arc[arc].a_arrow];
+ goto arc_found;
+ }
+ }
+ /* What would this state have accepted? */
+ {
+ short a_label = dfa_state->s_arc->a_lbl;
+ int next_type;
+ if (!a_label) /* Wouldn't accept any more children */
+ goto illegal_num_children;
+
+ next_type = _PyParser_Grammar.g_ll.ll_label[a_label].lb_type;
+ if (ISNONTERMINAL(next_type))
+ PyErr_Format(parser_error, "Expected node type %d, got %d.",
+ next_type, ch_type);
+ else
+ PyErr_Format(parser_error, "Illegal terminal: expected %s.",
+ _PyParser_TokenNames[next_type]);
+ return 0;
+ }
+
+arc_found:
+ continue;
+ }
+ /* Are we in a final state? If so, return 1 for successful validation. */
+ for (arc = 0; arc < dfa_state->s_narcs; ++arc) {
+ if (!dfa_state->s_arc[arc].a_lbl) {
+ return 1;
+ }
+ }
+
+illegal_num_children:
+ PyErr_Format(parser_error,
+ "Illegal number of children for %s node.", nt_dfa->d_name);
+ return 0;
+}
/* PyObject* parser_tuple2st(PyObject* self, PyObject* args)
*
@@ -681,7 +747,7 @@
* tuple can be validated. It does this by checking the first code of the
* tuple, and, if acceptable, builds the internal representation. If this
* step succeeds, the internal representation is validated as fully as
- * possible with the various validate_*() routines defined below.
+ * possible with the recursive validate_node() routine defined above.
*
* This function must be changed if support is to be added for PyST_FRAGMENT
* ST objects.
@@ -710,33 +776,35 @@
*/
tree = build_node_tree(tuple);
if (tree != 0) {
- int start_sym = TYPE(tree);
- if (start_sym == eval_input) {
+ node *validation_root = tree;
+ int tree_type = 0;
+ switch (TYPE(tree)) {
+ case eval_input:
/* Might be an eval form. */
- if (validate_expr_tree(tree))
- st = parser_newstobject(tree, PyST_EXPR);
- else
- PyNode_Free(tree);
- }
- else if (start_sym == file_input) {
- /* This looks like an exec form so far. */
- if (validate_file_input(tree))
- st = parser_newstobject(tree, PyST_SUITE);
- else
- PyNode_Free(tree);
- }
- else if (start_sym == encoding_decl) {
+ tree_type = PyST_EXPR;
+ break;
+ case encoding_decl:
/* This looks like an encoding_decl so far. */
- if (validate_encoding_decl(tree))
- st = parser_newstobject(tree, PyST_SUITE);
- else
- PyNode_Free(tree);
- }
- else {
+ if (NCH(tree) != 1)
+ err_string("Error Parsing encoding_decl");
+ validation_root = CHILD(tree, 0);
+ /* Fall through */
+ case file_input:
+ /* This looks like an exec form so far. */
+
+ tree_type = PyST_SUITE;
+ break;
+ default:
/* This is a fragment, at best. */
PyNode_Free(tree);
err_string("parse tree does not use a valid start symbol");
+ return (0);
}
+
+ if (validate_node(validation_root))
+ st = parser_newstobject(tree, tree_type);
+ else
+ PyNode_Free(tree);
}
/* Make sure we raise an exception on all errors. We should never
* get this, but we'd do well to be sure something is done.
@@ -981,2433 +1049,6 @@
}
-/*
- * Validation routines used within the validation section:
- */
-static int validate_terminal(node *terminal, int type, char *string);
-
-#define validate_ampersand(ch) validate_terminal(ch, AMPER, "&")
-#define validate_circumflex(ch) validate_terminal(ch, CIRCUMFLEX, "^")
-#define validate_colon(ch) validate_terminal(ch, COLON, ":")
-#define validate_comma(ch) validate_terminal(ch, COMMA, ",")
-#define validate_dedent(ch) validate_terminal(ch, DEDENT, "")
-#define validate_equal(ch) validate_terminal(ch, EQUAL, "=")
-#define validate_indent(ch) validate_terminal(ch, INDENT, (char*)NULL)
-#define validate_lparen(ch) validate_terminal(ch, LPAR, "(")
-#define validate_newline(ch) validate_terminal(ch, NEWLINE, (char*)NULL)
-#define validate_rparen(ch) validate_terminal(ch, RPAR, ")")
-#define validate_semi(ch) validate_terminal(ch, SEMI, ";")
-#define validate_star(ch) validate_terminal(ch, STAR, "*")
-#define validate_vbar(ch) validate_terminal(ch, VBAR, "|")
-#define validate_doublestar(ch) validate_terminal(ch, DOUBLESTAR, "**")
-#define validate_dot(ch) validate_terminal(ch, DOT, ".")
-#define validate_at(ch) validate_terminal(ch, AT, "@")
-#define validate_rarrow(ch) validate_terminal(ch, RARROW, "->")
-#define validate_name(ch, str) validate_terminal(ch, NAME, str)
-
-#define VALIDATER(n) static int validate_##n(node *tree)
-
-VALIDATER(node); VALIDATER(small_stmt);
-VALIDATER(class); VALIDATER(node);
-VALIDATER(parameters); VALIDATER(suite);
-VALIDATER(testlist); VALIDATER(varargslist);
-VALIDATER(vfpdef);
-VALIDATER(stmt); VALIDATER(simple_stmt);
-VALIDATER(expr_stmt); VALIDATER(power);
-VALIDATER(del_stmt);
-VALIDATER(return_stmt); VALIDATER(raise_stmt);
-VALIDATER(import_stmt); VALIDATER(import_stmt);
-VALIDATER(import_name); VALIDATER(yield_stmt);
-VALIDATER(global_stmt); VALIDATER(nonlocal_stmt);
-VALIDATER(assert_stmt);
-VALIDATER(compound_stmt); VALIDATER(test_or_star_expr);
-VALIDATER(while); VALIDATER(for);
-VALIDATER(try); VALIDATER(except_clause);
-VALIDATER(test); VALIDATER(and_test);
-VALIDATER(not_test); VALIDATER(comparison);
-VALIDATER(comp_op);
-VALIDATER(star_expr); VALIDATER(expr);
-VALIDATER(xor_expr); VALIDATER(and_expr);
-VALIDATER(shift_expr); VALIDATER(arith_expr);
-VALIDATER(term); VALIDATER(factor);
-VALIDATER(atom); VALIDATER(lambdef);
-VALIDATER(trailer); VALIDATER(subscript);
-VALIDATER(subscriptlist); VALIDATER(sliceop);
-VALIDATER(exprlist); VALIDATER(dictorsetmaker);
-VALIDATER(arglist); VALIDATER(argument);
-VALIDATER(comp_for);
-VALIDATER(comp_iter); VALIDATER(comp_if);
-VALIDATER(testlist_comp); VALIDATER(yield_expr);
-VALIDATER(or_test);
-VALIDATER(test_nocond); VALIDATER(lambdef_nocond);
-VALIDATER(yield_arg);
-VALIDATER(async_funcdef); VALIDATER(async_stmt);
-VALIDATER(atom_expr);
-
-#undef VALIDATER
-
-#define is_even(n) (((n) & 1) == 0)
-#define is_odd(n) (((n) & 1) == 1)
-
-
-static int
-validate_ntype(node *n, int t)
-{
- if (TYPE(n) != t) {
- PyErr_Format(parser_error, "Expected node type %d, got %d.",
- t, TYPE(n));
- return 0;
- }
- return 1;
-}
-
-
-/* Verifies that the number of child nodes is exactly 'num', raising
- * an exception if it isn't. The exception message does not indicate
- * the exact number of nodes, allowing this to be used to raise the
- * "right" exception when the wrong number of nodes is present in a
- * specific variant of a statement's syntax. This is commonly used
- * in that fashion.
- */
-static int
-validate_numnodes(node *n, int num, const char *const name)
-{
- if (NCH(n) != num) {
- PyErr_Format(parser_error,
- "Illegal number of children for %s node.", name);
- return 0;
- }
- return 1;
-}
-
-
-static int
-validate_terminal(node *terminal, int type, char *string)
-{
- int res = (validate_ntype(terminal, type)
- && ((string == 0) || (strcmp(string, STR(terminal)) == 0)));
-
- if (!res && !PyErr_Occurred()) {
- PyErr_Format(parser_error,
- "Illegal terminal: expected \"%s\"", string);
- }
- return (res);
-}
-
-/* X (',' X) [','] */
-static int
-validate_repeating_list_variable(node *tree,
- int list_node_type,
- int (*validate_child_func_inc)(node *, int *),
- int *pos,
- const char *const list_node_type_name)
-{
- int nch = NCH(tree);
- int res = (nch && validate_ntype(tree, list_node_type));
-
- if (!res && !PyErr_Occurred()) {
- /* Unconditionally raise. */
- (void) validate_numnodes(tree, 1, list_node_type_name);
- }
- else {
- for ( ; res && *pos < nch; ) {
- res = validate_child_func_inc(tree, pos);
- if (!res || *pos >= nch)
- break;
- res = validate_comma(CHILD(tree, (*pos)++));
- }
- }
- return res;
-}
-
-/* X (',' X) [','] */
-static int
-validate_repeating_list(node *tree,
- int list_node_type,
- int (*validate_child_func)(node *),
- const char *const list_node_type_name)
-{
- int nch = NCH(tree);
- int res = (nch && validate_ntype(tree, list_node_type));
- int pos = 0;
-
- if (!res && !PyErr_Occurred()) {
- /* Unconditionally raise. */
- (void) validate_numnodes(tree, 1, list_node_type_name);
- }
- else {
- for ( ; res && pos < nch; ) {
- res = validate_child_func(CHILD(tree, pos++));
- if (!res || pos >= nch)
- break;
- res = validate_comma(CHILD(tree, pos++));
- }
- }
- return res;
-}
-
-
-/* validate_class()
- *
- * classdef:
- * 'class' NAME ['(' testlist ')'] ':' suite
- */
-static int
-validate_class(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, classdef) &&
- ((nch == 4) || (nch == 6) || (nch == 7)));
-
- if (res) {
- res = (validate_name(CHILD(tree, 0), "class")
- && validate_ntype(CHILD(tree, 1), NAME)
- && validate_colon(CHILD(tree, nch - 2))
- && validate_suite(CHILD(tree, nch - 1)));
- }
- else {
- (void) validate_numnodes(tree, 4, "class");
- }
-
- if (res) {
- if (nch == 7) {
- res = ((validate_lparen(CHILD(tree, 2)) &&
- validate_arglist(CHILD(tree, 3)) &&
- validate_rparen(CHILD(tree, 4))));
- }
- else if (nch == 6) {
- res = (validate_lparen(CHILD(tree,2)) &&
- validate_rparen(CHILD(tree,3)));
- }
- }
- return (res);
-}
-
-
-/* if_stmt:
- * 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
- */
-static int
-validate_if(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, if_stmt)
- && (nch >= 4)
- && validate_name(CHILD(tree, 0), "if")
- && validate_test(CHILD(tree, 1))
- && validate_colon(CHILD(tree, 2))
- && validate_suite(CHILD(tree, 3)));
-
- if (res && ((nch % 4) == 3)) {
- /* ... 'else' ':' suite */
- res = (validate_name(CHILD(tree, nch - 3), "else")
- && validate_colon(CHILD(tree, nch - 2))
- && validate_suite(CHILD(tree, nch - 1)));
- nch -= 3;
- }
- else if (!res && !PyErr_Occurred())
- (void) validate_numnodes(tree, 4, "if");
- if ((nch % 4) != 0)
- /* Will catch the case for nch < 4 */
- res = validate_numnodes(tree, 0, "if");
- else if (res && (nch > 4)) {
- /* ... ('elif' test ':' suite)+ ... */
- int j = 4;
- while ((j < nch) && res) {
- res = (validate_name(CHILD(tree, j), "elif")
- && validate_colon(CHILD(tree, j + 2))
- && validate_test(CHILD(tree, j + 1))
- && validate_suite(CHILD(tree, j + 3)));
- j += 4;
- }
- }
- return (res);
-}
-
-
-/* parameters:
- * '(' [varargslist] ')'
- *
- */
-static int
-validate_parameters(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_ntype(tree, parameters) && ((nch == 2) || (nch == 3));
-
- if (res) {
- res = (validate_lparen(CHILD(tree, 0))
- && validate_rparen(CHILD(tree, nch - 1)));
- if (res && (nch == 3))
- res = validate_varargslist(CHILD(tree, 1));
- }
- else {
- (void) validate_numnodes(tree, 2, "parameters");
- }
- return (res);
-}
-
-
-/* validate_suite()
- *
- * suite:
- * simple_stmt
- * | NEWLINE INDENT stmt+ DEDENT
- */
-static int
-validate_suite(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, suite) && ((nch == 1) || (nch >= 4)));
-
- if (res && (nch == 1))
- res = validate_simple_stmt(CHILD(tree, 0));
- else if (res) {
- /* NEWLINE INDENT stmt+ DEDENT */
- res = (validate_newline(CHILD(tree, 0))
- && validate_indent(CHILD(tree, 1))
- && validate_stmt(CHILD(tree, 2))
- && validate_dedent(CHILD(tree, nch - 1)));
-
- if (res && (nch > 4)) {
- int i = 3;
- --nch; /* forget the DEDENT */
- for ( ; res && (i < nch); ++i)
- res = validate_stmt(CHILD(tree, i));
- }
- else if (nch < 4)
- res = validate_numnodes(tree, 4, "suite");
- }
- return (res);
-}
-
-
-static int
-validate_testlist(node *tree)
-{
- return (validate_repeating_list(tree, testlist,
- validate_test, "testlist"));
-}
-
-static int
-validate_testlist_star_expr(node *tl)
-{
- return (validate_repeating_list(tl, testlist_star_expr, validate_test_or_star_expr,
- "testlist"));
-}
-
-
-/* validate either vfpdef or tfpdef.
- * vfpdef: NAME
- * tfpdef: NAME [':' test]
- */
-static int
-validate_vfpdef(node *tree)
-{
- int nch = NCH(tree);
- if (TYPE(tree) == vfpdef) {
- return nch == 1 && validate_name(CHILD(tree, 0), NULL);
- }
- else if (TYPE(tree) == tfpdef) {
- if (nch == 1) {
- return validate_name(CHILD(tree, 0), NULL);
- }
- else if (nch == 3) {
- return validate_name(CHILD(tree, 0), NULL) &&
- validate_colon(CHILD(tree, 1)) &&
- validate_test(CHILD(tree, 2));
- }
- }
- return 0;
-}
-
-/* '*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef
- * ..or tfpdef in place of vfpdef. vfpdef: NAME; tfpdef: NAME [':' test]
- */
-static int
-validate_varargslist_trailer(node *tree, int start)
-{
- int nch = NCH(tree);
- int res = 0;
-
- if (nch <= start) {
- err_string("expected variable argument trailer for varargslist");
- return 0;
- }
- if (TYPE(CHILD(tree, start)) == STAR) {
- /*
- * '*' [vfpdef]
- */
- res = validate_star(CHILD(tree, start++));
- if (res && start < nch && (TYPE(CHILD(tree, start)) == vfpdef ||
- TYPE(CHILD(tree, start)) == tfpdef))
- res = validate_vfpdef(CHILD(tree, start++));
- /*
- * (',' vfpdef ['=' test])*
- */
- while (res && start + 1 < nch && (
- TYPE(CHILD(tree, start + 1)) == vfpdef ||
- TYPE(CHILD(tree, start + 1)) == tfpdef)) {
- res = (validate_comma(CHILD(tree, start++))
- && validate_vfpdef(CHILD(tree, start++)));
- if (res && start + 1 < nch && TYPE(CHILD(tree, start)) == EQUAL)
- res = (validate_equal(CHILD(tree, start++))
- && validate_test(CHILD(tree, start++)));
- }
- /*
- * [',' '**' vfpdef]
- */
- if (res && start + 2 < nch && TYPE(CHILD(tree, start+1)) == DOUBLESTAR)
- res = (validate_comma(CHILD(tree, start++))
- && validate_doublestar(CHILD(tree, start++))
- && validate_vfpdef(CHILD(tree, start++)));
- }
- else if (TYPE(CHILD(tree, start)) == DOUBLESTAR) {
- /*
- * '**' vfpdef
- */
- if (start + 1 < nch)
- res = (validate_doublestar(CHILD(tree, start++))
- && validate_vfpdef(CHILD(tree, start++)));
- else {
- res = 0;
- err_string("expected vfpdef after ** in varargslist trailer");
- }
- }
- else {
- res = 0;
- err_string("expected * or ** in varargslist trailer");
- }
-
- if (res && start != nch) {
- res = 0;
- err_string("unexpected extra children in varargslist trailer");
- }
- return res;
-}
-
-
-/* validate_varargslist()
- *
- * Validate typedargslist or varargslist.
- *
- * typedargslist: ((tfpdef ['=' test] ',')*
- * ('*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] |
- * '**' tfpdef)
- * | tfpdef ['=' test] (',' tfpdef ['=' test])* [','])
- * tfpdef: NAME [':' test]
- * varargslist: ((vfpdef ['=' test] ',')*
- * ('*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] |
- * '**' vfpdef)
- * | vfpdef ['=' test] (',' vfpdef ['=' test])* [','])
- * vfpdef: NAME
- *
- */
-static int
-validate_varargslist(node *tree)
-{
- int nch = NCH(tree);
- int res = (TYPE(tree) == varargslist ||
- TYPE(tree) == typedargslist) &&
- (nch != 0);
- int sym;
- node *ch;
- int i = 0;
-
- if (!res)
- return 0;
- if (nch < 1) {
- err_string("varargslist missing child nodes");
- return 0;
- }
- while (i < nch) {
- ch = CHILD(tree, i);
- sym = TYPE(ch);
- if (sym == vfpdef || sym == tfpdef) {
- /* validate (vfpdef ['=' test] ',')+ */
- res = validate_vfpdef(ch);
- ++i;
- if (res && (i+2 <= nch) && TYPE(CHILD(tree, i)) == EQUAL) {
- res = (validate_equal(CHILD(tree, i))
- && validate_test(CHILD(tree, i+1)));
- if (res)
- i += 2;
- }
- if (res && i < nch) {
- res = validate_comma(CHILD(tree, i));
- ++i;
- }
- } else if (sym == DOUBLESTAR || sym == STAR) {
- res = validate_varargslist_trailer(tree, i);
- break;
- } else {
- res = 0;
- err_string("illegal formation for varargslist");
- }
- }
- return res;
-}
-
-
-/* comp_iter: comp_for | comp_if
- */
-static int
-validate_comp_iter(node *tree)
-{
- int res = (validate_ntype(tree, comp_iter)
- && validate_numnodes(tree, 1, "comp_iter"));
- if (res && TYPE(CHILD(tree, 0)) == comp_for)
- res = validate_comp_for(CHILD(tree, 0));
- else
- res = validate_comp_if(CHILD(tree, 0));
-
- return res;
-}
-
-/* comp_for: 'for' exprlist 'in' test [comp_iter]
- */
-static int
-validate_comp_for(node *tree)
-{
- int nch = NCH(tree);
- int res;
-
- if (nch == 5)
- res = validate_comp_iter(CHILD(tree, 4));
- else
- res = validate_numnodes(tree, 4, "comp_for");
-
- if (res)
- res = (validate_name(CHILD(tree, 0), "for")
- && validate_exprlist(CHILD(tree, 1))
- && validate_name(CHILD(tree, 2), "in")
- && validate_or_test(CHILD(tree, 3)));
-
- return res;
-}
-
-/* comp_if: 'if' test_nocond [comp_iter]
- */
-static int
-validate_comp_if(node *tree)
-{
- int nch = NCH(tree);
- int res;
-
- if (nch == 3)
- res = validate_comp_iter(CHILD(tree, 2));
- else
- res = validate_numnodes(tree, 2, "comp_if");
-
- if (res)
- res = (validate_name(CHILD(tree, 0), "if")
- && validate_test_nocond(CHILD(tree, 1)));
-
- return res;
-}
-
-
-/* simple_stmt | compound_stmt
- *
- */
-static int
-validate_stmt(node *tree)
-{
- int res = (validate_ntype(tree, stmt)
- && validate_numnodes(tree, 1, "stmt"));
-
- if (res) {
- tree = CHILD(tree, 0);
-
- if (TYPE(tree) == simple_stmt)
- res = validate_simple_stmt(tree);
- else
- res = validate_compound_stmt(tree);
- }
- return (res);
-}
-
-
-/* small_stmt (';' small_stmt)* [';'] NEWLINE
- *
- */
-static int
-validate_simple_stmt(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, simple_stmt)
- && (nch >= 2)
- && validate_small_stmt(CHILD(tree, 0))
- && validate_newline(CHILD(tree, nch - 1)));
-
- if (nch < 2)
- res = validate_numnodes(tree, 2, "simple_stmt");
- --nch; /* forget the NEWLINE */
- if (res && is_even(nch))
- res = validate_semi(CHILD(tree, --nch));
- if (res && (nch > 2)) {
- int i;
-
- for (i = 1; res && (i < nch); i += 2)
- res = (validate_semi(CHILD(tree, i))
- && validate_small_stmt(CHILD(tree, i + 1)));
- }
- return (res);
-}
-
-
-static int
-validate_small_stmt(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_numnodes(tree, 1, "small_stmt");
-
- if (res) {
- int ntype = TYPE(CHILD(tree, 0));
-
- if ( (ntype == expr_stmt)
- || (ntype == del_stmt)
- || (ntype == pass_stmt)
- || (ntype == flow_stmt)
- || (ntype == import_stmt)
- || (ntype == global_stmt)
- || (ntype == nonlocal_stmt)
- || (ntype == assert_stmt))
- res = validate_node(CHILD(tree, 0));
- else {
- res = 0;
- err_string("illegal small_stmt child type");
- }
- }
- else if (nch == 1) {
- res = 0;
- PyErr_Format(parser_error,
- "Unrecognized child node of small_stmt: %d.",
- TYPE(CHILD(tree, 0)));
- }
- return (res);
-}
-
-
-/* compound_stmt:
- * if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated
- */
-static int
-validate_compound_stmt(node *tree)
-{
- int res = (validate_ntype(tree, compound_stmt)
- && validate_numnodes(tree, 1, "compound_stmt"));
- int ntype;
-
- if (!res)
- return (0);
-
- tree = CHILD(tree, 0);
- ntype = TYPE(tree);
- if ( (ntype == if_stmt)
- || (ntype == while_stmt)
- || (ntype == for_stmt)
- || (ntype == try_stmt)
- || (ntype == with_stmt)
- || (ntype == funcdef)
- || (ntype == async_stmt)
- || (ntype == classdef)
- || (ntype == decorated))
- res = validate_node(tree);
- else {
- res = 0;
- PyErr_Format(parser_error,
- "Illegal compound statement type: %d.", TYPE(tree));
- }
- return (res);
-}
-
-static int
-validate_yield_or_testlist(node *tree, int tse)
-{
- if (TYPE(tree) == yield_expr) {
- return validate_yield_expr(tree);
- }
- else {
- if (tse)
- return validate_testlist_star_expr(tree);
- else
- return validate_testlist(tree);
- }
-}
-
-static int
-validate_expr_stmt(node *tree)
-{
- int j;
- int nch = NCH(tree);
- int res = (validate_ntype(tree, expr_stmt)
- && is_odd(nch)
- && validate_testlist_star_expr(CHILD(tree, 0)));
-
- if (res && nch == 3
- && TYPE(CHILD(tree, 1)) == augassign) {
- res = validate_numnodes(CHILD(tree, 1), 1, "augassign")
- && validate_yield_or_testlist(CHILD(tree, 2), 0);
-
- if (res) {
- char *s = STR(CHILD(CHILD(tree, 1), 0));
-
- res = (strcmp(s, "+=") == 0
- || strcmp(s, "-=") == 0
- || strcmp(s, "*=") == 0
- || strcmp(s, "/=") == 0
- || strcmp(s, "//=") == 0
- || strcmp(s, "%=") == 0
- || strcmp(s, "&=") == 0
- || strcmp(s, "|=") == 0
- || strcmp(s, "^=") == 0
- || strcmp(s, "<<=") == 0
- || strcmp(s, ">>=") == 0
- || strcmp(s, "**=") == 0);
- if (!res)
- err_string("illegal augmented assignment operator");
- }
- }
- else {
- for (j = 1; res && (j < nch); j += 2)
- res = validate_equal(CHILD(tree, j))
- && validate_yield_or_testlist(CHILD(tree, j + 1), 1);
- }
- return (res);
-}
-
-
-static int
-validate_del_stmt(node *tree)
-{
- return (validate_numnodes(tree, 2, "del_stmt")
- && validate_name(CHILD(tree, 0), "del")
- && validate_exprlist(CHILD(tree, 1)));
-}
-
-
-static int
-validate_return_stmt(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, return_stmt)
- && ((nch == 1) || (nch == 2))
- && validate_name(CHILD(tree, 0), "return"));
-
- if (res && (nch == 2))
- res = validate_testlist(CHILD(tree, 1));
-
- return (res);
-}
-
-
-/*
- * raise_stmt:
- *
- * 'raise' [test ['from' test]]
- */
-static int
-validate_raise_stmt(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, raise_stmt)
- && ((nch == 1) || (nch == 2) || (nch == 4)));
-
- if (!res && !PyErr_Occurred())
- (void) validate_numnodes(tree, 2, "raise");
-
- if (res) {
- res = validate_name(CHILD(tree, 0), "raise");
- if (res && (nch >= 2))
- res = validate_test(CHILD(tree, 1));
- if (res && (nch == 4)) {
- res = (validate_name(CHILD(tree, 2), "from")
- && validate_test(CHILD(tree, 3)));
- }
- }
- return (res);
-}
-
-
-/* yield_expr: 'yield' [yield_arg]
- */
-static int
-validate_yield_expr(node *tree)
-{
- int nch = NCH(tree);
- if (nch < 1 || nch > 2)
- return 0;
- if (!validate_ntype(tree, yield_expr))
- return 0;
- if (!validate_name(CHILD(tree, 0), "yield"))
- return 0;
- if (nch == 2) {
- if (!validate_yield_arg(CHILD(tree, 1)))
- return 0;
- }
- return 1;
-}
-
-/* yield_arg: 'from' test | testlist
- */
-static int
-validate_yield_arg(node *tree)
-{
- int nch = NCH(tree);
- if (!validate_ntype(tree, yield_arg))
- return 0;
- switch (nch) {
- case 1:
- if (!validate_testlist(CHILD(tree, nch - 1)))
- return 0;
- break;
- case 2:
- if (!validate_name(CHILD(tree, 0), "from"))
- return 0;
- if (!validate_test(CHILD(tree, 1)))
- return 0;
- break;
- default:
- return 0;
- }
- return 1;
-}
-
-/* yield_stmt: yield_expr
- */
-static int
-validate_yield_stmt(node *tree)
-{
- return (validate_ntype(tree, yield_stmt)
- && validate_numnodes(tree, 1, "yield_stmt")
- && validate_yield_expr(CHILD(tree, 0)));
-}
-
-
-static int
-validate_import_as_name(node *tree)
-{
- int nch = NCH(tree);
- int ok = validate_ntype(tree, import_as_name);
-
- if (ok) {
- if (nch == 1)
- ok = validate_name(CHILD(tree, 0), NULL);
- else if (nch == 3)
- ok = (validate_name(CHILD(tree, 0), NULL)
- && validate_name(CHILD(tree, 1), "as")
- && validate_name(CHILD(tree, 2), NULL));
- else
- ok = validate_numnodes(tree, 3, "import_as_name");
- }
- return ok;
-}
-
-
-/* dotted_name: NAME ("." NAME)*
- */
-static int
-validate_dotted_name(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, dotted_name)
- && is_odd(nch)
- && validate_name(CHILD(tree, 0), NULL));
- int i;
-
- for (i = 1; res && (i < nch); i += 2) {
- res = (validate_dot(CHILD(tree, i))
- && validate_name(CHILD(tree, i+1), NULL));
- }
- return res;
-}
-
-
-/* dotted_as_name: dotted_name [NAME NAME]
- */
-static int
-validate_dotted_as_name(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_ntype(tree, dotted_as_name);
-
- if (res) {
- if (nch == 1)
- res = validate_dotted_name(CHILD(tree, 0));
- else if (nch == 3)
- res = (validate_dotted_name(CHILD(tree, 0))
- && validate_name(CHILD(tree, 1), "as")
- && validate_name(CHILD(tree, 2), NULL));
- else {
- res = 0;
- err_string("illegal number of children for dotted_as_name");
- }
- }
- return res;
-}
-
-
-/* dotted_as_name (',' dotted_as_name)* */
-static int
-validate_dotted_as_names(node *tree)
-{
- int nch = NCH(tree);
- int res = is_odd(nch) && validate_dotted_as_name(CHILD(tree, 0));
- int i;
-
- for (i = 1; res && (i < nch); i += 2)
- res = (validate_comma(CHILD(tree, i))
- && validate_dotted_as_name(CHILD(tree, i + 1)));
- return (res);
-}
-
-
-/* import_as_name (',' import_as_name)* [','] */
-static int
-validate_import_as_names(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_import_as_name(CHILD(tree, 0));
- int i;
-
- for (i = 1; res && (i + 1 < nch); i += 2)
- res = (validate_comma(CHILD(tree, i))
- && validate_import_as_name(CHILD(tree, i + 1)));
- return (res);
-}
-
-
-/* 'import' dotted_as_names */
-static int
-validate_import_name(node *tree)
-{
- return (validate_ntype(tree, import_name)
- && validate_numnodes(tree, 2, "import_name")
- && validate_name(CHILD(tree, 0), "import")
- && validate_dotted_as_names(CHILD(tree, 1)));
-}
-
-/* Helper function to count the number of leading dots (or ellipsis tokens) in
- * 'from ...module import name'
- */
-static int
-count_from_dots(node *tree)
-{
- int i;
- for (i = 1; i < NCH(tree); i++)
- if (TYPE(CHILD(tree, i)) != DOT && TYPE(CHILD(tree, i)) != ELLIPSIS)
- break;
- return i - 1;
-}
-
-/* import_from: ('from' ('.'* dotted_name | '.'+)
- * 'import' ('*' | '(' import_as_names ')' | import_as_names))
- */
-static int
-validate_import_from(node *tree)
-{
- int nch = NCH(tree);
- int ndots = count_from_dots(tree);
- int havename = (TYPE(CHILD(tree, ndots + 1)) == dotted_name);
- int offset = ndots + havename;
- int res = validate_ntype(tree, import_from)
- && (offset >= 1)
- && (nch >= 3 + offset)
- && validate_name(CHILD(tree, 0), "from")
- && (!havename || validate_dotted_name(CHILD(tree, ndots + 1)))
- && validate_name(CHILD(tree, offset + 1), "import");
-
- if (res && TYPE(CHILD(tree, offset + 2)) == LPAR)
- res = ((nch == offset + 5)
- && validate_lparen(CHILD(tree, offset + 2))
- && validate_import_as_names(CHILD(tree, offset + 3))
- && validate_rparen(CHILD(tree, offset + 4)));
- else if (res && TYPE(CHILD(tree, offset + 2)) != STAR)
- res = validate_import_as_names(CHILD(tree, offset + 2));
- return (res);
-}
-
-
-/* import_stmt: import_name | import_from */
-static int
-validate_import_stmt(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_numnodes(tree, 1, "import_stmt");
-
- if (res) {
- int ntype = TYPE(CHILD(tree, 0));
-
- if (ntype == import_name || ntype == import_from)
- res = validate_node(CHILD(tree, 0));
- else {
- res = 0;
- err_string("illegal import_stmt child type");
- }
- }
- else if (nch == 1) {
- res = 0;
- PyErr_Format(parser_error,
- "Unrecognized child node of import_stmt: %d.",
- TYPE(CHILD(tree, 0)));
- }
- return (res);
-}
-
-
-/* global_stmt:
- *
- * 'global' NAME (',' NAME)*
- */
-static int
-validate_global_stmt(node *tree)
-{
- int j;
- int nch = NCH(tree);
- int res = (validate_ntype(tree, global_stmt)
- && is_even(nch) && (nch >= 2));
-
- if (!res && !PyErr_Occurred())
- err_string("illegal global statement");
-
- if (res)
- res = (validate_name(CHILD(tree, 0), "global")
- && validate_ntype(CHILD(tree, 1), NAME));
- for (j = 2; res && (j < nch); j += 2)
- res = (validate_comma(CHILD(tree, j))
- && validate_ntype(CHILD(tree, j + 1), NAME));
-
- return (res);
-}
-
-/* nonlocal_stmt:
- *
- * 'nonlocal' NAME (',' NAME)*
- */
-static int
-validate_nonlocal_stmt(node *tree)
-{
- int j;
- int nch = NCH(tree);
- int res = (validate_ntype(tree, nonlocal_stmt)
- && is_even(nch) && (nch >= 2));
-
- if (!res && !PyErr_Occurred())
- err_string("illegal nonlocal statement");
-
- if (res)
- res = (validate_name(CHILD(tree, 0), "nonlocal")
- && validate_ntype(CHILD(tree, 1), NAME));
- for (j = 2; res && (j < nch); j += 2)
- res = (validate_comma(CHILD(tree, j))
- && validate_ntype(CHILD(tree, j + 1), NAME));
-
- return res;
-}
-
-/* assert_stmt:
- *
- * 'assert' test [',' test]
- */
-static int
-validate_assert_stmt(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, assert_stmt)
- && ((nch == 2) || (nch == 4))
- && (validate_name(CHILD(tree, 0), "assert"))
- && validate_test(CHILD(tree, 1)));
-
- if (!res && !PyErr_Occurred())
- err_string("illegal assert statement");
- if (res && (nch > 2))
- res = (validate_comma(CHILD(tree, 2))
- && validate_test(CHILD(tree, 3)));
-
- return (res);
-}
-
-
-static int
-validate_while(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, while_stmt)
- && ((nch == 4) || (nch == 7))
- && validate_name(CHILD(tree, 0), "while")
- && validate_test(CHILD(tree, 1))
- && validate_colon(CHILD(tree, 2))
- && validate_suite(CHILD(tree, 3)));
-
- if (res && (nch == 7))
- res = (validate_name(CHILD(tree, 4), "else")
- && validate_colon(CHILD(tree, 5))
- && validate_suite(CHILD(tree, 6)));
-
- return (res);
-}
-
-
-static int
-validate_for(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, for_stmt)
- && ((nch == 6) || (nch == 9))
- && validate_name(CHILD(tree, 0), "for")
- && validate_exprlist(CHILD(tree, 1))
- && validate_name(CHILD(tree, 2), "in")
- && validate_testlist(CHILD(tree, 3))
- && validate_colon(CHILD(tree, 4))
- && validate_suite(CHILD(tree, 5)));
-
- if (res && (nch == 9))
- res = (validate_name(CHILD(tree, 6), "else")
- && validate_colon(CHILD(tree, 7))
- && validate_suite(CHILD(tree, 8)));
-
- return (res);
-}
-
-
-/* try_stmt:
- * 'try' ':' suite (except_clause ':' suite)+ ['else' ':' suite]
- ['finally' ':' suite]
- * | 'try' ':' suite 'finally' ':' suite
- *
- */
-static int
-validate_try(node *tree)
-{
- int nch = NCH(tree);
- int pos = 3;
- int res = (validate_ntype(tree, try_stmt)
- && (nch >= 6) && ((nch % 3) == 0));
-
- if (res)
- res = (validate_name(CHILD(tree, 0), "try")
- && validate_colon(CHILD(tree, 1))
- && validate_suite(CHILD(tree, 2))
- && validate_colon(CHILD(tree, nch - 2))
- && validate_suite(CHILD(tree, nch - 1)));
- else if (!PyErr_Occurred()) {
- const char* name = "except";
- if (TYPE(CHILD(tree, nch - 3)) != except_clause)
- name = STR(CHILD(tree, nch - 3));
-
- PyErr_Format(parser_error,
- "Illegal number of children for try/%s node.", name);
- }
- /* Handle try/finally statement */
- if (res && (TYPE(CHILD(tree, pos)) == NAME) &&
- (strcmp(STR(CHILD(tree, pos)), "finally") == 0)) {
- res = (validate_numnodes(tree, 6, "try/finally")
- && validate_colon(CHILD(tree, 4))
- && validate_suite(CHILD(tree, 5)));
- return (res);
- }
- /* try/except statement: skip past except_clause sections */
- while (res && pos < nch && (TYPE(CHILD(tree, pos)) == except_clause)) {
- res = (validate_except_clause(CHILD(tree, pos))
- && validate_colon(CHILD(tree, pos + 1))
- && validate_suite(CHILD(tree, pos + 2)));
- pos += 3;
- }
- /* skip else clause */
- if (res && pos < nch && (TYPE(CHILD(tree, pos)) == NAME) &&
- (strcmp(STR(CHILD(tree, pos)), "else") == 0)) {
- res = (validate_colon(CHILD(tree, pos + 1))
- && validate_suite(CHILD(tree, pos + 2)));
- pos += 3;
- }
- if (res && pos < nch) {
- /* last clause must be a finally */
- res = (validate_name(CHILD(tree, pos), "finally")
- && validate_numnodes(tree, pos + 3, "try/except/finally")
- && validate_colon(CHILD(tree, pos + 1))
- && validate_suite(CHILD(tree, pos + 2)));
- }
- return (res);
-}
-
-
-static int
-validate_except_clause(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, except_clause)
- && ((nch == 1) || (nch == 2) || (nch == 4))
- && validate_name(CHILD(tree, 0), "except"));
-
- if (res && (nch > 1))
- res = validate_test(CHILD(tree, 1));
- if (res && (nch == 4))
- res = (validate_name(CHILD(tree, 2), "as")
- && validate_ntype(CHILD(tree, 3), NAME));
-
- return (res);
-}
-
-
-static int
-validate_test(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_ntype(tree, test) && is_odd(nch);
-
- if (res && (TYPE(CHILD(tree, 0)) == lambdef))
- res = ((nch == 1)
- && validate_lambdef(CHILD(tree, 0)));
- else if (res) {
- res = validate_or_test(CHILD(tree, 0));
- res = (res && (nch == 1 || (nch == 5 &&
- validate_name(CHILD(tree, 1), "if") &&
- validate_or_test(CHILD(tree, 2)) &&
- validate_name(CHILD(tree, 3), "else") &&
- validate_test(CHILD(tree, 4)))));
- }
- return (res);
-}
-
-static int
-validate_test_nocond(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_ntype(tree, test_nocond) && (nch == 1);
-
- if (res && (TYPE(CHILD(tree, 0)) == lambdef_nocond))
- res = (validate_lambdef_nocond(CHILD(tree, 0)));
- else if (res) {
- res = (validate_or_test(CHILD(tree, 0)));
- }
- return (res);
-}
-
-static int
-validate_or_test(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_ntype(tree, or_test) && is_odd(nch);
-
- if (res) {
- int pos;
- res = validate_and_test(CHILD(tree, 0));
- for (pos = 1; res && (pos < nch); pos += 2)
- res = (validate_name(CHILD(tree, pos), "or")
- && validate_and_test(CHILD(tree, pos + 1)));
- }
- return (res);
-}
-
-
-static int
-validate_and_test(node *tree)
-{
- int pos;
- int nch = NCH(tree);
- int res = (validate_ntype(tree, and_test)
- && is_odd(nch)
- && validate_not_test(CHILD(tree, 0)));
-
- for (pos = 1; res && (pos < nch); pos += 2)
- res = (validate_name(CHILD(tree, pos), "and")
- && validate_not_test(CHILD(tree, 0)));
-
- return (res);
-}
-
-
-static int
-validate_not_test(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_ntype(tree, not_test) && ((nch == 1) || (nch == 2));
-
- if (res) {
- if (nch == 2)
- res = (validate_name(CHILD(tree, 0), "not")
- && validate_not_test(CHILD(tree, 1)));
- else if (nch == 1)
- res = validate_comparison(CHILD(tree, 0));
- }
- return (res);
-}
-
-
-static int
-validate_comparison(node *tree)
-{
- int pos;
- int nch = NCH(tree);
- int res = (validate_ntype(tree, comparison)
- && is_odd(nch)
- && validate_expr(CHILD(tree, 0)));
-
- for (pos = 1; res && (pos < nch); pos += 2)
- res = (validate_comp_op(CHILD(tree, pos))
- && validate_expr(CHILD(tree, pos + 1)));
-
- return (res);
-}
-
-
-static int
-validate_comp_op(node *tree)
-{
- int res = 0;
- int nch = NCH(tree);
-
- if (!validate_ntype(tree, comp_op))
- return (0);
- if (nch == 1) {
- /*
- * Only child will be a terminal with a well-defined symbolic name
- * or a NAME with a string of either 'is' or 'in'
- */
- tree = CHILD(tree, 0);
- switch (TYPE(tree)) {
- case LESS:
- case GREATER:
- case EQEQUAL:
- case EQUAL:
- case LESSEQUAL:
- case GREATEREQUAL:
- case NOTEQUAL:
- res = 1;
- break;
- case NAME:
- res = ((strcmp(STR(tree), "in") == 0)
- || (strcmp(STR(tree), "is") == 0));
- if (!res) {
- PyErr_Format(parser_error,
- "illegal operator '%s'", STR(tree));
- }
- break;
- default:
- err_string("illegal comparison operator type");
- break;
- }
- }
- else if ((res = validate_numnodes(tree, 2, "comp_op")) != 0) {
- res = (validate_ntype(CHILD(tree, 0), NAME)
- && validate_ntype(CHILD(tree, 1), NAME)
- && (((strcmp(STR(CHILD(tree, 0)), "is") == 0)
- && (strcmp(STR(CHILD(tree, 1)), "not") == 0))
- || ((strcmp(STR(CHILD(tree, 0)), "not") == 0)
- && (strcmp(STR(CHILD(tree, 1)), "in") == 0))));
- if (!res && !PyErr_Occurred())
- err_string("unknown comparison operator");
- }
- return (res);
-}
-
-
-static int
-validate_star_expr(node *tree)
-{
- int res = validate_ntype(tree, star_expr);
- if (!res) return res;
- if (!validate_numnodes(tree, 2, "star_expr"))
- return 0;
- return validate_ntype(CHILD(tree, 0), STAR) && \
- validate_expr(CHILD(tree, 1));
-}
-
-
-static int
-validate_expr(node *tree)
-{
- int j;
- int nch = NCH(tree);
- int res = (validate_ntype(tree, expr)
- && is_odd(nch)
- && validate_xor_expr(CHILD(tree, 0)));
-
- for (j = 2; res && (j < nch); j += 2)
- res = (validate_xor_expr(CHILD(tree, j))
- && validate_vbar(CHILD(tree, j - 1)));
-
- return (res);
-}
-
-
-static int
-validate_xor_expr(node *tree)
-{
- int j;
- int nch = NCH(tree);
- int res = (validate_ntype(tree, xor_expr)
- && is_odd(nch)
- && validate_and_expr(CHILD(tree, 0)));
-
- for (j = 2; res && (j < nch); j += 2)
- res = (validate_circumflex(CHILD(tree, j - 1))
- && validate_and_expr(CHILD(tree, j)));
-
- return (res);
-}
-
-
-static int
-validate_and_expr(node *tree)
-{
- int pos;
- int nch = NCH(tree);
- int res = (validate_ntype(tree, and_expr)
- && is_odd(nch)
- && validate_shift_expr(CHILD(tree, 0)));
-
- for (pos = 1; res && (pos < nch); pos += 2)
- res = (validate_ampersand(CHILD(tree, pos))
- && validate_shift_expr(CHILD(tree, pos + 1)));
-
- return (res);
-}
-
-
-static int
-validate_chain_two_ops(node *tree, int (*termvalid)(node *), int op1, int op2)
- {
- int pos = 1;
- int nch = NCH(tree);
- int res = (is_odd(nch)
- && (*termvalid)(CHILD(tree, 0)));
-
- for ( ; res && (pos < nch); pos += 2) {
- if (TYPE(CHILD(tree, pos)) != op1)
- res = validate_ntype(CHILD(tree, pos), op2);
- if (res)
- res = (*termvalid)(CHILD(tree, pos + 1));
- }
- return (res);
-}
-
-
-static int
-validate_shift_expr(node *tree)
-{
- return (validate_ntype(tree, shift_expr)
- && validate_chain_two_ops(tree, validate_arith_expr,
- LEFTSHIFT, RIGHTSHIFT));
-}
-
-
-static int
-validate_arith_expr(node *tree)
-{
- return (validate_ntype(tree, arith_expr)
- && validate_chain_two_ops(tree, validate_term, PLUS, MINUS));
-}
-
-
-static int
-validate_term(node *tree)
-{
- int pos = 1;
- int nch = NCH(tree);
- int res = (validate_ntype(tree, term)
- && is_odd(nch)
- && validate_factor(CHILD(tree, 0)));
-
- for ( ; res && (pos < nch); pos += 2)
- res = (((TYPE(CHILD(tree, pos)) == STAR)
- || (TYPE(CHILD(tree, pos)) == SLASH)
- || (TYPE(CHILD(tree, pos)) == DOUBLESLASH)
- || (TYPE(CHILD(tree, pos)) == PERCENT))
- && validate_factor(CHILD(tree, pos + 1)));
-
- return (res);
-}
-
-
-/* factor:
- *
- * factor: ('+'|'-'|'~') factor | power
- */
-static int
-validate_factor(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, factor)
- && (((nch == 2)
- && ((TYPE(CHILD(tree, 0)) == PLUS)
- || (TYPE(CHILD(tree, 0)) == MINUS)
- || (TYPE(CHILD(tree, 0)) == TILDE))
- && validate_factor(CHILD(tree, 1)))
- || ((nch == 1)
- && validate_power(CHILD(tree, 0)))));
- return (res);
-}
-
-
-/* power:
- *
- * power: atom_expr trailer* ['**' factor]
- */
-static int
-validate_power(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, power) && (nch >= 1)
- && validate_atom_expr(CHILD(tree, 0)));
-
- if (nch > 1) {
- if (nch != 3) {
- err_string("illegal number of nodes for 'power'");
- return (0);
- }
- res = (validate_doublestar(CHILD(tree, 1))
- && validate_factor(CHILD(tree, 2)));
- }
-
- return (res);
-}
-
-
-/* atom_expr:
- *
- * atom_expr: [AWAIT] atom trailer*
- */
-static int
-validate_atom_expr(node *tree)
-{
- int start = 0;
- int nch = NCH(tree);
- int res;
- int pos;
-
- res = validate_ntype(tree, atom_expr) && (nch >= 1);
- if (!res) {
- return (res);
- }
-
- if (TYPE(CHILD(tree, 0)) == AWAIT) {
- start = 1;
- if (nch < 2) {
- err_string("illegal number of nodes for 'atom_expr'");
- return (0);
- }
- }
-
- res = validate_atom(CHILD(tree, start));
- if (res) {
- pos = start + 1;
- while (res && (pos < nch) && (TYPE(CHILD(tree, pos)) == trailer))
- res = validate_trailer(CHILD(tree, pos++));
- }
-
- return (res);
-}
-
-
-static int
-validate_atom(node *tree)
-{
- int pos;
- int nch = NCH(tree);
- int res = validate_ntype(tree, atom);
-
- if (res && nch < 1)
- res = validate_numnodes(tree, nch+1, "atom");
- if (res) {
- switch (TYPE(CHILD(tree, 0))) {
- case LPAR:
- res = ((nch <= 3)
- && (validate_rparen(CHILD(tree, nch - 1))));
-
- if (res && (nch == 3)) {
- if (TYPE(CHILD(tree, 1))==yield_expr)
- res = validate_yield_expr(CHILD(tree, 1));
- else
- res = validate_testlist_comp(CHILD(tree, 1));
- }
- break;
- case LSQB:
- if (nch == 2)
- res = validate_ntype(CHILD(tree, 1), RSQB);
- else if (nch == 3)
- res = (validate_testlist_comp(CHILD(tree, 1))
- && validate_ntype(CHILD(tree, 2), RSQB));
- else {
- res = 0;
- err_string("illegal list display atom");
- }
- break;
- case LBRACE:
- res = ((nch <= 3)
- && validate_ntype(CHILD(tree, nch - 1), RBRACE));
-
- if (res && (nch == 3))
- res = validate_dictorsetmaker(CHILD(tree, 1));
- break;
- case NAME:
- case NUMBER:
- case ELLIPSIS:
- res = (nch == 1);
- break;
- case STRING:
- for (pos = 1; res && (pos < nch); ++pos)
- res = validate_ntype(CHILD(tree, pos), STRING);
- break;
- default:
- res = 0;
- break;
- }
- }
- return (res);
-}
-
-
-/* testlist_comp:
- * (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] )
- */
-static int
-validate_testlist_comp(node *tree)
-{
- int nch = NCH(tree);
- int ok;
-
- if (nch == 0) {
- err_string("missing child nodes of testlist_comp");
- return 0;
- }
-
- if (nch == 2 && TYPE(CHILD(tree, 1)) == comp_for) {
- ok = (validate_test(CHILD(tree, 0))
- && validate_comp_for(CHILD(tree, 1)));
- }
- else {
- ok = validate_repeating_list(tree,
- testlist_comp,
- validate_test_or_star_expr,
- "testlist_comp");
- }
- return ok;
-}
-
-/* decorator:
- * '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
- */
-static int
-validate_decorator(node *tree)
-{
- int ok;
- int nch = NCH(tree);
- ok = (validate_ntype(tree, decorator) &&
- (nch == 3 || nch == 5 || nch == 6) &&
- validate_at(CHILD(tree, 0)) &&
- validate_dotted_name(CHILD(tree, 1)) &&
- validate_newline(RCHILD(tree, -1)));
-
- if (ok && nch != 3) {
- ok = (validate_lparen(CHILD(tree, 2)) &&
- validate_rparen(RCHILD(tree, -2)));
-
- if (ok && nch == 6)
- ok = validate_arglist(CHILD(tree, 3));
- }
-
- return ok;
-}
-
-/* decorators:
- * decorator+
- */
-static int
-validate_decorators(node *tree)
-{
- int i, nch, ok;
- nch = NCH(tree);
- ok = validate_ntype(tree, decorators) && nch >= 1;
-
- for (i = 0; ok && i < nch; ++i)
- ok = validate_decorator(CHILD(tree, i));
-
- return ok;
-}
-
-/* with_item:
- * test ['as' expr]
- */
-static int
-validate_with_item(node *tree)
-{
- int nch = NCH(tree);
- int ok = (validate_ntype(tree, with_item)
- && (nch == 1 || nch == 3)
- && validate_test(CHILD(tree, 0)));
- if (ok && nch == 3)
- ok = (validate_name(CHILD(tree, 1), "as")
- && validate_expr(CHILD(tree, 2)));
- return ok;
-}
-
-/* with_stmt:
- * 0 1 ... -2 -1
- * 'with' with_item (',' with_item)* ':' suite
- */
-static int
-validate_with_stmt(node *tree)
-{
- int i;
- int nch = NCH(tree);
- int ok = (validate_ntype(tree, with_stmt)
- && (nch % 2 == 0)
- && validate_name(CHILD(tree, 0), "with")
- && validate_colon(RCHILD(tree, -2))
- && validate_suite(RCHILD(tree, -1)));
- for (i = 1; ok && i < nch - 2; i += 2)
- ok = validate_with_item(CHILD(tree, i));
- return ok;
-}
-
-/* funcdef: 'def' NAME parameters ['->' test] ':' suite */
-
-static int
-validate_funcdef(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_ntype(tree, funcdef);
- if (res) {
- if (nch == 5) {
- res = (validate_name(CHILD(tree, 0), "def")
- && validate_ntype(CHILD(tree, 1), NAME)
- && validate_parameters(CHILD(tree, 2))
- && validate_colon(CHILD(tree, 3))
- && validate_suite(CHILD(tree, 4)));
- }
- else if (nch == 7) {
- res = (validate_name(CHILD(tree, 0), "def")
- && validate_ntype(CHILD(tree, 1), NAME)
- && validate_parameters(CHILD(tree, 2))
- && validate_rarrow(CHILD(tree, 3))
- && validate_test(CHILD(tree, 4))
- && validate_colon(CHILD(tree, 5))
- && validate_suite(CHILD(tree, 6)));
- }
- else {
- res = 0;
- err_string("illegal number of children for funcdef");
- }
- }
- return res;
-}
-
-/* async_funcdef: ASYNC funcdef */
-
-static int
-validate_async_funcdef(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_ntype(tree, async_funcdef);
- if (res) {
- if (nch == 2) {
- res = (validate_ntype(CHILD(tree, 0), ASYNC)
- && validate_funcdef(CHILD(tree, 1)));
- }
- else {
- res = 0;
- err_string("illegal number of children for async_funcdef");
- }
- }
- return res;
-}
-
-
-/* async_stmt: ASYNC (funcdef | with_stmt | for_stmt) */
-
-static int
-validate_async_stmt(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, async_stmt)
- && validate_ntype(CHILD(tree, 0), ASYNC));
-
- if (nch != 2) {
- res = 0;
- err_string("illegal number of children for async_stmt");
- } else {
- if (TYPE(CHILD(tree, 1)) == funcdef) {
- res = validate_funcdef(CHILD(tree, 1));
- }
- else if (TYPE(CHILD(tree, 1)) == with_stmt) {
- res = validate_with_stmt(CHILD(tree, 1));
- }
- else if (TYPE(CHILD(tree, 1)) == for_stmt) {
- res = validate_for(CHILD(tree, 1));
- }
- }
-
- return res;
-}
-
-
-
-/* decorated
- * decorators (classdef | funcdef)
- */
-static int
-validate_decorated(node *tree)
-{
- int nch = NCH(tree);
- int ok = (validate_ntype(tree, decorated)
- && (nch == 2)
- && validate_decorators(RCHILD(tree, -2)));
- if (TYPE(RCHILD(tree, -1)) == funcdef)
- ok = ok && validate_funcdef(RCHILD(tree, -1));
- else
- ok = ok && validate_class(RCHILD(tree, -1));
- return ok;
-}
-
-static int
-validate_lambdef(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, lambdef)
- && ((nch == 3) || (nch == 4))
- && validate_name(CHILD(tree, 0), "lambda")
- && validate_colon(CHILD(tree, nch - 2))
- && validate_test(CHILD(tree, nch - 1)));
-
- if (res && (nch == 4))
- res = validate_varargslist(CHILD(tree, 1));
- else if (!res && !PyErr_Occurred())
- (void) validate_numnodes(tree, 3, "lambdef");
-
- return (res);
-}
-
-
-static int
-validate_lambdef_nocond(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, lambdef_nocond)
- && ((nch == 3) || (nch == 4))
- && validate_name(CHILD(tree, 0), "lambda")
- && validate_colon(CHILD(tree, nch - 2))
- && validate_test(CHILD(tree, nch - 1)));
-
- if (res && (nch == 4))
- res = validate_varargslist(CHILD(tree, 1));
- else if (!res && !PyErr_Occurred())
- (void) validate_numnodes(tree, 3, "lambdef_nocond");
-
- return (res);
-}
-
-
-/* arglist:
- *
- * (argument ',')* (argument [','] | '*' test [',' '**' test] | '**' test)
- */
-static int
-validate_arglist(node *tree)
-{
- int nch = NCH(tree);
- int i = 0;
- int ok = 1;
-
- if (nch <= 0)
- /* raise the right error from having an invalid number of children */
- return validate_numnodes(tree, nch + 1, "arglist");
-
- if (nch > 1) {
- for (i=0; i<nch; i++) {
- if (TYPE(CHILD(tree, i)) == argument) {
- node *ch = CHILD(tree, i);
- if (NCH(ch) == 2 && TYPE(CHILD(ch, 1)) == comp_for) {
- err_string("need '(', ')' for generator expression");
- return 0;
- }
- }
- }
- }
-
- while (ok && nch-i >= 2) {
- /* skip leading (argument ',') */
- ok = (validate_argument(CHILD(tree, i))
- && validate_comma(CHILD(tree, i+1)));
- if (ok)
- i += 2;
- else
- PyErr_Clear();
- }
- ok = 1;
- if (nch-i > 0) {
- int sym = TYPE(CHILD(tree, i));
-
- if (sym == argument) {
- ok = validate_argument(CHILD(tree, i));
- if (ok && i+1 != nch) {
- err_string("illegal arglist specification"
- " (extra stuff on end)");
- ok = 0;
- }
- }
- else {
- err_string("illegal arglist specification");
- ok = 0;
- }
- }
- return (ok);
-}
-
-
-
-/* argument: ( test [comp_for] |
- * test '=' test |
- * '**' test |
- * '*' test )
- */
-static int
-validate_argument(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, argument)
- && ((nch == 1) || (nch == 2) || (nch == 3)));
-
- if (res) {
- if (TYPE(CHILD(tree, 0)) == DOUBLESTAR) {
- res = validate_test(CHILD(tree, 1));
- }
- else if (TYPE(CHILD(tree, 0)) == STAR) {
- res = validate_test(CHILD(tree, 1));
- }
- else if (nch == 1) {
- res = validate_test(CHILD(tree, 0));
- }
- else if (nch == 2) {
- res = (validate_test(CHILD(tree, 0))
- && validate_comp_for(CHILD(tree, 1)));
- }
- else if (res && (nch == 3)) {
- res = (validate_test(CHILD(tree, 0))
- && validate_equal(CHILD(tree, 1))
- && validate_test(CHILD(tree, 2)));
- }
- }
- return (res);
-}
-
-
-
-/* trailer:
- *
- * '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
- */
-static int
-validate_trailer(node *tree)
-{
- int nch = NCH(tree);
- int res = validate_ntype(tree, trailer) && ((nch == 2) || (nch == 3));
-
- if (res) {
- switch (TYPE(CHILD(tree, 0))) {
- case LPAR:
- res = validate_rparen(CHILD(tree, nch - 1));
- if (res && (nch == 3))
- res = validate_arglist(CHILD(tree, 1));
- break;
- case LSQB:
- res = (validate_numnodes(tree, 3, "trailer")
- && validate_subscriptlist(CHILD(tree, 1))
- && validate_ntype(CHILD(tree, 2), RSQB));
- break;
- case DOT:
- res = (validate_numnodes(tree, 2, "trailer")
- && validate_ntype(CHILD(tree, 1), NAME));
- break;
- default:
- res = 0;
- break;
- }
- }
- else {
- (void) validate_numnodes(tree, 2, "trailer");
- }
- return (res);
-}
-
-
-/* subscriptlist:
- *
- * subscript (',' subscript)* [',']
- */
-static int
-validate_subscriptlist(node *tree)
-{
- return (validate_repeating_list(tree, subscriptlist,
- validate_subscript, "subscriptlist"));
-}
-
-
-/* subscript:
- *
- * '.' '.' '.' | test | [test] ':' [test] [sliceop]
- */
-static int
-validate_subscript(node *tree)
-{
- int offset = 0;
- int nch = NCH(tree);
- int res = validate_ntype(tree, subscript) && (nch >= 1) && (nch <= 4);
-
- if (!res) {
- if (!PyErr_Occurred())
- err_string("invalid number of arguments for subscript node");
- return (0);
- }
- if (TYPE(CHILD(tree, 0)) == DOT)
- /* take care of ('.' '.' '.') possibility */
- return (validate_numnodes(tree, 3, "subscript")
- && validate_dot(CHILD(tree, 0))
- && validate_dot(CHILD(tree, 1))
- && validate_dot(CHILD(tree, 2)));
- if (nch == 1) {
- if (TYPE(CHILD(tree, 0)) == test)
- res = validate_test(CHILD(tree, 0));
- else
- res = validate_colon(CHILD(tree, 0));
- return (res);
- }
- /* Must be [test] ':' [test] [sliceop],
- * but at least one of the optional components will
- * be present, but we don't know which yet.
- */
- if ((TYPE(CHILD(tree, 0)) != COLON) || (nch == 4)) {
- res = validate_test(CHILD(tree, 0));
- offset = 1;
- }
- if (res)
- res = validate_colon(CHILD(tree, offset));
- if (res) {
- int rem = nch - ++offset;
- if (rem) {
- if (TYPE(CHILD(tree, offset)) == test) {
- res = validate_test(CHILD(tree, offset));
- ++offset;
- --rem;
- }
- if (res && rem)
- res = validate_sliceop(CHILD(tree, offset));
- }
- }
- return (res);
-}
-
-
-static int
-validate_sliceop(node *tree)
-{
- int nch = NCH(tree);
- int res = ((nch == 1) || validate_numnodes(tree, 2, "sliceop"))
- && validate_ntype(tree, sliceop);
- if (!res && !PyErr_Occurred()) {
- res = validate_numnodes(tree, 1, "sliceop");
- }
- if (res)
- res = validate_colon(CHILD(tree, 0));
- if (res && (nch == 2))
- res = validate_test(CHILD(tree, 1));
-
- return (res);
-}
-
-
-static int
-validate_test_or_star_expr(node *n)
-{
- if (TYPE(n) == test)
- return validate_test(n);
- return validate_star_expr(n);
-}
-
-static int
-validate_expr_or_star_expr(node *n)
-{
- if (TYPE(n) == expr)
- return validate_expr(n);
- return validate_star_expr(n);
-}
-
-
-static int
-validate_exprlist(node *tree)
-{
- return (validate_repeating_list(tree, exprlist,
- validate_expr_or_star_expr, "exprlist"));
-}
-
-/* Incrementing validate functions returns nonzero iff success (like other
- * validate functions, and advance *i by the length of the matched pattern. */
-
-/* test ':' test */
-static int
-validate_test_colon_test_inc(node *tree, int *i)
-{
- return (validate_test(CHILD(tree, (*i)++))
- && validate_colon(CHILD(tree, (*i)++))
- && validate_test(CHILD(tree, (*i)++)));
-}
-
-/* test ':' test | '**' expr */
-static int
-validate_dict_element_inc(node *tree, int *i)
-{
- int nch = NCH(tree);
- int res = 0;
- if (nch - *i >= 2) {
- if (TYPE(CHILD(tree, *i+1)) == COLON) {
- /* test ':' test */
- res = validate_test_colon_test_inc(tree, i);
- } else {
- /* '**' expr */
- res = (validate_doublestar(CHILD(tree, (*i)++))
- && validate_expr(CHILD(tree, (*i)++)));
- }
- }
- return res;
-}
-
-/*
- * dictorsetmaker:
- *
- * ( ((test ':' test | '**' expr)
- * (comp_for | (',' (test ':' test | '**' expr))* [','])) |
- * ((test | '*' test)
- * (comp_for | (',' (test | '*' test))* [','])) )
- */
-static int
-validate_dictorsetmaker(node *tree)
-{
- int nch = NCH(tree);
- int res;
- int i = 0;
-
- res = validate_ntype(tree, dictorsetmaker);
- if (!res)
- return 0;
-
- if (nch - i < 1) {
- /* Unconditionally raise. */
- (void) validate_numnodes(tree, 1, "dictorsetmaker");
- return 0;
- }
-
- if (nch - i >= 2
- && ((TYPE(CHILD(tree, i+1)) == COLON) ||
- (TYPE(CHILD(tree, i)) == DOUBLESTAR))) {
- /* Dictionary display or dictionary comprehension. */
- if (nch - i >= 4 && TYPE(CHILD(tree, i+3)) == comp_for) {
- /* Dictionary comprehension. */
- res = (validate_test_colon_test_inc(tree, &i)
- && validate_comp_for(CHILD(tree, i++)));
- if (!res)
- return 0;
- } else {
- /* Dictionary display. */
- return validate_repeating_list_variable(
- tree,
- dictorsetmaker,
- validate_dict_element_inc,
- &i,
- "dictorsetmaker");
- }
- } else {
- /* Set display or set comprehension. */
- if (nch - i >= 2 && TYPE(CHILD(tree, i + 1)) == comp_for) {
- /* Set comprehension. */
- res = (validate_test(CHILD(tree, i++))
- && validate_comp_for(CHILD(tree, i++)));
- if (!res)
- return 0;
- } else {
- /* Set display. */
- return validate_repeating_list(tree,
- dictorsetmaker,
- validate_test_or_star_expr,
- "dictorsetmaker");
- }
- }
-
- if (nch - i > 0) {
- err_string("Illegal trailing nodes for dictorsetmaker.");
- return 0;
- }
-
- return 1;
-}
-
-
-static int
-validate_eval_input(node *tree)
-{
- int pos;
- int nch = NCH(tree);
- int res = (validate_ntype(tree, eval_input)
- && (nch >= 2)
- && validate_testlist(CHILD(tree, 0))
- && validate_ntype(CHILD(tree, nch - 1), ENDMARKER));
-
- for (pos = 1; res && (pos < (nch - 1)); ++pos)
- res = validate_ntype(CHILD(tree, pos), NEWLINE);
-
- return (res);
-}
-
-
-static int
-validate_node(node *tree)
-{
- int nch = 0; /* num. children on current node */
- int res = 1; /* result value */
- node* next = 0; /* node to process after this one */
-
- while (res && (tree != 0)) {
- nch = NCH(tree);
- next = 0;
- switch (TYPE(tree)) {
- /*
- * Definition nodes.
- */
- case async_funcdef:
- res = validate_async_funcdef(tree);
- break;
- case async_stmt:
- res = validate_async_stmt(tree);
- break;
- case funcdef:
- res = validate_funcdef(tree);
- break;
- case with_stmt:
- res = validate_with_stmt(tree);
- break;
- case classdef:
- res = validate_class(tree);
- break;
- case decorated:
- res = validate_decorated(tree);
- break;
- /*
- * "Trivial" parse tree nodes.
- * (Why did I call these trivial?)
- */
- case stmt:
- res = validate_stmt(tree);
- break;
- case small_stmt:
- /*
- * expr_stmt | del_stmt | pass_stmt | flow_stmt |
- * import_stmt | global_stmt | nonlocal_stmt | assert_stmt
- */
- res = validate_small_stmt(tree);
- break;
- case flow_stmt:
- res = (validate_numnodes(tree, 1, "flow_stmt")
- && ((TYPE(CHILD(tree, 0)) == break_stmt)
- || (TYPE(CHILD(tree, 0)) == continue_stmt)
- || (TYPE(CHILD(tree, 0)) == yield_stmt)
- || (TYPE(CHILD(tree, 0)) == return_stmt)
- || (TYPE(CHILD(tree, 0)) == raise_stmt)));
- if (res)
- next = CHILD(tree, 0);
- else if (nch == 1)
- err_string("illegal flow_stmt type");
- break;
- case yield_stmt:
- res = validate_yield_stmt(tree);
- break;
- /*
- * Compound statements.
- */
- case simple_stmt:
- res = validate_simple_stmt(tree);
- break;
- case compound_stmt:
- res = validate_compound_stmt(tree);
- break;
- /*
- * Fundamental statements.
- */
- case expr_stmt:
- res = validate_expr_stmt(tree);
- break;
- case del_stmt:
- res = validate_del_stmt(tree);
- break;
- case pass_stmt:
- res = (validate_numnodes(tree, 1, "pass")
- && validate_name(CHILD(tree, 0), "pass"));
- break;
- case break_stmt:
- res = (validate_numnodes(tree, 1, "break")
- && validate_name(CHILD(tree, 0), "break"));
- break;
- case continue_stmt:
- res = (validate_numnodes(tree, 1, "continue")
- && validate_name(CHILD(tree, 0), "continue"));
- break;
- case return_stmt:
- res = validate_return_stmt(tree);
- break;
- case raise_stmt:
- res = validate_raise_stmt(tree);
- break;
- case import_stmt:
- res = validate_import_stmt(tree);
- break;
- case import_name:
- res = validate_import_name(tree);
- break;
- case import_from:
- res = validate_import_from(tree);
- break;
- case global_stmt:
- res = validate_global_stmt(tree);
- break;
- case nonlocal_stmt:
- res = validate_nonlocal_stmt(tree);
- break;
- case assert_stmt:
- res = validate_assert_stmt(tree);
- break;
- case if_stmt:
- res = validate_if(tree);
- break;
- case while_stmt:
- res = validate_while(tree);
- break;
- case for_stmt:
- res = validate_for(tree);
- break;
- case try_stmt:
- res = validate_try(tree);
- break;
- case suite:
- res = validate_suite(tree);
- break;
- /*
- * Expression nodes.
- */
- case testlist:
- res = validate_testlist(tree);
- break;
- case yield_expr:
- res = validate_yield_expr(tree);
- break;
- case test:
- res = validate_test(tree);
- break;
- case and_test:
- res = validate_and_test(tree);
- break;
- case not_test:
- res = validate_not_test(tree);
- break;
- case comparison:
- res = validate_comparison(tree);
- break;
- case exprlist:
- res = validate_exprlist(tree);
- break;
- case comp_op:
- res = validate_comp_op(tree);
- break;
- case expr:
- res = validate_expr(tree);
- break;
- case xor_expr:
- res = validate_xor_expr(tree);
- break;
- case and_expr:
- res = validate_and_expr(tree);
- break;
- case shift_expr:
- res = validate_shift_expr(tree);
- break;
- case arith_expr:
- res = validate_arith_expr(tree);
- break;
- case term:
- res = validate_term(tree);
- break;
- case factor:
- res = validate_factor(tree);
- break;
- case power:
- res = validate_power(tree);
- break;
- case atom:
- res = validate_atom(tree);
- break;
-
- default:
- /* Hopefully never reached! */
- err_string("unrecognized node type");
- res = 0;
- break;
- }
- tree = next;
- }
- return (res);
-}
-
-
-static int
-validate_expr_tree(node *tree)
-{
- int res = validate_eval_input(tree);
-
- if (!res && !PyErr_Occurred())
- err_string("could not validate expression tuple");
-
- return (res);
-}
-
-
-/* file_input:
- * (NEWLINE | stmt)* ENDMARKER
- */
-static int
-validate_file_input(node *tree)
-{
- int j;
- int nch = NCH(tree) - 1;
- int res = ((nch >= 0)
- && validate_ntype(CHILD(tree, nch), ENDMARKER));
-
- for (j = 0; res && (j < nch); ++j) {
- if (TYPE(CHILD(tree, j)) == stmt)
- res = validate_stmt(CHILD(tree, j));
- else
- res = validate_newline(CHILD(tree, j));
- }
- /* This stays in to prevent any internal failures from getting to the
- * user. Hopefully, this won't be needed. If a user reports getting
- * this, we have some debugging to do.
- */
- if (!res && !PyErr_Occurred())
- err_string("VALIDATION FAILURE: report this to the maintainer!");
-
- return (res);
-}
-
-static int
-validate_encoding_decl(node *tree)
-{
- int nch = NCH(tree);
- int res = ((nch == 1)
- && validate_file_input(CHILD(tree, 0)));
-
- if (!res && !PyErr_Occurred())
- err_string("Error Parsing encoding_decl");
-
- return res;
-}
-
static PyObject*
pickle_constructor = NULL;
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index e5f58ab..4dc7c49 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -32,6 +32,12 @@
#include "winreparse.h"
#endif
+/* On android API level 21, 'AT_EACCESS' is not declared although
+ * HAVE_FACCESSAT is defined. */
+#ifdef __ANDROID__
+#undef HAVE_FACCESSAT
+#endif
+
#include <stdio.h> /* needed for ctermid() */
#ifdef __cplusplus
@@ -671,21 +677,20 @@
#endif
static int
-_fd_converter(PyObject *o, int *p, const char *allowed)
+_fd_converter(PyObject *o, int *p)
{
int overflow;
long long_value;
PyObject *index = PyNumber_Index(o);
if (index == NULL) {
- PyErr_Format(PyExc_TypeError,
- "argument should be %s, not %.200s",
- allowed, Py_TYPE(o)->tp_name);
return 0;
}
+ assert(PyLong_Check(index));
long_value = PyLong_AsLongAndOverflow(index, &overflow);
Py_DECREF(index);
+ assert(!PyErr_Occurred());
if (overflow > 0 || long_value > INT_MAX) {
PyErr_SetString(PyExc_OverflowError,
"fd is greater than maximum");
@@ -708,7 +713,15 @@
*(int *)p = DEFAULT_DIR_FD;
return 1;
}
- return _fd_converter(o, (int *)p, "integer");
+ else if (PyIndex_Check(o)) {
+ return _fd_converter(o, (int *)p);
+ }
+ else {
+ PyErr_Format(PyExc_TypeError,
+ "argument should be integer or None, not %.200s",
+ Py_TYPE(o)->tp_name);
+ return 0;
+ }
}
@@ -799,8 +812,8 @@
const char *argument_name;
int nullable;
int allow_fd;
- wchar_t *wide;
- char *narrow;
+ const wchar_t *wide;
+ const char *narrow;
int fd;
Py_ssize_t length;
PyObject *object;
@@ -818,11 +831,12 @@
}
static int
-path_converter(PyObject *o, void *p) {
+path_converter(PyObject *o, void *p)
+{
path_t *path = (path_t *)p;
- PyObject *unicode, *bytes;
+ PyObject *bytes;
Py_ssize_t length;
- char *narrow;
+ const char *narrow;
#define FORMAT_EXCEPTION(exc, fmt) \
PyErr_Format(exc, "%s%s" fmt, \
@@ -839,12 +853,7 @@
/* ensure it's always safe to call path_cleanup() */
path->cleanup = NULL;
- if (o == Py_None) {
- if (!path->nullable) {
- FORMAT_EXCEPTION(PyExc_TypeError,
- "can't specify None for %s argument");
- return 0;
- }
+ if ((o == Py_None) && path->nullable) {
path->wide = NULL;
path->narrow = NULL;
path->length = 0;
@@ -853,24 +862,20 @@
return 1;
}
- unicode = PyUnicode_FromObject(o);
- if (unicode) {
+ if (PyUnicode_Check(o)) {
#ifdef MS_WINDOWS
- wchar_t *wide;
+ const wchar_t *wide;
- wide = PyUnicode_AsUnicodeAndSize(unicode, &length);
+ wide = PyUnicode_AsUnicodeAndSize(o, &length);
if (!wide) {
- Py_DECREF(unicode);
return 0;
}
if (length > 32767) {
FORMAT_EXCEPTION(PyExc_ValueError, "%s too long for Windows");
- Py_DECREF(unicode);
return 0;
}
if (wcslen(wide) != length) {
- FORMAT_EXCEPTION(PyExc_ValueError, "embedded null character");
- Py_DECREF(unicode);
+ FORMAT_EXCEPTION(PyExc_ValueError, "embedded null character in %s");
return 0;
}
@@ -879,52 +884,47 @@
path->length = length;
path->object = o;
path->fd = -1;
- path->cleanup = unicode;
- return Py_CLEANUP_SUPPORTED;
+ return 1;
#else
- int converted = PyUnicode_FSConverter(unicode, &bytes);
- Py_DECREF(unicode);
- if (!converted)
- bytes = NULL;
+ if (!PyUnicode_FSConverter(o, &bytes)) {
+ return 0;
+ }
#endif
}
- else {
- PyErr_Clear();
- if (PyObject_CheckBuffer(o))
- bytes = PyBytes_FromObject(o);
- else
- bytes = NULL;
+ else if (PyObject_CheckBuffer(o)) {
+#ifdef MS_WINDOWS
+ if (win32_warn_bytes_api()) {
+ return 0;
+ }
+#endif
+ bytes = PyBytes_FromObject(o);
if (!bytes) {
- PyErr_Clear();
- if (path->allow_fd) {
- int fd;
- int result = _fd_converter(o, &fd,
- "string, bytes or integer");
- if (result) {
- path->wide = NULL;
- path->narrow = NULL;
- path->length = 0;
- path->object = o;
- path->fd = fd;
- return result;
- }
- }
+ return 0;
}
}
-
- if (!bytes) {
- if (!PyErr_Occurred())
- FORMAT_EXCEPTION(PyExc_TypeError, "illegal type for %s parameter");
+ else if (path->allow_fd && PyIndex_Check(o)) {
+ if (!_fd_converter(o, &path->fd)) {
+ return 0;
+ }
+ path->wide = NULL;
+ path->narrow = NULL;
+ path->length = 0;
+ path->object = o;
+ return 1;
+ }
+ else {
+ PyErr_Format(PyExc_TypeError, "%s%s%s should be %s, not %.200s",
+ path->function_name ? path->function_name : "",
+ path->function_name ? ": " : "",
+ path->argument_name ? path->argument_name : "path",
+ path->allow_fd && path->nullable ? "string, bytes, integer or None" :
+ path->allow_fd ? "string, bytes or integer" :
+ path->nullable ? "string, bytes or None" :
+ "string or bytes",
+ Py_TYPE(o)->tp_name);
return 0;
}
-#ifdef MS_WINDOWS
- if (win32_warn_bytes_api()) {
- Py_DECREF(bytes);
- return 0;
- }
-#endif
-
length = PyBytes_GET_SIZE(bytes);
#ifdef MS_WINDOWS
if (length > MAX_PATH-1) {
@@ -951,7 +951,8 @@
}
static void
-argument_unavailable_error(char *function_name, char *argument_name) {
+argument_unavailable_error(const char *function_name, const char *argument_name)
+{
PyErr_Format(PyExc_NotImplementedError,
"%s%s%s unavailable on this platform",
(function_name != NULL) ? function_name : "",
@@ -974,7 +975,8 @@
}
static int
-fd_specified(char *function_name, int fd) {
+fd_specified(const char *function_name, int fd)
+{
if (fd == -1)
return 0;
@@ -983,7 +985,8 @@
}
static int
-follow_symlinks_specified(char *function_name, int follow_symlinks) {
+follow_symlinks_specified(const char *function_name, int follow_symlinks)
+{
if (follow_symlinks)
return 0;
@@ -992,7 +995,8 @@
}
static int
-path_and_dir_fd_invalid(char *function_name, path_t *path, int dir_fd) {
+path_and_dir_fd_invalid(const char *function_name, path_t *path, int dir_fd)
+{
if (!path->narrow && !path->wide && (dir_fd != DEFAULT_DIR_FD)) {
PyErr_Format(PyExc_ValueError,
"%s: can't specify dir_fd without matching path",
@@ -1003,7 +1007,8 @@
}
static int
-dir_fd_and_fd_invalid(char *function_name, int dir_fd, int fd) {
+dir_fd_and_fd_invalid(const char *function_name, int dir_fd, int fd)
+{
if ((dir_fd != DEFAULT_DIR_FD) && (fd != -1)) {
PyErr_Format(PyExc_ValueError,
"%s: can't specify both dir_fd and fd",
@@ -1014,8 +1019,9 @@
}
static int
-fd_and_follow_symlinks_invalid(char *function_name, int fd,
- int follow_symlinks) {
+fd_and_follow_symlinks_invalid(const char *function_name, int fd,
+ int follow_symlinks)
+{
if ((fd > 0) && (!follow_symlinks)) {
PyErr_Format(PyExc_ValueError,
"%s: cannot use fd and follow_symlinks together",
@@ -1026,8 +1032,9 @@
}
static int
-dir_fd_and_follow_symlinks_invalid(char *function_name, int dir_fd,
- int follow_symlinks) {
+dir_fd_and_follow_symlinks_invalid(const char *function_name, int dir_fd,
+ int follow_symlinks)
+{
if ((dir_fd != DEFAULT_DIR_FD) && (!follow_symlinks)) {
PyErr_Format(PyExc_ValueError,
"%s: cannot use dir_fd and follow_symlinks together",
@@ -1159,7 +1166,7 @@
for (e = _wenviron; *e != NULL; e++) {
PyObject *k;
PyObject *v;
- wchar_t *p = wcschr(*e, L'=');
+ const wchar_t *p = wcschr(*e, L'=');
if (p == NULL)
continue;
k = PyUnicode_FromWideChar(*e, (Py_ssize_t)(p-*e));
@@ -1187,7 +1194,7 @@
for (e = environ; *e != NULL; e++) {
PyObject *k;
PyObject *v;
- char *p = strchr(*e, '=');
+ const char *p = strchr(*e, '=');
if (p == NULL)
continue;
k = PyBytes_FromStringAndSize(*e, (int)(p-*e));
@@ -1222,7 +1229,7 @@
#ifdef MS_WINDOWS
static PyObject *
-win32_error(char* function, const char* filename)
+win32_error(const char* function, const char* filename)
{
/* XXX We should pass the function name along in the future.
(winreg.c also wants to pass the function name.)
@@ -1237,7 +1244,7 @@
}
static PyObject *
-win32_error_object(char* function, PyObject* filename)
+win32_error_object(const char* function, PyObject* filename)
{
/* XXX - see win32_error for comments on 'function' */
errno = GetLastError();
@@ -1458,7 +1465,7 @@
if(!buf_size)
return FALSE;
- buf = PyMem_New(wchar_t, buf_size+1);
+ buf = (wchar_t *)PyMem_RawMalloc((buf_size + 1) * sizeof(wchar_t));
if (!buf) {
SetLastError(ERROR_OUTOFMEMORY);
return FALSE;
@@ -1468,12 +1475,12 @@
buf, buf_size, VOLUME_NAME_DOS);
if(!result_length) {
- PyMem_Free(buf);
+ PyMem_RawFree(buf);
return FALSE;
}
if(!CloseHandle(hdl)) {
- PyMem_Free(buf);
+ PyMem_RawFree(buf);
return FALSE;
}
@@ -1558,7 +1565,7 @@
return -1;
code = win32_xstat_impl_w(target_path, result, FALSE);
- PyMem_Free(target_path);
+ PyMem_RawFree(target_path);
return code;
}
} else
@@ -1648,7 +1655,7 @@
return -1;
code = win32_xstat_impl_w(target_path, result, FALSE);
- PyMem_Free(target_path);
+ PyMem_RawFree(target_path);
return code;
}
} else
@@ -2102,7 +2109,7 @@
static PyObject *
-posix_do_stat(char *function_name, path_t *path,
+posix_do_stat(const char *function_name, path_t *path,
int dir_fd, int follow_symlinks)
{
STRUCT_STAT st;
@@ -3315,12 +3322,22 @@
Py_BEGIN_ALLOW_THREADS
do {
buflen += chunk;
+#ifdef MS_WINDOWS
+ if (buflen > INT_MAX) {
+ PyErr_NoMemory();
+ break;
+ }
+#endif
tmpbuf = PyMem_RawRealloc(buf, buflen);
if (tmpbuf == NULL)
break;
buf = tmpbuf;
+#ifdef MS_WINDOWS
+ cwd = getcwd(buf, (int)buflen);
+#else
cwd = getcwd(buf, buflen);
+#endif
} while (cwd == NULL && errno == ERANGE);
Py_END_ALLOW_THREADS
@@ -3462,15 +3479,13 @@
BOOL result;
WIN32_FIND_DATA FileData;
char namebuf[MAX_PATH+4]; /* Overallocate for "\*.*" */
- char *bufptr = namebuf;
/* only claim to have space for MAX_PATH */
Py_ssize_t len = Py_ARRAY_LENGTH(namebuf)-4;
- PyObject *po = NULL;
wchar_t *wnamebuf = NULL;
if (!path->narrow) {
WIN32_FIND_DATAW wFileData;
- wchar_t *po_wchars;
+ const wchar_t *po_wchars;
if (!path->wide) { /* Default arg: "." */
po_wchars = L".";
@@ -3636,7 +3651,7 @@
else
#endif
{
- char *name;
+ const char *name;
if (path->narrow) {
name = path->narrow;
/* only return bytes if they specified a bytes object */
@@ -3818,7 +3833,7 @@
wchar_t *target_path;
int result_length;
PyObject *result;
- wchar_t *path_wchar;
+ const wchar_t *path_wchar;
path_wchar = PyUnicode_AsUnicode(path);
if (path_wchar == NULL)
@@ -3907,7 +3922,8 @@
/*[clinic end generated code: output=79a0ba729f956dbe input=7eacadc40acbda6b]*/
{
PyObject *result;
- wchar_t *path_wchar, *mountpath=NULL;
+ const wchar_t *path_wchar;
+ wchar_t *mountpath=NULL;
size_t buflen;
BOOL ret;
@@ -4105,7 +4121,7 @@
static PyObject *
internal_rename(path_t *src, path_t *dst, int src_dir_fd, int dst_dir_fd, int is_replace)
{
- char *function_name = is_replace ? "replace" : "rename";
+ const char *function_name = is_replace ? "replace" : "rename";
int dir_fd_specified;
#ifdef MS_WINDOWS
@@ -4285,7 +4301,7 @@
/*[clinic end generated code: output=800f775e10b7be55 input=86a58554ba6094af]*/
{
long result;
- char *bytes = PyBytes_AsString(command);
+ const char *bytes = PyBytes_AsString(command);
Py_BEGIN_ALLOW_THREADS
result = system(bytes);
Py_END_ALLOW_THREADS
@@ -4565,7 +4581,7 @@
#if defined(HAVE_FUTIMESAT) || defined(HAVE_UTIMENSAT)
static int
-utime_dir_fd(utime_t *ut, int dir_fd, char *path, int follow_symlinks)
+utime_dir_fd(utime_t *ut, int dir_fd, const char *path, int follow_symlinks)
{
#ifdef HAVE_UTIMENSAT
int flags = follow_symlinks ? 0 : AT_SYMLINK_NOFOLLOW;
@@ -4607,14 +4623,14 @@
#define PATH_UTIME_HAVE_FD 0
#endif
+#if defined(HAVE_UTIMENSAT) || defined(HAVE_LUTIMES)
+# define UTIME_HAVE_NOFOLLOW_SYMLINKS
+#endif
-#define UTIME_HAVE_NOFOLLOW_SYMLINKS \
- (defined(HAVE_UTIMENSAT) || defined(HAVE_LUTIMES))
-
-#if UTIME_HAVE_NOFOLLOW_SYMLINKS
+#ifdef UTIME_HAVE_NOFOLLOW_SYMLINKS
static int
-utime_nofollow_symlinks(utime_t *ut, char *path)
+utime_nofollow_symlinks(utime_t *ut, const char *path)
{
#ifdef HAVE_UTIMENSAT
UTIME_TO_TIMESPEC;
@@ -4630,7 +4646,7 @@
#ifndef MS_WINDOWS
static int
-utime_default(utime_t *ut, char *path)
+utime_default(utime_t *ut, const char *path)
{
#ifdef HAVE_UTIMENSAT
UTIME_TO_TIMESPEC;
@@ -4773,7 +4789,7 @@
utime.now = 1;
}
-#if !UTIME_HAVE_NOFOLLOW_SYMLINKS
+#if !defined(UTIME_HAVE_NOFOLLOW_SYMLINKS)
if (follow_symlinks_specified("utime", follow_symlinks))
goto exit;
#endif
@@ -4827,7 +4843,7 @@
#else /* MS_WINDOWS */
Py_BEGIN_ALLOW_THREADS
-#if UTIME_HAVE_NOFOLLOW_SYMLINKS
+#ifdef UTIME_HAVE_NOFOLLOW_SYMLINKS
if ((!follow_symlinks) && (dir_fd == DEFAULT_DIR_FD))
result = utime_nofollow_symlinks(&utime, path->narrow);
else
@@ -4924,7 +4940,8 @@
Py_ssize_t i, pos, envc;
PyObject *keys=NULL, *vals=NULL;
PyObject *key, *val, *key2, *val2;
- char *p, *k, *v;
+ char *p;
+ const char *k, *v;
size_t len;
i = PyMapping_Size(env);
@@ -5039,7 +5056,7 @@
os_execv_impl(PyModuleDef *module, PyObject *path, PyObject *argv)
/*[clinic end generated code: output=9221f08143146fff input=96041559925e5229]*/
{
- char *path_char;
+ const char *path_char;
char **argvlist;
Py_ssize_t argc;
@@ -5160,7 +5177,7 @@
os_spawnv_impl(PyModuleDef *module, int mode, PyObject *path, PyObject *argv)
/*[clinic end generated code: output=140a7945484c8cc5 input=042c91dfc1e6debc]*/
{
- char *path_char;
+ const char *path_char;
char **argvlist;
int i;
Py_ssize_t argc;
@@ -5238,7 +5255,7 @@
PyObject *argv, PyObject *env)
/*[clinic end generated code: output=e7f5f0703610531f input=02362fd937963f8f]*/
{
- char *path_char;
+ const char *path_char;
char **argvlist;
char **envlist;
PyObject *res = NULL;
@@ -5758,14 +5775,14 @@
pid: pid_t
/
-Return the affinity of the process identified by pid.
+Return the affinity of the process identified by pid (or the current process if zero).
The affinity is returned as a set of CPU identifiers.
[clinic start generated code]*/
static PyObject *
os_sched_getaffinity_impl(PyModuleDef *module, pid_t pid)
-/*[clinic end generated code: output=b431a8f310e369e7 input=eaf161936874b8a1]*/
+/*[clinic end generated code: output=b431a8f310e369e7 input=983ce7cb4a565980]*/
{
int cpu, ncpus, count;
size_t setsize;
@@ -5926,7 +5943,7 @@
if (_Py_set_inheritable(master_fd, 0, NULL) < 0)
goto posix_error;
-#if !defined(__CYGWIN__) && !defined(HAVE_DEV_PTC)
+#if !defined(__CYGWIN__) && !defined(__ANDROID__) && !defined(HAVE_DEV_PTC)
ioctl(slave_fd, I_PUSH, "ptem"); /* push ptem */
ioctl(slave_fd, I_PUSH, "ldterm"); /* push ldterm */
#ifndef __hpux
@@ -6251,7 +6268,7 @@
posix_initgroups(PyObject *self, PyObject *args)
{
PyObject *oname;
- char *username;
+ const char *username;
int res;
#ifdef __APPLE__
int gid;
@@ -7125,16 +7142,16 @@
static PyObject *
win_readlink(PyObject *self, PyObject *args, PyObject *kwargs)
{
- wchar_t *path;
+ const wchar_t *path;
DWORD n_bytes_returned;
DWORD io_result;
PyObject *po, *result;
- int dir_fd;
+ int dir_fd;
HANDLE reparse_point_handle;
char target_buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
REPARSE_DATA_BUFFER *rdb = (REPARSE_DATA_BUFFER *)target_buffer;
- wchar_t *print_name;
+ const wchar_t *print_name;
static char *keywords[] = {"path", "dir_fd", NULL};
@@ -7202,8 +7219,8 @@
#if defined(MS_WINDOWS)
/* Grab CreateSymbolicLinkW dynamically from kernel32 */
-static DWORD (CALLBACK *Py_CreateSymbolicLinkW)(LPWSTR, LPWSTR, DWORD) = NULL;
-static DWORD (CALLBACK *Py_CreateSymbolicLinkA)(LPSTR, LPSTR, DWORD) = NULL;
+static DWORD (CALLBACK *Py_CreateSymbolicLinkW)(LPCWSTR, LPCWSTR, DWORD) = NULL;
+static DWORD (CALLBACK *Py_CreateSymbolicLinkA)(LPCSTR, LPCSTR, DWORD) = NULL;
static int
check_CreateSymbolicLink(void)
@@ -7308,7 +7325,7 @@
/* Return True if the path at src relative to dest is a directory */
static int
-_check_dirW(WCHAR *src, WCHAR *dest)
+_check_dirW(LPCWSTR src, LPCWSTR dest)
{
WIN32_FILE_ATTRIBUTE_DATA src_info;
WCHAR dest_parent[MAX_PATH];
@@ -7327,7 +7344,7 @@
/* Return True if the path at src relative to dest is a directory */
static int
-_check_dirA(char *src, char *dest)
+_check_dirA(LPCSTR src, LPCSTR dest)
{
WIN32_FILE_ATTRIBUTE_DATA src_info;
char dest_parent[MAX_PATH];
@@ -9017,7 +9034,7 @@
os_putenv_impl(PyModuleDef *module, PyObject *name, PyObject *value)
/*[clinic end generated code: output=a2438cf95e5a0c1c input=ba586581c2e6105f]*/
{
- wchar_t *env;
+ const wchar_t *env;
PyObject *unicode = PyUnicode_FromFormat("%U=%U", name, value);
if (unicode == NULL) {
@@ -9063,8 +9080,8 @@
{
PyObject *bytes = NULL;
char *env;
- char *name_string = PyBytes_AsString(name);
- char *value_string = PyBytes_AsString(value);
+ const char *name_string = PyBytes_AsString(name);
+ const char *value_string = PyBytes_AsString(value);
bytes = PyBytes_FromFormat("%s=%s", name_string, value_string);
if (bytes == NULL) {
@@ -9483,8 +9500,8 @@
* sufficiently pervasive that it's not worth the loss of readability.
*/
struct constdef {
- char *name;
- long value;
+ const char *name;
+ int value;
};
static int
@@ -9492,7 +9509,10 @@
size_t tablesize)
{
if (PyLong_Check(arg)) {
- *valuep = PyLong_AS_LONG(arg);
+ int value = _PyLong_AsInt(arg);
+ if (value == -1 && PyErr_Occurred())
+ return 0;
+ *valuep = value;
return 1;
}
else {
@@ -10453,7 +10473,7 @@
static int
setup_confname_table(struct constdef *table, size_t tablesize,
- char *tablename, PyObject *module)
+ const char *tablename, PyObject *module)
{
PyObject *d = NULL;
size_t i;
@@ -10580,9 +10600,9 @@
win32_startfile(PyObject *self, PyObject *args)
{
PyObject *ofilepath;
- char *filepath;
- char *operation = NULL;
- wchar_t *wpath, *woperation;
+ const char *filepath;
+ const char *operation = NULL;
+ const wchar_t *wpath, *woperation;
HINSTANCE rc;
PyObject *unipath, *uoperation = NULL;
@@ -10823,7 +10843,7 @@
for (i = 0; ; i++) {
void *ptr;
ssize_t result;
- static Py_ssize_t buffer_sizes[] = {128, XATTR_SIZE_MAX, 0};
+ static const Py_ssize_t buffer_sizes[] = {128, XATTR_SIZE_MAX, 0};
Py_ssize_t buffer_size = buffer_sizes[i];
if (!buffer_size) {
path_error(path);
@@ -10987,9 +11007,9 @@
name = path->narrow ? path->narrow : ".";
for (i = 0; ; i++) {
- char *start, *trace, *end;
+ const char *start, *trace, *end;
ssize_t length;
- static Py_ssize_t buffer_sizes[] = { 256, XATTR_LIST_MAX, 0 };
+ static const Py_ssize_t buffer_sizes[] = { 256, XATTR_LIST_MAX, 0 };
Py_ssize_t buffer_size = buffer_sizes[i];
if (!buffer_size) {
/* ERANGE */
@@ -11201,11 +11221,15 @@
os.cpu_count
Return the number of CPUs in the system; return None if indeterminable.
+
+This number is not equivalent to the number of CPUs the current process can
+use. The number of usable CPUs can be obtained with
+``len(os.sched_getaffinity(0))``
[clinic start generated code]*/
static PyObject *
os_cpu_count_impl(PyModuleDef *module)
-/*[clinic end generated code: output=c59ee7f6bce832b8 input=d55e2f8f3823a628]*/
+/*[clinic end generated code: output=c59ee7f6bce832b8 input=e7c8f4ba6dbbadd3]*/
{
int ncpu = 0;
#ifdef MS_WINDOWS
@@ -11462,7 +11486,7 @@
struct _Py_stat_struct st;
#ifdef MS_WINDOWS
- wchar_t *path;
+ const wchar_t *path;
path = PyUnicode_AsUnicode(self->path);
if (!path)
@@ -11479,7 +11503,7 @@
}
#else /* POSIX */
PyObject *bytes;
- char *path;
+ const char *path;
if (!PyUnicode_FSConverter(self->path, &bytes))
return NULL;
@@ -11663,7 +11687,7 @@
{
#ifdef MS_WINDOWS
if (!self->got_file_index) {
- wchar_t *path;
+ const wchar_t *path;
struct _Py_stat_struct stat;
path = PyUnicode_AsUnicode(self->path);
@@ -11694,6 +11718,13 @@
return PyUnicode_FromFormat("<DirEntry %R>", self->name);
}
+static PyObject *
+DirEntry_fspath(DirEntry *self)
+{
+ Py_INCREF(self->path);
+ return self->path;
+}
+
static PyMemberDef DirEntry_members[] = {
{"name", T_OBJECT_EX, offsetof(DirEntry, name), READONLY,
"the entry's base filename, relative to scandir() \"path\" argument"},
@@ -11718,6 +11749,9 @@
{"inode", (PyCFunction)DirEntry_inode, METH_NOARGS,
"return inode of the entry; cached per entry",
},
+ {"__fspath__", (PyCFunction)DirEntry_fspath, METH_NOARGS,
+ "returns the path for the entry",
+ },
{NULL}
};
@@ -11757,7 +11791,7 @@
#ifdef MS_WINDOWS
static wchar_t *
-join_path_filenameW(wchar_t *path_wide, wchar_t* filename)
+join_path_filenameW(const wchar_t *path_wide, const wchar_t *filename)
{
Py_ssize_t path_len;
Py_ssize_t size;
@@ -11832,7 +11866,7 @@
#else /* POSIX */
static char *
-join_path_filename(char *path_narrow, char* filename, Py_ssize_t filename_len)
+join_path_filename(const char *path_narrow, const char* filename, Py_ssize_t filename_len)
{
Py_ssize_t path_len;
Py_ssize_t size;
@@ -11864,7 +11898,7 @@
}
static PyObject *
-DirEntry_from_posix_info(path_t *path, char *name, Py_ssize_t name_len,
+DirEntry_from_posix_info(path_t *path, const char *name, Py_ssize_t name_len,
ino_t d_ino
#ifdef HAVE_DIRENT_D_TYPE
, unsigned char d_type
@@ -11927,8 +11961,14 @@
#ifdef MS_WINDOWS
+static int
+ScandirIterator_is_closed(ScandirIterator *iterator)
+{
+ return iterator->handle == INVALID_HANDLE_VALUE;
+}
+
static void
-ScandirIterator_close(ScandirIterator *iterator)
+ScandirIterator_closedir(ScandirIterator *iterator)
{
HANDLE handle = iterator->handle;
@@ -11948,7 +11988,7 @@
BOOL success;
PyObject *entry;
- /* Happens if the iterator is iterated twice */
+ /* Happens if the iterator is iterated twice, or closed explicitly */
if (iterator->handle == INVALID_HANDLE_VALUE)
return NULL;
@@ -11979,14 +12019,20 @@
}
/* Error or no more files */
- ScandirIterator_close(iterator);
+ ScandirIterator_closedir(iterator);
return NULL;
}
#else /* POSIX */
+static int
+ScandirIterator_is_closed(ScandirIterator *iterator)
+{
+ return !iterator->dirp;
+}
+
static void
-ScandirIterator_close(ScandirIterator *iterator)
+ScandirIterator_closedir(ScandirIterator *iterator)
{
DIR *dirp = iterator->dirp;
@@ -12008,7 +12054,7 @@
int is_dot;
PyObject *entry;
- /* Happens if the iterator is iterated twice */
+ /* Happens if the iterator is iterated twice, or closed explicitly */
if (!iterator->dirp)
return NULL;
@@ -12045,21 +12091,76 @@
}
/* Error or no more files */
- ScandirIterator_close(iterator);
+ ScandirIterator_closedir(iterator);
return NULL;
}
#endif
+static PyObject *
+ScandirIterator_close(ScandirIterator *self, PyObject *args)
+{
+ ScandirIterator_closedir(self);
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+ScandirIterator_enter(PyObject *self, PyObject *args)
+{
+ Py_INCREF(self);
+ return self;
+}
+
+static PyObject *
+ScandirIterator_exit(ScandirIterator *self, PyObject *args)
+{
+ ScandirIterator_closedir(self);
+ Py_RETURN_NONE;
+}
+
+static void
+ScandirIterator_finalize(ScandirIterator *iterator)
+{
+ PyObject *error_type, *error_value, *error_traceback;
+
+ /* Save the current exception, if any. */
+ PyErr_Fetch(&error_type, &error_value, &error_traceback);
+
+ if (!ScandirIterator_is_closed(iterator)) {
+ ScandirIterator_closedir(iterator);
+
+ if (PyErr_ResourceWarning((PyObject *)iterator, 1,
+ "unclosed scandir iterator %R", iterator)) {
+ /* Spurious errors can appear at shutdown */
+ if (PyErr_ExceptionMatches(PyExc_Warning)) {
+ PyErr_WriteUnraisable((PyObject *) iterator);
+ }
+ }
+ }
+
+ Py_CLEAR(iterator->path.object);
+ path_cleanup(&iterator->path);
+
+ /* Restore the saved exception. */
+ PyErr_Restore(error_type, error_value, error_traceback);
+}
+
static void
ScandirIterator_dealloc(ScandirIterator *iterator)
{
- ScandirIterator_close(iterator);
- Py_XDECREF(iterator->path.object);
- path_cleanup(&iterator->path);
+ if (PyObject_CallFinalizerFromDealloc((PyObject *)iterator) < 0)
+ return;
+
Py_TYPE(iterator)->tp_free((PyObject *)iterator);
}
+static PyMethodDef ScandirIterator_methods[] = {
+ {"__enter__", (PyCFunction)ScandirIterator_enter, METH_NOARGS},
+ {"__exit__", (PyCFunction)ScandirIterator_exit, METH_VARARGS},
+ {"close", (PyCFunction)ScandirIterator_close, METH_NOARGS},
+ {NULL}
+};
+
static PyTypeObject ScandirIteratorType = {
PyVarObject_HEAD_INIT(NULL, 0)
MODNAME ".ScandirIterator", /* tp_name */
@@ -12081,7 +12182,8 @@
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
+ Py_TPFLAGS_DEFAULT
+ | Py_TPFLAGS_HAVE_FINALIZE, /* tp_flags */
0, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
@@ -12089,6 +12191,27 @@
0, /* tp_weaklistoffset */
PyObject_SelfIter, /* tp_iter */
(iternextfunc)ScandirIterator_iternext, /* tp_iternext */
+ ScandirIterator_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+ 0, /* tp_free */
+ 0, /* tp_is_gc */
+ 0, /* tp_bases */
+ 0, /* tp_mro */
+ 0, /* tp_cache */
+ 0, /* tp_subclasses */
+ 0, /* tp_weaklist */
+ 0, /* tp_del */
+ 0, /* tp_version_tag */
+ (destructor)ScandirIterator_finalize, /* tp_finalize */
};
static PyObject *
@@ -12099,7 +12222,7 @@
#ifdef MS_WINDOWS
wchar_t *path_strW;
#else
- char *path;
+ const char *path;
#endif
iterator = PyObject_New(ScandirIterator, &ScandirIteratorType);
@@ -12171,6 +12294,65 @@
return NULL;
}
+/*
+ Return the file system path representation of the object.
+
+ If the object is str or bytes, then allow it to pass through with
+ an incremented refcount. If the object defines __fspath__(), then
+ return the result of that method. All other types raise a TypeError.
+*/
+PyObject *
+PyOS_FSPath(PyObject *path)
+{
+ _Py_IDENTIFIER(__fspath__);
+ PyObject *func = NULL;
+ PyObject *path_repr = NULL;
+
+ if (PyUnicode_Check(path) || PyBytes_Check(path)) {
+ Py_INCREF(path);
+ return path;
+ }
+
+ func = _PyObject_LookupSpecial(path, &PyId___fspath__);
+ if (NULL == func) {
+ return PyErr_Format(PyExc_TypeError,
+ "expected str, bytes or os.PathLike object, "
+ "not %.200s",
+ Py_TYPE(path)->tp_name);
+ }
+
+ path_repr = PyObject_CallFunctionObjArgs(func, NULL);
+ Py_DECREF(func);
+ if (!(PyUnicode_Check(path_repr) || PyBytes_Check(path_repr))) {
+ PyErr_Format(PyExc_TypeError,
+ "expected %.200s.__fspath__() to return str or bytes, "
+ "not %.200s", Py_TYPE(path)->tp_name,
+ Py_TYPE(path_repr)->tp_name);
+ Py_DECREF(path_repr);
+ return NULL;
+ }
+
+ return path_repr;
+}
+
+/*[clinic input]
+os.fspath
+
+ path: object
+
+Return the file system path representation of the object.
+
+If the object is str or bytes, then allow it to pass through as-is. If the
+object defines __fspath__(), then return the result of that method. All other
+types raise a TypeError.
+[clinic start generated code]*/
+
+static PyObject *
+os_fspath_impl(PyModuleDef *module, PyObject *path)
+/*[clinic end generated code: output=51ef0c2772c1932a input=e357165f7b22490f]*/
+{
+ return PyOS_FSPath(path);
+}
#include "clinic/posixmodule.c.h"
@@ -12371,6 +12553,7 @@
{"scandir", (PyCFunction)posix_scandir,
METH_VARARGS | METH_KEYWORDS,
posix_scandir__doc__},
+ OS_FSPATH_METHODDEF
{NULL, NULL} /* Sentinel */
};
@@ -12382,7 +12565,6 @@
HANDLE tok;
TOKEN_PRIVILEGES tok_priv;
LUID luid;
- int meth_idx = 0;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &tok))
return 0;
@@ -12485,12 +12667,14 @@
#ifdef O_LARGEFILE
if (PyModule_AddIntMacro(m, O_LARGEFILE)) return -1;
#endif
+#ifndef __GNU__
#ifdef O_SHLOCK
if (PyModule_AddIntMacro(m, O_SHLOCK)) return -1;
#endif
#ifdef O_EXLOCK
if (PyModule_AddIntMacro(m, O_EXLOCK)) return -1;
#endif
+#endif
#ifdef O_EXEC
if (PyModule_AddIntMacro(m, O_EXEC)) return -1;
#endif
@@ -12787,25 +12971,25 @@
if (PyModule_AddIntMacro(m, XATTR_SIZE_MAX)) return -1;
#endif
-#ifdef RTLD_LAZY
+#if HAVE_DECL_RTLD_LAZY
if (PyModule_AddIntMacro(m, RTLD_LAZY)) return -1;
#endif
-#ifdef RTLD_NOW
+#if HAVE_DECL_RTLD_NOW
if (PyModule_AddIntMacro(m, RTLD_NOW)) return -1;
#endif
-#ifdef RTLD_GLOBAL
+#if HAVE_DECL_RTLD_GLOBAL
if (PyModule_AddIntMacro(m, RTLD_GLOBAL)) return -1;
#endif
-#ifdef RTLD_LOCAL
+#if HAVE_DECL_RTLD_LOCAL
if (PyModule_AddIntMacro(m, RTLD_LOCAL)) return -1;
#endif
-#ifdef RTLD_NODELETE
+#if HAVE_DECL_RTLD_NODELETE
if (PyModule_AddIntMacro(m, RTLD_NODELETE)) return -1;
#endif
-#ifdef RTLD_NOLOAD
+#if HAVE_DECL_RTLD_NOLOAD
if (PyModule_AddIntMacro(m, RTLD_NOLOAD)) return -1;
#endif
-#ifdef RTLD_DEEPBIND
+#if HAVE_DECL_RTLD_DEEPBIND
if (PyModule_AddIntMacro(m, RTLD_DEEPBIND)) return -1;
#endif
@@ -12826,7 +13010,7 @@
};
-static char *have_functions[] = {
+static const char * const have_functions[] = {
#ifdef HAVE_FACCESSAT
"HAVE_FACCESSAT",
@@ -12961,7 +13145,7 @@
{
PyObject *m, *v;
PyObject *list;
- char **trace;
+ const char * const *trace;
#if defined(HAVE_SYMLINK) && defined(MS_WINDOWS)
win32_can_symlink = enable_symlink();
@@ -13136,6 +13320,7 @@
Py_DECREF(unicode);
}
PyModule_AddObject(m, "_have_functions", list);
+ PyModule_AddObject(m, "DirEntry", (PyObject *)&DirEntryType);
initialized = 1;
diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c
index 281c30b..61be3b2 100644
--- a/Modules/pwdmodule.c
+++ b/Modules/pwdmodule.c
@@ -75,10 +75,18 @@
#define SETS(i,val) sets(v, i, val)
SETS(setIndex++, p->pw_name);
+#if defined(HAVE_STRUCT_PASSWD_PW_PASSWD) && !defined(__ANDROID__)
SETS(setIndex++, p->pw_passwd);
+#else
+ SETS(setIndex++, "");
+#endif
PyStructSequence_SET_ITEM(v, setIndex++, _PyLong_FromUid(p->pw_uid));
PyStructSequence_SET_ITEM(v, setIndex++, _PyLong_FromGid(p->pw_gid));
+#if defined(HAVE_STRUCT_PASSWD_PW_GECOS)
SETS(setIndex++, p->pw_gecos);
+#else
+ SETS(setIndex++, "");
+#endif
SETS(setIndex++, p->pw_dir);
SETS(setIndex++, p->pw_shell);
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index 9a6da73..2dafbb0 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -91,7 +91,7 @@
* false on an exception.
*/
static int
-set_error_attr(PyObject *err, char *name, int value)
+set_error_attr(PyObject *err, const char *name, int value)
{
PyObject *v = PyLong_FromLong(value);
@@ -218,7 +218,7 @@
}
static PyObject*
-call_with_frame(char *funcname, int lineno, PyObject* func, PyObject* args,
+call_with_frame(const char *funcname, int lineno, PyObject* func, PyObject* args,
xmlparseobject *self)
{
PyObject *res;
@@ -747,7 +747,8 @@
s += MAX_CHUNK_SIZE;
slen -= MAX_CHUNK_SIZE;
}
- assert(MAX_CHUNK_SIZE < INT_MAX && slen < INT_MAX);
+ Py_BUILD_ASSERT(MAX_CHUNK_SIZE <= INT_MAX);
+ assert(slen <= INT_MAX);
rc = XML_Parse(self->itself, s, (int)slen, isfinal);
done:
@@ -765,7 +766,7 @@
{
PyObject *str;
Py_ssize_t len;
- char *ptr;
+ const char *ptr;
str = PyObject_CallFunction(meth, "n", buf_size);
if (str == NULL)
@@ -1225,12 +1226,8 @@
self->itself = NULL;
if (self->handlers != NULL) {
- PyObject *temp;
- for (i = 0; handler_info[i].name != NULL; i++) {
- temp = self->handlers[i];
- self->handlers[i] = NULL;
- Py_XDECREF(temp);
- }
+ for (i = 0; handler_info[i].name != NULL; i++)
+ Py_CLEAR(self->handlers[i]);
PyMem_Free(self->handlers);
self->handlers = NULL;
}
@@ -1344,7 +1341,6 @@
int handlernum = handlername2int(name);
if (handlernum >= 0) {
xmlhandler c_handler = NULL;
- PyObject *temp = self->handlers[handlernum];
if (v == Py_None) {
/* If this is the character data handler, and a character
@@ -1366,8 +1362,7 @@
Py_INCREF(v);
c_handler = handler_info[handlernum].handler;
}
- self->handlers[handlernum] = v;
- Py_XDECREF(temp);
+ Py_XSETREF(self->handlers[handlernum], v);
handler_info[handlernum].setter(self->itself, c_handler);
return 1;
}
@@ -1897,15 +1892,12 @@
clear_handlers(xmlparseobject *self, int initial)
{
int i = 0;
- PyObject *temp;
for (; handler_info[i].name != NULL; i++) {
if (initial)
self->handlers[i] = NULL;
else {
- temp = self->handlers[i];
- self->handlers[i] = NULL;
- Py_XDECREF(temp);
+ Py_CLEAR(self->handlers[i]);
handler_info[i].setter(self->itself, NULL);
}
}
diff --git a/Modules/readline.c b/Modules/readline.c
index 91f7cca..f8876e0 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -343,10 +343,8 @@
Py_CLEAR(*hook_var);
}
else if (PyCallable_Check(function)) {
- PyObject *tmp = *hook_var;
Py_INCREF(function);
- *hook_var = function;
- Py_XDECREF(tmp);
+ Py_XSETREF(*hook_var, function);
}
else {
PyErr_Format(PyExc_TypeError,
@@ -604,6 +602,24 @@
"add_history(string) -> None\n\
add an item to the history buffer");
+static int should_auto_add_history = 1;
+
+/* Enable or disable automatic history */
+
+static PyObject *
+py_set_auto_history(PyObject *self, PyObject *args)
+{
+ if (!PyArg_ParseTuple(args, "p:set_auto_history",
+ &should_auto_add_history)) {
+ return NULL;
+ }
+ Py_RETURN_NONE;
+}
+
+PyDoc_STRVAR(doc_set_auto_history,
+"set_auto_history(enabled) -> None\n\
+Enables or disables automatic history.");
+
/* Get the tab-completion word-delimiters that readline uses */
@@ -822,6 +838,7 @@
{"set_completer_delims", set_completer_delims,
METH_O, doc_set_completer_delims},
+ {"set_auto_history", py_set_auto_history, METH_VARARGS, doc_set_auto_history},
{"add_history", py_add_history, METH_O, doc_add_history},
{"remove_history_item", py_remove_history, METH_VARARGS, doc_remove_history},
{"replace_history_item", py_replace_history, METH_VARARGS, doc_replace_history},
@@ -857,7 +874,7 @@
if (r == Py_None)
result = 0;
else {
- result = PyLong_AsLong(r);
+ result = _PyLong_AsInt(r);
if (result == -1 && PyErr_Occurred())
goto error;
}
@@ -1324,7 +1341,7 @@
/* we have a valid line */
n = strlen(p);
- if (n > 0) {
+ if (should_auto_add_history && n > 0) {
const char *line;
int length = _py_get_history_length();
if (length > 0)
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
index 00324a5..a6b63d2 100644
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -1842,7 +1842,7 @@
PyObject *pfd;
static char *kwlist[] = {"ident", "filter", "flags", "fflags",
"data", "udata", NULL};
- static char *fmt = "O|hHI" DATA_FMT_UNIT UINTPTRT_FMT_UNIT ":kevent";
+ static const char fmt[] = "O|hHI" DATA_FMT_UNIT UINTPTRT_FMT_UNIT ":kevent";
EV_SET(&(self->e), 0, EVFILT_READ, EV_ADD, 0, 0, 0); /* defaults */
@@ -2127,7 +2127,7 @@
if (_PyTime_FromSecondsObject(&timeout,
otimeout, _PyTime_ROUND_CEILING) < 0) {
PyErr_Format(PyExc_TypeError,
- "timeout argument must be an number "
+ "timeout argument must be a number "
"or None, got %.200s",
Py_TYPE(otimeout)->tp_name);
return NULL;
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 8f571a2..f7fe218 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -163,7 +163,11 @@
# include <sys/uio.h>
#endif
-#ifndef WITH_THREAD
+#if !defined(WITH_THREAD)
+# undef HAVE_GETHOSTBYNAME_R
+#endif
+
+#if defined(__ANDROID__) && __ANDROID_API__ < 23
# undef HAVE_GETHOSTBYNAME_R
#endif
@@ -926,7 +930,7 @@
an error occurred; then an exception is raised. */
static int
-setipaddr(char *name, struct sockaddr *addr_ret, size_t addr_ret_size, int af)
+setipaddr(const char *name, struct sockaddr *addr_ret, size_t addr_ret_size, int af)
{
struct addrinfo hints, *res;
int error;
@@ -1107,7 +1111,7 @@
an error occurred. */
static int
-setbdaddr(char *name, bdaddr_t *bdaddr)
+setbdaddr(const char *name, bdaddr_t *bdaddr)
{
unsigned int b0, b1, b2, b3, b4, b5;
char ch;
@@ -1401,7 +1405,7 @@
idna_converter(PyObject *obj, struct maybe_idna *data)
{
size_t len;
- PyObject *obj2, *obj3;
+ PyObject *obj2;
if (obj == NULL) {
idna_cleanup(data);
return 1;
@@ -1416,31 +1420,27 @@
data->buf = PyByteArray_AsString(obj);
len = PyByteArray_Size(obj);
}
- else if (PyUnicode_Check(obj) && PyUnicode_READY(obj) == 0 && PyUnicode_IS_COMPACT_ASCII(obj)) {
- data->buf = PyUnicode_DATA(obj);
- len = PyUnicode_GET_LENGTH(obj);
+ else if (PyUnicode_Check(obj)) {
+ if (PyUnicode_READY(obj) == 0 && PyUnicode_IS_COMPACT_ASCII(obj)) {
+ data->buf = PyUnicode_DATA(obj);
+ len = PyUnicode_GET_LENGTH(obj);
+ }
+ else {
+ obj2 = PyUnicode_AsEncodedString(obj, "idna", NULL);
+ if (!obj2) {
+ PyErr_SetString(PyExc_TypeError, "encoding of hostname failed");
+ return 0;
+ }
+ assert(PyBytes_Check(obj2));
+ data->obj = obj2;
+ data->buf = PyBytes_AS_STRING(obj2);
+ len = PyBytes_GET_SIZE(obj2);
+ }
}
else {
- obj2 = PyUnicode_FromObject(obj);
- if (!obj2) {
- PyErr_Format(PyExc_TypeError, "string or unicode text buffer expected, not %s",
- obj->ob_type->tp_name);
- return 0;
- }
- obj3 = PyUnicode_AsEncodedString(obj2, "idna", NULL);
- Py_DECREF(obj2);
- if (!obj3) {
- PyErr_SetString(PyExc_TypeError, "encoding of hostname failed");
- return 0;
- }
- if (!PyBytes_Check(obj3)) {
- Py_DECREF(obj3);
- PyErr_SetString(PyExc_TypeError, "encoding of hostname failed to return bytes");
- return 0;
- }
- data->obj = obj3;
- data->buf = PyBytes_AS_STRING(obj3);
- len = PyBytes_GET_SIZE(obj3);
+ PyErr_Format(PyExc_TypeError, "str, bytes or bytearray expected, not %s",
+ obj->ob_type->tp_name);
+ return 0;
}
if (strlen(data->buf) != len) {
Py_CLEAR(data->obj);
@@ -2458,13 +2458,26 @@
if (!PyArg_ParseTuple(args, "iiy*:setsockopt",
&level, &optname, &optval))
return NULL;
+#ifdef MS_WINDOWS
+ if (optval.len > INT_MAX) {
+ PyBuffer_Release(&optval);
+ PyErr_Format(PyExc_OverflowError,
+ "socket option is larger than %i bytes",
+ INT_MAX);
+ return NULL;
+ }
+ res = setsockopt(s->sock_fd, level, optname,
+ optval.buf, (int)optval.len);
+#else
res = setsockopt(s->sock_fd, level, optname, optval.buf, optval.len);
+#endif
PyBuffer_Release(&optval);
}
- if (res < 0)
+ if (res < 0) {
return s->errorhandler();
- Py_INCREF(Py_None);
- return Py_None;
+ }
+
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(setsockopt_doc,
@@ -2563,16 +2576,22 @@
sock_close(PySocketSockObject *s)
{
SOCKET_T fd;
+ int res;
- /* We do not want to retry upon EINTR: see http://lwn.net/Articles/576478/
- * and http://linux.derkeiler.com/Mailing-Lists/Kernel/2005-09/3000.html
- * for more details.
- */
- if ((fd = s->sock_fd) != -1) {
+ fd = s->sock_fd;
+ if (fd != -1) {
s->sock_fd = -1;
+
+ /* We do not want to retry upon EINTR: see
+ http://lwn.net/Articles/576478/ and
+ http://linux.derkeiler.com/Mailing-Lists/Kernel/2005-09/3000.html
+ for more details. */
Py_BEGIN_ALLOW_THREADS
- (void) SOCKETCLOSE(fd);
+ res = SOCKETCLOSE(fd);
Py_END_ALLOW_THREADS
+ if (res < 0) {
+ return s->errorhandler();
+ }
}
Py_INCREF(Py_None);
return Py_None;
@@ -4034,6 +4053,17 @@
return set_error();
}
return PyLong_FromUnsignedLong(recv); }
+#if defined(SIO_LOOPBACK_FAST_PATH)
+ case SIO_LOOPBACK_FAST_PATH: {
+ unsigned int option;
+ if (!PyArg_ParseTuple(arg, "kI:ioctl", &cmd, &option))
+ return NULL;
+ if (WSAIoctl(s->sock_fd, cmd, &option, sizeof(option),
+ NULL, 0, &recv, NULL, NULL) == SOCKET_ERROR) {
+ return set_error();
+ }
+ return PyLong_FromUnsignedLong(recv); }
+#endif
default:
PyErr_Format(PyExc_ValueError, "invalid ioctl command %d", cmd);
return NULL;
@@ -4044,7 +4074,8 @@
\n\
Control the socket with WSAIoctl syscall. Currently supported 'cmd' values are\n\
SIO_RCVALL: 'option' must be one of the socket.RCVALL_* constants.\n\
-SIO_KEEPALIVE_VALS: 'option' is a tuple of (onoff, timeout, interval).");
+SIO_KEEPALIVE_VALS: 'option' is a tuple of (onoff, timeout, interval).\n\
+SIO_LOOPBACK_FAST_PATH: 'option' is a boolean value, and is disabled by default");
#endif
#if defined(MS_WINDOWS)
@@ -4163,22 +4194,45 @@
First close the file description. */
static void
+sock_finalize(PySocketSockObject *s)
+{
+ SOCKET_T fd;
+ PyObject *error_type, *error_value, *error_traceback;
+
+ /* Save the current exception, if any. */
+ PyErr_Fetch(&error_type, &error_value, &error_traceback);
+
+ if (s->sock_fd != -1) {
+ if (PyErr_ResourceWarning((PyObject *)s, 1, "unclosed %R", s)) {
+ /* Spurious errors can appear at shutdown */
+ if (PyErr_ExceptionMatches(PyExc_Warning)) {
+ PyErr_WriteUnraisable((PyObject *)s);
+ }
+ }
+
+ /* Only close the socket *after* logging the ResourceWarning warning
+ to allow the logger to call socket methods like
+ socket.getsockname(). If the socket is closed before, socket
+ methods fails with the EBADF error. */
+ fd = s->sock_fd;
+ s->sock_fd = -1;
+
+ /* We do not want to retry upon EINTR: see sock_close() */
+ Py_BEGIN_ALLOW_THREADS
+ (void) SOCKETCLOSE(fd);
+ Py_END_ALLOW_THREADS
+ }
+
+ /* Restore the saved exception. */
+ PyErr_Restore(error_type, error_value, error_traceback);
+}
+
+static void
sock_dealloc(PySocketSockObject *s)
{
- if (s->sock_fd != -1) {
- PyObject *exc, *val, *tb;
- Py_ssize_t old_refcount = Py_REFCNT(s);
- ++Py_REFCNT(s);
- PyErr_Fetch(&exc, &val, &tb);
- if (PyErr_WarnFormat(PyExc_ResourceWarning, 1,
- "unclosed %R", s))
- /* Spurious errors can appear at shutdown */
- if (PyErr_ExceptionMatches(PyExc_Warning))
- PyErr_WriteUnraisable((PyObject *) s);
- PyErr_Restore(exc, val, tb);
- (void) SOCKETCLOSE(s->sock_fd);
- Py_REFCNT(s) = old_refcount;
- }
+ if (PyObject_CallFinalizerFromDealloc((PyObject *)s) < 0)
+ return;
+
Py_TYPE(s)->tp_free((PyObject *)s);
}
@@ -4395,7 +4449,8 @@
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE
+ | Py_TPFLAGS_HAVE_FINALIZE, /* tp_flags */
sock_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
@@ -4415,6 +4470,15 @@
PyType_GenericAlloc, /* tp_alloc */
sock_new, /* tp_new */
PyObject_Del, /* tp_free */
+ 0, /* tp_is_gc */
+ 0, /* tp_bases */
+ 0, /* tp_mro */
+ 0, /* tp_cache */
+ 0, /* tp_subclasses */
+ 0, /* tp_weaklist */
+ 0, /* tp_del */
+ 0, /* tp_version_tag */
+ (destructor)sock_finalize, /* tp_finalize */
};
@@ -5450,10 +5514,6 @@
} else {
return PyUnicode_FromString(retval);
}
-
- /* NOTREACHED */
- PyErr_SetString(PyExc_RuntimeError, "invalid handling of inet_ntop");
- return NULL;
}
#elif defined(MS_WINDOWS)
@@ -6187,9 +6247,6 @@
PyModule_AddIntMacro(m, AF_UNSPEC);
#endif
PyModule_AddIntMacro(m, AF_INET);
-#ifdef AF_INET6
- PyModule_AddIntMacro(m, AF_INET6);
-#endif /* AF_INET6 */
#if defined(AF_UNIX)
PyModule_AddIntMacro(m, AF_UNIX);
#endif /* AF_UNIX */
@@ -6481,9 +6538,11 @@
#ifdef SO_OOBINLINE
PyModule_AddIntMacro(m, SO_OOBINLINE);
#endif
+#ifndef __GNU__
#ifdef SO_REUSEPORT
PyModule_AddIntMacro(m, SO_REUSEPORT);
#endif
+#endif
#ifdef SO_SNDBUF
PyModule_AddIntMacro(m, SO_SNDBUF);
#endif
@@ -7224,8 +7283,16 @@
#ifdef SIO_RCVALL
{
- DWORD codes[] = {SIO_RCVALL, SIO_KEEPALIVE_VALS};
- const char *names[] = {"SIO_RCVALL", "SIO_KEEPALIVE_VALS"};
+ DWORD codes[] = {SIO_RCVALL, SIO_KEEPALIVE_VALS,
+#if defined(SIO_LOOPBACK_FAST_PATH)
+ SIO_LOOPBACK_FAST_PATH
+#endif
+ };
+ const char *names[] = {"SIO_RCVALL", "SIO_KEEPALIVE_VALS",
+#if defined(SIO_LOOPBACK_FAST_PATH)
+ "SIO_LOOPBACK_FAST_PATH"
+#endif
+ };
int i;
for(i = 0; i<Py_ARRAY_LENGTH(codes); ++i) {
PyObject *tmp;
diff --git a/Modules/spwdmodule.c b/Modules/spwdmodule.c
index 49324d5..e715d01 100644
--- a/Modules/spwdmodule.c
+++ b/Modules/spwdmodule.c
@@ -137,7 +137,10 @@
if (PyBytes_AsStringAndSize(bytes, &name, NULL) == -1)
goto out;
if ((p = getspnam(name)) == NULL) {
- PyErr_SetString(PyExc_KeyError, "getspnam(): name not found");
+ if (errno != 0)
+ PyErr_SetFromErrno(PyExc_OSError);
+ else
+ PyErr_SetString(PyExc_KeyError, "getspnam(): name not found");
goto out;
}
retval = mkspent(p);
diff --git a/Modules/sre_lib.h b/Modules/sre_lib.h
index 128c71e..78f7ac7 100644
--- a/Modules/sre_lib.h
+++ b/Modules/sre_lib.h
@@ -367,14 +367,12 @@
#define RETURN_ON_FAILURE(i) \
do { RETURN_ON_ERROR(i); if (i == 0) RETURN_FAILURE; } while (0)
-#define SFY(x) #x
-
#define DATA_STACK_ALLOC(state, type, ptr) \
do { \
alloc_pos = state->data_stack_base; \
TRACE(("allocating %s in %" PY_FORMAT_SIZE_T "d " \
"(%" PY_FORMAT_SIZE_T "d)\n", \
- SFY(type), alloc_pos, sizeof(type))); \
+ Py_STRINGIFY(type), alloc_pos, sizeof(type))); \
if (sizeof(type) > state->data_stack_size - alloc_pos) { \
int j = data_stack_grow(state, sizeof(type)); \
if (j < 0) return j; \
@@ -387,7 +385,7 @@
#define DATA_STACK_LOOKUP_AT(state, type, ptr, pos) \
do { \
- TRACE(("looking up %s at %" PY_FORMAT_SIZE_T "d\n", SFY(type), pos)); \
+ TRACE(("looking up %s at %" PY_FORMAT_SIZE_T "d\n", Py_STRINGIFY(type), pos)); \
ptr = (type*)(state->data_stack+pos); \
} while (0)
@@ -1256,7 +1254,32 @@
prefix, prefix_len, prefix_skip));
TRACE(("charset = %p\n", charset));
-#if defined(USE_FAST_SEARCH)
+ if (prefix_len == 1) {
+ /* pattern starts with a literal character */
+ SRE_CHAR c = (SRE_CHAR) prefix[0];
+#if SIZEOF_SRE_CHAR < 4
+ if ((SRE_CODE) c != prefix[0])
+ return 0; /* literal can't match: doesn't fit in char width */
+#endif
+ end = (SRE_CHAR *)state->end;
+ while (ptr < end) {
+ while (*ptr != c) {
+ if (++ptr >= end)
+ return 0;
+ }
+ TRACE(("|%p|%p|SEARCH LITERAL\n", pattern, ptr));
+ state->start = ptr;
+ state->ptr = ptr + prefix_skip;
+ if (flags & SRE_INFO_LITERAL)
+ return 1; /* we got all of it */
+ status = SRE(match)(state, pattern + 2*prefix_skip, 0);
+ if (status != 0)
+ return status;
+ ++ptr;
+ }
+ return 0;
+ }
+
if (prefix_len > 1) {
/* pattern starts with a known prefix. use the overlap
table to skip forward as fast as we possibly can */
@@ -1305,32 +1328,8 @@
}
return 0;
}
-#endif
- if (pattern[0] == SRE_OP_LITERAL) {
- /* pattern starts with a literal character. this is used
- for short prefixes, and if fast search is disabled */
- SRE_CHAR c = (SRE_CHAR) pattern[1];
-#if SIZEOF_SRE_CHAR < 4
- if ((SRE_CODE) c != pattern[1])
- return 0; /* literal can't match: doesn't fit in char width */
-#endif
- end = (SRE_CHAR *)state->end;
- while (ptr < end) {
- while (*ptr != c) {
- if (++ptr >= end)
- return 0;
- }
- TRACE(("|%p|%p|SEARCH LITERAL\n", pattern, ptr));
- state->start = ptr;
- state->ptr = ++ptr;
- if (flags & SRE_INFO_LITERAL)
- return 1; /* we got all of it */
- status = SRE(match)(state, pattern + 2, 0);
- if (status != 0)
- break;
- }
- } else if (charset) {
+ if (charset) {
/* pattern starts with a character from a known set */
end = (SRE_CHAR *)state->end;
for (;;) {
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index d2caacd..0b6d461 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -311,7 +311,7 @@
Returns non-zero on success (parallels PyArg_ParseTuple).
*/
static int
-parse_time_t_args(PyObject *args, char *format, time_t *pwhen)
+parse_time_t_args(PyObject *args, const char *format, time_t *pwhen)
{
PyObject *ot = NULL;
time_t whent;
@@ -732,10 +732,10 @@
{
/* Inspired by Open Group reference implementation available at
* http://pubs.opengroup.org/onlinepubs/009695399/functions/asctime.html */
- static char wday_name[7][4] = {
+ static const char wday_name[7][4] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};
- static char mon_name[12][4] = {
+ static const char mon_name[12][4] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c
index fe4e908..7d518fa 100644
--- a/Modules/unicodedata.c
+++ b/Modules/unicodedata.c
@@ -884,7 +884,7 @@
return h;
}
-static char *hangul_syllables[][3] = {
+static const char * const hangul_syllables[][3] = {
{ "G", "A", "" },
{ "GG", "AE", "G" },
{ "N", "YA", "GG" },
@@ -1057,7 +1057,7 @@
int i, len1;
*len = -1;
for (i = 0; i < count; i++) {
- char *s = hangul_syllables[i][column];
+ const char *s = hangul_syllables[i][column];
len1 = Py_SAFE_DOWNCAST(strlen(s), size_t, int);
if (len1 <= *len)
continue;
diff --git a/Modules/xxlimited.c b/Modules/xxlimited.c
index 40c1760..c1a9be9 100644
--- a/Modules/xxlimited.c
+++ b/Modules/xxlimited.c
@@ -89,7 +89,7 @@
}
static int
-Xxo_setattr(XxoObject *self, char *name, PyObject *v)
+Xxo_setattr(XxoObject *self, const char *name, PyObject *v)
{
if (self->x_attr == NULL) {
self->x_attr = PyDict_New();
diff --git a/Modules/xxmodule.c b/Modules/xxmodule.c
index 85230d9..0764407 100644
--- a/Modules/xxmodule.c
+++ b/Modules/xxmodule.c
@@ -76,7 +76,7 @@
}
static int
-Xxo_setattr(XxoObject *self, char *name, PyObject *v)
+Xxo_setattr(XxoObject *self, const char *name, PyObject *v)
{
if (self->x_attr == NULL) {
self->x_attr = PyDict_New();
diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c
index 16cc178..3a459a5 100644
--- a/Modules/zlibmodule.c
+++ b/Modules/zlibmodule.c
@@ -57,7 +57,7 @@
} compobject;
static void
-zlib_error(z_stream zst, int err, char *msg)
+zlib_error(z_stream zst, int err, const char *msg)
{
const char *zmsg = Z_NULL;
/* In case of a version mismatch, zst.msg won't be initialized.
@@ -141,18 +141,18 @@
/*[clinic input]
zlib.compress
- bytes: Py_buffer
+ data: Py_buffer
Binary data to be compressed.
- level: int(c_default="Z_DEFAULT_COMPRESSION") = Z_DEFAULT_COMPRESSION
- Compression level, in 0-9.
/
+ level: int(c_default="Z_DEFAULT_COMPRESSION") = Z_DEFAULT_COMPRESSION
+ Compression level, in 0-9 or -1.
Returns a bytes object containing compressed data.
[clinic start generated code]*/
static PyObject *
-zlib_compress_impl(PyModuleDef *module, Py_buffer *bytes, int level)
-/*[clinic end generated code: output=5d7dd4588788efd3 input=be3abe9934bda4b3]*/
+zlib_compress_impl(PyModuleDef *module, Py_buffer *data, int level)
+/*[clinic end generated code: output=1b97589132b203b4 input=638d54b6315dbed3]*/
{
PyObject *ReturnVal = NULL;
Byte *input, *output = NULL;
@@ -160,13 +160,13 @@
int err;
z_stream zst;
- if ((size_t)bytes->len > UINT_MAX) {
+ if ((size_t)data->len > UINT_MAX) {
PyErr_SetString(PyExc_OverflowError,
"Size does not fit in an unsigned int");
goto error;
}
- input = bytes->buf;
- length = (unsigned int)bytes->len;
+ input = data->buf;
+ length = (unsigned int)data->len;
zst.avail_out = length + length/1000 + 12 + 1;
@@ -1352,7 +1352,7 @@
"zlib library, which is based on GNU zip.\n"
"\n"
"adler32(string[, start]) -- Compute an Adler-32 checksum.\n"
-"compress(string[, level]) -- Compress string, with compression level in 0-9.\n"
+"compress(data[, level]) -- Compress data, with compression level 0-9 or -1.\n"
"compressobj([level[, ...]]) -- Return a compressor object.\n"
"crc32(string[, start]) -- Compute a CRC-32 checksum.\n"
"decompress(string,[wbits],[bufsize]) -- Decompresses a compressed string.\n"
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 585992d..885d8de 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -141,8 +141,11 @@
return null_error();
m = o->ob_type->tp_as_mapping;
- if (m && m->mp_subscript)
- return m->mp_subscript(o, key);
+ if (m && m->mp_subscript) {
+ PyObject *item = m->mp_subscript(o, key);
+ assert((item != NULL) ^ (PyErr_Occurred() != NULL));
+ return item;
+ }
if (o->ob_type->tp_as_sequence) {
if (PyIndex_Check(key)) {
@@ -1348,21 +1351,39 @@
if (o == NULL)
return null_error();
+ if (PyFloat_CheckExact(o)) {
+ Py_INCREF(o);
+ return o;
+ }
m = o->ob_type->tp_as_number;
if (m && m->nb_float) { /* This should include subclasses of float */
PyObject *res = m->nb_float(o);
- if (res && !PyFloat_Check(res)) {
+ double val;
+ if (!res || PyFloat_CheckExact(res)) {
+ return res;
+ }
+ if (!PyFloat_Check(res)) {
PyErr_Format(PyExc_TypeError,
- "__float__ returned non-float (type %.200s)",
- res->ob_type->tp_name);
+ "%.50s.__float__ returned non-float (type %.50s)",
+ o->ob_type->tp_name, res->ob_type->tp_name);
Py_DECREF(res);
return NULL;
}
- return res;
+ /* Issue #26983: warn if 'res' not of exact type float. */
+ if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
+ "%.50s.__float__ returned non-float (type %.50s). "
+ "The ability to return an instance of a strict subclass of float "
+ "is deprecated, and may be removed in a future version of Python.",
+ o->ob_type->tp_name, res->ob_type->tp_name)) {
+ Py_DECREF(res);
+ return NULL;
+ }
+ val = PyFloat_AS_DOUBLE(res);
+ Py_DECREF(res);
+ return PyFloat_FromDouble(val);
}
if (PyFloat_Check(o)) { /* A float subclass with nb_float == NULL */
- PyFloatObject *po = (PyFloatObject *)o;
- return PyFloat_FromDouble(po->ob_fval);
+ return PyFloat_FromDouble(PyFloat_AS_DOUBLE(o));
}
return PyFloat_FromString(o);
}
@@ -1544,8 +1565,10 @@
if (i < 0) {
if (m->sq_length) {
Py_ssize_t l = (*m->sq_length)(s);
- if (l < 0)
+ if (l < 0) {
+ assert(PyErr_Occurred());
return NULL;
+ }
i += l;
}
}
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 277be59..b7dfd6f 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -279,31 +279,6 @@
return (PyObject *)result;
}
-static PyObject *
-bytearray_format(PyByteArrayObject *self, PyObject *args)
-{
- PyObject *bytes_in, *bytes_out, *res;
- char *bytestring;
-
- if (self == NULL || !PyByteArray_Check(self) || args == NULL) {
- PyErr_BadInternalCall();
- return NULL;
- }
- bytestring = PyByteArray_AS_STRING(self);
- bytes_in = PyBytes_FromString(bytestring);
- if (bytes_in == NULL)
- return NULL;
- bytes_out = _PyBytes_Format(bytes_in, args);
- Py_DECREF(bytes_in);
- if (bytes_out == NULL)
- return NULL;
- res = PyByteArray_FromObject(bytes_out);
- Py_DECREF(bytes_out);
- if (res == NULL)
- return NULL;
- return res;
-}
-
/* Functions stuffed into the type object */
static Py_ssize_t
@@ -1122,161 +1097,27 @@
#include "stringlib/transmogrify.h"
-/* The following Py_LOCAL_INLINE and Py_LOCAL functions
-were copied from the old char* style string object. */
-
-/* helper macro to fixup start/end slice values */
-#define ADJUST_INDICES(start, end, len) \
- if (end > len) \
- end = len; \
- else if (end < 0) { \
- end += len; \
- if (end < 0) \
- end = 0; \
- } \
- if (start < 0) { \
- start += len; \
- if (start < 0) \
- start = 0; \
- }
-
-Py_LOCAL_INLINE(Py_ssize_t)
-bytearray_find_internal(PyByteArrayObject *self, PyObject *args, int dir)
-{
- PyObject *subobj;
- char byte;
- Py_buffer subbuf;
- const char *sub;
- Py_ssize_t len, sub_len;
- Py_ssize_t start=0, end=PY_SSIZE_T_MAX;
- Py_ssize_t res;
-
- if (!stringlib_parse_args_finds_byte("find/rfind/index/rindex",
- args, &subobj, &byte, &start, &end))
- return -2;
-
- if (subobj) {
- if (PyObject_GetBuffer(subobj, &subbuf, PyBUF_SIMPLE) != 0)
- return -2;
-
- sub = subbuf.buf;
- sub_len = subbuf.len;
- }
- else {
- sub = &byte;
- sub_len = 1;
- }
- len = PyByteArray_GET_SIZE(self);
-
- ADJUST_INDICES(start, end, len);
- if (end - start < sub_len)
- res = -1;
- else if (sub_len == 1
-#ifndef HAVE_MEMRCHR
- && dir > 0
-#endif
- ) {
- unsigned char needle = *sub;
- int mode = (dir > 0) ? FAST_SEARCH : FAST_RSEARCH;
- res = stringlib_fastsearch_memchr_1char(
- PyByteArray_AS_STRING(self) + start, end - start,
- needle, needle, mode);
- if (res >= 0)
- res += start;
- }
- else {
- if (dir > 0)
- res = stringlib_find_slice(
- PyByteArray_AS_STRING(self), len,
- sub, sub_len, start, end);
- else
- res = stringlib_rfind_slice(
- PyByteArray_AS_STRING(self), len,
- sub, sub_len, start, end);
- }
-
- if (subobj)
- PyBuffer_Release(&subbuf);
-
- return res;
-}
-
-PyDoc_STRVAR(find__doc__,
-"B.find(sub[, start[, end]]) -> int\n\
-\n\
-Return the lowest index in B where subsection sub is found,\n\
-such that sub is contained within B[start,end]. Optional\n\
-arguments start and end are interpreted as in slice notation.\n\
-\n\
-Return -1 on failure.");
-
static PyObject *
bytearray_find(PyByteArrayObject *self, PyObject *args)
{
- Py_ssize_t result = bytearray_find_internal(self, args, +1);
- if (result == -2)
- return NULL;
- return PyLong_FromSsize_t(result);
+ return _Py_bytes_find(PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), args);
}
-PyDoc_STRVAR(count__doc__,
-"B.count(sub[, start[, end]]) -> int\n\
-\n\
-Return the number of non-overlapping occurrences of subsection sub in\n\
-bytes B[start:end]. Optional arguments start and end are interpreted\n\
-as in slice notation.");
-
static PyObject *
bytearray_count(PyByteArrayObject *self, PyObject *args)
{
- PyObject *sub_obj;
- const char *str = PyByteArray_AS_STRING(self), *sub;
- Py_ssize_t sub_len;
- char byte;
- Py_ssize_t start = 0, end = PY_SSIZE_T_MAX;
-
- Py_buffer vsub;
- PyObject *count_obj;
-
- if (!stringlib_parse_args_finds_byte("count", args, &sub_obj, &byte,
- &start, &end))
- return NULL;
-
- if (sub_obj) {
- if (PyObject_GetBuffer(sub_obj, &vsub, PyBUF_SIMPLE) != 0)
- return NULL;
-
- sub = vsub.buf;
- sub_len = vsub.len;
- }
- else {
- sub = &byte;
- sub_len = 1;
- }
-
- ADJUST_INDICES(start, end, PyByteArray_GET_SIZE(self));
-
- count_obj = PyLong_FromSsize_t(
- stringlib_count(str + start, end - start, sub, sub_len, PY_SSIZE_T_MAX)
- );
-
- if (sub_obj)
- PyBuffer_Release(&vsub);
-
- return count_obj;
+ return _Py_bytes_count(PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), args);
}
/*[clinic input]
bytearray.clear
- self: self(type="PyByteArrayObject *")
-
Remove all items from the bytearray.
[clinic start generated code]*/
static PyObject *
bytearray_clear_impl(PyByteArrayObject *self)
-/*[clinic end generated code: output=85c2fe6aede0956c input=e524fd330abcdc18]*/
+/*[clinic end generated code: output=85c2fe6aede0956c input=ed6edae9de447ac4]*/
{
if (PyByteArray_Resize((PyObject *)self, 0) < 0)
return NULL;
@@ -1286,236 +1127,57 @@
/*[clinic input]
bytearray.copy
- self: self(type="PyByteArrayObject *")
-
Return a copy of B.
[clinic start generated code]*/
static PyObject *
bytearray_copy_impl(PyByteArrayObject *self)
-/*[clinic end generated code: output=68cfbcfed484c132 input=6d5d2975aa0f33f3]*/
+/*[clinic end generated code: output=68cfbcfed484c132 input=6597b0c01bccaa9e]*/
{
return PyByteArray_FromStringAndSize(PyByteArray_AS_STRING((PyObject *)self),
PyByteArray_GET_SIZE(self));
}
-PyDoc_STRVAR(index__doc__,
-"B.index(sub[, start[, end]]) -> int\n\
-\n\
-Like B.find() but raise ValueError when the subsection is not found.");
-
static PyObject *
bytearray_index(PyByteArrayObject *self, PyObject *args)
{
- Py_ssize_t result = bytearray_find_internal(self, args, +1);
- if (result == -2)
- return NULL;
- if (result == -1) {
- PyErr_SetString(PyExc_ValueError,
- "subsection not found");
- return NULL;
- }
- return PyLong_FromSsize_t(result);
+ return _Py_bytes_index(PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), args);
}
-
-PyDoc_STRVAR(rfind__doc__,
-"B.rfind(sub[, start[, end]]) -> int\n\
-\n\
-Return the highest index in B where subsection sub is found,\n\
-such that sub is contained within B[start,end]. Optional\n\
-arguments start and end are interpreted as in slice notation.\n\
-\n\
-Return -1 on failure.");
-
static PyObject *
bytearray_rfind(PyByteArrayObject *self, PyObject *args)
{
- Py_ssize_t result = bytearray_find_internal(self, args, -1);
- if (result == -2)
- return NULL;
- return PyLong_FromSsize_t(result);
+ return _Py_bytes_rfind(PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), args);
}
-
-PyDoc_STRVAR(rindex__doc__,
-"B.rindex(sub[, start[, end]]) -> int\n\
-\n\
-Like B.rfind() but raise ValueError when the subsection is not found.");
-
static PyObject *
bytearray_rindex(PyByteArrayObject *self, PyObject *args)
{
- Py_ssize_t result = bytearray_find_internal(self, args, -1);
- if (result == -2)
- return NULL;
- if (result == -1) {
- PyErr_SetString(PyExc_ValueError,
- "subsection not found");
- return NULL;
- }
- return PyLong_FromSsize_t(result);
+ return _Py_bytes_rindex(PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), args);
}
-
static int
bytearray_contains(PyObject *self, PyObject *arg)
{
- Py_ssize_t ival = PyNumber_AsSsize_t(arg, PyExc_ValueError);
- if (ival == -1 && PyErr_Occurred()) {
- Py_buffer varg;
- Py_ssize_t pos;
- PyErr_Clear();
- if (PyObject_GetBuffer(arg, &varg, PyBUF_SIMPLE) != 0)
- return -1;
- pos = stringlib_find(PyByteArray_AS_STRING(self), Py_SIZE(self),
- varg.buf, varg.len, 0);
- PyBuffer_Release(&varg);
- return pos >= 0;
- }
- if (ival < 0 || ival >= 256) {
- PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)");
- return -1;
- }
-
- return memchr(PyByteArray_AS_STRING(self), (int) ival, Py_SIZE(self)) != NULL;
+ return _Py_bytes_contains(PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), arg);
}
-
-/* Matches the end (direction >= 0) or start (direction < 0) of self
- * against substr, using the start and end arguments. Returns
- * -1 on error, 0 if not found and 1 if found.
- */
-Py_LOCAL(int)
-_bytearray_tailmatch(PyByteArrayObject *self, PyObject *substr, Py_ssize_t start,
- Py_ssize_t end, int direction)
-{
- Py_ssize_t len = PyByteArray_GET_SIZE(self);
- const char* str;
- Py_buffer vsubstr;
- int rv = 0;
-
- str = PyByteArray_AS_STRING(self);
-
- if (PyObject_GetBuffer(substr, &vsubstr, PyBUF_SIMPLE) != 0)
- return -1;
-
- ADJUST_INDICES(start, end, len);
-
- if (direction < 0) {
- /* startswith */
- if (start+vsubstr.len > len) {
- goto done;
- }
- } else {
- /* endswith */
- if (end-start < vsubstr.len || start > len) {
- goto done;
- }
-
- if (end-vsubstr.len > start)
- start = end - vsubstr.len;
- }
- if (end-start >= vsubstr.len)
- rv = ! memcmp(str+start, vsubstr.buf, vsubstr.len);
-
-done:
- PyBuffer_Release(&vsubstr);
- return rv;
-}
-
-
-PyDoc_STRVAR(startswith__doc__,
-"B.startswith(prefix[, start[, end]]) -> bool\n\
-\n\
-Return True if B starts with the specified prefix, False otherwise.\n\
-With optional start, test B beginning at that position.\n\
-With optional end, stop comparing B at that position.\n\
-prefix can also be a tuple of bytes to try.");
-
static PyObject *
bytearray_startswith(PyByteArrayObject *self, PyObject *args)
{
- Py_ssize_t start = 0;
- Py_ssize_t end = PY_SSIZE_T_MAX;
- PyObject *subobj;
- int result;
-
- if (!stringlib_parse_args_finds("startswith", args, &subobj, &start, &end))
- return NULL;
- if (PyTuple_Check(subobj)) {
- Py_ssize_t i;
- for (i = 0; i < PyTuple_GET_SIZE(subobj); i++) {
- result = _bytearray_tailmatch(self,
- PyTuple_GET_ITEM(subobj, i),
- start, end, -1);
- if (result == -1)
- return NULL;
- else if (result) {
- Py_RETURN_TRUE;
- }
- }
- Py_RETURN_FALSE;
- }
- result = _bytearray_tailmatch(self, subobj, start, end, -1);
- if (result == -1) {
- if (PyErr_ExceptionMatches(PyExc_TypeError))
- PyErr_Format(PyExc_TypeError, "startswith first arg must be bytes "
- "or a tuple of bytes, not %s", Py_TYPE(subobj)->tp_name);
- return NULL;
- }
- else
- return PyBool_FromLong(result);
+ return _Py_bytes_startswith(PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), args);
}
-PyDoc_STRVAR(endswith__doc__,
-"B.endswith(suffix[, start[, end]]) -> bool\n\
-\n\
-Return True if B ends with the specified suffix, False otherwise.\n\
-With optional start, test B beginning at that position.\n\
-With optional end, stop comparing B at that position.\n\
-suffix can also be a tuple of bytes to try.");
-
static PyObject *
bytearray_endswith(PyByteArrayObject *self, PyObject *args)
{
- Py_ssize_t start = 0;
- Py_ssize_t end = PY_SSIZE_T_MAX;
- PyObject *subobj;
- int result;
-
- if (!stringlib_parse_args_finds("endswith", args, &subobj, &start, &end))
- return NULL;
- if (PyTuple_Check(subobj)) {
- Py_ssize_t i;
- for (i = 0; i < PyTuple_GET_SIZE(subobj); i++) {
- result = _bytearray_tailmatch(self,
- PyTuple_GET_ITEM(subobj, i),
- start, end, +1);
- if (result == -1)
- return NULL;
- else if (result) {
- Py_RETURN_TRUE;
- }
- }
- Py_RETURN_FALSE;
- }
- result = _bytearray_tailmatch(self, subobj, start, end, +1);
- if (result == -1) {
- if (PyErr_ExceptionMatches(PyExc_TypeError))
- PyErr_Format(PyExc_TypeError, "endswith first arg must be bytes or "
- "a tuple of bytes, not %s", Py_TYPE(subobj)->tp_name);
- return NULL;
- }
- else
- return PyBool_FromLong(result);
+ return _Py_bytes_endswith(PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), args);
}
/*[clinic input]
bytearray.translate
- self: self(type="PyByteArrayObject *")
table: object
Translation table, which must be a bytes object of length 256.
[
@@ -1532,7 +1194,7 @@
static PyObject *
bytearray_translate_impl(PyByteArrayObject *self, PyObject *table,
int group_right_1, PyObject *deletechars)
-/*[clinic end generated code: output=2bebc86a9a1ff083 input=b749ad85f4860824]*/
+/*[clinic end generated code: output=2bebc86a9a1ff083 input=846a01671bccc1c5]*/
{
char *input, *output;
const char *table_chars;
@@ -1575,7 +1237,7 @@
result = PyByteArray_FromStringAndSize((char *)NULL, inlen);
if (result == NULL)
goto done;
- output_start = output = PyByteArray_AsString(result);
+ output_start = output = PyByteArray_AS_STRING(result);
input = PyByteArray_AS_STRING(input_obj);
if (vdel.len == 0 && table_chars != NULL) {
@@ -1645,493 +1307,6 @@
}
-/* find and count characters and substrings */
-
-#define findchar(target, target_len, c) \
- ((char *)memchr((const void *)(target), c, target_len))
-
-
-/* Bytes ops must return a string, create a copy */
-Py_LOCAL(PyByteArrayObject *)
-return_self(PyByteArrayObject *self)
-{
- /* always return a new bytearray */
- return (PyByteArrayObject *)PyByteArray_FromStringAndSize(
- PyByteArray_AS_STRING(self),
- PyByteArray_GET_SIZE(self));
-}
-
-Py_LOCAL_INLINE(Py_ssize_t)
-countchar(const char *target, Py_ssize_t target_len, char c, Py_ssize_t maxcount)
-{
- Py_ssize_t count=0;
- const char *start=target;
- const char *end=target+target_len;
-
- while ( (start=findchar(start, end-start, c)) != NULL ) {
- count++;
- if (count >= maxcount)
- break;
- start += 1;
- }
- return count;
-}
-
-
-/* Algorithms for different cases of string replacement */
-
-/* len(self)>=1, from="", len(to)>=1, maxcount>=1 */
-Py_LOCAL(PyByteArrayObject *)
-replace_interleave(PyByteArrayObject *self,
- const char *to_s, Py_ssize_t to_len,
- Py_ssize_t maxcount)
-{
- char *self_s, *result_s;
- Py_ssize_t self_len, result_len;
- Py_ssize_t count, i;
- PyByteArrayObject *result;
-
- self_len = PyByteArray_GET_SIZE(self);
-
- /* 1 at the end plus 1 after every character;
- count = min(maxcount, self_len + 1) */
- if (maxcount <= self_len)
- count = maxcount;
- else
- /* Can't overflow: self_len + 1 <= maxcount <= PY_SSIZE_T_MAX. */
- count = self_len + 1;
-
- /* Check for overflow */
- /* result_len = count * to_len + self_len; */
- assert(count > 0);
- if (to_len > (PY_SSIZE_T_MAX - self_len) / count) {
- PyErr_SetString(PyExc_OverflowError,
- "replace string is too long");
- return NULL;
- }
- result_len = count * to_len + self_len;
-
- if (! (result = (PyByteArrayObject *)
- PyByteArray_FromStringAndSize(NULL, result_len)) )
- return NULL;
-
- self_s = PyByteArray_AS_STRING(self);
- result_s = PyByteArray_AS_STRING(result);
-
- /* TODO: special case single character, which doesn't need memcpy */
-
- /* Lay the first one down (guaranteed this will occur) */
- Py_MEMCPY(result_s, to_s, to_len);
- result_s += to_len;
- count -= 1;
-
- for (i=0; i<count; i++) {
- *result_s++ = *self_s++;
- Py_MEMCPY(result_s, to_s, to_len);
- result_s += to_len;
- }
-
- /* Copy the rest of the original string */
- Py_MEMCPY(result_s, self_s, self_len-i);
-
- return result;
-}
-
-/* Special case for deleting a single character */
-/* len(self)>=1, len(from)==1, to="", maxcount>=1 */
-Py_LOCAL(PyByteArrayObject *)
-replace_delete_single_character(PyByteArrayObject *self,
- char from_c, Py_ssize_t maxcount)
-{
- char *self_s, *result_s;
- char *start, *next, *end;
- Py_ssize_t self_len, result_len;
- Py_ssize_t count;
- PyByteArrayObject *result;
-
- self_len = PyByteArray_GET_SIZE(self);
- self_s = PyByteArray_AS_STRING(self);
-
- count = countchar(self_s, self_len, from_c, maxcount);
- if (count == 0) {
- return return_self(self);
- }
-
- result_len = self_len - count; /* from_len == 1 */
- assert(result_len>=0);
-
- if ( (result = (PyByteArrayObject *)
- PyByteArray_FromStringAndSize(NULL, result_len)) == NULL)
- return NULL;
- result_s = PyByteArray_AS_STRING(result);
-
- start = self_s;
- end = self_s + self_len;
- while (count-- > 0) {
- next = findchar(start, end-start, from_c);
- if (next == NULL)
- break;
- Py_MEMCPY(result_s, start, next-start);
- result_s += (next-start);
- start = next+1;
- }
- Py_MEMCPY(result_s, start, end-start);
-
- return result;
-}
-
-/* len(self)>=1, len(from)>=2, to="", maxcount>=1 */
-
-Py_LOCAL(PyByteArrayObject *)
-replace_delete_substring(PyByteArrayObject *self,
- const char *from_s, Py_ssize_t from_len,
- Py_ssize_t maxcount)
-{
- char *self_s, *result_s;
- char *start, *next, *end;
- Py_ssize_t self_len, result_len;
- Py_ssize_t count, offset;
- PyByteArrayObject *result;
-
- self_len = PyByteArray_GET_SIZE(self);
- self_s = PyByteArray_AS_STRING(self);
-
- count = stringlib_count(self_s, self_len,
- from_s, from_len,
- maxcount);
-
- if (count == 0) {
- /* no matches */
- return return_self(self);
- }
-
- result_len = self_len - (count * from_len);
- assert (result_len>=0);
-
- if ( (result = (PyByteArrayObject *)
- PyByteArray_FromStringAndSize(NULL, result_len)) == NULL )
- return NULL;
-
- result_s = PyByteArray_AS_STRING(result);
-
- start = self_s;
- end = self_s + self_len;
- while (count-- > 0) {
- offset = stringlib_find(start, end-start,
- from_s, from_len,
- 0);
- if (offset == -1)
- break;
- next = start + offset;
-
- Py_MEMCPY(result_s, start, next-start);
-
- result_s += (next-start);
- start = next+from_len;
- }
- Py_MEMCPY(result_s, start, end-start);
- return result;
-}
-
-/* len(self)>=1, len(from)==len(to)==1, maxcount>=1 */
-Py_LOCAL(PyByteArrayObject *)
-replace_single_character_in_place(PyByteArrayObject *self,
- char from_c, char to_c,
- Py_ssize_t maxcount)
-{
- char *self_s, *result_s, *start, *end, *next;
- Py_ssize_t self_len;
- PyByteArrayObject *result;
-
- /* The result string will be the same size */
- self_s = PyByteArray_AS_STRING(self);
- self_len = PyByteArray_GET_SIZE(self);
-
- next = findchar(self_s, self_len, from_c);
-
- if (next == NULL) {
- /* No matches; return the original bytes */
- return return_self(self);
- }
-
- /* Need to make a new bytes */
- result = (PyByteArrayObject *) PyByteArray_FromStringAndSize(NULL, self_len);
- if (result == NULL)
- return NULL;
- result_s = PyByteArray_AS_STRING(result);
- Py_MEMCPY(result_s, self_s, self_len);
-
- /* change everything in-place, starting with this one */
- start = result_s + (next-self_s);
- *start = to_c;
- start++;
- end = result_s + self_len;
-
- while (--maxcount > 0) {
- next = findchar(start, end-start, from_c);
- if (next == NULL)
- break;
- *next = to_c;
- start = next+1;
- }
-
- return result;
-}
-
-/* len(self)>=1, len(from)==len(to)>=2, maxcount>=1 */
-Py_LOCAL(PyByteArrayObject *)
-replace_substring_in_place(PyByteArrayObject *self,
- const char *from_s, Py_ssize_t from_len,
- const char *to_s, Py_ssize_t to_len,
- Py_ssize_t maxcount)
-{
- char *result_s, *start, *end;
- char *self_s;
- Py_ssize_t self_len, offset;
- PyByteArrayObject *result;
-
- /* The result bytes will be the same size */
-
- self_s = PyByteArray_AS_STRING(self);
- self_len = PyByteArray_GET_SIZE(self);
-
- offset = stringlib_find(self_s, self_len,
- from_s, from_len,
- 0);
- if (offset == -1) {
- /* No matches; return the original bytes */
- return return_self(self);
- }
-
- /* Need to make a new bytes */
- result = (PyByteArrayObject *) PyByteArray_FromStringAndSize(NULL, self_len);
- if (result == NULL)
- return NULL;
- result_s = PyByteArray_AS_STRING(result);
- Py_MEMCPY(result_s, self_s, self_len);
-
- /* change everything in-place, starting with this one */
- start = result_s + offset;
- Py_MEMCPY(start, to_s, from_len);
- start += from_len;
- end = result_s + self_len;
-
- while ( --maxcount > 0) {
- offset = stringlib_find(start, end-start,
- from_s, from_len,
- 0);
- if (offset==-1)
- break;
- Py_MEMCPY(start+offset, to_s, from_len);
- start += offset+from_len;
- }
-
- return result;
-}
-
-/* len(self)>=1, len(from)==1, len(to)>=2, maxcount>=1 */
-Py_LOCAL(PyByteArrayObject *)
-replace_single_character(PyByteArrayObject *self,
- char from_c,
- const char *to_s, Py_ssize_t to_len,
- Py_ssize_t maxcount)
-{
- char *self_s, *result_s;
- char *start, *next, *end;
- Py_ssize_t self_len, result_len;
- Py_ssize_t count;
- PyByteArrayObject *result;
-
- self_s = PyByteArray_AS_STRING(self);
- self_len = PyByteArray_GET_SIZE(self);
-
- count = countchar(self_s, self_len, from_c, maxcount);
- if (count == 0) {
- /* no matches, return unchanged */
- return return_self(self);
- }
-
- /* use the difference between current and new, hence the "-1" */
- /* result_len = self_len + count * (to_len-1) */
- assert(count > 0);
- if (to_len - 1 > (PY_SSIZE_T_MAX - self_len) / count) {
- PyErr_SetString(PyExc_OverflowError, "replace bytes is too long");
- return NULL;
- }
- result_len = self_len + count * (to_len - 1);
-
- if ( (result = (PyByteArrayObject *)
- PyByteArray_FromStringAndSize(NULL, result_len)) == NULL)
- return NULL;
- result_s = PyByteArray_AS_STRING(result);
-
- start = self_s;
- end = self_s + self_len;
- while (count-- > 0) {
- next = findchar(start, end-start, from_c);
- if (next == NULL)
- break;
-
- if (next == start) {
- /* replace with the 'to' */
- Py_MEMCPY(result_s, to_s, to_len);
- result_s += to_len;
- start += 1;
- } else {
- /* copy the unchanged old then the 'to' */
- Py_MEMCPY(result_s, start, next-start);
- result_s += (next-start);
- Py_MEMCPY(result_s, to_s, to_len);
- result_s += to_len;
- start = next+1;
- }
- }
- /* Copy the remainder of the remaining bytes */
- Py_MEMCPY(result_s, start, end-start);
-
- return result;
-}
-
-/* len(self)>=1, len(from)>=2, len(to)>=2, maxcount>=1 */
-Py_LOCAL(PyByteArrayObject *)
-replace_substring(PyByteArrayObject *self,
- const char *from_s, Py_ssize_t from_len,
- const char *to_s, Py_ssize_t to_len,
- Py_ssize_t maxcount)
-{
- char *self_s, *result_s;
- char *start, *next, *end;
- Py_ssize_t self_len, result_len;
- Py_ssize_t count, offset;
- PyByteArrayObject *result;
-
- self_s = PyByteArray_AS_STRING(self);
- self_len = PyByteArray_GET_SIZE(self);
-
- count = stringlib_count(self_s, self_len,
- from_s, from_len,
- maxcount);
-
- if (count == 0) {
- /* no matches, return unchanged */
- return return_self(self);
- }
-
- /* Check for overflow */
- /* result_len = self_len + count * (to_len-from_len) */
- assert(count > 0);
- if (to_len - from_len > (PY_SSIZE_T_MAX - self_len) / count) {
- PyErr_SetString(PyExc_OverflowError, "replace bytes is too long");
- return NULL;
- }
- result_len = self_len + count * (to_len - from_len);
-
- if ( (result = (PyByteArrayObject *)
- PyByteArray_FromStringAndSize(NULL, result_len)) == NULL)
- return NULL;
- result_s = PyByteArray_AS_STRING(result);
-
- start = self_s;
- end = self_s + self_len;
- while (count-- > 0) {
- offset = stringlib_find(start, end-start,
- from_s, from_len,
- 0);
- if (offset == -1)
- break;
- next = start+offset;
- if (next == start) {
- /* replace with the 'to' */
- Py_MEMCPY(result_s, to_s, to_len);
- result_s += to_len;
- start += from_len;
- } else {
- /* copy the unchanged old then the 'to' */
- Py_MEMCPY(result_s, start, next-start);
- result_s += (next-start);
- Py_MEMCPY(result_s, to_s, to_len);
- result_s += to_len;
- start = next+from_len;
- }
- }
- /* Copy the remainder of the remaining bytes */
- Py_MEMCPY(result_s, start, end-start);
-
- return result;
-}
-
-
-Py_LOCAL(PyByteArrayObject *)
-replace(PyByteArrayObject *self,
- const char *from_s, Py_ssize_t from_len,
- const char *to_s, Py_ssize_t to_len,
- Py_ssize_t maxcount)
-{
- if (maxcount < 0) {
- maxcount = PY_SSIZE_T_MAX;
- } else if (maxcount == 0 || PyByteArray_GET_SIZE(self) == 0) {
- /* nothing to do; return the original bytes */
- return return_self(self);
- }
-
- if (maxcount == 0 ||
- (from_len == 0 && to_len == 0)) {
- /* nothing to do; return the original bytes */
- return return_self(self);
- }
-
- /* Handle zero-length special cases */
-
- if (from_len == 0) {
- /* insert the 'to' bytes everywhere. */
- /* >>> "Python".replace("", ".") */
- /* '.P.y.t.h.o.n.' */
- return replace_interleave(self, to_s, to_len, maxcount);
- }
-
- /* Except for "".replace("", "A") == "A" there is no way beyond this */
- /* point for an empty self bytes to generate a non-empty bytes */
- /* Special case so the remaining code always gets a non-empty bytes */
- if (PyByteArray_GET_SIZE(self) == 0) {
- return return_self(self);
- }
-
- if (to_len == 0) {
- /* delete all occurrences of 'from' bytes */
- if (from_len == 1) {
- return replace_delete_single_character(
- self, from_s[0], maxcount);
- } else {
- return replace_delete_substring(self, from_s, from_len, maxcount);
- }
- }
-
- /* Handle special case where both bytes have the same length */
-
- if (from_len == to_len) {
- if (from_len == 1) {
- return replace_single_character_in_place(
- self,
- from_s[0],
- to_s[0],
- maxcount);
- } else {
- return replace_substring_in_place(
- self, from_s, from_len, to_s, to_len, maxcount);
- }
- }
-
- /* Otherwise use the more generic algorithms */
- if (from_len == 1) {
- return replace_single_character(self, from_s[0],
- to_s, to_len, maxcount);
- } else {
- /* len('from')>=2, len('to')>=1 */
- return replace_substring(self, from_s, from_len, to_s, to_len, maxcount);
- }
-}
-
-
/*[clinic input]
bytearray.replace
@@ -2153,9 +1328,9 @@
Py_buffer *new, Py_ssize_t count)
/*[clinic end generated code: output=d39884c4dc59412a input=aa379d988637c7fb]*/
{
- return (PyObject *)replace((PyByteArrayObject *) self,
- old->buf, old->len,
- new->buf, new->len, count);
+ return stringlib_replace((PyObject *)self,
+ (const char *)old->buf, old->len,
+ (const char *)new->buf, new->len, count);
}
/*[clinic input]
@@ -2203,7 +1378,6 @@
/*[clinic input]
bytearray.partition
- self: self(type="PyByteArrayObject *")
sep: object
/
@@ -2219,7 +1393,7 @@
static PyObject *
bytearray_partition(PyByteArrayObject *self, PyObject *sep)
-/*[clinic end generated code: output=45d2525ddd35f957 input=7d7fe37b1696d506]*/
+/*[clinic end generated code: output=45d2525ddd35f957 input=86f89223892b70b5]*/
{
PyObject *bytesep, *result;
@@ -2241,7 +1415,6 @@
/*[clinic input]
bytearray.rpartition
- self: self(type="PyByteArrayObject *")
sep: object
/
@@ -2257,7 +1430,7 @@
static PyObject *
bytearray_rpartition(PyByteArrayObject *self, PyObject *sep)
-/*[clinic end generated code: output=440de3c9426115e8 input=9b8cd540c1b75853]*/
+/*[clinic end generated code: output=440de3c9426115e8 input=5f4094f2de87c8f3]*/
{
PyObject *bytesep, *result;
@@ -2315,14 +1488,12 @@
/*[clinic input]
bytearray.reverse
- self: self(type="PyByteArrayObject *")
-
Reverse the order of the values in B in place.
[clinic start generated code]*/
static PyObject *
bytearray_reverse_impl(PyByteArrayObject *self)
-/*[clinic end generated code: output=9f7616f29ab309d3 input=7933a499b8597bd1]*/
+/*[clinic end generated code: output=9f7616f29ab309d3 input=543356319fc78557]*/
{
char swap, *head, *tail;
Py_ssize_t i, j, n = Py_SIZE(self);
@@ -2351,7 +1522,6 @@
/*[clinic input]
bytearray.insert
- self: self(type="PyByteArrayObject *")
index: Py_ssize_t
The index where the value is to be inserted.
item: bytesvalue
@@ -2363,7 +1533,7 @@
static PyObject *
bytearray_insert_impl(PyByteArrayObject *self, Py_ssize_t index, int item)
-/*[clinic end generated code: output=76c775a70e7b07b7 input=833766836ba30e1e]*/
+/*[clinic end generated code: output=76c775a70e7b07b7 input=b2b5d07e9de6c070]*/
{
Py_ssize_t n = Py_SIZE(self);
char *buf;
@@ -2393,7 +1563,6 @@
/*[clinic input]
bytearray.append
- self: self(type="PyByteArrayObject *")
item: bytesvalue
The item to be appended.
/
@@ -2403,7 +1572,7 @@
static PyObject *
bytearray_append_impl(PyByteArrayObject *self, int item)
-/*[clinic end generated code: output=a154e19ed1886cb6 input=ae56ea87380407cc]*/
+/*[clinic end generated code: output=a154e19ed1886cb6 input=20d6bec3d1340593]*/
{
Py_ssize_t n = Py_SIZE(self);
@@ -2423,7 +1592,6 @@
/*[clinic input]
bytearray.extend
- self: self(type="PyByteArrayObject *")
iterable_of_ints: object
The iterable of items to append.
/
@@ -2433,7 +1601,7 @@
static PyObject *
bytearray_extend(PyByteArrayObject *self, PyObject *iterable_of_ints)
-/*[clinic end generated code: output=98155dbe249170b1 input=ce83a5d75b70d850]*/
+/*[clinic end generated code: output=98155dbe249170b1 input=c617b3a93249ba28]*/
{
PyObject *it, *item, *bytearray_obj;
Py_ssize_t buf_size = 0, len = 0;
@@ -2508,7 +1676,6 @@
/*[clinic input]
bytearray.pop
- self: self(type="PyByteArrayObject *")
index: Py_ssize_t = -1
The index from where to remove the item.
-1 (the default value) means remove the last item.
@@ -2521,7 +1688,7 @@
static PyObject *
bytearray_pop_impl(PyByteArrayObject *self, Py_ssize_t index)
-/*[clinic end generated code: output=e0ccd401f8021da8 input=0797e6c0ca9d5a85]*/
+/*[clinic end generated code: output=e0ccd401f8021da8 input=3591df2d06c0d237]*/
{
int value;
Py_ssize_t n = Py_SIZE(self);
@@ -2553,7 +1720,6 @@
/*[clinic input]
bytearray.remove
- self: self(type="PyByteArrayObject *")
value: bytesvalue
The value to remove.
/
@@ -2563,20 +1729,20 @@
static PyObject *
bytearray_remove_impl(PyByteArrayObject *self, int value)
-/*[clinic end generated code: output=d659e37866709c13 input=47560b11fd856c24]*/
+/*[clinic end generated code: output=d659e37866709c13 input=121831240cd51ddf]*/
{
- Py_ssize_t n = Py_SIZE(self);
+ Py_ssize_t where, n = Py_SIZE(self);
char *buf = PyByteArray_AS_STRING(self);
- char *where = memchr(buf, value, n);
- if (!where) {
+ where = stringlib_find_char(buf, n, value);
+ if (where < 0) {
PyErr_SetString(PyExc_ValueError, "value not found in bytearray");
return NULL;
}
if (!_canresize(self))
return NULL;
- memmove(where, where + 1, buf + n - where);
+ memmove(buf + where, buf + where + 1, n - where);
if (PyByteArray_Resize((PyObject *)self, n - 1) < 0)
return NULL;
@@ -2586,8 +1752,8 @@
/* XXX These two helpers could be optimized if argsize == 1 */
static Py_ssize_t
-lstrip_helper(char *myptr, Py_ssize_t mysize,
- void *argptr, Py_ssize_t argsize)
+lstrip_helper(const char *myptr, Py_ssize_t mysize,
+ const void *argptr, Py_ssize_t argsize)
{
Py_ssize_t i = 0;
while (i < mysize && memchr(argptr, (unsigned char) myptr[i], argsize))
@@ -2596,8 +1762,8 @@
}
static Py_ssize_t
-rstrip_helper(char *myptr, Py_ssize_t mysize,
- void *argptr, Py_ssize_t argsize)
+rstrip_helper(const char *myptr, Py_ssize_t mysize,
+ const void *argptr, Py_ssize_t argsize)
{
Py_ssize_t i = mysize - 1;
while (i >= 0 && memchr(argptr, (unsigned char) myptr[i], argsize))
@@ -2798,22 +1964,6 @@
);
}
-static int
-hex_digit_to_int(Py_UCS4 c)
-{
- if (c >= 128)
- return -1;
- if (Py_ISDIGIT(c))
- return c - '0';
- else {
- if (Py_ISUPPER(c))
- c = Py_TOLOWER(c);
- if (c >= 'a' && c <= 'f')
- return c - 'a' + 10;
- }
- return -1;
-}
-
/*[clinic input]
@classmethod
bytearray.fromhex
@@ -2832,48 +1982,7 @@
bytearray_fromhex_impl(PyObject*cls, PyObject *string)
/*[clinic end generated code: output=df3da60129b3700c input=907bbd2d34d9367a]*/
{
- PyObject *newbytes;
- char *buf;
- Py_ssize_t hexlen, byteslen, i, j;
- int top, bot;
- void *data;
- unsigned int kind;
-
- assert(PyUnicode_Check(string));
- if (PyUnicode_READY(string))
- return NULL;
- kind = PyUnicode_KIND(string);
- data = PyUnicode_DATA(string);
- hexlen = PyUnicode_GET_LENGTH(string);
-
- byteslen = hexlen/2; /* This overestimates if there are spaces */
- newbytes = PyByteArray_FromStringAndSize(NULL, byteslen);
- if (!newbytes)
- return NULL;
- buf = PyByteArray_AS_STRING(newbytes);
- for (i = j = 0; i < hexlen; i += 2) {
- /* skip over spaces in the input */
- while (PyUnicode_READ(kind, data, i) == ' ')
- i++;
- if (i >= hexlen)
- break;
- top = hex_digit_to_int(PyUnicode_READ(kind, data, i));
- bot = hex_digit_to_int(PyUnicode_READ(kind, data, i+1));
- if (top == -1 || bot == -1) {
- PyErr_Format(PyExc_ValueError,
- "non-hexadecimal number found in "
- "fromhex() arg at position %zd", i);
- goto error;
- }
- buf[j++] = (top << 4) + bot;
- }
- if (PyByteArray_Resize(newbytes, j) < 0)
- goto error;
- return newbytes;
-
- error:
- Py_DECREF(newbytes);
- return NULL;
+ return _PyBytes_FromHex(string, 1);
}
PyDoc_STRVAR(hex__doc__,
@@ -2928,14 +2037,12 @@
/*[clinic input]
bytearray.__reduce__ as bytearray_reduce
- self: self(type="PyByteArrayObject *")
-
Return state information for pickling.
[clinic start generated code]*/
static PyObject *
bytearray_reduce_impl(PyByteArrayObject *self)
-/*[clinic end generated code: output=52bf304086464cab input=fbb07de4d102a03a]*/
+/*[clinic end generated code: output=52bf304086464cab input=44b5737ada62dd3f]*/
{
return _common_reduce(self, 2);
}
@@ -2943,7 +2050,6 @@
/*[clinic input]
bytearray.__reduce_ex__ as bytearray_reduce_ex
- self: self(type="PyByteArrayObject *")
proto: int = 0
/
@@ -2952,7 +2058,7 @@
static PyObject *
bytearray_reduce_ex_impl(PyByteArrayObject *self, int proto)
-/*[clinic end generated code: output=52eac33377197520 input=0e091a42ca6dbd91]*/
+/*[clinic end generated code: output=52eac33377197520 input=f129bc1a1aa151ee]*/
{
return _common_reduce(self, proto);
}
@@ -2960,14 +2066,12 @@
/*[clinic input]
bytearray.__sizeof__ as bytearray_sizeof
- self: self(type="PyByteArrayObject *")
-
Returns the size of the bytearray object in memory, in bytes.
[clinic start generated code]*/
static PyObject *
bytearray_sizeof_impl(PyByteArrayObject *self)
-/*[clinic end generated code: output=738abdd17951c427 input=6b23d305362b462b]*/
+/*[clinic end generated code: output=738abdd17951c427 input=e27320fd98a4bc5a]*/
{
Py_ssize_t res;
@@ -3008,19 +2112,22 @@
BYTEARRAY_APPEND_METHODDEF
{"capitalize", (PyCFunction)stringlib_capitalize, METH_NOARGS,
_Py_capitalize__doc__},
- {"center", (PyCFunction)stringlib_center, METH_VARARGS, center__doc__},
+ {"center", (PyCFunction)stringlib_center, METH_VARARGS, _Py_center__doc__},
BYTEARRAY_CLEAR_METHODDEF
BYTEARRAY_COPY_METHODDEF
- {"count", (PyCFunction)bytearray_count, METH_VARARGS, count__doc__},
+ {"count", (PyCFunction)bytearray_count, METH_VARARGS,
+ _Py_count__doc__},
BYTEARRAY_DECODE_METHODDEF
- {"endswith", (PyCFunction)bytearray_endswith, METH_VARARGS, endswith__doc__},
+ {"endswith", (PyCFunction)bytearray_endswith, METH_VARARGS,
+ _Py_endswith__doc__},
{"expandtabs", (PyCFunction)stringlib_expandtabs, METH_VARARGS | METH_KEYWORDS,
- expandtabs__doc__},
+ _Py_expandtabs__doc__},
BYTEARRAY_EXTEND_METHODDEF
- {"find", (PyCFunction)bytearray_find, METH_VARARGS, find__doc__},
+ {"find", (PyCFunction)bytearray_find, METH_VARARGS,
+ _Py_find__doc__},
BYTEARRAY_FROMHEX_METHODDEF
{"hex", (PyCFunction)bytearray_hex, METH_NOARGS, hex__doc__},
- {"index", (PyCFunction)bytearray_index, METH_VARARGS, index__doc__},
+ {"index", (PyCFunction)bytearray_index, METH_VARARGS, _Py_index__doc__},
BYTEARRAY_INSERT_METHODDEF
{"isalnum", (PyCFunction)stringlib_isalnum, METH_NOARGS,
_Py_isalnum__doc__},
@@ -3037,7 +2144,7 @@
{"isupper", (PyCFunction)stringlib_isupper, METH_NOARGS,
_Py_isupper__doc__},
BYTEARRAY_JOIN_METHODDEF
- {"ljust", (PyCFunction)stringlib_ljust, METH_VARARGS, ljust__doc__},
+ {"ljust", (PyCFunction)stringlib_ljust, METH_VARARGS, _Py_ljust__doc__},
{"lower", (PyCFunction)stringlib_lower, METH_NOARGS, _Py_lower__doc__},
BYTEARRAY_LSTRIP_METHODDEF
BYTEARRAY_MAKETRANS_METHODDEF
@@ -3046,23 +2153,23 @@
BYTEARRAY_REMOVE_METHODDEF
BYTEARRAY_REPLACE_METHODDEF
BYTEARRAY_REVERSE_METHODDEF
- {"rfind", (PyCFunction)bytearray_rfind, METH_VARARGS, rfind__doc__},
- {"rindex", (PyCFunction)bytearray_rindex, METH_VARARGS, rindex__doc__},
- {"rjust", (PyCFunction)stringlib_rjust, METH_VARARGS, rjust__doc__},
+ {"rfind", (PyCFunction)bytearray_rfind, METH_VARARGS, _Py_rfind__doc__},
+ {"rindex", (PyCFunction)bytearray_rindex, METH_VARARGS, _Py_rindex__doc__},
+ {"rjust", (PyCFunction)stringlib_rjust, METH_VARARGS, _Py_rjust__doc__},
BYTEARRAY_RPARTITION_METHODDEF
BYTEARRAY_RSPLIT_METHODDEF
BYTEARRAY_RSTRIP_METHODDEF
BYTEARRAY_SPLIT_METHODDEF
BYTEARRAY_SPLITLINES_METHODDEF
{"startswith", (PyCFunction)bytearray_startswith, METH_VARARGS ,
- startswith__doc__},
+ _Py_startswith__doc__},
BYTEARRAY_STRIP_METHODDEF
{"swapcase", (PyCFunction)stringlib_swapcase, METH_NOARGS,
_Py_swapcase__doc__},
{"title", (PyCFunction)stringlib_title, METH_NOARGS, _Py_title__doc__},
BYTEARRAY_TRANSLATE_METHODDEF
{"upper", (PyCFunction)stringlib_upper, METH_NOARGS, _Py_upper__doc__},
- {"zfill", (PyCFunction)stringlib_zfill, METH_VARARGS, zfill__doc__},
+ {"zfill", (PyCFunction)stringlib_zfill, METH_VARARGS, _Py_zfill__doc__},
{NULL}
};
@@ -3071,7 +2178,7 @@
{
if (!PyByteArray_Check(v))
Py_RETURN_NOTIMPLEMENTED;
- return bytearray_format((PyByteArrayObject *)v, w);
+ return _PyBytes_FormatEx(PyByteArray_AS_STRING(v), PyByteArray_GET_SIZE(v), w, 1);
}
static PyNumberMethods bytearray_as_number = {
diff --git a/Objects/bytes_methods.c b/Objects/bytes_methods.c
index a299915..fe666c6 100644
--- a/Objects/bytes_methods.c
+++ b/Objects/bytes_methods.c
@@ -277,7 +277,7 @@
characters, all remaining cased characters have lowercase.");
void
-_Py_bytes_title(char *result, char *s, Py_ssize_t len)
+_Py_bytes_title(char *result, const char *s, Py_ssize_t len)
{
Py_ssize_t i;
int previous_is_cased = 0;
@@ -306,7 +306,7 @@
and the rest lower-cased.");
void
-_Py_bytes_capitalize(char *result, char *s, Py_ssize_t len)
+_Py_bytes_capitalize(char *result, const char *s, Py_ssize_t len)
{
Py_ssize_t i;
@@ -336,7 +336,7 @@
to lowercase ASCII and vice versa.");
void
-_Py_bytes_swapcase(char *result, char *s, Py_ssize_t len)
+_Py_bytes_swapcase(char *result, const char *s, Py_ssize_t len)
{
Py_ssize_t i;
@@ -387,3 +387,427 @@
return res;
}
+
+#define FASTSEARCH fastsearch
+#define STRINGLIB(F) stringlib_##F
+#define STRINGLIB_CHAR char
+#define STRINGLIB_SIZEOF_CHAR 1
+
+#include "stringlib/fastsearch.h"
+#include "stringlib/count.h"
+#include "stringlib/find.h"
+
+/*
+Wraps stringlib_parse_args_finds() and additionally checks whether the
+first argument is an integer in range(0, 256).
+
+If this is the case, writes the integer value to the byte parameter
+and sets subobj to NULL. Otherwise, sets the first argument to subobj
+and doesn't touch byte. The other parameters are similar to those of
+stringlib_parse_args_finds().
+*/
+
+Py_LOCAL_INLINE(int)
+parse_args_finds_byte(const char *function_name, PyObject *args,
+ PyObject **subobj, char *byte,
+ Py_ssize_t *start, Py_ssize_t *end)
+{
+ PyObject *tmp_subobj;
+ Py_ssize_t ival;
+ PyObject *err;
+
+ if(!stringlib_parse_args_finds(function_name, args, &tmp_subobj,
+ start, end))
+ return 0;
+
+ if (!PyNumber_Check(tmp_subobj)) {
+ *subobj = tmp_subobj;
+ return 1;
+ }
+
+ ival = PyNumber_AsSsize_t(tmp_subobj, PyExc_OverflowError);
+ if (ival == -1) {
+ err = PyErr_Occurred();
+ if (err && !PyErr_GivenExceptionMatches(err, PyExc_OverflowError)) {
+ PyErr_Clear();
+ *subobj = tmp_subobj;
+ return 1;
+ }
+ }
+
+ if (ival < 0 || ival > 255) {
+ PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)");
+ return 0;
+ }
+
+ *subobj = NULL;
+ *byte = (char)ival;
+ return 1;
+}
+
+/* helper macro to fixup start/end slice values */
+#define ADJUST_INDICES(start, end, len) \
+ if (end > len) \
+ end = len; \
+ else if (end < 0) { \
+ end += len; \
+ if (end < 0) \
+ end = 0; \
+ } \
+ if (start < 0) { \
+ start += len; \
+ if (start < 0) \
+ start = 0; \
+ }
+
+Py_LOCAL_INLINE(Py_ssize_t)
+find_internal(const char *str, Py_ssize_t len,
+ const char *function_name, PyObject *args, int dir)
+{
+ PyObject *subobj;
+ char byte;
+ Py_buffer subbuf;
+ const char *sub;
+ Py_ssize_t sub_len;
+ Py_ssize_t start = 0, end = PY_SSIZE_T_MAX;
+ Py_ssize_t res;
+
+ if (!parse_args_finds_byte(function_name, args,
+ &subobj, &byte, &start, &end))
+ return -2;
+
+ if (subobj) {
+ if (PyObject_GetBuffer(subobj, &subbuf, PyBUF_SIMPLE) != 0)
+ return -2;
+
+ sub = subbuf.buf;
+ sub_len = subbuf.len;
+ }
+ else {
+ sub = &byte;
+ sub_len = 1;
+ }
+
+ ADJUST_INDICES(start, end, len);
+ if (end - start < sub_len)
+ res = -1;
+ else if (sub_len == 1) {
+ if (dir > 0)
+ res = stringlib_find_char(
+ str + start, end - start,
+ *sub);
+ else
+ res = stringlib_rfind_char(
+ str + start, end - start,
+ *sub);
+ if (res >= 0)
+ res += start;
+ }
+ else {
+ if (dir > 0)
+ res = stringlib_find_slice(
+ str, len,
+ sub, sub_len, start, end);
+ else
+ res = stringlib_rfind_slice(
+ str, len,
+ sub, sub_len, start, end);
+ }
+
+ if (subobj)
+ PyBuffer_Release(&subbuf);
+
+ return res;
+}
+
+PyDoc_STRVAR_shared(_Py_find__doc__,
+"B.find(sub[, start[, end]]) -> int\n\
+\n\
+Return the lowest index in B where subsection sub is found,\n\
+such that sub is contained within B[start,end]. Optional\n\
+arguments start and end are interpreted as in slice notation.\n\
+\n\
+Return -1 on failure.");
+
+PyObject *
+_Py_bytes_find(const char *str, Py_ssize_t len, PyObject *args)
+{
+ Py_ssize_t result = find_internal(str, len, "find", args, +1);
+ if (result == -2)
+ return NULL;
+ return PyLong_FromSsize_t(result);
+}
+
+PyDoc_STRVAR_shared(_Py_index__doc__,
+"B.index(sub[, start[, end]]) -> int\n\
+\n\
+Like B.find() but raise ValueError when the subsection is not found.");
+
+PyObject *
+_Py_bytes_index(const char *str, Py_ssize_t len, PyObject *args)
+{
+ Py_ssize_t result = find_internal(str, len, "index", args, +1);
+ if (result == -2)
+ return NULL;
+ if (result == -1) {
+ PyErr_SetString(PyExc_ValueError,
+ "subsection not found");
+ return NULL;
+ }
+ return PyLong_FromSsize_t(result);
+}
+
+PyDoc_STRVAR_shared(_Py_rfind__doc__,
+"B.rfind(sub[, start[, end]]) -> int\n\
+\n\
+Return the highest index in B where subsection sub is found,\n\
+such that sub is contained within B[start,end]. Optional\n\
+arguments start and end are interpreted as in slice notation.\n\
+\n\
+Return -1 on failure.");
+
+PyObject *
+_Py_bytes_rfind(const char *str, Py_ssize_t len, PyObject *args)
+{
+ Py_ssize_t result = find_internal(str, len, "rfind", args, -1);
+ if (result == -2)
+ return NULL;
+ return PyLong_FromSsize_t(result);
+}
+
+PyDoc_STRVAR_shared(_Py_rindex__doc__,
+"B.rindex(sub[, start[, end]]) -> int\n\
+\n\
+Like B.rfind() but raise ValueError when the subsection is not found.");
+
+PyObject *
+_Py_bytes_rindex(const char *str, Py_ssize_t len, PyObject *args)
+{
+ Py_ssize_t result = find_internal(str, len, "rindex", args, -1);
+ if (result == -2)
+ return NULL;
+ if (result == -1) {
+ PyErr_SetString(PyExc_ValueError,
+ "subsection not found");
+ return NULL;
+ }
+ return PyLong_FromSsize_t(result);
+}
+
+PyDoc_STRVAR_shared(_Py_count__doc__,
+"B.count(sub[, start[, end]]) -> int\n\
+\n\
+Return the number of non-overlapping occurrences of subsection sub in\n\
+bytes B[start:end]. Optional arguments start and end are interpreted\n\
+as in slice notation.");
+
+PyObject *
+_Py_bytes_count(const char *str, Py_ssize_t len, PyObject *args)
+{
+ PyObject *sub_obj;
+ const char *sub;
+ Py_ssize_t sub_len;
+ char byte;
+ Py_ssize_t start = 0, end = PY_SSIZE_T_MAX;
+
+ Py_buffer vsub;
+ PyObject *count_obj;
+
+ if (!parse_args_finds_byte("count", args,
+ &sub_obj, &byte, &start, &end))
+ return NULL;
+
+ if (sub_obj) {
+ if (PyObject_GetBuffer(sub_obj, &vsub, PyBUF_SIMPLE) != 0)
+ return NULL;
+
+ sub = vsub.buf;
+ sub_len = vsub.len;
+ }
+ else {
+ sub = &byte;
+ sub_len = 1;
+ }
+
+ ADJUST_INDICES(start, end, len);
+
+ count_obj = PyLong_FromSsize_t(
+ stringlib_count(str + start, end - start, sub, sub_len, PY_SSIZE_T_MAX)
+ );
+
+ if (sub_obj)
+ PyBuffer_Release(&vsub);
+
+ return count_obj;
+}
+
+int
+_Py_bytes_contains(const char *str, Py_ssize_t len, PyObject *arg)
+{
+ Py_ssize_t ival = PyNumber_AsSsize_t(arg, PyExc_ValueError);
+ if (ival == -1 && PyErr_Occurred()) {
+ Py_buffer varg;
+ Py_ssize_t pos;
+ PyErr_Clear();
+ if (PyObject_GetBuffer(arg, &varg, PyBUF_SIMPLE) != 0)
+ return -1;
+ pos = stringlib_find(str, len,
+ varg.buf, varg.len, 0);
+ PyBuffer_Release(&varg);
+ return pos >= 0;
+ }
+ if (ival < 0 || ival >= 256) {
+ PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)");
+ return -1;
+ }
+
+ return memchr(str, (int) ival, len) != NULL;
+}
+
+
+/* Matches the end (direction >= 0) or start (direction < 0) of the buffer
+ * against substr, using the start and end arguments. Returns
+ * -1 on error, 0 if not found and 1 if found.
+ */
+Py_LOCAL(int)
+tailmatch(const char *str, Py_ssize_t len, PyObject *substr,
+ Py_ssize_t start, Py_ssize_t end, int direction)
+{
+ Py_buffer sub_view = {NULL, NULL};
+ const char *sub;
+ Py_ssize_t slen;
+
+ if (PyBytes_Check(substr)) {
+ sub = PyBytes_AS_STRING(substr);
+ slen = PyBytes_GET_SIZE(substr);
+ }
+ else {
+ if (PyObject_GetBuffer(substr, &sub_view, PyBUF_SIMPLE) != 0)
+ return -1;
+ sub = sub_view.buf;
+ slen = sub_view.len;
+ }
+
+ ADJUST_INDICES(start, end, len);
+
+ if (direction < 0) {
+ /* startswith */
+ if (start + slen > len)
+ goto notfound;
+ } else {
+ /* endswith */
+ if (end - start < slen || start > len)
+ goto notfound;
+
+ if (end - slen > start)
+ start = end - slen;
+ }
+ if (end - start < slen)
+ goto notfound;
+ if (memcmp(str + start, sub, slen) != 0)
+ goto notfound;
+
+ PyBuffer_Release(&sub_view);
+ return 1;
+
+notfound:
+ PyBuffer_Release(&sub_view);
+ return 0;
+}
+
+Py_LOCAL(PyObject *)
+_Py_bytes_tailmatch(const char *str, Py_ssize_t len,
+ const char *function_name, PyObject *args,
+ int direction)
+{
+ Py_ssize_t start = 0;
+ Py_ssize_t end = PY_SSIZE_T_MAX;
+ PyObject *subobj;
+ int result;
+
+ if (!stringlib_parse_args_finds(function_name, args, &subobj, &start, &end))
+ return NULL;
+ if (PyTuple_Check(subobj)) {
+ Py_ssize_t i;
+ for (i = 0; i < PyTuple_GET_SIZE(subobj); i++) {
+ result = tailmatch(str, len, PyTuple_GET_ITEM(subobj, i),
+ start, end, direction);
+ if (result == -1)
+ return NULL;
+ else if (result) {
+ Py_RETURN_TRUE;
+ }
+ }
+ Py_RETURN_FALSE;
+ }
+ result = tailmatch(str, len, subobj, start, end, direction);
+ if (result == -1) {
+ if (PyErr_ExceptionMatches(PyExc_TypeError))
+ PyErr_Format(PyExc_TypeError,
+ "%s first arg must be bytes or a tuple of bytes, "
+ "not %s",
+ function_name, Py_TYPE(subobj)->tp_name);
+ return NULL;
+ }
+ else
+ return PyBool_FromLong(result);
+}
+
+PyDoc_STRVAR_shared(_Py_startswith__doc__,
+"B.startswith(prefix[, start[, end]]) -> bool\n\
+\n\
+Return True if B starts with the specified prefix, False otherwise.\n\
+With optional start, test B beginning at that position.\n\
+With optional end, stop comparing B at that position.\n\
+prefix can also be a tuple of bytes to try.");
+
+PyObject *
+_Py_bytes_startswith(const char *str, Py_ssize_t len, PyObject *args)
+{
+ return _Py_bytes_tailmatch(str, len, "startswith", args, -1);
+}
+
+PyDoc_STRVAR_shared(_Py_endswith__doc__,
+"B.endswith(suffix[, start[, end]]) -> bool\n\
+\n\
+Return True if B ends with the specified suffix, False otherwise.\n\
+With optional start, test B beginning at that position.\n\
+With optional end, stop comparing B at that position.\n\
+suffix can also be a tuple of bytes to try.");
+
+PyObject *
+_Py_bytes_endswith(const char *str, Py_ssize_t len, PyObject *args)
+{
+ return _Py_bytes_tailmatch(str, len, "endswith", args, +1);
+}
+
+PyDoc_STRVAR_shared(_Py_expandtabs__doc__,
+"B.expandtabs(tabsize=8) -> copy of B\n\
+\n\
+Return a copy of B where all tab characters are expanded using spaces.\n\
+If tabsize is not given, a tab size of 8 characters is assumed.");
+
+PyDoc_STRVAR_shared(_Py_ljust__doc__,
+"B.ljust(width[, fillchar]) -> copy of B\n"
+"\n"
+"Return B left justified in a string of length width. Padding is\n"
+"done using the specified fill character (default is a space).");
+
+PyDoc_STRVAR_shared(_Py_rjust__doc__,
+"B.rjust(width[, fillchar]) -> copy of B\n"
+"\n"
+"Return B right justified in a string of length width. Padding is\n"
+"done using the specified fill character (default is a space)");
+
+PyDoc_STRVAR_shared(_Py_center__doc__,
+"B.center(width[, fillchar]) -> copy of B\n"
+"\n"
+"Return B centered in a string of length width. Padding is\n"
+"done using the specified fill character (default is a space).");
+
+PyDoc_STRVAR_shared(_Py_zfill__doc__,
+"B.zfill(width) -> copy of B\n"
+"\n"
+"Pad a numeric string B with zeros on the left, to fill a field\n"
+"of the specified width. B is never truncated.");
+
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index c2aa65c..83776aa 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -9,9 +9,9 @@
#include <stddef.h>
/*[clinic input]
-class bytes "PyBytesObject*" "&PyBytes_Type"
+class bytes "PyBytesObject *" "&PyBytes_Type"
[clinic start generated code]*/
-/*[clinic end generated code: output=da39a3ee5e6b4b0d input=1a1d9102afc1b00c]*/
+/*[clinic end generated code: output=da39a3ee5e6b4b0d input=7a238f965d64892b]*/
#include "clinic/bytesobject.c.h"
@@ -30,6 +30,10 @@
*/
#define PyBytesObject_SIZE (offsetof(PyBytesObject, ob_sval) + 1)
+/* Forward declaration */
+Py_LOCAL_INLINE(Py_ssize_t) _PyBytesWriter_GetSize(_PyBytesWriter *writer,
+ char *str);
+
/*
For PyBytes_FromString(), the parameter `str' points to a null-terminated
string containing exactly `size' bytes.
@@ -174,190 +178,184 @@
PyObject *
PyBytes_FromFormatV(const char *format, va_list vargs)
{
- va_list count;
- Py_ssize_t n = 0;
- const char* f;
char *s;
- PyObject* string;
+ const char *f;
+ const char *p;
+ Py_ssize_t prec;
+ int longflag;
+ int size_tflag;
+ /* Longest 64-bit formatted numbers:
+ - "18446744073709551615\0" (21 bytes)
+ - "-9223372036854775808\0" (21 bytes)
+ Decimal takes the most space (it isn't enough for octal.)
- Py_VA_COPY(count, vargs);
- /* step 1: figure out how large a buffer we need */
- for (f = format; *f; f++) {
- if (*f == '%') {
- const char* p = f;
- while (*++f && *f != '%' && !Py_ISALPHA(*f))
- ;
+ Longest 64-bit pointer representation:
+ "0xffffffffffffffff\0" (19 bytes). */
+ char buffer[21];
+ _PyBytesWriter writer;
- /* skip the 'l' or 'z' in {%ld, %zd, %lu, %zu} since
- * they don't affect the amount of space we reserve.
- */
- if ((*f == 'l' || *f == 'z') &&
- (f[1] == 'd' || f[1] == 'u'))
- ++f;
+ _PyBytesWriter_Init(&writer);
- switch (*f) {
- case 'c':
- {
- int c = va_arg(count, int);
- if (c < 0 || c > 255) {
- PyErr_SetString(PyExc_OverflowError,
- "PyBytes_FromFormatV(): %c format "
- "expects an integer in range [0; 255]");
- return NULL;
- }
- n++;
- break;
- }
- case '%':
- n++;
- break;
- case 'd': case 'u': case 'i': case 'x':
- (void) va_arg(count, int);
- /* 20 bytes is enough to hold a 64-bit
- integer. Decimal takes the most space.
- This isn't enough for octal. */
- n += 20;
- break;
- case 's':
- s = va_arg(count, char*);
- n += strlen(s);
- break;
- case 'p':
- (void) va_arg(count, int);
- /* maximum 64-bit pointer representation:
- * 0xffffffffffffffff
- * so 19 characters is enough.
- * XXX I count 18 -- what's the extra for?
- */
- n += 19;
- break;
- default:
- /* if we stumble upon an unknown
- formatting code, copy the rest of
- the format string to the output
- string. (we cannot just skip the
- code, since there's no way to know
- what's in the argument list) */
- n += strlen(p);
- goto expand;
- }
- } else
- n++;
- }
- expand:
- /* step 2: fill the buffer */
- /* Since we've analyzed how much space we need for the worst case,
- use sprintf directly instead of the slower PyOS_snprintf. */
- string = PyBytes_FromStringAndSize(NULL, n);
- if (!string)
+ s = _PyBytesWriter_Alloc(&writer, strlen(format));
+ if (s == NULL)
return NULL;
+ writer.overallocate = 1;
- s = PyBytes_AsString(string);
+#define WRITE_BYTES(str) \
+ do { \
+ s = _PyBytesWriter_WriteBytes(&writer, s, (str), strlen(str)); \
+ if (s == NULL) \
+ goto error; \
+ } while (0)
for (f = format; *f; f++) {
- if (*f == '%') {
- const char* p = f++;
+ if (*f != '%') {
+ *s++ = *f;
+ continue;
+ }
+
+ p = f++;
+
+ /* ignore the width (ex: 10 in "%10s") */
+ while (Py_ISDIGIT(*f))
+ f++;
+
+ /* parse the precision (ex: 10 in "%.10s") */
+ prec = 0;
+ if (*f == '.') {
+ f++;
+ for (; Py_ISDIGIT(*f); f++) {
+ prec = (prec * 10) + (*f - '0');
+ }
+ }
+
+ while (*f && *f != '%' && !Py_ISALPHA(*f))
+ f++;
+
+ /* handle the long flag ('l'), but only for %ld and %lu.
+ others can be added when necessary. */
+ longflag = 0;
+ if (*f == 'l' && (f[1] == 'd' || f[1] == 'u')) {
+ longflag = 1;
+ ++f;
+ }
+
+ /* handle the size_t flag ('z'). */
+ size_tflag = 0;
+ if (*f == 'z' && (f[1] == 'd' || f[1] == 'u')) {
+ size_tflag = 1;
+ ++f;
+ }
+
+ /* substract bytes preallocated for the format string
+ (ex: 2 for "%s") */
+ writer.min_size -= (f - p + 1);
+
+ switch (*f) {
+ case 'c':
+ {
+ int c = va_arg(vargs, int);
+ if (c < 0 || c > 255) {
+ PyErr_SetString(PyExc_OverflowError,
+ "PyBytes_FromFormatV(): %c format "
+ "expects an integer in range [0; 255]");
+ goto error;
+ }
+ writer.min_size++;
+ *s++ = (unsigned char)c;
+ break;
+ }
+
+ case 'd':
+ if (longflag)
+ sprintf(buffer, "%ld", va_arg(vargs, long));
+ else if (size_tflag)
+ sprintf(buffer, "%" PY_FORMAT_SIZE_T "d",
+ va_arg(vargs, Py_ssize_t));
+ else
+ sprintf(buffer, "%d", va_arg(vargs, int));
+ assert(strlen(buffer) < sizeof(buffer));
+ WRITE_BYTES(buffer);
+ break;
+
+ case 'u':
+ if (longflag)
+ sprintf(buffer, "%lu",
+ va_arg(vargs, unsigned long));
+ else if (size_tflag)
+ sprintf(buffer, "%" PY_FORMAT_SIZE_T "u",
+ va_arg(vargs, size_t));
+ else
+ sprintf(buffer, "%u",
+ va_arg(vargs, unsigned int));
+ assert(strlen(buffer) < sizeof(buffer));
+ WRITE_BYTES(buffer);
+ break;
+
+ case 'i':
+ sprintf(buffer, "%i", va_arg(vargs, int));
+ assert(strlen(buffer) < sizeof(buffer));
+ WRITE_BYTES(buffer);
+ break;
+
+ case 'x':
+ sprintf(buffer, "%x", va_arg(vargs, int));
+ assert(strlen(buffer) < sizeof(buffer));
+ WRITE_BYTES(buffer);
+ break;
+
+ case 's':
+ {
Py_ssize_t i;
- int longflag = 0;
- int size_tflag = 0;
- /* parse the width.precision part (we're only
- interested in the precision value, if any) */
- n = 0;
- while (Py_ISDIGIT(*f))
- n = (n*10) + *f++ - '0';
- if (*f == '.') {
- f++;
- n = 0;
- while (Py_ISDIGIT(*f))
- n = (n*10) + *f++ - '0';
+
+ p = va_arg(vargs, const char*);
+ i = strlen(p);
+ if (prec > 0 && i > prec)
+ i = prec;
+ s = _PyBytesWriter_WriteBytes(&writer, s, p, i);
+ if (s == NULL)
+ goto error;
+ break;
+ }
+
+ case 'p':
+ sprintf(buffer, "%p", va_arg(vargs, void*));
+ assert(strlen(buffer) < sizeof(buffer));
+ /* %p is ill-defined: ensure leading 0x. */
+ if (buffer[1] == 'X')
+ buffer[1] = 'x';
+ else if (buffer[1] != 'x') {
+ memmove(buffer+2, buffer, strlen(buffer)+1);
+ buffer[0] = '0';
+ buffer[1] = 'x';
}
- while (*f && *f != '%' && !Py_ISALPHA(*f))
- f++;
- /* handle the long flag, but only for %ld and %lu.
- others can be added when necessary. */
- if (*f == 'l' && (f[1] == 'd' || f[1] == 'u')) {
- longflag = 1;
- ++f;
- }
- /* handle the size_t flag. */
- if (*f == 'z' && (f[1] == 'd' || f[1] == 'u')) {
- size_tflag = 1;
- ++f;
+ WRITE_BYTES(buffer);
+ break;
+
+ case '%':
+ writer.min_size++;
+ *s++ = '%';
+ break;
+
+ default:
+ if (*f == 0) {
+ /* fix min_size if we reached the end of the format string */
+ writer.min_size++;
}
- switch (*f) {
- case 'c':
- {
- int c = va_arg(vargs, int);
- /* c has been checked for overflow in the first step */
- *s++ = (unsigned char)c;
- break;
- }
- case 'd':
- if (longflag)
- sprintf(s, "%ld", va_arg(vargs, long));
- else if (size_tflag)
- sprintf(s, "%" PY_FORMAT_SIZE_T "d",
- va_arg(vargs, Py_ssize_t));
- else
- sprintf(s, "%d", va_arg(vargs, int));
- s += strlen(s);
- break;
- case 'u':
- if (longflag)
- sprintf(s, "%lu",
- va_arg(vargs, unsigned long));
- else if (size_tflag)
- sprintf(s, "%" PY_FORMAT_SIZE_T "u",
- va_arg(vargs, size_t));
- else
- sprintf(s, "%u",
- va_arg(vargs, unsigned int));
- s += strlen(s);
- break;
- case 'i':
- sprintf(s, "%i", va_arg(vargs, int));
- s += strlen(s);
- break;
- case 'x':
- sprintf(s, "%x", va_arg(vargs, int));
- s += strlen(s);
- break;
- case 's':
- p = va_arg(vargs, char*);
- i = strlen(p);
- if (n > 0 && i > n)
- i = n;
- Py_MEMCPY(s, p, i);
- s += i;
- break;
- case 'p':
- sprintf(s, "%p", va_arg(vargs, void*));
- /* %p is ill-defined: ensure leading 0x. */
- if (s[1] == 'X')
- s[1] = 'x';
- else if (s[1] != 'x') {
- memmove(s+2, s, strlen(s)+1);
- s[0] = '0';
- s[1] = 'x';
- }
- s += strlen(s);
- break;
- case '%':
- *s++ = '%';
- break;
- default:
- strcpy(s, p);
- s += strlen(s);
- goto end;
- }
- } else
- *s++ = *f;
+ /* invalid format string: copy unformatted string and exit */
+ WRITE_BYTES(p);
+ return _PyBytesWriter_Finish(&writer, s);
+ }
}
- end:
- _PyBytes_Resize(&string, s - PyBytes_AS_STRING(string));
- return string;
+#undef WRITE_BYTES
+
+ return _PyBytesWriter_Finish(&writer, s);
+
+ error:
+ _PyBytesWriter_Dealloc(&writer);
+ return NULL;
}
PyObject *
@@ -409,12 +407,14 @@
/* Returns a new reference to a PyBytes object, or NULL on failure. */
-static PyObject *
-formatfloat(PyObject *v, int flags, int prec, int type)
+static char*
+formatfloat(PyObject *v, int flags, int prec, int type,
+ PyObject **p_result, _PyBytesWriter *writer, char *str)
{
char *p;
PyObject *result;
double x;
+ size_t len;
x = PyFloat_AsDouble(v);
if (x == -1.0 && PyErr_Occurred()) {
@@ -431,9 +431,22 @@
if (p == NULL)
return NULL;
- result = PyBytes_FromStringAndSize(p, strlen(p));
+
+ len = strlen(p);
+ if (writer != NULL) {
+ str = _PyBytesWriter_Prepare(writer, str, len);
+ if (str == NULL)
+ return NULL;
+ Py_MEMCPY(str, p, len);
+ PyMem_Free(p);
+ str += len;
+ return str;
+ }
+
+ result = PyBytes_FromStringAndSize(p, len);
PyMem_Free(p);
- return result;
+ *p_result = result;
+ return str;
}
static PyObject *
@@ -473,11 +486,11 @@
static int
byte_converter(PyObject *arg, char *p)
{
- if (PyBytes_Check(arg) && PyBytes_Size(arg) == 1) {
+ if (PyBytes_Check(arg) && PyBytes_GET_SIZE(arg) == 1) {
*p = PyBytes_AS_STRING(arg)[0];
return 1;
}
- else if (PyByteArray_Check(arg) && PyByteArray_Size(arg) == 1) {
+ else if (PyByteArray_Check(arg) && PyByteArray_GET_SIZE(arg) == 1) {
*p = PyByteArray_AS_STRING(arg)[0];
return 1;
}
@@ -557,36 +570,36 @@
return NULL;
}
-/* fmt%(v1,v2,...) is roughly equivalent to sprintf(fmt, v1, v2, ...)
-
- FORMATBUFLEN is the length of the buffer in which the ints &
- chars are formatted. XXX This is a magic number. Each formatting
- routine does bounds checking to ensure no overflow, but a better
- solution may be to malloc a buffer of appropriate size for each
- format. For now, the current solution is sufficient.
-*/
-#define FORMATBUFLEN (size_t)120
+/* fmt%(v1,v2,...) is roughly equivalent to sprintf(fmt, v1, v2, ...) */
PyObject *
-_PyBytes_Format(PyObject *format, PyObject *args)
+_PyBytes_FormatEx(const char *format, Py_ssize_t format_len,
+ PyObject *args, int use_bytearray)
{
- char *fmt, *res;
+ const char *fmt;
+ char *res;
Py_ssize_t arglen, argidx;
- Py_ssize_t reslen, rescnt, fmtcnt;
+ Py_ssize_t fmtcnt;
int args_owned = 0;
- PyObject *result;
PyObject *dict = NULL;
- if (format == NULL || !PyBytes_Check(format) || args == NULL) {
+ _PyBytesWriter writer;
+
+ if (args == NULL) {
PyErr_BadInternalCall();
return NULL;
}
- fmt = PyBytes_AS_STRING(format);
- fmtcnt = PyBytes_GET_SIZE(format);
- reslen = rescnt = fmtcnt + 100;
- result = PyBytes_FromStringAndSize((char *)NULL, reslen);
- if (result == NULL)
+ fmt = format;
+ fmtcnt = format_len;
+
+ _PyBytesWriter_Init(&writer);
+ writer.use_bytearray = use_bytearray;
+
+ res = _PyBytesWriter_Alloc(&writer, fmtcnt);
+ if (res == NULL)
return NULL;
- res = PyBytes_AsString(result);
+ if (!use_bytearray)
+ writer.overallocate = 1;
+
if (PyTuple_Check(args)) {
arglen = PyTuple_GET_SIZE(args);
argidx = 0;
@@ -600,18 +613,23 @@
!PyByteArray_Check(args)) {
dict = args;
}
+
while (--fmtcnt >= 0) {
if (*fmt != '%') {
- if (--rescnt < 0) {
- rescnt = fmtcnt + 100;
- reslen += rescnt;
- if (_PyBytes_Resize(&result, reslen))
- return NULL;
- res = PyBytes_AS_STRING(result)
- + reslen - rescnt;
- --rescnt;
- }
- *res++ = *fmt++;
+ Py_ssize_t len;
+ char *pos;
+
+ pos = strchr(fmt + 1, '%');
+ if (pos != NULL)
+ len = pos - fmt;
+ else
+ len = format_len - (fmt - format);
+ assert(len != 0);
+
+ Py_MEMCPY(res, fmt, len);
+ res += len;
+ fmt += len;
+ fmtcnt -= (len - 1);
}
else {
/* Got a format specifier */
@@ -626,10 +644,14 @@
int sign;
Py_ssize_t len = 0;
char onechar; /* For byte_converter() */
+ Py_ssize_t alloc;
+#ifdef Py_DEBUG
+ char *before;
+#endif
fmt++;
if (*fmt == '(') {
- char *keystart;
+ const char *keystart;
Py_ssize_t keylen;
PyObject *key;
int pcount = 1;
@@ -673,6 +695,8 @@
arglen = -1;
argidx = -2;
}
+
+ /* Parse flags. Example: "%+i" => flags=F_SIGN. */
while (--fmtcnt >= 0) {
switch (c = *fmt++) {
case '-': flags |= F_LJUST; continue;
@@ -683,6 +707,8 @@
}
break;
}
+
+ /* Parse width. Example: "%10s" => width=10 */
if (c == '*') {
v = getnextarg(args, arglen, &argidx);
if (v == NULL)
@@ -717,6 +743,8 @@
width = width*10 + (c - '0');
}
}
+
+ /* Parse precision. Example: "%.3f" => prec=3 */
if (c == '.') {
prec = 0;
if (--fmtcnt >= 0)
@@ -771,13 +799,19 @@
if (v == NULL)
goto error;
}
+
+ if (fmtcnt < 0) {
+ /* last writer: disable writer overallocation */
+ writer.overallocate = 0;
+ }
+
sign = 0;
fill = ' ';
switch (c) {
case '%':
- pbuf = "%";
- len = 1;
- break;
+ *res++ = '%';
+ continue;
+
case 'r':
// %r is only for 2/3 code; 3 only code should use %a
case 'a':
@@ -790,6 +824,7 @@
if (prec >= 0 && len > prec)
len = prec;
break;
+
case 's':
// %s is only for 2/3 code; 3 only code should use %b
case 'b':
@@ -799,12 +834,49 @@
if (prec >= 0 && len > prec)
len = prec;
break;
+
case 'i':
case 'd':
case 'u':
case 'o':
case 'x':
case 'X':
+ if (PyLong_CheckExact(v)
+ && width == -1 && prec == -1
+ && !(flags & (F_SIGN | F_BLANK))
+ && c != 'X')
+ {
+ /* Fast path */
+ int alternate = flags & F_ALT;
+ int base;
+
+ switch(c)
+ {
+ default:
+ assert(0 && "'type' not in [diuoxX]");
+ case 'd':
+ case 'i':
+ case 'u':
+ base = 10;
+ break;
+ case 'o':
+ base = 8;
+ break;
+ case 'x':
+ case 'X':
+ base = 16;
+ break;
+ }
+
+ /* Fast path */
+ writer.min_size -= 2; /* size preallocated for "%d" */
+ res = _PyLong_FormatBytesWriter(&writer, res,
+ v, base, alternate);
+ if (res == NULL)
+ goto error;
+ continue;
+ }
+
temp = formatlong(v, flags, prec, c);
if (!temp)
goto error;
@@ -815,14 +887,25 @@
if (flags & F_ZERO)
fill = '0';
break;
+
case 'e':
case 'E':
case 'f':
case 'F':
case 'g':
case 'G':
- temp = formatfloat(v, flags, prec, c);
- if (temp == NULL)
+ if (width == -1 && prec == -1
+ && !(flags & (F_SIGN | F_BLANK)))
+ {
+ /* Fast path */
+ writer.min_size -= 2; /* size preallocated for "%f" */
+ res = formatfloat(v, flags, prec, c, NULL, &writer, res);
+ if (res == NULL)
+ goto error;
+ continue;
+ }
+
+ if (!formatfloat(v, flags, prec, c, &temp, NULL, res))
goto error;
pbuf = PyBytes_AS_STRING(temp);
len = PyBytes_GET_SIZE(temp);
@@ -830,21 +913,28 @@
if (flags & F_ZERO)
fill = '0';
break;
+
case 'c':
pbuf = &onechar;
len = byte_converter(v, &onechar);
if (!len)
goto error;
+ if (width == -1) {
+ /* Fast path */
+ *res++ = onechar;
+ continue;
+ }
break;
+
default:
PyErr_Format(PyExc_ValueError,
"unsupported format character '%c' (0x%x) "
"at index %zd",
c, c,
- (Py_ssize_t)(fmt - 1 -
- PyBytes_AsString(format)));
+ (Py_ssize_t)(fmt - 1 - format));
goto error;
}
+
if (sign) {
if (*pbuf == '-' || *pbuf == '+') {
sign = *pbuf++;
@@ -859,29 +949,31 @@
}
if (width < len)
width = len;
- if (rescnt - (sign != 0) < width) {
- reslen -= rescnt;
- rescnt = width + fmtcnt + 100;
- reslen += rescnt;
- if (reslen < 0) {
- Py_DECREF(result);
- Py_XDECREF(temp);
- return PyErr_NoMemory();
- }
- if (_PyBytes_Resize(&result, reslen)) {
- Py_XDECREF(temp);
- return NULL;
- }
- res = PyBytes_AS_STRING(result)
- + reslen - rescnt;
+
+ alloc = width;
+ if (sign != 0 && len == width)
+ alloc++;
+ /* 2: size preallocated for %s */
+ if (alloc > 2) {
+ res = _PyBytesWriter_Prepare(&writer, res, alloc - 2);
+ if (res == NULL)
+ goto error;
}
+#ifdef Py_DEBUG
+ before = res;
+#endif
+
+ /* Write the sign if needed */
if (sign) {
if (fill != ' ')
*res++ = sign;
- rescnt--;
if (width > len)
width--;
}
+
+ /* Write the numeric prefix for "x", "X" and "o" formats
+ if the alternate form is used.
+ For example, write "0x" for the "%#x" format. */
if ((flags & F_ALT) && (c == 'x' || c == 'X')) {
assert(pbuf[0] == '0');
assert(pbuf[1] == c);
@@ -889,18 +981,21 @@
*res++ = *pbuf++;
*res++ = *pbuf++;
}
- rescnt -= 2;
width -= 2;
if (width < 0)
width = 0;
len -= 2;
}
+
+ /* Pad left with the fill character if needed */
if (width > len && !(flags & F_LJUST)) {
- do {
- --rescnt;
- *res++ = fill;
- } while (--width > len);
+ memset(res, fill, width - len);
+ res += (width - len);
+ width = len;
}
+
+ /* If padding with spaces: write sign if needed and/or numeric
+ prefix if the alternate form is used */
if (fill == ' ') {
if (sign)
*res++ = sign;
@@ -912,13 +1007,17 @@
*res++ = *pbuf++;
}
}
+
+ /* Copy bytes */
Py_MEMCPY(res, pbuf, len);
res += len;
- rescnt -= len;
- while (--width >= len) {
- --rescnt;
- *res++ = ' ';
+
+ /* Pad right with the fill character if needed */
+ if (width > len) {
+ memset(res, ' ', width - len);
+ res += (width - len);
}
+
if (dict && (argidx < arglen) && c != '%') {
PyErr_SetString(PyExc_TypeError,
"not all arguments converted during bytes formatting");
@@ -926,22 +1025,31 @@
goto error;
}
Py_XDECREF(temp);
+
+#ifdef Py_DEBUG
+ /* check that we computed the exact size for this write */
+ assert((res - before) == alloc);
+#endif
} /* '%' */
+
+ /* If overallocation was disabled, ensure that it was the last
+ write. Otherwise, we missed an optimization */
+ assert(writer.overallocate || fmtcnt < 0 || use_bytearray);
} /* until end */
+
if (argidx < arglen && !dict) {
PyErr_SetString(PyExc_TypeError,
"not all arguments converted during bytes formatting");
goto error;
}
+
if (args_owned) {
Py_DECREF(args);
}
- if (_PyBytes_Resize(&result, reslen - rescnt))
- return NULL;
- return result;
+ return _PyBytesWriter_Finish(&writer, res);
error:
- Py_DECREF(result);
+ _PyBytesWriter_Dealloc(&writer);
if (args_owned) {
Py_DECREF(args);
}
@@ -961,6 +1069,42 @@
the string is UTF-8 encoded and should be re-encoded in the
specified encoding. */
+static char *
+_PyBytes_DecodeEscapeRecode(const char **s, const char *end,
+ const char *errors, const char *recode_encoding,
+ _PyBytesWriter *writer, char *p)
+{
+ PyObject *u, *w;
+ const char* t;
+
+ t = *s;
+ /* Decode non-ASCII bytes as UTF-8. */
+ while (t < end && (*t & 0x80))
+ t++;
+ u = PyUnicode_DecodeUTF8(*s, t - *s, errors);
+ if (u == NULL)
+ return NULL;
+
+ /* Recode them in target encoding. */
+ w = PyUnicode_AsEncodedString(u, recode_encoding, errors);
+ Py_DECREF(u);
+ if (w == NULL)
+ return NULL;
+ assert(PyBytes_Check(w));
+
+ /* Append bytes to output buffer. */
+ writer->min_size--; /* substract 1 preallocated byte */
+ p = _PyBytesWriter_WriteBytes(writer, p,
+ PyBytes_AS_STRING(w),
+ PyBytes_GET_SIZE(w));
+ Py_DECREF(w);
+ if (p == NULL)
+ return NULL;
+
+ *s = t;
+ return p;
+}
+
PyObject *PyBytes_DecodeEscape(const char *s,
Py_ssize_t len,
const char *errors,
@@ -968,54 +1112,42 @@
const char *recode_encoding)
{
int c;
- char *p, *buf;
+ char *p;
const char *end;
- PyObject *v;
- Py_ssize_t newlen = recode_encoding ? 4*len:len;
- v = PyBytes_FromStringAndSize((char *)NULL, newlen);
- if (v == NULL)
+ _PyBytesWriter writer;
+
+ _PyBytesWriter_Init(&writer);
+
+ p = _PyBytesWriter_Alloc(&writer, len);
+ if (p == NULL)
return NULL;
- p = buf = PyBytes_AsString(v);
+ writer.overallocate = 1;
+
end = s + len;
while (s < end) {
if (*s != '\\') {
non_esc:
- if (recode_encoding && (*s & 0x80)) {
- PyObject *u, *w;
- char *r;
- const char* t;
- Py_ssize_t rn;
- t = s;
- /* Decode non-ASCII bytes as UTF-8. */
- while (t < end && (*t & 0x80)) t++;
- u = PyUnicode_DecodeUTF8(s, t - s, errors);
- if(!u) goto failed;
-
- /* Recode them in target encoding. */
- w = PyUnicode_AsEncodedString(
- u, recode_encoding, errors);
- Py_DECREF(u);
- if (!w) goto failed;
-
- /* Append bytes to output buffer. */
- assert(PyBytes_Check(w));
- r = PyBytes_AS_STRING(w);
- rn = PyBytes_GET_SIZE(w);
- Py_MEMCPY(p, r, rn);
- p += rn;
- Py_DECREF(w);
- s = t;
- } else {
+ if (!(recode_encoding && (*s & 0x80))) {
*p++ = *s++;
}
+ else {
+ /* non-ASCII character and need to recode */
+ p = _PyBytes_DecodeEscapeRecode(&s, end,
+ errors, recode_encoding,
+ &writer, p);
+ if (p == NULL)
+ goto failed;
+ }
continue;
}
+
s++;
- if (s==end) {
+ if (s == end) {
PyErr_SetString(PyExc_ValueError,
"Trailing \\ in string");
goto failed;
}
+
switch (*s++) {
/* XXX This assumes ASCII! */
case '\n': break;
@@ -1040,28 +1172,18 @@
*p++ = c;
break;
case 'x':
- if (s+1 < end && Py_ISXDIGIT(s[0]) && Py_ISXDIGIT(s[1])) {
- unsigned int x = 0;
- c = Py_CHARMASK(*s);
- s++;
- if (Py_ISDIGIT(c))
- x = c - '0';
- else if (Py_ISLOWER(c))
- x = 10 + c - 'a';
- else
- x = 10 + c - 'A';
- x = x << 4;
- c = Py_CHARMASK(*s);
- s++;
- if (Py_ISDIGIT(c))
- x += c - '0';
- else if (Py_ISLOWER(c))
- x += 10 + c - 'a';
- else
- x += 10 + c - 'A';
- *p++ = x;
- break;
+ if (s+1 < end) {
+ int digit1, digit2;
+ digit1 = _PyLong_DigitValue[Py_CHARMASK(s[0])];
+ digit2 = _PyLong_DigitValue[Py_CHARMASK(s[1])];
+ if (digit1 < 16 && digit2 < 16) {
+ *p++ = (unsigned char)((digit1 << 4) + digit2);
+ s += 2;
+ break;
+ }
}
+ /* invalid hexadecimal digits */
+
if (!errors || strcmp(errors, "strict") == 0) {
PyErr_Format(PyExc_ValueError,
"invalid \\x escape at position %d",
@@ -1083,6 +1205,7 @@
if (s < end && Py_ISXDIGIT(s[0]))
s++; /* and a hexdigit */
break;
+
default:
*p++ = '\\';
s--;
@@ -1090,11 +1213,11 @@
UTF-8 bytes may follow. */
}
}
- if (p-buf < newlen)
- _PyBytes_Resize(&v, p - buf);
- return v;
+
+ return _PyBytesWriter_Finish(&writer, p);
+
failed:
- Py_DECREF(v);
+ _PyBytesWriter_Dealloc(&writer);
return NULL;
}
@@ -1365,24 +1488,7 @@
static int
bytes_contains(PyObject *self, PyObject *arg)
{
- Py_ssize_t ival = PyNumber_AsSsize_t(arg, PyExc_ValueError);
- if (ival == -1 && PyErr_Occurred()) {
- Py_buffer varg;
- Py_ssize_t pos;
- PyErr_Clear();
- if (PyObject_GetBuffer(arg, &varg, PyBUF_SIMPLE) != 0)
- return -1;
- pos = stringlib_find(PyBytes_AS_STRING(self), Py_SIZE(self),
- varg.buf, varg.len, 0);
- PyBuffer_Release(&varg);
- return pos >= 0;
- }
- if (ival < 0 || ival >= 256) {
- PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)");
- return -1;
- }
-
- return memchr(PyBytes_AS_STRING(self), (int) ival, Py_SIZE(self)) != NULL;
+ return _Py_bytes_contains(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), arg);
}
static PyObject *
@@ -1629,8 +1735,8 @@
[clinic start generated code]*/
static PyObject *
-bytes_split_impl(PyBytesObject*self, PyObject *sep, Py_ssize_t maxsplit)
-/*[clinic end generated code: output=8bde44dacb36ef2e input=8b809b39074abbfa]*/
+bytes_split_impl(PyBytesObject *self, PyObject *sep, Py_ssize_t maxsplit)
+/*[clinic end generated code: output=52126b5844c1d8ef input=8b809b39074abbfa]*/
{
Py_ssize_t len = PyBytes_GET_SIZE(self), n;
const char *s = PyBytes_AS_STRING(self), *sub;
@@ -1654,7 +1760,6 @@
/*[clinic input]
bytes.partition
- self: self(type="PyBytesObject *")
sep: Py_buffer
/
@@ -1670,7 +1775,7 @@
static PyObject *
bytes_partition_impl(PyBytesObject *self, Py_buffer *sep)
-/*[clinic end generated code: output=f532b392a17ff695 input=bc855dc63ca949de]*/
+/*[clinic end generated code: output=f532b392a17ff695 input=61cca95519406099]*/
{
return stringlib_partition(
(PyObject*) self,
@@ -1682,7 +1787,6 @@
/*[clinic input]
bytes.rpartition
- self: self(type="PyBytesObject *")
sep: Py_buffer
/
@@ -1698,7 +1802,7 @@
static PyObject *
bytes_rpartition_impl(PyBytesObject *self, Py_buffer *sep)
-/*[clinic end generated code: output=191b114cbb028e50 input=6588fff262a9170e]*/
+/*[clinic end generated code: output=191b114cbb028e50 input=67f689e63a62d478]*/
{
return stringlib_rpartition(
(PyObject*) self,
@@ -1716,8 +1820,8 @@
[clinic start generated code]*/
static PyObject *
-bytes_rsplit_impl(PyBytesObject*self, PyObject *sep, Py_ssize_t maxsplit)
-/*[clinic end generated code: output=0b6570b977911d88 input=0f86c9f28f7d7b7b]*/
+bytes_rsplit_impl(PyBytesObject *self, PyObject *sep, Py_ssize_t maxsplit)
+/*[clinic end generated code: output=ba698d9ea01e1c8f input=0f86c9f28f7d7b7b]*/
{
Py_ssize_t len = PyBytes_GET_SIZE(self), n;
const char *s = PyBytes_AS_STRING(self), *sub;
@@ -1755,8 +1859,8 @@
[clinic start generated code]*/
static PyObject *
-bytes_join(PyBytesObject*self, PyObject *iterable_of_bytes)
-/*[clinic end generated code: output=634aff14764ff997 input=7fe377b95bd549d2]*/
+bytes_join(PyBytesObject *self, PyObject *iterable_of_bytes)
+/*[clinic end generated code: output=a046f379f626f6f8 input=7fe377b95bd549d2]*/
{
return stringlib_bytes_join((PyObject*)self, iterable_of_bytes);
}
@@ -1769,158 +1873,30 @@
return bytes_join((PyBytesObject*)sep, x);
}
-/* helper macro to fixup start/end slice values */
-#define ADJUST_INDICES(start, end, len) \
- if (end > len) \
- end = len; \
- else if (end < 0) { \
- end += len; \
- if (end < 0) \
- end = 0; \
- } \
- if (start < 0) { \
- start += len; \
- if (start < 0) \
- start = 0; \
- }
-
-Py_LOCAL_INLINE(Py_ssize_t)
-bytes_find_internal(PyBytesObject *self, PyObject *args, int dir)
-{
- PyObject *subobj;
- char byte;
- Py_buffer subbuf;
- const char *sub;
- Py_ssize_t len, sub_len;
- Py_ssize_t start=0, end=PY_SSIZE_T_MAX;
- Py_ssize_t res;
-
- if (!stringlib_parse_args_finds_byte("find/rfind/index/rindex",
- args, &subobj, &byte, &start, &end))
- return -2;
-
- if (subobj) {
- if (PyObject_GetBuffer(subobj, &subbuf, PyBUF_SIMPLE) != 0)
- return -2;
-
- sub = subbuf.buf;
- sub_len = subbuf.len;
- }
- else {
- sub = &byte;
- sub_len = 1;
- }
- len = PyBytes_GET_SIZE(self);
-
- ADJUST_INDICES(start, end, len);
- if (end - start < sub_len)
- res = -1;
- else if (sub_len == 1
-#ifndef HAVE_MEMRCHR
- && dir > 0
-#endif
- ) {
- unsigned char needle = *sub;
- int mode = (dir > 0) ? FAST_SEARCH : FAST_RSEARCH;
- res = stringlib_fastsearch_memchr_1char(
- PyBytes_AS_STRING(self) + start, end - start,
- needle, needle, mode);
- if (res >= 0)
- res += start;
- }
- else {
- if (dir > 0)
- res = stringlib_find_slice(
- PyBytes_AS_STRING(self), len,
- sub, sub_len, start, end);
- else
- res = stringlib_rfind_slice(
- PyBytes_AS_STRING(self), len,
- sub, sub_len, start, end);
- }
-
- if (subobj)
- PyBuffer_Release(&subbuf);
-
- return res;
-}
-
-
-PyDoc_STRVAR(find__doc__,
-"B.find(sub[, start[, end]]) -> int\n\
-\n\
-Return the lowest index in B where substring sub is found,\n\
-such that sub is contained within B[start:end]. Optional\n\
-arguments start and end are interpreted as in slice notation.\n\
-\n\
-Return -1 on failure.");
-
static PyObject *
bytes_find(PyBytesObject *self, PyObject *args)
{
- Py_ssize_t result = bytes_find_internal(self, args, +1);
- if (result == -2)
- return NULL;
- return PyLong_FromSsize_t(result);
+ return _Py_bytes_find(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args);
}
-
-PyDoc_STRVAR(index__doc__,
-"B.index(sub[, start[, end]]) -> int\n\
-\n\
-Like B.find() but raise ValueError when the substring is not found.");
-
static PyObject *
bytes_index(PyBytesObject *self, PyObject *args)
{
- Py_ssize_t result = bytes_find_internal(self, args, +1);
- if (result == -2)
- return NULL;
- if (result == -1) {
- PyErr_SetString(PyExc_ValueError,
- "substring not found");
- return NULL;
- }
- return PyLong_FromSsize_t(result);
+ return _Py_bytes_index(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args);
}
-PyDoc_STRVAR(rfind__doc__,
-"B.rfind(sub[, start[, end]]) -> int\n\
-\n\
-Return the highest index in B where substring sub is found,\n\
-such that sub is contained within B[start:end]. Optional\n\
-arguments start and end are interpreted as in slice notation.\n\
-\n\
-Return -1 on failure.");
-
static PyObject *
bytes_rfind(PyBytesObject *self, PyObject *args)
{
- Py_ssize_t result = bytes_find_internal(self, args, -1);
- if (result == -2)
- return NULL;
- return PyLong_FromSsize_t(result);
+ return _Py_bytes_rfind(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args);
}
-PyDoc_STRVAR(rindex__doc__,
-"B.rindex(sub[, start[, end]]) -> int\n\
-\n\
-Like B.rfind() but raise ValueError when the substring is not found.");
-
static PyObject *
bytes_rindex(PyBytesObject *self, PyObject *args)
{
- Py_ssize_t result = bytes_find_internal(self, args, -1);
- if (result == -2)
- return NULL;
- if (result == -1) {
- PyErr_SetString(PyExc_ValueError,
- "substring not found");
- return NULL;
- }
- return PyLong_FromSsize_t(result);
+ return _Py_bytes_rindex(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args);
}
@@ -2007,7 +1983,6 @@
/*[clinic input]
bytes.strip
- self: self(type="PyBytesObject *")
bytes: object = None
/
@@ -2018,7 +1993,7 @@
static PyObject *
bytes_strip_impl(PyBytesObject *self, PyObject *bytes)
-/*[clinic end generated code: output=c7c228d3bd104a1b input=37daa5fad1395d95]*/
+/*[clinic end generated code: output=c7c228d3bd104a1b input=8a354640e4e0b3ef]*/
{
return do_argstrip(self, BOTHSTRIP, bytes);
}
@@ -2026,7 +2001,6 @@
/*[clinic input]
bytes.lstrip
- self: self(type="PyBytesObject *")
bytes: object = None
/
@@ -2037,7 +2011,7 @@
static PyObject *
bytes_lstrip_impl(PyBytesObject *self, PyObject *bytes)
-/*[clinic end generated code: output=28602e586f524e82 input=88811b09dfbc2988]*/
+/*[clinic end generated code: output=28602e586f524e82 input=9baff4398c3f6857]*/
{
return do_argstrip(self, LEFTSTRIP, bytes);
}
@@ -2045,7 +2019,6 @@
/*[clinic input]
bytes.rstrip
- self: self(type="PyBytesObject *")
bytes: object = None
/
@@ -2056,64 +2029,22 @@
static PyObject *
bytes_rstrip_impl(PyBytesObject *self, PyObject *bytes)
-/*[clinic end generated code: output=547e3815c95447da input=8f93c9cd361f0140]*/
+/*[clinic end generated code: output=547e3815c95447da input=b78af445c727e32b]*/
{
return do_argstrip(self, RIGHTSTRIP, bytes);
}
-PyDoc_STRVAR(count__doc__,
-"B.count(sub[, start[, end]]) -> int\n\
-\n\
-Return the number of non-overlapping occurrences of substring sub in\n\
-string B[start:end]. Optional arguments start and end are interpreted\n\
-as in slice notation.");
-
static PyObject *
bytes_count(PyBytesObject *self, PyObject *args)
{
- PyObject *sub_obj;
- const char *str = PyBytes_AS_STRING(self), *sub;
- Py_ssize_t sub_len;
- char byte;
- Py_ssize_t start = 0, end = PY_SSIZE_T_MAX;
-
- Py_buffer vsub;
- PyObject *count_obj;
-
- if (!stringlib_parse_args_finds_byte("count", args, &sub_obj, &byte,
- &start, &end))
- return NULL;
-
- if (sub_obj) {
- if (PyObject_GetBuffer(sub_obj, &vsub, PyBUF_SIMPLE) != 0)
- return NULL;
-
- sub = vsub.buf;
- sub_len = vsub.len;
- }
- else {
- sub = &byte;
- sub_len = 1;
- }
-
- ADJUST_INDICES(start, end, PyBytes_GET_SIZE(self));
-
- count_obj = PyLong_FromSsize_t(
- stringlib_count(str + start, end - start, sub, sub_len, PY_SSIZE_T_MAX)
- );
-
- if (sub_obj)
- PyBuffer_Release(&vsub);
-
- return count_obj;
+ return _Py_bytes_count(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args);
}
/*[clinic input]
bytes.translate
- self: self(type="PyBytesObject *")
table: object
Translation table, which must be a bytes object of length 256.
[
@@ -2130,7 +2061,7 @@
static PyObject *
bytes_translate_impl(PyBytesObject *self, PyObject *table, int group_right_1,
PyObject *deletechars)
-/*[clinic end generated code: output=233df850eb50bf8d input=d8fa5519d7cc4be7]*/
+/*[clinic end generated code: output=233df850eb50bf8d input=ca20edf39d780d49]*/
{
char *input, *output;
Py_buffer table_view = {NULL, NULL};
@@ -2191,7 +2122,7 @@
PyBuffer_Release(&table_view);
return NULL;
}
- output_start = output = PyBytes_AsString(result);
+ output_start = output = PyBytes_AS_STRING(result);
input = PyBytes_AS_STRING(input_obj);
if (dellen == 0 && table_chars != NULL) {
@@ -2267,498 +2198,6 @@
return _Py_bytes_maketrans(frm, to);
}
-/* find and count characters and substrings */
-
-#define findchar(target, target_len, c) \
- ((char *)memchr((const void *)(target), c, target_len))
-
-/* String ops must return a string. */
-/* If the object is subclass of string, create a copy */
-Py_LOCAL(PyBytesObject *)
-return_self(PyBytesObject *self)
-{
- if (PyBytes_CheckExact(self)) {
- Py_INCREF(self);
- return self;
- }
- return (PyBytesObject *)PyBytes_FromStringAndSize(
- PyBytes_AS_STRING(self),
- PyBytes_GET_SIZE(self));
-}
-
-Py_LOCAL_INLINE(Py_ssize_t)
-countchar(const char *target, Py_ssize_t target_len, char c, Py_ssize_t maxcount)
-{
- Py_ssize_t count=0;
- const char *start=target;
- const char *end=target+target_len;
-
- while ( (start=findchar(start, end-start, c)) != NULL ) {
- count++;
- if (count >= maxcount)
- break;
- start += 1;
- }
- return count;
-}
-
-
-/* Algorithms for different cases of string replacement */
-
-/* len(self)>=1, from="", len(to)>=1, maxcount>=1 */
-Py_LOCAL(PyBytesObject *)
-replace_interleave(PyBytesObject *self,
- const char *to_s, Py_ssize_t to_len,
- Py_ssize_t maxcount)
-{
- char *self_s, *result_s;
- Py_ssize_t self_len, result_len;
- Py_ssize_t count, i;
- PyBytesObject *result;
-
- self_len = PyBytes_GET_SIZE(self);
-
- /* 1 at the end plus 1 after every character;
- count = min(maxcount, self_len + 1) */
- if (maxcount <= self_len)
- count = maxcount;
- else
- /* Can't overflow: self_len + 1 <= maxcount <= PY_SSIZE_T_MAX. */
- count = self_len + 1;
-
- /* Check for overflow */
- /* result_len = count * to_len + self_len; */
- assert(count > 0);
- if (to_len > (PY_SSIZE_T_MAX - self_len) / count) {
- PyErr_SetString(PyExc_OverflowError,
- "replacement bytes are too long");
- return NULL;
- }
- result_len = count * to_len + self_len;
-
- if (! (result = (PyBytesObject *)
- PyBytes_FromStringAndSize(NULL, result_len)) )
- return NULL;
-
- self_s = PyBytes_AS_STRING(self);
- result_s = PyBytes_AS_STRING(result);
-
- /* TODO: special case single character, which doesn't need memcpy */
-
- /* Lay the first one down (guaranteed this will occur) */
- Py_MEMCPY(result_s, to_s, to_len);
- result_s += to_len;
- count -= 1;
-
- for (i=0; i<count; i++) {
- *result_s++ = *self_s++;
- Py_MEMCPY(result_s, to_s, to_len);
- result_s += to_len;
- }
-
- /* Copy the rest of the original string */
- Py_MEMCPY(result_s, self_s, self_len-i);
-
- return result;
-}
-
-/* Special case for deleting a single character */
-/* len(self)>=1, len(from)==1, to="", maxcount>=1 */
-Py_LOCAL(PyBytesObject *)
-replace_delete_single_character(PyBytesObject *self,
- char from_c, Py_ssize_t maxcount)
-{
- char *self_s, *result_s;
- char *start, *next, *end;
- Py_ssize_t self_len, result_len;
- Py_ssize_t count;
- PyBytesObject *result;
-
- self_len = PyBytes_GET_SIZE(self);
- self_s = PyBytes_AS_STRING(self);
-
- count = countchar(self_s, self_len, from_c, maxcount);
- if (count == 0) {
- return return_self(self);
- }
-
- result_len = self_len - count; /* from_len == 1 */
- assert(result_len>=0);
-
- if ( (result = (PyBytesObject *)
- PyBytes_FromStringAndSize(NULL, result_len)) == NULL)
- return NULL;
- result_s = PyBytes_AS_STRING(result);
-
- start = self_s;
- end = self_s + self_len;
- while (count-- > 0) {
- next = findchar(start, end-start, from_c);
- if (next == NULL)
- break;
- Py_MEMCPY(result_s, start, next-start);
- result_s += (next-start);
- start = next+1;
- }
- Py_MEMCPY(result_s, start, end-start);
-
- return result;
-}
-
-/* len(self)>=1, len(from)>=2, to="", maxcount>=1 */
-
-Py_LOCAL(PyBytesObject *)
-replace_delete_substring(PyBytesObject *self,
- const char *from_s, Py_ssize_t from_len,
- Py_ssize_t maxcount) {
- char *self_s, *result_s;
- char *start, *next, *end;
- Py_ssize_t self_len, result_len;
- Py_ssize_t count, offset;
- PyBytesObject *result;
-
- self_len = PyBytes_GET_SIZE(self);
- self_s = PyBytes_AS_STRING(self);
-
- count = stringlib_count(self_s, self_len,
- from_s, from_len,
- maxcount);
-
- if (count == 0) {
- /* no matches */
- return return_self(self);
- }
-
- result_len = self_len - (count * from_len);
- assert (result_len>=0);
-
- if ( (result = (PyBytesObject *)
- PyBytes_FromStringAndSize(NULL, result_len)) == NULL )
- return NULL;
-
- result_s = PyBytes_AS_STRING(result);
-
- start = self_s;
- end = self_s + self_len;
- while (count-- > 0) {
- offset = stringlib_find(start, end-start,
- from_s, from_len,
- 0);
- if (offset == -1)
- break;
- next = start + offset;
-
- Py_MEMCPY(result_s, start, next-start);
-
- result_s += (next-start);
- start = next+from_len;
- }
- Py_MEMCPY(result_s, start, end-start);
- return result;
-}
-
-/* len(self)>=1, len(from)==len(to)==1, maxcount>=1 */
-Py_LOCAL(PyBytesObject *)
-replace_single_character_in_place(PyBytesObject *self,
- char from_c, char to_c,
- Py_ssize_t maxcount)
-{
- char *self_s, *result_s, *start, *end, *next;
- Py_ssize_t self_len;
- PyBytesObject *result;
-
- /* The result string will be the same size */
- self_s = PyBytes_AS_STRING(self);
- self_len = PyBytes_GET_SIZE(self);
-
- next = findchar(self_s, self_len, from_c);
-
- if (next == NULL) {
- /* No matches; return the original string */
- return return_self(self);
- }
-
- /* Need to make a new string */
- result = (PyBytesObject *) PyBytes_FromStringAndSize(NULL, self_len);
- if (result == NULL)
- return NULL;
- result_s = PyBytes_AS_STRING(result);
- Py_MEMCPY(result_s, self_s, self_len);
-
- /* change everything in-place, starting with this one */
- start = result_s + (next-self_s);
- *start = to_c;
- start++;
- end = result_s + self_len;
-
- while (--maxcount > 0) {
- next = findchar(start, end-start, from_c);
- if (next == NULL)
- break;
- *next = to_c;
- start = next+1;
- }
-
- return result;
-}
-
-/* len(self)>=1, len(from)==len(to)>=2, maxcount>=1 */
-Py_LOCAL(PyBytesObject *)
-replace_substring_in_place(PyBytesObject *self,
- const char *from_s, Py_ssize_t from_len,
- const char *to_s, Py_ssize_t to_len,
- Py_ssize_t maxcount)
-{
- char *result_s, *start, *end;
- char *self_s;
- Py_ssize_t self_len, offset;
- PyBytesObject *result;
-
- /* The result string will be the same size */
-
- self_s = PyBytes_AS_STRING(self);
- self_len = PyBytes_GET_SIZE(self);
-
- offset = stringlib_find(self_s, self_len,
- from_s, from_len,
- 0);
- if (offset == -1) {
- /* No matches; return the original string */
- return return_self(self);
- }
-
- /* Need to make a new string */
- result = (PyBytesObject *) PyBytes_FromStringAndSize(NULL, self_len);
- if (result == NULL)
- return NULL;
- result_s = PyBytes_AS_STRING(result);
- Py_MEMCPY(result_s, self_s, self_len);
-
- /* change everything in-place, starting with this one */
- start = result_s + offset;
- Py_MEMCPY(start, to_s, from_len);
- start += from_len;
- end = result_s + self_len;
-
- while ( --maxcount > 0) {
- offset = stringlib_find(start, end-start,
- from_s, from_len,
- 0);
- if (offset==-1)
- break;
- Py_MEMCPY(start+offset, to_s, from_len);
- start += offset+from_len;
- }
-
- return result;
-}
-
-/* len(self)>=1, len(from)==1, len(to)>=2, maxcount>=1 */
-Py_LOCAL(PyBytesObject *)
-replace_single_character(PyBytesObject *self,
- char from_c,
- const char *to_s, Py_ssize_t to_len,
- Py_ssize_t maxcount)
-{
- char *self_s, *result_s;
- char *start, *next, *end;
- Py_ssize_t self_len, result_len;
- Py_ssize_t count;
- PyBytesObject *result;
-
- self_s = PyBytes_AS_STRING(self);
- self_len = PyBytes_GET_SIZE(self);
-
- count = countchar(self_s, self_len, from_c, maxcount);
- if (count == 0) {
- /* no matches, return unchanged */
- return return_self(self);
- }
-
- /* use the difference between current and new, hence the "-1" */
- /* result_len = self_len + count * (to_len-1) */
- assert(count > 0);
- if (to_len - 1 > (PY_SSIZE_T_MAX - self_len) / count) {
- PyErr_SetString(PyExc_OverflowError,
- "replacement bytes are too long");
- return NULL;
- }
- result_len = self_len + count * (to_len - 1);
-
- if ( (result = (PyBytesObject *)
- PyBytes_FromStringAndSize(NULL, result_len)) == NULL)
- return NULL;
- result_s = PyBytes_AS_STRING(result);
-
- start = self_s;
- end = self_s + self_len;
- while (count-- > 0) {
- next = findchar(start, end-start, from_c);
- if (next == NULL)
- break;
-
- if (next == start) {
- /* replace with the 'to' */
- Py_MEMCPY(result_s, to_s, to_len);
- result_s += to_len;
- start += 1;
- } else {
- /* copy the unchanged old then the 'to' */
- Py_MEMCPY(result_s, start, next-start);
- result_s += (next-start);
- Py_MEMCPY(result_s, to_s, to_len);
- result_s += to_len;
- start = next+1;
- }
- }
- /* Copy the remainder of the remaining string */
- Py_MEMCPY(result_s, start, end-start);
-
- return result;
-}
-
-/* len(self)>=1, len(from)>=2, len(to)>=2, maxcount>=1 */
-Py_LOCAL(PyBytesObject *)
-replace_substring(PyBytesObject *self,
- const char *from_s, Py_ssize_t from_len,
- const char *to_s, Py_ssize_t to_len,
- Py_ssize_t maxcount) {
- char *self_s, *result_s;
- char *start, *next, *end;
- Py_ssize_t self_len, result_len;
- Py_ssize_t count, offset;
- PyBytesObject *result;
-
- self_s = PyBytes_AS_STRING(self);
- self_len = PyBytes_GET_SIZE(self);
-
- count = stringlib_count(self_s, self_len,
- from_s, from_len,
- maxcount);
-
- if (count == 0) {
- /* no matches, return unchanged */
- return return_self(self);
- }
-
- /* Check for overflow */
- /* result_len = self_len + count * (to_len-from_len) */
- assert(count > 0);
- if (to_len - from_len > (PY_SSIZE_T_MAX - self_len) / count) {
- PyErr_SetString(PyExc_OverflowError,
- "replacement bytes are too long");
- return NULL;
- }
- result_len = self_len + count * (to_len-from_len);
-
- if ( (result = (PyBytesObject *)
- PyBytes_FromStringAndSize(NULL, result_len)) == NULL)
- return NULL;
- result_s = PyBytes_AS_STRING(result);
-
- start = self_s;
- end = self_s + self_len;
- while (count-- > 0) {
- offset = stringlib_find(start, end-start,
- from_s, from_len,
- 0);
- if (offset == -1)
- break;
- next = start+offset;
- if (next == start) {
- /* replace with the 'to' */
- Py_MEMCPY(result_s, to_s, to_len);
- result_s += to_len;
- start += from_len;
- } else {
- /* copy the unchanged old then the 'to' */
- Py_MEMCPY(result_s, start, next-start);
- result_s += (next-start);
- Py_MEMCPY(result_s, to_s, to_len);
- result_s += to_len;
- start = next+from_len;
- }
- }
- /* Copy the remainder of the remaining string */
- Py_MEMCPY(result_s, start, end-start);
-
- return result;
-}
-
-
-Py_LOCAL(PyBytesObject *)
-replace(PyBytesObject *self,
- const char *from_s, Py_ssize_t from_len,
- const char *to_s, Py_ssize_t to_len,
- Py_ssize_t maxcount)
-{
- if (maxcount < 0) {
- maxcount = PY_SSIZE_T_MAX;
- } else if (maxcount == 0 || PyBytes_GET_SIZE(self) == 0) {
- /* nothing to do; return the original string */
- return return_self(self);
- }
-
- if (maxcount == 0 ||
- (from_len == 0 && to_len == 0)) {
- /* nothing to do; return the original string */
- return return_self(self);
- }
-
- /* Handle zero-length special cases */
-
- if (from_len == 0) {
- /* insert the 'to' string everywhere. */
- /* >>> "Python".replace("", ".") */
- /* '.P.y.t.h.o.n.' */
- return replace_interleave(self, to_s, to_len, maxcount);
- }
-
- /* Except for "".replace("", "A") == "A" there is no way beyond this */
- /* point for an empty self string to generate a non-empty string */
- /* Special case so the remaining code always gets a non-empty string */
- if (PyBytes_GET_SIZE(self) == 0) {
- return return_self(self);
- }
-
- if (to_len == 0) {
- /* delete all occurrences of 'from' string */
- if (from_len == 1) {
- return replace_delete_single_character(
- self, from_s[0], maxcount);
- } else {
- return replace_delete_substring(self, from_s,
- from_len, maxcount);
- }
- }
-
- /* Handle special case where both strings have the same length */
-
- if (from_len == to_len) {
- if (from_len == 1) {
- return replace_single_character_in_place(
- self,
- from_s[0],
- to_s[0],
- maxcount);
- } else {
- return replace_substring_in_place(
- self, from_s, from_len, to_s, to_len,
- maxcount);
- }
- }
-
- /* Otherwise use the more generic algorithms */
- if (from_len == 1) {
- return replace_single_character(self, from_s[0],
- to_s, to_len, maxcount);
- } else {
- /* len('from')>=2, len('to')>=1 */
- return replace_substring(self, from_s, from_len, to_s, to_len,
- maxcount);
- }
-}
-
/*[clinic input]
bytes.replace
@@ -2777,156 +2216,28 @@
[clinic start generated code]*/
static PyObject *
-bytes_replace_impl(PyBytesObject*self, Py_buffer *old, Py_buffer *new,
+bytes_replace_impl(PyBytesObject *self, Py_buffer *old, Py_buffer *new,
Py_ssize_t count)
-/*[clinic end generated code: output=403dc9d7a83c5a1d input=b2fbbf0bf04de8e5]*/
+/*[clinic end generated code: output=994fa588b6b9c104 input=b2fbbf0bf04de8e5]*/
{
- return (PyObject *)replace((PyBytesObject *) self,
- (const char *)old->buf, old->len,
- (const char *)new->buf, new->len, count);
+ return stringlib_replace((PyObject *)self,
+ (const char *)old->buf, old->len,
+ (const char *)new->buf, new->len, count);
}
/** End DALKE **/
-/* Matches the end (direction >= 0) or start (direction < 0) of self
- * against substr, using the start and end arguments. Returns
- * -1 on error, 0 if not found and 1 if found.
- */
-Py_LOCAL(int)
-_bytes_tailmatch(PyBytesObject *self, PyObject *substr, Py_ssize_t start,
- Py_ssize_t end, int direction)
-{
- Py_ssize_t len = PyBytes_GET_SIZE(self);
- Py_ssize_t slen;
- Py_buffer sub_view = {NULL, NULL};
- const char* sub;
- const char* str;
-
- if (PyBytes_Check(substr)) {
- sub = PyBytes_AS_STRING(substr);
- slen = PyBytes_GET_SIZE(substr);
- }
- else {
- if (PyObject_GetBuffer(substr, &sub_view, PyBUF_SIMPLE) != 0)
- return -1;
- sub = sub_view.buf;
- slen = sub_view.len;
- }
- str = PyBytes_AS_STRING(self);
-
- ADJUST_INDICES(start, end, len);
-
- if (direction < 0) {
- /* startswith */
- if (start+slen > len)
- goto notfound;
- } else {
- /* endswith */
- if (end-start < slen || start > len)
- goto notfound;
-
- if (end-slen > start)
- start = end - slen;
- }
- if (end-start < slen)
- goto notfound;
- if (memcmp(str+start, sub, slen) != 0)
- goto notfound;
-
- PyBuffer_Release(&sub_view);
- return 1;
-
-notfound:
- PyBuffer_Release(&sub_view);
- return 0;
-}
-
-
-PyDoc_STRVAR(startswith__doc__,
-"B.startswith(prefix[, start[, end]]) -> bool\n\
-\n\
-Return True if B starts with the specified prefix, False otherwise.\n\
-With optional start, test B beginning at that position.\n\
-With optional end, stop comparing B at that position.\n\
-prefix can also be a tuple of bytes to try.");
static PyObject *
bytes_startswith(PyBytesObject *self, PyObject *args)
{
- Py_ssize_t start = 0;
- Py_ssize_t end = PY_SSIZE_T_MAX;
- PyObject *subobj;
- int result;
-
- if (!stringlib_parse_args_finds("startswith", args, &subobj, &start, &end))
- return NULL;
- if (PyTuple_Check(subobj)) {
- Py_ssize_t i;
- for (i = 0; i < PyTuple_GET_SIZE(subobj); i++) {
- result = _bytes_tailmatch(self,
- PyTuple_GET_ITEM(subobj, i),
- start, end, -1);
- if (result == -1)
- return NULL;
- else if (result) {
- Py_RETURN_TRUE;
- }
- }
- Py_RETURN_FALSE;
- }
- result = _bytes_tailmatch(self, subobj, start, end, -1);
- if (result == -1) {
- if (PyErr_ExceptionMatches(PyExc_TypeError))
- PyErr_Format(PyExc_TypeError, "startswith first arg must be bytes "
- "or a tuple of bytes, not %s", Py_TYPE(subobj)->tp_name);
- return NULL;
- }
- else
- return PyBool_FromLong(result);
+ return _Py_bytes_startswith(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args);
}
-
-PyDoc_STRVAR(endswith__doc__,
-"B.endswith(suffix[, start[, end]]) -> bool\n\
-\n\
-Return True if B ends with the specified suffix, False otherwise.\n\
-With optional start, test B beginning at that position.\n\
-With optional end, stop comparing B at that position.\n\
-suffix can also be a tuple of bytes to try.");
-
static PyObject *
bytes_endswith(PyBytesObject *self, PyObject *args)
{
- Py_ssize_t start = 0;
- Py_ssize_t end = PY_SSIZE_T_MAX;
- PyObject *subobj;
- int result;
-
- if (!stringlib_parse_args_finds("endswith", args, &subobj, &start, &end))
- return NULL;
- if (PyTuple_Check(subobj)) {
- Py_ssize_t i;
- for (i = 0; i < PyTuple_GET_SIZE(subobj); i++) {
- result = _bytes_tailmatch(self,
- PyTuple_GET_ITEM(subobj, i),
- start, end, +1);
- if (result == -1)
- return NULL;
- else if (result) {
- Py_RETURN_TRUE;
- }
- }
- Py_RETURN_FALSE;
- }
- result = _bytes_tailmatch(self, subobj, start, end, +1);
- if (result == -1) {
- if (PyErr_ExceptionMatches(PyExc_TypeError))
- PyErr_Format(PyExc_TypeError, "endswith first arg must be bytes or "
- "a tuple of bytes, not %s", Py_TYPE(subobj)->tp_name);
- return NULL;
- }
- else
- return PyBool_FromLong(result);
+ return _Py_bytes_endswith(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args);
}
@@ -2946,9 +2257,9 @@
[clinic start generated code]*/
static PyObject *
-bytes_decode_impl(PyBytesObject*self, const char *encoding,
+bytes_decode_impl(PyBytesObject *self, const char *encoding,
const char *errors)
-/*[clinic end generated code: output=2d2016ff8e0bb176 input=958174769d2a40ca]*/
+/*[clinic end generated code: output=5649a53dde27b314 input=958174769d2a40ca]*/
{
return PyUnicode_FromEncodedObject((PyObject*)self, encoding, errors);
}
@@ -2966,8 +2277,8 @@
[clinic start generated code]*/
static PyObject *
-bytes_splitlines_impl(PyBytesObject*self, int keepends)
-/*[clinic end generated code: output=995c3598f7833cad input=7f4aac67144f9944]*/
+bytes_splitlines_impl(PyBytesObject *self, int keepends)
+/*[clinic end generated code: output=3484149a5d880ffb input=7f4aac67144f9944]*/
{
return stringlib_splitlines(
(PyObject*) self, PyBytes_AS_STRING(self),
@@ -2975,22 +2286,6 @@
);
}
-static int
-hex_digit_to_int(Py_UCS4 c)
-{
- if (c >= 128)
- return -1;
- if (Py_ISDIGIT(c))
- return c - '0';
- else {
- if (Py_ISUPPER(c))
- c = Py_TOLOWER(c);
- if (c >= 'a' && c <= 'f')
- return c - 'a' + 10;
- }
- return -1;
-}
-
/*[clinic input]
@classmethod
bytes.fromhex
@@ -3008,47 +2303,83 @@
bytes_fromhex_impl(PyTypeObject *type, PyObject *string)
/*[clinic end generated code: output=0973acc63661bb2e input=bf4d1c361670acd3]*/
{
- PyObject *newstring;
+ return _PyBytes_FromHex(string, 0);
+}
+
+PyObject*
+_PyBytes_FromHex(PyObject *string, int use_bytearray)
+{
char *buf;
- Py_ssize_t hexlen, byteslen, i, j;
- int top, bot;
- void *data;
- unsigned int kind;
+ Py_ssize_t hexlen, invalid_char;
+ unsigned int top, bot;
+ Py_UCS1 *str, *end;
+ _PyBytesWriter writer;
+
+ _PyBytesWriter_Init(&writer);
+ writer.use_bytearray = use_bytearray;
assert(PyUnicode_Check(string));
if (PyUnicode_READY(string))
return NULL;
- kind = PyUnicode_KIND(string);
- data = PyUnicode_DATA(string);
hexlen = PyUnicode_GET_LENGTH(string);
- byteslen = hexlen/2; /* This overestimates if there are spaces */
- newstring = PyBytes_FromStringAndSize(NULL, byteslen);
- if (!newstring)
+ if (!PyUnicode_IS_ASCII(string)) {
+ void *data = PyUnicode_DATA(string);
+ unsigned int kind = PyUnicode_KIND(string);
+ Py_ssize_t i;
+
+ /* search for the first non-ASCII character */
+ for (i = 0; i < hexlen; i++) {
+ if (PyUnicode_READ(kind, data, i) >= 128)
+ break;
+ }
+ invalid_char = i;
+ goto error;
+ }
+
+ assert(PyUnicode_KIND(string) == PyUnicode_1BYTE_KIND);
+ str = PyUnicode_1BYTE_DATA(string);
+
+ /* This overestimates if there are spaces */
+ buf = _PyBytesWriter_Alloc(&writer, hexlen / 2);
+ if (buf == NULL)
return NULL;
- buf = PyBytes_AS_STRING(newstring);
- for (i = j = 0; i < hexlen; i += 2) {
+
+ end = str + hexlen;
+ while (str < end) {
/* skip over spaces in the input */
- while (PyUnicode_READ(kind, data, i) == ' ')
- i++;
- if (i >= hexlen)
- break;
- top = hex_digit_to_int(PyUnicode_READ(kind, data, i));
- bot = hex_digit_to_int(PyUnicode_READ(kind, data, i+1));
- if (top == -1 || bot == -1) {
- PyErr_Format(PyExc_ValueError,
- "non-hexadecimal number found in "
- "fromhex() arg at position %zd", i);
+ if (*str == ' ') {
+ do {
+ str++;
+ } while (*str == ' ');
+ if (str >= end)
+ break;
+ }
+
+ top = _PyLong_DigitValue[*str];
+ if (top >= 16) {
+ invalid_char = str - PyUnicode_1BYTE_DATA(string);
goto error;
}
- buf[j++] = (top << 4) + bot;
+ str++;
+
+ bot = _PyLong_DigitValue[*str];
+ if (bot >= 16) {
+ invalid_char = str - PyUnicode_1BYTE_DATA(string);
+ goto error;
+ }
+ str++;
+
+ *buf++ = (unsigned char)((top << 4) + bot);
}
- if (j != byteslen && _PyBytes_Resize(&newstring, j) < 0)
- goto error;
- return newstring;
+
+ return _PyBytesWriter_Finish(&writer, buf);
error:
- Py_XDECREF(newstring);
+ PyErr_Format(PyExc_ValueError,
+ "non-hexadecimal number found in "
+ "fromhex() arg at position %zd", invalid_char);
+ _PyBytesWriter_Dealloc(&writer);
return NULL;
}
@@ -3078,17 +2409,20 @@
{"__getnewargs__", (PyCFunction)bytes_getnewargs, METH_NOARGS},
{"capitalize", (PyCFunction)stringlib_capitalize, METH_NOARGS,
_Py_capitalize__doc__},
- {"center", (PyCFunction)stringlib_center, METH_VARARGS, center__doc__},
- {"count", (PyCFunction)bytes_count, METH_VARARGS, count__doc__},
+ {"center", (PyCFunction)stringlib_center, METH_VARARGS,
+ _Py_center__doc__},
+ {"count", (PyCFunction)bytes_count, METH_VARARGS,
+ _Py_count__doc__},
BYTES_DECODE_METHODDEF
{"endswith", (PyCFunction)bytes_endswith, METH_VARARGS,
- endswith__doc__},
+ _Py_endswith__doc__},
{"expandtabs", (PyCFunction)stringlib_expandtabs, METH_VARARGS | METH_KEYWORDS,
- expandtabs__doc__},
- {"find", (PyCFunction)bytes_find, METH_VARARGS, find__doc__},
+ _Py_expandtabs__doc__},
+ {"find", (PyCFunction)bytes_find, METH_VARARGS,
+ _Py_find__doc__},
BYTES_FROMHEX_METHODDEF
{"hex", (PyCFunction)bytes_hex, METH_NOARGS, hex__doc__},
- {"index", (PyCFunction)bytes_index, METH_VARARGS, index__doc__},
+ {"index", (PyCFunction)bytes_index, METH_VARARGS, _Py_index__doc__},
{"isalnum", (PyCFunction)stringlib_isalnum, METH_NOARGS,
_Py_isalnum__doc__},
{"isalpha", (PyCFunction)stringlib_isalpha, METH_NOARGS,
@@ -3104,38 +2438,40 @@
{"isupper", (PyCFunction)stringlib_isupper, METH_NOARGS,
_Py_isupper__doc__},
BYTES_JOIN_METHODDEF
- {"ljust", (PyCFunction)stringlib_ljust, METH_VARARGS, ljust__doc__},
+ {"ljust", (PyCFunction)stringlib_ljust, METH_VARARGS, _Py_ljust__doc__},
{"lower", (PyCFunction)stringlib_lower, METH_NOARGS, _Py_lower__doc__},
BYTES_LSTRIP_METHODDEF
BYTES_MAKETRANS_METHODDEF
BYTES_PARTITION_METHODDEF
BYTES_REPLACE_METHODDEF
- {"rfind", (PyCFunction)bytes_rfind, METH_VARARGS, rfind__doc__},
- {"rindex", (PyCFunction)bytes_rindex, METH_VARARGS, rindex__doc__},
- {"rjust", (PyCFunction)stringlib_rjust, METH_VARARGS, rjust__doc__},
+ {"rfind", (PyCFunction)bytes_rfind, METH_VARARGS, _Py_rfind__doc__},
+ {"rindex", (PyCFunction)bytes_rindex, METH_VARARGS, _Py_rindex__doc__},
+ {"rjust", (PyCFunction)stringlib_rjust, METH_VARARGS, _Py_rjust__doc__},
BYTES_RPARTITION_METHODDEF
BYTES_RSPLIT_METHODDEF
BYTES_RSTRIP_METHODDEF
BYTES_SPLIT_METHODDEF
BYTES_SPLITLINES_METHODDEF
{"startswith", (PyCFunction)bytes_startswith, METH_VARARGS,
- startswith__doc__},
+ _Py_startswith__doc__},
BYTES_STRIP_METHODDEF
{"swapcase", (PyCFunction)stringlib_swapcase, METH_NOARGS,
_Py_swapcase__doc__},
{"title", (PyCFunction)stringlib_title, METH_NOARGS, _Py_title__doc__},
BYTES_TRANSLATE_METHODDEF
{"upper", (PyCFunction)stringlib_upper, METH_NOARGS, _Py_upper__doc__},
- {"zfill", (PyCFunction)stringlib_zfill, METH_VARARGS, zfill__doc__},
+ {"zfill", (PyCFunction)stringlib_zfill, METH_VARARGS, _Py_zfill__doc__},
{NULL, NULL} /* sentinel */
};
static PyObject *
-bytes_mod(PyObject *v, PyObject *w)
+bytes_mod(PyObject *self, PyObject *arg)
{
- if (!PyBytes_Check(v))
+ if (!PyBytes_Check(self)) {
Py_RETURN_NOTIMPLEMENTED;
- return _PyBytes_Format(v, w);
+ }
+ return _PyBytes_FormatEx(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self),
+ arg, 0);
}
static PyNumberMethods bytes_as_number = {
@@ -3244,108 +2580,93 @@
return PyBytes_FromObject(x);
}
-PyObject *
-PyBytes_FromObject(PyObject *x)
+static PyObject*
+_PyBytes_FromBuffer(PyObject *x)
{
- PyObject *new, *it;
+ PyObject *new;
+ Py_buffer view;
+
+ if (PyObject_GetBuffer(x, &view, PyBUF_FULL_RO) < 0)
+ return NULL;
+
+ new = PyBytes_FromStringAndSize(NULL, view.len);
+ if (!new)
+ goto fail;
+ if (PyBuffer_ToContiguous(((PyBytesObject *)new)->ob_sval,
+ &view, view.len, 'C') < 0)
+ goto fail;
+ PyBuffer_Release(&view);
+ return new;
+
+fail:
+ Py_XDECREF(new);
+ PyBuffer_Release(&view);
+ return NULL;
+}
+
+#define _PyBytes_FROM_LIST_BODY(x, GET_ITEM) \
+ do { \
+ PyObject *bytes; \
+ Py_ssize_t i; \
+ Py_ssize_t value; \
+ char *str; \
+ PyObject *item; \
+ \
+ bytes = PyBytes_FromStringAndSize(NULL, Py_SIZE(x)); \
+ if (bytes == NULL) \
+ return NULL; \
+ str = ((PyBytesObject *)bytes)->ob_sval; \
+ \
+ for (i = 0; i < Py_SIZE(x); i++) { \
+ item = GET_ITEM((x), i); \
+ value = PyNumber_AsSsize_t(item, PyExc_ValueError); \
+ if (value == -1 && PyErr_Occurred()) \
+ goto error; \
+ \
+ if (value < 0 || value >= 256) { \
+ PyErr_SetString(PyExc_ValueError, \
+ "bytes must be in range(0, 256)"); \
+ goto error; \
+ } \
+ *str++ = (char) value; \
+ } \
+ return bytes; \
+ \
+ error: \
+ Py_DECREF(bytes); \
+ return NULL; \
+ } while (0)
+
+static PyObject*
+_PyBytes_FromList(PyObject *x)
+{
+ _PyBytes_FROM_LIST_BODY(x, PyList_GET_ITEM);
+}
+
+static PyObject*
+_PyBytes_FromTuple(PyObject *x)
+{
+ _PyBytes_FROM_LIST_BODY(x, PyTuple_GET_ITEM);
+}
+
+static PyObject *
+_PyBytes_FromIterator(PyObject *it, PyObject *x)
+{
+ char *str;
Py_ssize_t i, size;
-
- if (x == NULL) {
- PyErr_BadInternalCall();
- return NULL;
- }
-
- if (PyBytes_CheckExact(x)) {
- Py_INCREF(x);
- return x;
- }
-
- /* Use the modern buffer interface */
- if (PyObject_CheckBuffer(x)) {
- Py_buffer view;
- if (PyObject_GetBuffer(x, &view, PyBUF_FULL_RO) < 0)
- return NULL;
- new = PyBytes_FromStringAndSize(NULL, view.len);
- if (!new)
- goto fail;
- if (PyBuffer_ToContiguous(((PyBytesObject *)new)->ob_sval,
- &view, view.len, 'C') < 0)
- goto fail;
- PyBuffer_Release(&view);
- return new;
- fail:
- Py_XDECREF(new);
- PyBuffer_Release(&view);
- return NULL;
- }
- if (PyUnicode_Check(x)) {
- PyErr_SetString(PyExc_TypeError,
- "cannot convert unicode object to bytes");
- return NULL;
- }
-
- if (PyList_CheckExact(x)) {
- new = PyBytes_FromStringAndSize(NULL, Py_SIZE(x));
- if (new == NULL)
- return NULL;
- for (i = 0; i < Py_SIZE(x); i++) {
- Py_ssize_t value = PyNumber_AsSsize_t(
- PyList_GET_ITEM(x, i), PyExc_ValueError);
- if (value == -1 && PyErr_Occurred()) {
- Py_DECREF(new);
- return NULL;
- }
- if (value < 0 || value >= 256) {
- PyErr_SetString(PyExc_ValueError,
- "bytes must be in range(0, 256)");
- Py_DECREF(new);
- return NULL;
- }
- ((PyBytesObject *)new)->ob_sval[i] = (char) value;
- }
- return new;
- }
- if (PyTuple_CheckExact(x)) {
- new = PyBytes_FromStringAndSize(NULL, Py_SIZE(x));
- if (new == NULL)
- return NULL;
- for (i = 0; i < Py_SIZE(x); i++) {
- Py_ssize_t value = PyNumber_AsSsize_t(
- PyTuple_GET_ITEM(x, i), PyExc_ValueError);
- if (value == -1 && PyErr_Occurred()) {
- Py_DECREF(new);
- return NULL;
- }
- if (value < 0 || value >= 256) {
- PyErr_SetString(PyExc_ValueError,
- "bytes must be in range(0, 256)");
- Py_DECREF(new);
- return NULL;
- }
- ((PyBytesObject *)new)->ob_sval[i] = (char) value;
- }
- return new;
- }
+ _PyBytesWriter writer;
/* For iterator version, create a string object and resize as needed */
size = PyObject_LengthHint(x, 64);
if (size == -1 && PyErr_Occurred())
return NULL;
- /* Allocate an extra byte to prevent PyBytes_FromStringAndSize() from
- returning a shared empty bytes string. This required because we
- want to call _PyBytes_Resize() the returned object, which we can
- only do on bytes objects with refcount == 1. */
- if (size == 0)
- size = 1;
- new = PyBytes_FromStringAndSize(NULL, size);
- if (new == NULL)
- return NULL;
- assert(Py_REFCNT(new) == 1);
- /* Get the iterator */
- it = PyObject_GetIter(x);
- if (it == NULL)
- goto error;
+ _PyBytesWriter_Init(&writer);
+ str = _PyBytesWriter_Alloc(&writer, size);
+ if (str == NULL)
+ return NULL;
+ writer.overallocate = 1;
+ size = writer.allocated;
/* Run the iterator to exhaustion */
for (i = 0; ; i++) {
@@ -3375,21 +2696,58 @@
/* Append the byte */
if (i >= size) {
- size = 2 * size + 1;
- if (_PyBytes_Resize(&new, size) < 0)
- goto error;
+ str = _PyBytesWriter_Resize(&writer, str, size+1);
+ if (str == NULL)
+ return NULL;
+ size = writer.allocated;
}
- ((PyBytesObject *)new)->ob_sval[i] = (char) value;
+ *str++ = (char) value;
}
- _PyBytes_Resize(&new, i);
- /* Clean up and return success */
- Py_DECREF(it);
- return new;
+ return _PyBytesWriter_Finish(&writer, str);
error:
- Py_XDECREF(it);
- Py_XDECREF(new);
+ _PyBytesWriter_Dealloc(&writer);
+ return NULL;
+}
+
+PyObject *
+PyBytes_FromObject(PyObject *x)
+{
+ PyObject *it, *result;
+
+ if (x == NULL) {
+ PyErr_BadInternalCall();
+ return NULL;
+ }
+
+ if (PyBytes_CheckExact(x)) {
+ Py_INCREF(x);
+ return x;
+ }
+
+ /* Use the modern buffer interface */
+ if (PyObject_CheckBuffer(x))
+ return _PyBytes_FromBuffer(x);
+
+ if (PyList_CheckExact(x))
+ return _PyBytes_FromList(x);
+
+ if (PyTuple_CheckExact(x))
+ return _PyBytes_FromTuple(x);
+
+ if (!PyUnicode_Check(x)) {
+ it = PyObject_GetIter(x);
+ if (it != NULL) {
+ result = _PyBytes_FromIterator(it, x);
+ Py_DECREF(it);
+ return result;
+ }
+ }
+
+ PyErr_Format(PyExc_TypeError,
+ "cannot convert '%.200s' object to bytes",
+ x->ob_type->tp_name);
return NULL;
}
@@ -3740,3 +3098,282 @@
_PyObject_GC_TRACK(it);
return (PyObject *)it;
}
+
+
+/* _PyBytesWriter API */
+
+#ifdef MS_WINDOWS
+ /* On Windows, overallocate by 50% is the best factor */
+# define OVERALLOCATE_FACTOR 2
+#else
+ /* On Linux, overallocate by 25% is the best factor */
+# define OVERALLOCATE_FACTOR 4
+#endif
+
+void
+_PyBytesWriter_Init(_PyBytesWriter *writer)
+{
+ /* Set all attributes before small_buffer to 0 */
+ memset(writer, 0, offsetof(_PyBytesWriter, small_buffer));
+#ifdef Py_DEBUG
+ memset(writer->small_buffer, 0xCB, sizeof(writer->small_buffer));
+#endif
+}
+
+void
+_PyBytesWriter_Dealloc(_PyBytesWriter *writer)
+{
+ Py_CLEAR(writer->buffer);
+}
+
+Py_LOCAL_INLINE(char*)
+_PyBytesWriter_AsString(_PyBytesWriter *writer)
+{
+ if (writer->use_small_buffer) {
+ assert(writer->buffer == NULL);
+ return writer->small_buffer;
+ }
+ else if (writer->use_bytearray) {
+ assert(writer->buffer != NULL);
+ return PyByteArray_AS_STRING(writer->buffer);
+ }
+ else {
+ assert(writer->buffer != NULL);
+ return PyBytes_AS_STRING(writer->buffer);
+ }
+}
+
+Py_LOCAL_INLINE(Py_ssize_t)
+_PyBytesWriter_GetSize(_PyBytesWriter *writer, char *str)
+{
+ char *start = _PyBytesWriter_AsString(writer);
+ assert(str != NULL);
+ assert(str >= start);
+ assert(str - start <= writer->allocated);
+ return str - start;
+}
+
+Py_LOCAL_INLINE(void)
+_PyBytesWriter_CheckConsistency(_PyBytesWriter *writer, char *str)
+{
+#ifdef Py_DEBUG
+ char *start, *end;
+
+ if (writer->use_small_buffer) {
+ assert(writer->buffer == NULL);
+ }
+ else {
+ assert(writer->buffer != NULL);
+ if (writer->use_bytearray)
+ assert(PyByteArray_CheckExact(writer->buffer));
+ else
+ assert(PyBytes_CheckExact(writer->buffer));
+ assert(Py_REFCNT(writer->buffer) == 1);
+ }
+
+ if (writer->use_bytearray) {
+ /* bytearray has its own overallocation algorithm,
+ writer overallocation must be disabled */
+ assert(!writer->overallocate);
+ }
+
+ assert(0 <= writer->allocated);
+ assert(0 <= writer->min_size && writer->min_size <= writer->allocated);
+ /* the last byte must always be null */
+ start = _PyBytesWriter_AsString(writer);
+ assert(start[writer->allocated] == 0);
+
+ end = start + writer->allocated;
+ assert(str != NULL);
+ assert(start <= str && str <= end);
+#endif
+}
+
+void*
+_PyBytesWriter_Resize(_PyBytesWriter *writer, void *str, Py_ssize_t size)
+{
+ Py_ssize_t allocated, pos;
+
+ _PyBytesWriter_CheckConsistency(writer, str);
+ assert(writer->allocated < size);
+
+ allocated = size;
+ if (writer->overallocate
+ && allocated <= (PY_SSIZE_T_MAX - allocated / OVERALLOCATE_FACTOR)) {
+ /* overallocate to limit the number of realloc() */
+ allocated += allocated / OVERALLOCATE_FACTOR;
+ }
+
+ pos = _PyBytesWriter_GetSize(writer, str);
+ if (!writer->use_small_buffer) {
+ if (writer->use_bytearray) {
+ if (PyByteArray_Resize(writer->buffer, allocated))
+ goto error;
+ /* writer->allocated can be smaller than writer->buffer->ob_alloc,
+ but we cannot use ob_alloc because bytes may need to be moved
+ to use the whole buffer. bytearray uses an internal optimization
+ to avoid moving or copying bytes when bytes are removed at the
+ beginning (ex: del bytearray[:1]). */
+ }
+ else {
+ if (_PyBytes_Resize(&writer->buffer, allocated))
+ goto error;
+ }
+ }
+ else {
+ /* convert from stack buffer to bytes object buffer */
+ assert(writer->buffer == NULL);
+
+ if (writer->use_bytearray)
+ writer->buffer = PyByteArray_FromStringAndSize(NULL, allocated);
+ else
+ writer->buffer = PyBytes_FromStringAndSize(NULL, allocated);
+ if (writer->buffer == NULL)
+ goto error;
+
+ if (pos != 0) {
+ char *dest;
+ if (writer->use_bytearray)
+ dest = PyByteArray_AS_STRING(writer->buffer);
+ else
+ dest = PyBytes_AS_STRING(writer->buffer);
+ Py_MEMCPY(dest,
+ writer->small_buffer,
+ pos);
+ }
+
+ writer->use_small_buffer = 0;
+#ifdef Py_DEBUG
+ memset(writer->small_buffer, 0xDB, sizeof(writer->small_buffer));
+#endif
+ }
+ writer->allocated = allocated;
+
+ str = _PyBytesWriter_AsString(writer) + pos;
+ _PyBytesWriter_CheckConsistency(writer, str);
+ return str;
+
+error:
+ _PyBytesWriter_Dealloc(writer);
+ return NULL;
+}
+
+void*
+_PyBytesWriter_Prepare(_PyBytesWriter *writer, void *str, Py_ssize_t size)
+{
+ Py_ssize_t new_min_size;
+
+ _PyBytesWriter_CheckConsistency(writer, str);
+ assert(size >= 0);
+
+ if (size == 0) {
+ /* nothing to do */
+ return str;
+ }
+
+ if (writer->min_size > PY_SSIZE_T_MAX - size) {
+ PyErr_NoMemory();
+ _PyBytesWriter_Dealloc(writer);
+ return NULL;
+ }
+ new_min_size = writer->min_size + size;
+
+ if (new_min_size > writer->allocated)
+ str = _PyBytesWriter_Resize(writer, str, new_min_size);
+
+ writer->min_size = new_min_size;
+ return str;
+}
+
+/* Allocate the buffer to write size bytes.
+ Return the pointer to the beginning of buffer data.
+ Raise an exception and return NULL on error. */
+void*
+_PyBytesWriter_Alloc(_PyBytesWriter *writer, Py_ssize_t size)
+{
+ /* ensure that _PyBytesWriter_Alloc() is only called once */
+ assert(writer->min_size == 0 && writer->buffer == NULL);
+ assert(size >= 0);
+
+ writer->use_small_buffer = 1;
+#ifdef Py_DEBUG
+ writer->allocated = sizeof(writer->small_buffer) - 1;
+ /* In debug mode, don't use the full small buffer because it is less
+ efficient than bytes and bytearray objects to detect buffer underflow
+ and buffer overflow. Use 10 bytes of the small buffer to test also
+ code using the smaller buffer in debug mode.
+
+ Don't modify the _PyBytesWriter structure (use a shorter small buffer)
+ in debug mode to also be able to detect stack overflow when running
+ tests in debug mode. The _PyBytesWriter is large (more than 512 bytes),
+ if Py_EnterRecursiveCall() is not used in deep C callback, we may hit a
+ stack overflow. */
+ writer->allocated = Py_MIN(writer->allocated, 10);
+ /* _PyBytesWriter_CheckConsistency() requires the last byte to be 0,
+ to detect buffer overflow */
+ writer->small_buffer[writer->allocated] = 0;
+#else
+ writer->allocated = sizeof(writer->small_buffer);
+#endif
+ return _PyBytesWriter_Prepare(writer, writer->small_buffer, size);
+}
+
+PyObject *
+_PyBytesWriter_Finish(_PyBytesWriter *writer, void *str)
+{
+ Py_ssize_t size;
+ PyObject *result;
+
+ _PyBytesWriter_CheckConsistency(writer, str);
+
+ size = _PyBytesWriter_GetSize(writer, str);
+ if (size == 0 && !writer->use_bytearray) {
+ Py_CLEAR(writer->buffer);
+ /* Get the empty byte string singleton */
+ result = PyBytes_FromStringAndSize(NULL, 0);
+ }
+ else if (writer->use_small_buffer) {
+ if (writer->use_bytearray) {
+ result = PyByteArray_FromStringAndSize(writer->small_buffer, size);
+ }
+ else {
+ result = PyBytes_FromStringAndSize(writer->small_buffer, size);
+ }
+ }
+ else {
+ result = writer->buffer;
+ writer->buffer = NULL;
+
+ if (size != writer->allocated) {
+ if (writer->use_bytearray) {
+ if (PyByteArray_Resize(result, size)) {
+ Py_DECREF(result);
+ return NULL;
+ }
+ }
+ else {
+ if (_PyBytes_Resize(&result, size)) {
+ assert(result == NULL);
+ return NULL;
+ }
+ }
+ }
+ }
+ return result;
+}
+
+void*
+_PyBytesWriter_WriteBytes(_PyBytesWriter *writer, void *ptr,
+ const void *bytes, Py_ssize_t size)
+{
+ char *str = (char *)ptr;
+
+ str = _PyBytesWriter_Prepare(writer, str, size);
+ if (str == NULL)
+ return NULL;
+
+ Py_MEMCPY(str, bytes, size);
+ str += size;
+
+ return str;
+}
diff --git a/Objects/clinic/bytearrayobject.c.h b/Objects/clinic/bytearrayobject.c.h
index e87a221..f1ccaf1 100644
--- a/Objects/clinic/bytearrayobject.c.h
+++ b/Objects/clinic/bytearrayobject.c.h
@@ -65,12 +65,14 @@
switch (PyTuple_GET_SIZE(args)) {
case 1:
- if (!PyArg_ParseTuple(args, "O:translate", &table))
+ if (!PyArg_ParseTuple(args, "O:translate", &table)) {
goto exit;
+ }
break;
case 2:
- if (!PyArg_ParseTuple(args, "OO:translate", &table, &deletechars))
+ if (!PyArg_ParseTuple(args, "OO:translate", &table, &deletechars)) {
goto exit;
+ }
group_right_1 = 1;
break;
default:
@@ -108,17 +110,20 @@
Py_buffer to = {NULL, NULL};
if (!PyArg_ParseTuple(args, "y*y*:maketrans",
- &frm, &to))
+ &frm, &to)) {
goto exit;
+ }
return_value = bytearray_maketrans_impl(&frm, &to);
exit:
/* Cleanup for frm */
- if (frm.obj)
+ if (frm.obj) {
PyBuffer_Release(&frm);
+ }
/* Cleanup for to */
- if (to.obj)
+ if (to.obj) {
PyBuffer_Release(&to);
+ }
return return_value;
}
@@ -152,17 +157,20 @@
Py_ssize_t count = -1;
if (!PyArg_ParseTuple(args, "y*y*|n:replace",
- &old, &new, &count))
+ &old, &new, &count)) {
goto exit;
+ }
return_value = bytearray_replace_impl(self, &old, &new, count);
exit:
/* Cleanup for old */
- if (old.obj)
+ if (old.obj) {
PyBuffer_Release(&old);
+ }
/* Cleanup for new */
- if (new.obj)
+ if (new.obj) {
PyBuffer_Release(&new);
+ }
return return_value;
}
@@ -197,8 +205,9 @@
Py_ssize_t maxsplit = -1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|On:split", _keywords,
- &sep, &maxsplit))
+ &sep, &maxsplit)) {
goto exit;
+ }
return_value = bytearray_split_impl(self, sep, maxsplit);
exit:
@@ -269,8 +278,9 @@
Py_ssize_t maxsplit = -1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|On:rsplit", _keywords,
- &sep, &maxsplit))
+ &sep, &maxsplit)) {
goto exit;
+ }
return_value = bytearray_rsplit_impl(self, sep, maxsplit);
exit:
@@ -320,8 +330,9 @@
int item;
if (!PyArg_ParseTuple(args, "nO&:insert",
- &index, _getbytevalue, &item))
+ &index, _getbytevalue, &item)) {
goto exit;
+ }
return_value = bytearray_insert_impl(self, index, item);
exit:
@@ -349,8 +360,9 @@
PyObject *return_value = NULL;
int item;
- if (!PyArg_Parse(arg, "O&:append", _getbytevalue, &item))
+ if (!PyArg_Parse(arg, "O&:append", _getbytevalue, &item)) {
goto exit;
+ }
return_value = bytearray_append_impl(self, item);
exit:
@@ -394,8 +406,9 @@
Py_ssize_t index = -1;
if (!PyArg_ParseTuple(args, "|n:pop",
- &index))
+ &index)) {
goto exit;
+ }
return_value = bytearray_pop_impl(self, index);
exit:
@@ -423,8 +436,9 @@
PyObject *return_value = NULL;
int value;
- if (!PyArg_Parse(arg, "O&:remove", _getbytevalue, &value))
+ if (!PyArg_Parse(arg, "O&:remove", _getbytevalue, &value)) {
goto exit;
+ }
return_value = bytearray_remove_impl(self, value);
exit:
@@ -453,8 +467,9 @@
if (!PyArg_UnpackTuple(args, "strip",
0, 1,
- &bytes))
+ &bytes)) {
goto exit;
+ }
return_value = bytearray_strip_impl(self, bytes);
exit:
@@ -483,8 +498,9 @@
if (!PyArg_UnpackTuple(args, "lstrip",
0, 1,
- &bytes))
+ &bytes)) {
goto exit;
+ }
return_value = bytearray_lstrip_impl(self, bytes);
exit:
@@ -513,8 +529,9 @@
if (!PyArg_UnpackTuple(args, "rstrip",
0, 1,
- &bytes))
+ &bytes)) {
goto exit;
+ }
return_value = bytearray_rstrip_impl(self, bytes);
exit:
@@ -552,8 +569,9 @@
const char *errors = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ss:decode", _keywords,
- &encoding, &errors))
+ &encoding, &errors)) {
goto exit;
+ }
return_value = bytearray_decode_impl(self, encoding, errors);
exit:
@@ -596,8 +614,9 @@
int keepends = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:splitlines", _keywords,
- &keepends))
+ &keepends)) {
goto exit;
+ }
return_value = bytearray_splitlines_impl(self, keepends);
exit:
@@ -625,8 +644,9 @@
PyObject *return_value = NULL;
PyObject *string;
- if (!PyArg_Parse(arg, "U:fromhex", &string))
+ if (!PyArg_Parse(arg, "U:fromhex", &string)) {
goto exit;
+ }
return_value = bytearray_fromhex_impl((PyObject*)cls, string);
exit:
@@ -670,8 +690,9 @@
int proto = 0;
if (!PyArg_ParseTuple(args, "|i:__reduce_ex__",
- &proto))
+ &proto)) {
goto exit;
+ }
return_value = bytearray_reduce_ex_impl(self, proto);
exit:
@@ -695,4 +716,4 @@
{
return bytearray_sizeof_impl(self);
}
-/*[clinic end generated code: output=966c15ff22c5e243 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=044a6c26a836bcfe input=a9049054013a1b77]*/
diff --git a/Objects/clinic/bytesobject.c.h b/Objects/clinic/bytesobject.c.h
index 5a1a5e9..0cced8e 100644
--- a/Objects/clinic/bytesobject.c.h
+++ b/Objects/clinic/bytesobject.c.h
@@ -20,10 +20,10 @@
{"split", (PyCFunction)bytes_split, METH_VARARGS|METH_KEYWORDS, bytes_split__doc__},
static PyObject *
-bytes_split_impl(PyBytesObject*self, PyObject *sep, Py_ssize_t maxsplit);
+bytes_split_impl(PyBytesObject *self, PyObject *sep, Py_ssize_t maxsplit);
static PyObject *
-bytes_split(PyBytesObject*self, PyObject *args, PyObject *kwargs)
+bytes_split(PyBytesObject *self, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
static char *_keywords[] = {"sep", "maxsplit", NULL};
@@ -31,8 +31,9 @@
Py_ssize_t maxsplit = -1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|On:split", _keywords,
- &sep, &maxsplit))
+ &sep, &maxsplit)) {
goto exit;
+ }
return_value = bytes_split_impl(self, sep, maxsplit);
exit:
@@ -64,14 +65,16 @@
PyObject *return_value = NULL;
Py_buffer sep = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:partition", &sep))
+ if (!PyArg_Parse(arg, "y*:partition", &sep)) {
goto exit;
+ }
return_value = bytes_partition_impl(self, &sep);
exit:
/* Cleanup for sep */
- if (sep.obj)
+ if (sep.obj) {
PyBuffer_Release(&sep);
+ }
return return_value;
}
@@ -101,14 +104,16 @@
PyObject *return_value = NULL;
Py_buffer sep = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:rpartition", &sep))
+ if (!PyArg_Parse(arg, "y*:rpartition", &sep)) {
goto exit;
+ }
return_value = bytes_rpartition_impl(self, &sep);
exit:
/* Cleanup for sep */
- if (sep.obj)
+ if (sep.obj) {
PyBuffer_Release(&sep);
+ }
return return_value;
}
@@ -133,10 +138,10 @@
{"rsplit", (PyCFunction)bytes_rsplit, METH_VARARGS|METH_KEYWORDS, bytes_rsplit__doc__},
static PyObject *
-bytes_rsplit_impl(PyBytesObject*self, PyObject *sep, Py_ssize_t maxsplit);
+bytes_rsplit_impl(PyBytesObject *self, PyObject *sep, Py_ssize_t maxsplit);
static PyObject *
-bytes_rsplit(PyBytesObject*self, PyObject *args, PyObject *kwargs)
+bytes_rsplit(PyBytesObject *self, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
static char *_keywords[] = {"sep", "maxsplit", NULL};
@@ -144,8 +149,9 @@
Py_ssize_t maxsplit = -1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|On:rsplit", _keywords,
- &sep, &maxsplit))
+ &sep, &maxsplit)) {
goto exit;
+ }
return_value = bytes_rsplit_impl(self, sep, maxsplit);
exit:
@@ -189,8 +195,9 @@
if (!PyArg_UnpackTuple(args, "strip",
0, 1,
- &bytes))
+ &bytes)) {
goto exit;
+ }
return_value = bytes_strip_impl(self, bytes);
exit:
@@ -219,8 +226,9 @@
if (!PyArg_UnpackTuple(args, "lstrip",
0, 1,
- &bytes))
+ &bytes)) {
goto exit;
+ }
return_value = bytes_lstrip_impl(self, bytes);
exit:
@@ -249,8 +257,9 @@
if (!PyArg_UnpackTuple(args, "rstrip",
0, 1,
- &bytes))
+ &bytes)) {
goto exit;
+ }
return_value = bytes_rstrip_impl(self, bytes);
exit:
@@ -284,12 +293,14 @@
switch (PyTuple_GET_SIZE(args)) {
case 1:
- if (!PyArg_ParseTuple(args, "O:translate", &table))
+ if (!PyArg_ParseTuple(args, "O:translate", &table)) {
goto exit;
+ }
break;
case 2:
- if (!PyArg_ParseTuple(args, "OO:translate", &table, &deletechars))
+ if (!PyArg_ParseTuple(args, "OO:translate", &table, &deletechars)) {
goto exit;
+ }
group_right_1 = 1;
break;
default:
@@ -327,17 +338,20 @@
Py_buffer to = {NULL, NULL};
if (!PyArg_ParseTuple(args, "y*y*:maketrans",
- &frm, &to))
+ &frm, &to)) {
goto exit;
+ }
return_value = bytes_maketrans_impl(&frm, &to);
exit:
/* Cleanup for frm */
- if (frm.obj)
+ if (frm.obj) {
PyBuffer_Release(&frm);
+ }
/* Cleanup for to */
- if (to.obj)
+ if (to.obj) {
PyBuffer_Release(&to);
+ }
return return_value;
}
@@ -359,11 +373,11 @@
{"replace", (PyCFunction)bytes_replace, METH_VARARGS, bytes_replace__doc__},
static PyObject *
-bytes_replace_impl(PyBytesObject*self, Py_buffer *old, Py_buffer *new,
+bytes_replace_impl(PyBytesObject *self, Py_buffer *old, Py_buffer *new,
Py_ssize_t count);
static PyObject *
-bytes_replace(PyBytesObject*self, PyObject *args)
+bytes_replace(PyBytesObject *self, PyObject *args)
{
PyObject *return_value = NULL;
Py_buffer old = {NULL, NULL};
@@ -371,17 +385,20 @@
Py_ssize_t count = -1;
if (!PyArg_ParseTuple(args, "y*y*|n:replace",
- &old, &new, &count))
+ &old, &new, &count)) {
goto exit;
+ }
return_value = bytes_replace_impl(self, &old, &new, count);
exit:
/* Cleanup for old */
- if (old.obj)
+ if (old.obj) {
PyBuffer_Release(&old);
+ }
/* Cleanup for new */
- if (new.obj)
+ if (new.obj) {
PyBuffer_Release(&new);
+ }
return return_value;
}
@@ -405,11 +422,11 @@
{"decode", (PyCFunction)bytes_decode, METH_VARARGS|METH_KEYWORDS, bytes_decode__doc__},
static PyObject *
-bytes_decode_impl(PyBytesObject*self, const char *encoding,
+bytes_decode_impl(PyBytesObject *self, const char *encoding,
const char *errors);
static PyObject *
-bytes_decode(PyBytesObject*self, PyObject *args, PyObject *kwargs)
+bytes_decode(PyBytesObject *self, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
static char *_keywords[] = {"encoding", "errors", NULL};
@@ -417,8 +434,9 @@
const char *errors = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ss:decode", _keywords,
- &encoding, &errors))
+ &encoding, &errors)) {
goto exit;
+ }
return_value = bytes_decode_impl(self, encoding, errors);
exit:
@@ -438,18 +456,19 @@
{"splitlines", (PyCFunction)bytes_splitlines, METH_VARARGS|METH_KEYWORDS, bytes_splitlines__doc__},
static PyObject *
-bytes_splitlines_impl(PyBytesObject*self, int keepends);
+bytes_splitlines_impl(PyBytesObject *self, int keepends);
static PyObject *
-bytes_splitlines(PyBytesObject*self, PyObject *args, PyObject *kwargs)
+bytes_splitlines(PyBytesObject *self, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
static char *_keywords[] = {"keepends", NULL};
int keepends = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:splitlines", _keywords,
- &keepends))
+ &keepends)) {
goto exit;
+ }
return_value = bytes_splitlines_impl(self, keepends);
exit:
@@ -477,11 +496,12 @@
PyObject *return_value = NULL;
PyObject *string;
- if (!PyArg_Parse(arg, "U:fromhex", &string))
+ if (!PyArg_Parse(arg, "U:fromhex", &string)) {
goto exit;
+ }
return_value = bytes_fromhex_impl(type, string);
exit:
return return_value;
}
-/*[clinic end generated code: output=bd0ce8f25d7e18f4 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=6fe884a74e7d49cf input=a9049054013a1b77]*/
diff --git a/Objects/clinic/dictobject.c.h b/Objects/clinic/dictobject.c.h
index 5288b9a..d0cdfc3 100644
--- a/Objects/clinic/dictobject.c.h
+++ b/Objects/clinic/dictobject.c.h
@@ -23,8 +23,9 @@
if (!PyArg_UnpackTuple(args, "fromkeys",
1, 2,
- &iterable, &value))
+ &iterable, &value)) {
goto exit;
+ }
return_value = dict_fromkeys_impl(type, iterable, value);
exit:
@@ -39,4 +40,4 @@
#define DICT___CONTAINS___METHODDEF \
{"__contains__", (PyCFunction)dict___contains__, METH_O|METH_COEXIST, dict___contains____doc__},
-/*[clinic end generated code: output=fe74d676332fdba6 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=926326109e3d9839 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/unicodeobject.c.h b/Objects/clinic/unicodeobject.c.h
index d42a700..891e90c 100644
--- a/Objects/clinic/unicodeobject.c.h
+++ b/Objects/clinic/unicodeobject.c.h
@@ -31,11 +31,12 @@
PyObject *z = NULL;
if (!PyArg_ParseTuple(args, "O|UU:maketrans",
- &x, &y, &z))
+ &x, &y, &z)) {
goto exit;
+ }
return_value = unicode_maketrans_impl(x, y, z);
exit:
return return_value;
}
-/*[clinic end generated code: output=94affdff5b2daff5 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=4a86dd108d92d104 input=a9049054013a1b77]*/
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index 964ae62..f089f75 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -694,7 +694,8 @@
addr += *p++;
if (addr > addrq)
break;
- line += *p++;
+ line += (signed char)*p;
+ p++;
}
return line;
}
@@ -729,17 +730,19 @@
if (addr + *p > lasti)
break;
addr += *p++;
- if (*p)
+ if ((signed char)*p)
bounds->ap_lower = addr;
- line += *p++;
+ line += (signed char)*p;
+ p++;
--size;
}
if (size > 0) {
while (--size >= 0) {
addr += *p++;
- if (*p++)
+ if ((signed char)*p)
break;
+ p++;
}
bounds->ap_upper = addr;
}
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index da68e3b..4bc73b9 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -22,7 +22,7 @@
}
static PyObject *
-descr_repr(PyDescrObject *descr, char *format)
+descr_repr(PyDescrObject *descr, const char *format)
{
PyObject *name = NULL;
if (descr->d_name != NULL && PyUnicode_Check(descr->d_name))
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index d774586..31c45ef 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -324,7 +324,7 @@
assert(size >= PyDict_MINSIZE_SPLIT);
assert(IS_POWER_OF_2(size));
- dk = PyMem_MALLOC(sizeof(PyDictKeysObject) +
+ dk = PyObject_MALLOC(sizeof(PyDictKeysObject) +
sizeof(PyDictKeyEntry) * (size-1));
if (dk == NULL) {
PyErr_NoMemory();
@@ -353,7 +353,7 @@
Py_XDECREF(entries[i].me_key);
Py_XDECREF(entries[i].me_value);
}
- PyMem_FREE(keys);
+ PyObject_FREE(keys);
}
#define new_values(size) PyMem_NEW(PyObject *, size)
@@ -964,7 +964,7 @@
}
}
assert(oldkeys->dk_refcnt == 1);
- DK_DEBUG_DECREF PyMem_FREE(oldkeys);
+ DK_DEBUG_DECREF PyObject_FREE(oldkeys);
}
return 0;
}
@@ -1163,39 +1163,42 @@
return PyDict_GetItemWithError(dp, kv);
}
-/* Fast version of global value lookup.
+/* Fast version of global value lookup (LOAD_GLOBAL).
* Lookup in globals, then builtins.
+ *
+ * Raise an exception and return NULL if an error occurred (ex: computing the
+ * key hash failed, key comparison failed, ...). Return NULL if the key doesn't
+ * exist. Return the value if the key exists.
*/
PyObject *
_PyDict_LoadGlobal(PyDictObject *globals, PyDictObject *builtins, PyObject *key)
{
- PyObject *x;
- if (PyUnicode_CheckExact(key)) {
- PyObject **value_addr;
- Py_hash_t hash = ((PyASCIIObject *)key)->hash;
- if (hash != -1) {
- PyDictKeyEntry *e;
- e = globals->ma_keys->dk_lookup(globals, key, hash, &value_addr);
- if (e == NULL) {
- return NULL;
- }
- x = *value_addr;
- if (x != NULL)
- return x;
- e = builtins->ma_keys->dk_lookup(builtins, key, hash, &value_addr);
- if (e == NULL) {
- return NULL;
- }
- x = *value_addr;
- return x;
- }
+ Py_hash_t hash;
+ PyDictKeyEntry *entry;
+ PyObject **value_addr;
+ PyObject *value;
+
+ if (!PyUnicode_CheckExact(key) ||
+ (hash = ((PyASCIIObject *) key)->hash) == -1)
+ {
+ hash = PyObject_Hash(key);
+ if (hash == -1)
+ return NULL;
}
- x = PyDict_GetItemWithError((PyObject *)globals, key);
- if (x != NULL)
- return x;
- if (PyErr_Occurred())
+
+ /* namespace 1: globals */
+ entry = globals->ma_keys->dk_lookup(globals, key, hash, &value_addr);
+ if (entry == NULL)
return NULL;
- return PyDict_GetItemWithError((PyObject *)builtins, key);
+ value = *value_addr;
+ if (value != NULL)
+ return value;
+
+ /* namespace 2: builtins */
+ entry = builtins->ma_keys->dk_lookup(builtins, key, hash, &value_addr);
+ if (entry == NULL)
+ return NULL;
+ return *value_addr;
}
/* CAUTION: PyDict_SetItem() must guarantee that it won't resize the
@@ -1920,7 +1923,7 @@
}
static int
-dict_update_common(PyObject *self, PyObject *args, PyObject *kwds, char *methname)
+dict_update_common(PyObject *self, PyObject *args, PyObject *kwds, const char *methname)
{
PyObject *arg = NULL;
int result = 0;
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index aaff0bc..7bc9310 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -59,15 +59,11 @@
static int
BaseException_init(PyBaseExceptionObject *self, PyObject *args, PyObject *kwds)
{
- PyObject *tmp;
-
if (!_PyArg_NoKeywords(Py_TYPE(self)->tp_name, kwds))
return -1;
- tmp = self->args;
- self->args = args;
- Py_INCREF(self->args);
- Py_XDECREF(tmp);
+ Py_INCREF(args);
+ Py_XSETREF(self->args, args);
return 0;
}
@@ -328,11 +324,10 @@
/* Steals a reference to cause */
void
-PyException_SetCause(PyObject *self, PyObject *cause) {
- PyObject *old_cause = ((PyBaseExceptionObject *)self)->cause;
- ((PyBaseExceptionObject *)self)->cause = cause;
+PyException_SetCause(PyObject *self, PyObject *cause)
+{
((PyBaseExceptionObject *)self)->suppress_context = 1;
- Py_XDECREF(old_cause);
+ Py_XSETREF(((PyBaseExceptionObject *)self)->cause, cause);
}
PyObject *
@@ -344,10 +339,9 @@
/* Steals a reference to context */
void
-PyException_SetContext(PyObject *self, PyObject *context) {
- PyObject *old_context = ((PyBaseExceptionObject *)self)->context;
- ((PyBaseExceptionObject *)self)->context = context;
- Py_XDECREF(old_context);
+PyException_SetContext(PyObject *self, PyObject *context)
+{
+ Py_XSETREF(((PyBaseExceptionObject *)self)->context, context);
}
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index d92bec3..da600f4 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -215,35 +215,49 @@
PyFloat_AsDouble(PyObject *op)
{
PyNumberMethods *nb;
- PyFloatObject *fo;
+ PyObject *res;
double val;
- if (op && PyFloat_Check(op))
- return PyFloat_AS_DOUBLE((PyFloatObject*) op);
-
if (op == NULL) {
PyErr_BadArgument();
return -1;
}
- if ((nb = Py_TYPE(op)->tp_as_number) == NULL || nb->nb_float == NULL) {
- PyErr_SetString(PyExc_TypeError, "a float is required");
+ if (PyFloat_Check(op)) {
+ return PyFloat_AS_DOUBLE(op);
+ }
+
+ nb = Py_TYPE(op)->tp_as_number;
+ if (nb == NULL || nb->nb_float == NULL) {
+ PyErr_Format(PyExc_TypeError, "must be real number, not %.50s",
+ op->ob_type->tp_name);
return -1;
}
- fo = (PyFloatObject*) (*nb->nb_float) (op);
- if (fo == NULL)
- return -1;
- if (!PyFloat_Check(fo)) {
- Py_DECREF(fo);
- PyErr_SetString(PyExc_TypeError,
- "nb_float should return float object");
+ res = (*nb->nb_float) (op);
+ if (res == NULL) {
return -1;
}
+ if (!PyFloat_CheckExact(res)) {
+ if (!PyFloat_Check(res)) {
+ PyErr_Format(PyExc_TypeError,
+ "%.50s.__float__ returned non-float (type %.50s)",
+ op->ob_type->tp_name, res->ob_type->tp_name);
+ Py_DECREF(res);
+ return -1;
+ }
+ if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
+ "%.50s.__float__ returned non-float (type %.50s). "
+ "The ability to return an instance of a strict subclass of float "
+ "is deprecated, and may be removed in a future version of Python.",
+ op->ob_type->tp_name, res->ob_type->tp_name)) {
+ Py_DECREF(res);
+ return -1;
+ }
+ }
- val = PyFloat_AS_DOUBLE(fo);
- Py_DECREF(fo);
-
+ val = PyFloat_AS_DOUBLE(res);
+ Py_DECREF(res);
return val;
}
@@ -1195,7 +1209,7 @@
static PyObject *
float_fromhex(PyObject *cls, PyObject *arg)
{
- PyObject *result_as_float, *result;
+ PyObject *result;
double x;
long exp, top_exp, lsb, key_digit;
char *s, *coeff_start, *s_store, *coeff_end, *exp_start, *s_end;
@@ -1410,11 +1424,10 @@
s++;
if (s != s_end)
goto parse_error;
- result_as_float = Py_BuildValue("(d)", negate ? -x : x);
- if (result_as_float == NULL)
- return NULL;
- result = PyObject_CallObject(cls, result_as_float);
- Py_DECREF(result_as_float);
+ result = PyFloat_FromDouble(negate ? -x : x);
+ if (cls != (PyObject *)&PyFloat_Type && result != NULL) {
+ Py_SETREF(result, PyObject_CallFunctionObjArgs(cls, result, NULL));
+ }
return result;
overflow_error:
@@ -1451,29 +1464,23 @@
int exponent;
int i;
- PyObject *prev;
PyObject *py_exponent = NULL;
PyObject *numerator = NULL;
PyObject *denominator = NULL;
PyObject *result_pair = NULL;
PyNumberMethods *long_methods = PyLong_Type.tp_as_number;
-#define INPLACE_UPDATE(obj, call) \
- prev = obj; \
- obj = call; \
- Py_DECREF(prev); \
-
CONVERT_TO_DOUBLE(v, self);
if (Py_IS_INFINITY(self)) {
- PyErr_SetString(PyExc_OverflowError,
- "Cannot pass infinity to float.as_integer_ratio.");
- return NULL;
+ PyErr_SetString(PyExc_OverflowError,
+ "cannot convert Infinity to integer ratio");
+ return NULL;
}
if (Py_IS_NAN(self)) {
- PyErr_SetString(PyExc_ValueError,
- "Cannot pass NaN to float.as_integer_ratio.");
- return NULL;
+ PyErr_SetString(PyExc_ValueError,
+ "cannot convert NaN to integer ratio");
+ return NULL;
}
PyFPE_START_PROTECT("as_integer_ratio", goto error);
@@ -1489,29 +1496,31 @@
to be truncated by PyLong_FromDouble(). */
numerator = PyLong_FromDouble(float_part);
- if (numerator == NULL) goto error;
+ if (numerator == NULL)
+ goto error;
+ denominator = PyLong_FromLong(1);
+ if (denominator == NULL)
+ goto error;
+ py_exponent = PyLong_FromLong(Py_ABS(exponent));
+ if (py_exponent == NULL)
+ goto error;
/* fold in 2**exponent */
- denominator = PyLong_FromLong(1);
- py_exponent = PyLong_FromLong(labs((long)exponent));
- if (py_exponent == NULL) goto error;
- INPLACE_UPDATE(py_exponent,
- long_methods->nb_lshift(denominator, py_exponent));
- if (py_exponent == NULL) goto error;
if (exponent > 0) {
- INPLACE_UPDATE(numerator,
- long_methods->nb_multiply(numerator, py_exponent));
- if (numerator == NULL) goto error;
+ Py_SETREF(numerator,
+ long_methods->nb_lshift(numerator, py_exponent));
+ if (numerator == NULL)
+ goto error;
}
else {
- Py_DECREF(denominator);
- denominator = py_exponent;
- py_exponent = NULL;
+ Py_SETREF(denominator,
+ long_methods->nb_lshift(denominator, py_exponent));
+ if (denominator == NULL)
+ goto error;
}
result_pair = PyTuple_Pack(2, numerator, denominator);
-#undef INPLACE_UPDATE
error:
Py_XDECREF(py_exponent);
Py_XDECREF(denominator);
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 9aadd61..b115614 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -137,7 +137,7 @@
new_lasti = -1;
for (offset = 0; offset < lnotab_len; offset += 2) {
addr += lnotab[offset];
- line += lnotab[offset+1];
+ line += (signed char)lnotab[offset+1];
if (line >= new_lineno) {
new_lasti = addr;
new_lineno = line;
@@ -189,7 +189,7 @@
memset(blockstack, '\0', sizeof(blockstack));
memset(in_finally, '\0', sizeof(in_finally));
blockstack_top = 0;
- for (addr = 0; addr < code_len; addr++) {
+ for (addr = 0; addr < code_len; addr += 2) {
unsigned char op = code[addr];
switch (op) {
case SETUP_LOOP:
@@ -251,10 +251,6 @@
}
}
}
-
- if (op >= HAVE_ARGUMENT) {
- addr += 2;
- }
}
/* Verify that the blockstack tracking code didn't get lost. */
@@ -277,7 +273,7 @@
* can tell whether the jump goes into any blocks without coming out
* again - in that case we raise an exception below. */
delta_iblock = 0;
- for (addr = min_addr; addr < max_addr; addr++) {
+ for (addr = min_addr; addr < max_addr; addr += 2) {
unsigned char op = code[addr];
switch (op) {
case SETUP_LOOP:
@@ -294,10 +290,6 @@
}
min_delta_iblock = Py_MIN(min_delta_iblock, delta_iblock);
-
- if (op >= HAVE_ARGUMENT) {
- addr += 2;
- }
}
/* Derive the absolute iblock values from the deltas. */
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index e6c327d..261c16d 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -249,7 +249,6 @@
static int
func_set_code(PyFunctionObject *op, PyObject *value)
{
- PyObject *tmp;
Py_ssize_t nfree, nclosure;
/* Not legal to del f.func_code or to set it to anything
@@ -270,10 +269,8 @@
nclosure, nfree);
return -1;
}
- tmp = op->func_code;
Py_INCREF(value);
- op->func_code = value;
- Py_DECREF(tmp);
+ Py_XSETREF(op->func_code, value);
return 0;
}
@@ -287,8 +284,6 @@
static int
func_set_name(PyFunctionObject *op, PyObject *value)
{
- PyObject *tmp;
-
/* Not legal to del f.func_name or to set it to anything
* other than a string object. */
if (value == NULL || !PyUnicode_Check(value)) {
@@ -296,10 +291,8 @@
"__name__ must be set to a string object");
return -1;
}
- tmp = op->func_name;
Py_INCREF(value);
- op->func_name = value;
- Py_DECREF(tmp);
+ Py_XSETREF(op->func_name, value);
return 0;
}
@@ -313,8 +306,6 @@
static int
func_set_qualname(PyFunctionObject *op, PyObject *value)
{
- PyObject *tmp;
-
/* Not legal to del f.__qualname__ or to set it to anything
* other than a string object. */
if (value == NULL || !PyUnicode_Check(value)) {
@@ -322,10 +313,8 @@
"__qualname__ must be set to a string object");
return -1;
}
- tmp = op->func_qualname;
Py_INCREF(value);
- op->func_qualname = value;
- Py_DECREF(tmp);
+ Py_XSETREF(op->func_qualname, value);
return 0;
}
@@ -343,8 +332,6 @@
static int
func_set_defaults(PyFunctionObject *op, PyObject *value)
{
- PyObject *tmp;
-
/* Legal to del f.func_defaults.
* Can only set func_defaults to NULL or a tuple. */
if (value == Py_None)
@@ -354,10 +341,8 @@
"__defaults__ must be set to a tuple object");
return -1;
}
- tmp = op->func_defaults;
Py_XINCREF(value);
- op->func_defaults = value;
- Py_XDECREF(tmp);
+ Py_XSETREF(op->func_defaults, value);
return 0;
}
@@ -375,8 +360,6 @@
static int
func_set_kwdefaults(PyFunctionObject *op, PyObject *value)
{
- PyObject *tmp;
-
if (value == Py_None)
value = NULL;
/* Legal to del f.func_kwdefaults.
@@ -386,10 +369,8 @@
"__kwdefaults__ must be set to a dict object");
return -1;
}
- tmp = op->func_kwdefaults;
Py_XINCREF(value);
- op->func_kwdefaults = value;
- Py_XDECREF(tmp);
+ Py_XSETREF(op->func_kwdefaults, value);
return 0;
}
@@ -408,8 +389,6 @@
static int
func_set_annotations(PyFunctionObject *op, PyObject *value)
{
- PyObject *tmp;
-
if (value == Py_None)
value = NULL;
/* Legal to del f.func_annotations.
@@ -420,10 +399,8 @@
"__annotations__ must be set to a dict object");
return -1;
}
- tmp = op->func_annotations;
Py_XINCREF(value);
- op->func_annotations = value;
- Py_XDECREF(tmp);
+ Py_XSETREF(op->func_annotations, value);
return 0;
}
diff --git a/Objects/genobject.c b/Objects/genobject.c
index b3e0a46..c028db5 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -187,7 +187,7 @@
/* Pop the exception before issuing a warning. */
PyErr_Fetch(&exc, &val, &tb);
- if (PyErr_WarnFormat(PyExc_PendingDeprecationWarning, 1,
+ if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
"generator '%.50S' raised StopIteration",
gen->gi_qualname)) {
/* Warning was converted to an error. */
@@ -277,7 +277,7 @@
PyObject *bytecode = f->f_code->co_code;
unsigned char *code = (unsigned char *)PyBytes_AS_STRING(bytecode);
- if (code[f->f_lasti + 1] != YIELD_FROM)
+ if (code[f->f_lasti + 2] != YIELD_FROM)
return NULL;
yf = f->f_stacktop[-1];
Py_INCREF(yf);
@@ -376,7 +376,7 @@
assert(ret == yf);
Py_DECREF(ret);
/* Termination repetition of YIELD_FROM */
- gen->gi_frame->f_lasti++;
+ gen->gi_frame->f_lasti += 2;
if (_PyGen_FetchStopIterationValue(&val) == 0) {
ret = gen_send_ex(gen, val, 0, 0);
Py_DECREF(val);
@@ -519,8 +519,6 @@
static int
gen_set_name(PyGenObject *op, PyObject *value)
{
- PyObject *tmp;
-
/* Not legal to del gen.gi_name or to set it to anything
* other than a string object. */
if (value == NULL || !PyUnicode_Check(value)) {
@@ -528,10 +526,8 @@
"__name__ must be set to a string object");
return -1;
}
- tmp = op->gi_name;
Py_INCREF(value);
- op->gi_name = value;
- Py_DECREF(tmp);
+ Py_XSETREF(op->gi_name, value);
return 0;
}
@@ -545,8 +541,6 @@
static int
gen_set_qualname(PyGenObject *op, PyObject *value)
{
- PyObject *tmp;
-
/* Not legal to del gen.__qualname__ or to set it to anything
* other than a string object. */
if (value == NULL || !PyUnicode_Check(value)) {
@@ -554,10 +548,8 @@
"__qualname__ must be set to a string object");
return -1;
}
- tmp = op->gi_qualname;
Py_INCREF(value);
- op->gi_qualname = value;
- Py_DECREF(tmp);
+ Py_XSETREF(op->gi_qualname, value);
return 0;
}
diff --git a/Objects/listobject.c b/Objects/listobject.c
index d688179..6e2d026 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -216,7 +216,6 @@
PyList_SetItem(PyObject *op, Py_ssize_t i,
PyObject *newitem)
{
- PyObject *olditem;
PyObject **p;
if (!PyList_Check(op)) {
Py_XDECREF(newitem);
@@ -230,9 +229,7 @@
return -1;
}
p = ((PyListObject *)op) -> ob_item + i;
- olditem = *p;
- *p = newitem;
- Py_XDECREF(olditem);
+ Py_XSETREF(*p, newitem);
return 0;
}
@@ -251,7 +248,7 @@
return -1;
}
- if (list_resize(self, n+1) == -1)
+ if (list_resize(self, n+1) < 0)
return -1;
if (where < 0) {
@@ -291,7 +288,7 @@
return -1;
}
- if (list_resize(self, n+1) == -1)
+ if (list_resize(self, n+1) < 0)
return -1;
Py_INCREF(v);
@@ -711,7 +708,7 @@
return PyErr_NoMemory();
}
- if (list_resize(self, size*n) == -1)
+ if (list_resize(self, size*n) < 0)
return NULL;
p = size;
@@ -730,7 +727,6 @@
static int
list_ass_item(PyListObject *a, Py_ssize_t i, PyObject *v)
{
- PyObject *old_value;
if (i < 0 || i >= Py_SIZE(a)) {
PyErr_SetString(PyExc_IndexError,
"list assignment index out of range");
@@ -739,9 +735,7 @@
if (v == NULL)
return list_ass_slice(a, i, i+1, v);
Py_INCREF(v);
- old_value = a->ob_item[i];
- a->ob_item[i] = v;
- Py_DECREF(old_value);
+ Py_SETREF(a->ob_item[i], v);
return 0;
}
@@ -804,7 +798,7 @@
Py_RETURN_NONE;
}
m = Py_SIZE(self);
- if (list_resize(self, m + n) == -1) {
+ if (list_resize(self, m + n) < 0) {
Py_DECREF(b);
return NULL;
}
@@ -832,7 +826,7 @@
/* Guess a result list size. */
n = PyObject_LengthHint(b, 8);
- if (n == -1) {
+ if (n < 0) {
Py_DECREF(it);
return NULL;
}
@@ -840,7 +834,7 @@
mn = m + n;
if (mn >= m) {
/* Make room. */
- if (list_resize(self, mn) == -1)
+ if (list_resize(self, mn) < 0)
goto error;
/* Make the list sane again. */
Py_SIZE(self) = m;
diff --git a/Objects/listsort.txt b/Objects/listsort.txt
index 832e4f2..fef982f 100644
--- a/Objects/listsort.txt
+++ b/Objects/listsort.txt
@@ -486,7 +486,7 @@
I first learned about the galloping strategy in a related context; see:
"Adaptive Set Intersections, Unions, and Differences" (2000)
- Erik D. Demaine, Alejandro López-Ortiz, J. Ian Munro
+ Erik D. Demaine, Alejandro López-Ortiz, J. Ian Munro
and its followup(s). An earlier paper called the same strategy
"exponential search":
diff --git a/Objects/lnotab_notes.txt b/Objects/lnotab_notes.txt
index d247edd..5153757 100644
--- a/Objects/lnotab_notes.txt
+++ b/Objects/lnotab_notes.txt
@@ -12,42 +12,47 @@
0 1
6 2
50 7
- 350 307
- 361 308
+ 350 207
+ 361 208
Instead of storing these numbers literally, we compress the list by storing only
-the increments from one row to the next. Conceptually, the stored list might
+the difference from one row to the next. Conceptually, the stored list might
look like:
- 0, 1, 6, 1, 44, 5, 300, 300, 11, 1
+ 0, 1, 6, 1, 44, 5, 300, 200, 11, 1
-The above doesn't really work, but it's a start. Note that an unsigned byte
-can't hold negative values, or values larger than 255, and the above example
-contains two such values. So we make two tweaks:
+The above doesn't really work, but it's a start. An unsigned byte (byte code
+offset) can't hold negative values, or values larger than 255, a signed byte
+(line number) can't hold values larger than 127 or less than -128, and the
+above example contains two such values. So we make two tweaks:
- (a) there's a deep assumption that byte code offsets and their corresponding
- line #s both increase monotonically, and
- (b) if at least one column jumps by more than 255 from one row to the next,
- more than one pair is written to the table. In case #b, there's no way to know
- from looking at the table later how many were written. That's the delicate
- part. A user of co_lnotab desiring to find the source line number
- corresponding to a bytecode address A should do something like this
+ (a) there's a deep assumption that byte code offsets increase monotonically,
+ and
+ (b) if byte code offset jumps by more than 255 from one row to the next, or if
+ source code line number jumps by more than 127 or less than -128 from one row
+ to the next, more than one pair is written to the table. In case #b,
+ there's no way to know from looking at the table later how many were written.
+ That's the delicate part. A user of co_lnotab desiring to find the source
+ line number corresponding to a bytecode address A should do something like
+ this:
lineno = addr = 0
for addr_incr, line_incr in co_lnotab:
addr += addr_incr
if addr > A:
return lineno
+ if line_incr >= 0x80:
+ line_incr -= 0x100
lineno += line_incr
(In C, this is implemented by PyCode_Addr2Line().) In order for this to work,
when the addr field increments by more than 255, the line # increment in each
pair generated must be 0 until the remaining addr increment is < 256. So, in
the example above, assemble_lnotab in compile.c should not (as was actually done
-until 2.2) expand 300, 300 to
+until 2.2) expand 300, 200 to
255, 255, 45, 45,
but to
- 255, 0, 45, 255, 0, 45.
+ 255, 0, 45, 128, 0, 72.
The above is sufficient to reconstruct line numbers for tracebacks, but not for
line tracing. Tracing is handled by PyCode_CheckLineNumber() in codeobject.c
@@ -90,16 +95,16 @@
6 POP_JUMP_IF_FALSE 17
3 9 LOAD_CONST 1 (1)
- 12 PRINT_ITEM
+ 12 PRINT_ITEM
- 4 13 BREAK_LOOP
+ 4 13 BREAK_LOOP
14 JUMP_ABSOLUTE 3
- >> 17 POP_BLOCK
+ >> 17 POP_BLOCK
6 18 LOAD_CONST 2 (2)
- 21 PRINT_ITEM
+ 21 PRINT_ITEM
>> 22 LOAD_CONST 0 (None)
- 25 RETURN_VALUE
+ 25 RETURN_VALUE
If 'a' is false, execution will jump to the POP_BLOCK instruction at offset 17
and the co_lnotab will claim that execution has moved to line 4, which is wrong.
diff --git a/Objects/longobject.c b/Objects/longobject.c
index f68d15e..4732545 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -1582,10 +1582,12 @@
static int
long_to_decimal_string_internal(PyObject *aa,
PyObject **p_output,
- _PyUnicodeWriter *writer)
+ _PyUnicodeWriter *writer,
+ _PyBytesWriter *bytes_writer,
+ char **bytes_str)
{
PyLongObject *scratch, *a;
- PyObject *str;
+ PyObject *str = NULL;
Py_ssize_t size, strlen, size_a, i, j;
digit *pout, *pin, rem, tenpow;
int negative;
@@ -1662,7 +1664,13 @@
return -1;
}
kind = writer->kind;
- str = NULL;
+ }
+ else if (bytes_writer) {
+ *bytes_str = _PyBytesWriter_Prepare(bytes_writer, *bytes_str, strlen);
+ if (*bytes_str == NULL) {
+ Py_DECREF(scratch);
+ return -1;
+ }
}
else {
str = PyUnicode_New(strlen, '9');
@@ -1673,13 +1681,8 @@
kind = PyUnicode_KIND(str);
}
-#define WRITE_DIGITS(TYPE) \
+#define WRITE_DIGITS(p) \
do { \
- if (writer) \
- p = (TYPE*)PyUnicode_DATA(writer->buffer) + writer->pos + strlen; \
- else \
- p = (TYPE*)PyUnicode_DATA(str) + strlen; \
- \
/* pout[0] through pout[size-2] contribute exactly \
_PyLong_DECIMAL_SHIFT digits each */ \
for (i=0; i < size - 1; i++) { \
@@ -1699,6 +1702,16 @@
/* and sign */ \
if (negative) \
*--p = '-'; \
+ } while (0)
+
+#define WRITE_UNICODE_DIGITS(TYPE) \
+ do { \
+ if (writer) \
+ p = (TYPE*)PyUnicode_DATA(writer->buffer) + writer->pos + strlen; \
+ else \
+ p = (TYPE*)PyUnicode_DATA(str) + strlen; \
+ \
+ WRITE_DIGITS(p); \
\
/* check we've counted correctly */ \
if (writer) \
@@ -1708,25 +1721,34 @@
} while (0)
/* fill the string right-to-left */
- if (kind == PyUnicode_1BYTE_KIND) {
+ if (bytes_writer) {
+ char *p = *bytes_str + strlen;
+ WRITE_DIGITS(p);
+ assert(p == *bytes_str);
+ }
+ else if (kind == PyUnicode_1BYTE_KIND) {
Py_UCS1 *p;
- WRITE_DIGITS(Py_UCS1);
+ WRITE_UNICODE_DIGITS(Py_UCS1);
}
else if (kind == PyUnicode_2BYTE_KIND) {
Py_UCS2 *p;
- WRITE_DIGITS(Py_UCS2);
+ WRITE_UNICODE_DIGITS(Py_UCS2);
}
else {
Py_UCS4 *p;
assert (kind == PyUnicode_4BYTE_KIND);
- WRITE_DIGITS(Py_UCS4);
+ WRITE_UNICODE_DIGITS(Py_UCS4);
}
#undef WRITE_DIGITS
+#undef WRITE_UNICODE_DIGITS
Py_DECREF(scratch);
if (writer) {
writer->pos += strlen;
}
+ else if (bytes_writer) {
+ (*bytes_str) += strlen;
+ }
else {
assert(_PyUnicode_CheckConsistency(str, 1));
*p_output = (PyObject *)str;
@@ -1738,7 +1760,7 @@
long_to_decimal_string(PyObject *aa)
{
PyObject *v;
- if (long_to_decimal_string_internal(aa, &v, NULL) == -1)
+ if (long_to_decimal_string_internal(aa, &v, NULL, NULL, NULL) == -1)
return NULL;
return v;
}
@@ -1750,10 +1772,11 @@
static int
long_format_binary(PyObject *aa, int base, int alternate,
- PyObject **p_output, _PyUnicodeWriter *writer)
+ PyObject **p_output, _PyUnicodeWriter *writer,
+ _PyBytesWriter *bytes_writer, char **bytes_str)
{
PyLongObject *a = (PyLongObject *)aa;
- PyObject *v;
+ PyObject *v = NULL;
Py_ssize_t sz;
Py_ssize_t size_a;
enum PyUnicode_Kind kind;
@@ -1810,7 +1833,11 @@
if (_PyUnicodeWriter_Prepare(writer, sz, 'x') == -1)
return -1;
kind = writer->kind;
- v = NULL;
+ }
+ else if (bytes_writer) {
+ *bytes_str = _PyBytesWriter_Prepare(bytes_writer, *bytes_str, sz);
+ if (*bytes_str == NULL)
+ return -1;
}
else {
v = PyUnicode_New(sz, 'x');
@@ -1819,13 +1846,8 @@
kind = PyUnicode_KIND(v);
}
-#define WRITE_DIGITS(TYPE) \
+#define WRITE_DIGITS(p) \
do { \
- if (writer) \
- p = (TYPE*)PyUnicode_DATA(writer->buffer) + writer->pos + sz; \
- else \
- p = (TYPE*)PyUnicode_DATA(v) + sz; \
- \
if (size_a == 0) { \
*--p = '0'; \
} \
@@ -1860,30 +1882,50 @@
} \
if (negative) \
*--p = '-'; \
+ } while (0)
+
+#define WRITE_UNICODE_DIGITS(TYPE) \
+ do { \
+ if (writer) \
+ p = (TYPE*)PyUnicode_DATA(writer->buffer) + writer->pos + sz; \
+ else \
+ p = (TYPE*)PyUnicode_DATA(v) + sz; \
+ \
+ WRITE_DIGITS(p); \
+ \
if (writer) \
assert(p == ((TYPE*)PyUnicode_DATA(writer->buffer) + writer->pos)); \
else \
assert(p == (TYPE*)PyUnicode_DATA(v)); \
} while (0)
- if (kind == PyUnicode_1BYTE_KIND) {
+ if (bytes_writer) {
+ char *p = *bytes_str + sz;
+ WRITE_DIGITS(p);
+ assert(p == *bytes_str);
+ }
+ else if (kind == PyUnicode_1BYTE_KIND) {
Py_UCS1 *p;
- WRITE_DIGITS(Py_UCS1);
+ WRITE_UNICODE_DIGITS(Py_UCS1);
}
else if (kind == PyUnicode_2BYTE_KIND) {
Py_UCS2 *p;
- WRITE_DIGITS(Py_UCS2);
+ WRITE_UNICODE_DIGITS(Py_UCS2);
}
else {
Py_UCS4 *p;
assert (kind == PyUnicode_4BYTE_KIND);
- WRITE_DIGITS(Py_UCS4);
+ WRITE_UNICODE_DIGITS(Py_UCS4);
}
#undef WRITE_DIGITS
+#undef WRITE_UNICODE_DIGITS
if (writer) {
writer->pos += sz;
}
+ else if (bytes_writer) {
+ (*bytes_str) += sz;
+ }
else {
assert(_PyUnicode_CheckConsistency(v, 1));
*p_output = v;
@@ -1897,9 +1939,9 @@
PyObject *str;
int err;
if (base == 10)
- err = long_to_decimal_string_internal(obj, &str, NULL);
+ err = long_to_decimal_string_internal(obj, &str, NULL, NULL, NULL);
else
- err = long_format_binary(obj, base, 1, &str, NULL);
+ err = long_format_binary(obj, base, 1, &str, NULL, NULL, NULL);
if (err == -1)
return NULL;
return str;
@@ -1911,9 +1953,31 @@
int base, int alternate)
{
if (base == 10)
- return long_to_decimal_string_internal(obj, NULL, writer);
+ return long_to_decimal_string_internal(obj, NULL, writer,
+ NULL, NULL);
else
- return long_format_binary(obj, base, alternate, NULL, writer);
+ return long_format_binary(obj, base, alternate, NULL, writer,
+ NULL, NULL);
+}
+
+char*
+_PyLong_FormatBytesWriter(_PyBytesWriter *writer, char *str,
+ PyObject *obj,
+ int base, int alternate)
+{
+ char *str2;
+ int res;
+ str2 = str;
+ if (base == 10)
+ res = long_to_decimal_string_internal(obj, NULL, NULL,
+ writer, &str2);
+ else
+ res = long_format_binary(obj, base, alternate, NULL, NULL,
+ writer, &str2);
+ if (res < 0)
+ return NULL;
+ assert(str2 != NULL);
+ return str2;
}
/* Table of digit values for 8-bit string -> integer conversion.
@@ -2705,6 +2769,13 @@
PyErr_SetString(PyExc_TypeError, "an integer is required");
return -1.0;
}
+ if (Py_ABS(Py_SIZE(v)) <= 1) {
+ /* Fast path; single digit long (31 bits) will cast safely
+ to double. This improves performance of FP/long operations
+ by 20%.
+ */
+ return (double)MEDIUM_VALUE((PyLongObject *)v);
+ }
x = _PyLong_Frexp((PyLongObject *)v, &exponent);
if ((x == -1.0 && PyErr_Occurred()) || exponent > DBL_MAX_EXP) {
PyErr_SetString(PyExc_OverflowError,
@@ -2951,8 +3022,14 @@
if (Py_SIZE(a) < 0) {
if (Py_SIZE(b) < 0) {
z = x_add(a, b);
- if (z != NULL && Py_SIZE(z) != 0)
+ if (z != NULL) {
+ /* x_add received at least one multiple-digit int,
+ and thus z must be a multiple-digit int.
+ That also means z is not an element of
+ small_ints, so negating it in-place is safe. */
+ assert(Py_REFCNT(z) == 1);
Py_SIZE(z) = -(Py_SIZE(z));
+ }
}
else
z = x_sub(b, a);
@@ -2983,8 +3060,10 @@
z = x_sub(a, b);
else
z = x_add(a, b);
- if (z != NULL && Py_SIZE(z) != 0)
+ if (z != NULL) {
+ assert(Py_SIZE(z) == 0 || Py_REFCNT(z) == 1);
Py_SIZE(z) = -(Py_SIZE(z));
+ }
}
else {
if (Py_SIZE(b) < 0)
@@ -3431,6 +3510,52 @@
return (PyObject *)z;
}
+/* Fast modulo division for single-digit longs. */
+static PyObject *
+fast_mod(PyLongObject *a, PyLongObject *b)
+{
+ sdigit left = a->ob_digit[0];
+ sdigit right = b->ob_digit[0];
+ sdigit mod;
+
+ assert(Py_ABS(Py_SIZE(a)) == 1);
+ assert(Py_ABS(Py_SIZE(b)) == 1);
+
+ if (Py_SIZE(a) == Py_SIZE(b)) {
+ /* 'a' and 'b' have the same sign. */
+ mod = left % right;
+ }
+ else {
+ /* Either 'a' or 'b' is negative. */
+ mod = right - 1 - (left - 1) % right;
+ }
+
+ return PyLong_FromLong(mod * (sdigit)Py_SIZE(b));
+}
+
+/* Fast floor division for single-digit longs. */
+static PyObject *
+fast_floor_div(PyLongObject *a, PyLongObject *b)
+{
+ sdigit left = a->ob_digit[0];
+ sdigit right = b->ob_digit[0];
+ sdigit div;
+
+ assert(Py_ABS(Py_SIZE(a)) == 1);
+ assert(Py_ABS(Py_SIZE(b)) == 1);
+
+ if (Py_SIZE(a) == Py_SIZE(b)) {
+ /* 'a' and 'b' have the same sign. */
+ div = left / right;
+ }
+ else {
+ /* Either 'a' or 'b' is negative. */
+ div = -1 - (left - 1) / right;
+ }
+
+ return PyLong_FromLong(div);
+}
+
/* The / and % operators are now defined in terms of divmod().
The expression a mod b has the value a - b*floor(a/b).
The long_divrem function gives the remainder after division of
@@ -3458,6 +3583,30 @@
{
PyLongObject *div, *mod;
+ if (Py_ABS(Py_SIZE(v)) == 1 && Py_ABS(Py_SIZE(w)) == 1) {
+ /* Fast path for single-digit longs */
+ div = NULL;
+ if (pdiv != NULL) {
+ div = (PyLongObject *)fast_floor_div(v, w);
+ if (div == NULL) {
+ return -1;
+ }
+ }
+ if (pmod != NULL) {
+ mod = (PyLongObject *)fast_mod(v, w);
+ if (mod == NULL) {
+ Py_XDECREF(div);
+ return -1;
+ }
+ *pmod = mod;
+ }
+ if (pdiv != NULL) {
+ /* We only want to set `*pdiv` when `*pmod` is
+ set successfully. */
+ *pdiv = div;
+ }
+ return 0;
+ }
if (long_divrem(v, w, &div, &mod) < 0)
return -1;
if ((Py_SIZE(mod) < 0 && Py_SIZE(w) > 0) ||
@@ -3502,6 +3651,11 @@
PyLongObject *div;
CHECK_BINOP(a, b);
+
+ if (Py_ABS(Py_SIZE(a)) == 1 && Py_ABS(Py_SIZE(b)) == 1) {
+ return fast_floor_div((PyLongObject*)a, (PyLongObject*)b);
+ }
+
if (l_divmod((PyLongObject*)a, (PyLongObject*)b, &div, NULL) < 0)
div = NULL;
return (PyObject *)div;
@@ -3777,6 +3931,10 @@
CHECK_BINOP(a, b);
+ if (Py_ABS(Py_SIZE(a)) == 1 && Py_ABS(Py_SIZE(b)) == 1) {
+ return fast_mod((PyLongObject*)a, (PyLongObject*)b);
+ }
+
if (l_divmod((PyLongObject*)a, (PyLongObject*)b, NULL, &mod) < 0)
mod = NULL;
return (PyObject *)mod;
diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c
index 10162cb..e355a83 100644
--- a/Objects/memoryobject.c
+++ b/Objects/memoryobject.c
@@ -1133,7 +1133,7 @@
return -1;
}
-Py_LOCAL_INLINE(char *)
+Py_LOCAL_INLINE(const char *)
get_native_fmtstr(const char *fmt)
{
int at = 0;
@@ -1221,7 +1221,7 @@
goto out;
}
- view->format = get_native_fmtstr(PyBytes_AS_STRING(asciifmt));
+ view->format = (char *)get_native_fmtstr(PyBytes_AS_STRING(asciifmt));
if (view->format == NULL) {
/* NOT_REACHED: get_native_fmtchar() already validates the format. */
PyErr_SetString(PyExc_RuntimeError,
diff --git a/Objects/object.c b/Objects/object.c
index 8024889..c83c8ec 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -644,7 +644,7 @@
/* Map rich comparison operators to their swapped version, e.g. LT <--> GT */
int _Py_SwappedOp[] = {Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE};
-static char *opstrings[] = {"<", "<=", "==", "!=", ">", ">="};
+static const char * const opstrings[] = {"<", "<=", "==", "!=", ">", ">="};
/* Perform a rich comparison, raising TypeError when the requested comparison
operator is not supported. */
@@ -686,11 +686,10 @@
res = (v != w) ? Py_True : Py_False;
break;
default:
- /* XXX Special-case None so it doesn't show as NoneType() */
PyErr_Format(PyExc_TypeError,
- "unorderable types: %.100s() %s %.100s()",
- v->ob_type->tp_name,
+ "'%s' not supported between instances of '%.100s' and '%.100s'",
opstrings[op],
+ v->ob_type->tp_name,
w->ob_type->tp_name);
return NULL;
}
@@ -1041,8 +1040,7 @@
name->ob_type->tp_name);
return NULL;
}
- else
- Py_INCREF(name);
+ Py_INCREF(name);
if (tp->tp_dict == NULL) {
if (PyType_Ready(tp) < 0)
@@ -1050,10 +1048,10 @@
}
descr = _PyType_Lookup(tp, name);
- Py_XINCREF(descr);
f = NULL;
if (descr != NULL) {
+ Py_INCREF(descr);
f = descr->ob_type->tp_descr_get;
if (f != NULL && PyDescr_IsData(descr)) {
res = f(descr, obj, (PyObject *)obj->ob_type);
@@ -1073,8 +1071,9 @@
if (tsize < 0)
tsize = -tsize;
size = _PyObject_VAR_SIZE(tp, tsize);
+ assert(size <= PY_SSIZE_T_MAX);
- dictoffset += (long)size;
+ dictoffset += (Py_ssize_t)size;
assert(dictoffset > 0);
assert(dictoffset % SIZEOF_VOID_P == 0);
}
@@ -1142,12 +1141,11 @@
Py_INCREF(name);
descr = _PyType_Lookup(tp, name);
- Py_XINCREF(descr);
- f = NULL;
if (descr != NULL) {
+ Py_INCREF(descr);
f = descr->ob_type->tp_descr_set;
- if (f != NULL && PyDescr_IsData(descr)) {
+ if (f != NULL) {
res = f(descr, obj, value);
goto done;
}
@@ -1155,40 +1153,32 @@
if (dict == NULL) {
dictptr = _PyObject_GetDictPtr(obj);
- if (dictptr != NULL) {
- res = _PyObjectDict_SetItem(Py_TYPE(obj), dictptr, name, value);
- if (res < 0 && PyErr_ExceptionMatches(PyExc_KeyError))
- PyErr_SetObject(PyExc_AttributeError, name);
+ if (dictptr == NULL) {
+ if (descr == NULL) {
+ PyErr_Format(PyExc_AttributeError,
+ "'%.100s' object has no attribute '%U'",
+ tp->tp_name, name);
+ }
+ else {
+ PyErr_Format(PyExc_AttributeError,
+ "'%.50s' object attribute '%U' is read-only",
+ tp->tp_name, name);
+ }
goto done;
}
+ res = _PyObjectDict_SetItem(tp, dictptr, name, value);
}
- if (dict != NULL) {
+ else {
Py_INCREF(dict);
if (value == NULL)
res = PyDict_DelItem(dict, name);
else
res = PyDict_SetItem(dict, name, value);
Py_DECREF(dict);
- if (res < 0 && PyErr_ExceptionMatches(PyExc_KeyError))
- PyErr_SetObject(PyExc_AttributeError, name);
- goto done;
}
+ if (res < 0 && PyErr_ExceptionMatches(PyExc_KeyError))
+ PyErr_SetObject(PyExc_AttributeError, name);
- if (f != NULL) {
- res = f(descr, obj, value);
- goto done;
- }
-
- if (descr == NULL) {
- PyErr_Format(PyExc_AttributeError,
- "'%.100s' object has no attribute '%U'",
- tp->tp_name, name);
- goto done;
- }
-
- PyErr_Format(PyExc_AttributeError,
- "'%.50s' object attribute '%U' is read-only",
- tp->tp_name, name);
done:
Py_XDECREF(descr);
Py_DECREF(name);
@@ -1204,7 +1194,7 @@
int
PyObject_GenericSetDict(PyObject *obj, PyObject *value, void *context)
{
- PyObject *dict, **dictptr = _PyObject_GetDictPtr(obj);
+ PyObject **dictptr = _PyObject_GetDictPtr(obj);
if (dictptr == NULL) {
PyErr_SetString(PyExc_AttributeError,
"This object has no __dict__");
@@ -1220,10 +1210,8 @@
"not a '%.200s'", Py_TYPE(value)->tp_name);
return -1;
}
- dict = *dictptr;
- Py_XINCREF(value);
- *dictptr = value;
- Py_XDECREF(dict);
+ Py_INCREF(value);
+ Py_XSETREF(*dictptr, value);
return 0;
}
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
index 7cc889f..3f95133 100644
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -1,17 +1,38 @@
#include "Python.h"
+
+/* Defined in tracemalloc.c */
+extern void _PyMem_DumpTraceback(int fd, const void *ptr);
+
+
/* Python's malloc wrappers (see pymem.h) */
-#ifdef PYMALLOC_DEBUG /* WITH_PYMALLOC && PYMALLOC_DEBUG */
+/*
+ * Basic types
+ * I don't care if these are defined in <sys/types.h> or elsewhere. Axiom.
+ */
+#undef uchar
+#define uchar unsigned char /* assuming == 8 bits */
+
+#undef uint
+#define uint unsigned int /* assuming >= 16 bits */
+
+#undef uptr
+#define uptr Py_uintptr_t
+
/* Forward declaration */
+static void* _PyMem_DebugRawMalloc(void *ctx, size_t size);
+static void* _PyMem_DebugRawCalloc(void *ctx, size_t nelem, size_t elsize);
+static void* _PyMem_DebugRawRealloc(void *ctx, void *ptr, size_t size);
+static void _PyMem_DebugRawFree(void *ctx, void *p);
+
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);
+static void _PyMem_DebugFree(void *ctx, void *p);
static void _PyObject_DebugDumpAddress(const void *p);
static void _PyMem_DebugCheckAddress(char api_id, const void *p);
-#endif
#if defined(__has_feature) /* Clang */
#if __has_feature(address_sanitizer) /* is ASAN enabled? */
@@ -145,9 +166,8 @@
#else
# define PYOBJ_FUNCS PYRAW_FUNCS
#endif
-#define PYMEM_FUNCS PYRAW_FUNCS
+#define PYMEM_FUNCS PYOBJ_FUNCS
-#ifdef PYMALLOC_DEBUG
typedef struct {
/* We tag each block with an API ID in order to tag API violations */
char api_id;
@@ -163,19 +183,21 @@
{'o', {NULL, PYOBJ_FUNCS}}
};
-#define PYDBG_FUNCS _PyMem_DebugMalloc, _PyMem_DebugCalloc, _PyMem_DebugRealloc, _PyMem_DebugFree
-#endif
+#define PYRAWDBG_FUNCS \
+ _PyMem_DebugRawMalloc, _PyMem_DebugRawCalloc, _PyMem_DebugRawRealloc, _PyMem_DebugRawFree
+#define PYDBG_FUNCS \
+ _PyMem_DebugMalloc, _PyMem_DebugCalloc, _PyMem_DebugRealloc, _PyMem_DebugFree
static PyMemAllocatorEx _PyMem_Raw = {
-#ifdef PYMALLOC_DEBUG
- &_PyMem_Debug.raw, PYDBG_FUNCS
+#ifdef Py_DEBUG
+ &_PyMem_Debug.raw, PYRAWDBG_FUNCS
#else
NULL, PYRAW_FUNCS
#endif
};
static PyMemAllocatorEx _PyMem = {
-#ifdef PYMALLOC_DEBUG
+#ifdef Py_DEBUG
&_PyMem_Debug.mem, PYDBG_FUNCS
#else
NULL, PYMEM_FUNCS
@@ -183,16 +205,76 @@
};
static PyMemAllocatorEx _PyObject = {
-#ifdef PYMALLOC_DEBUG
+#ifdef Py_DEBUG
&_PyMem_Debug.obj, PYDBG_FUNCS
#else
NULL, PYOBJ_FUNCS
#endif
};
+int
+_PyMem_SetupAllocators(const char *opt)
+{
+ if (opt == NULL || *opt == '\0') {
+ /* PYTHONMALLOC is empty or is not set or ignored (-E/-I command line
+ options): use default allocators */
+#ifdef Py_DEBUG
+# ifdef WITH_PYMALLOC
+ opt = "pymalloc_debug";
+# else
+ opt = "malloc_debug";
+# endif
+#else
+ /* !Py_DEBUG */
+# ifdef WITH_PYMALLOC
+ opt = "pymalloc";
+# else
+ opt = "malloc";
+# endif
+#endif
+ }
+
+ if (strcmp(opt, "debug") == 0) {
+ PyMem_SetupDebugHooks();
+ }
+ else if (strcmp(opt, "malloc") == 0 || strcmp(opt, "malloc_debug") == 0)
+ {
+ PyMemAllocatorEx alloc = {NULL, PYRAW_FUNCS};
+
+ PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &alloc);
+ PyMem_SetAllocator(PYMEM_DOMAIN_MEM, &alloc);
+ PyMem_SetAllocator(PYMEM_DOMAIN_OBJ, &alloc);
+
+ if (strcmp(opt, "malloc_debug") == 0)
+ PyMem_SetupDebugHooks();
+ }
+#ifdef WITH_PYMALLOC
+ else if (strcmp(opt, "pymalloc") == 0
+ || strcmp(opt, "pymalloc_debug") == 0)
+ {
+ PyMemAllocatorEx raw_alloc = {NULL, PYRAW_FUNCS};
+ PyMemAllocatorEx mem_alloc = {NULL, PYMEM_FUNCS};
+ PyMemAllocatorEx obj_alloc = {NULL, PYOBJ_FUNCS};
+
+ PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &raw_alloc);
+ PyMem_SetAllocator(PYMEM_DOMAIN_MEM, &mem_alloc);
+ PyMem_SetAllocator(PYMEM_DOMAIN_OBJ, &obj_alloc);
+
+ if (strcmp(opt, "pymalloc_debug") == 0)
+ PyMem_SetupDebugHooks();
+ }
+#endif
+ else {
+ /* unknown allocator */
+ return -1;
+ }
+ return 0;
+}
+
#undef PYRAW_FUNCS
#undef PYMEM_FUNCS
#undef PYOBJ_FUNCS
+#undef PYRAWDBG_FUNCS
#undef PYDBG_FUNCS
static PyObjectArenaAllocator _PyObject_Arena = {NULL,
@@ -205,23 +287,46 @@
#endif
};
+#ifdef WITH_PYMALLOC
+static int
+_PyMem_DebugEnabled(void)
+{
+ return (_PyObject.malloc == _PyMem_DebugMalloc);
+}
+
+int
+_PyMem_PymallocEnabled(void)
+{
+ if (_PyMem_DebugEnabled()) {
+ return (_PyMem_Debug.obj.alloc.malloc == _PyObject_Malloc);
+ }
+ else {
+ return (_PyObject.malloc == _PyObject_Malloc);
+ }
+}
+#endif
+
void
PyMem_SetupDebugHooks(void)
{
-#ifdef PYMALLOC_DEBUG
PyMemAllocatorEx alloc;
+ alloc.malloc = _PyMem_DebugRawMalloc;
+ alloc.calloc = _PyMem_DebugRawCalloc;
+ alloc.realloc = _PyMem_DebugRawRealloc;
+ alloc.free = _PyMem_DebugRawFree;
+
+ if (_PyMem_Raw.malloc != _PyMem_DebugRawMalloc) {
+ alloc.ctx = &_PyMem_Debug.raw;
+ PyMem_GetAllocator(PYMEM_DOMAIN_RAW, &_PyMem_Debug.raw.alloc);
+ PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &alloc);
+ }
+
alloc.malloc = _PyMem_DebugMalloc;
alloc.calloc = _PyMem_DebugCalloc;
alloc.realloc = _PyMem_DebugRealloc;
alloc.free = _PyMem_DebugFree;
- if (_PyMem_Raw.malloc != _PyMem_DebugMalloc) {
- alloc.ctx = &_PyMem_Debug.raw;
- PyMem_GetAllocator(PYMEM_DOMAIN_RAW, &_PyMem_Debug.raw.alloc);
- PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &alloc);
- }
-
if (_PyMem.malloc != _PyMem_DebugMalloc) {
alloc.ctx = &_PyMem_Debug.mem;
PyMem_GetAllocator(PYMEM_DOMAIN_MEM, &_PyMem_Debug.mem.alloc);
@@ -233,7 +338,6 @@
PyMem_GetAllocator(PYMEM_DOMAIN_OBJ, &_PyMem_Debug.obj.alloc);
PyMem_SetAllocator(PYMEM_DOMAIN_OBJ, &alloc);
}
-#endif
}
void
@@ -264,7 +368,6 @@
case PYMEM_DOMAIN_OBJ: _PyObject = *allocator; break;
/* ignore unknown domain */
}
-
}
void
@@ -642,22 +745,6 @@
#define SIMPLELOCK_LOCK(lock) /* acquire released lock */
#define SIMPLELOCK_UNLOCK(lock) /* release acquired lock */
-/*
- * Basic types
- * I don't care if these are defined in <sys/types.h> or elsewhere. Axiom.
- */
-#undef uchar
-#define uchar unsigned char /* assuming == 8 bits */
-
-#undef uint
-#define uint unsigned int /* assuming >= 16 bits */
-
-#undef ulong
-#define ulong unsigned long /* assuming >= 32 bits */
-
-#undef uptr
-#define uptr Py_uintptr_t
-
/* When you say memory, my mind reasons in terms of (pointers to) blocks */
typedef uchar block;
@@ -949,11 +1036,15 @@
struct arena_object* arenaobj;
uint excess; /* number of bytes above pool alignment */
void *address;
+ static int debug_stats = -1;
-#ifdef PYMALLOC_DEBUG
- if (Py_GETENV("PYTHONMALLOCSTATS"))
+ if (debug_stats == -1) {
+ char *opt = Py_GETENV("PYTHONMALLOCSTATS");
+ debug_stats = (opt != NULL && *opt != '\0');
+ }
+ if (debug_stats)
_PyObject_DebugMallocStats(stderr);
-#endif
+
if (unused_arena_objects == NULL) {
uint i;
uint numarenas;
@@ -1709,7 +1800,7 @@
#endif /* WITH_PYMALLOC */
-#ifdef PYMALLOC_DEBUG
+
/*==========================================================================*/
/* A x-platform debugging allocator. This doesn't manage memory directly,
* it wraps a real allocator, adding extra debugging info to the memory blocks.
@@ -1767,31 +1858,6 @@
}
}
-#ifdef Py_DEBUG
-/* Is target in the list? The list is traversed via the nextpool pointers.
- * The list may be NULL-terminated, or circular. Return 1 if target is in
- * list, else 0.
- */
-static int
-pool_is_in_list(const poolp target, poolp list)
-{
- poolp origlist = list;
- assert(target != NULL);
- if (list == NULL)
- return 0;
- do {
- if (target == list)
- return 1;
- list = list->nextpool;
- } while (list != NULL && list != origlist);
- return 0;
-}
-
-#else
-#define pool_is_in_list(X, Y) 1
-
-#endif /* Py_DEBUG */
-
/* Let S = sizeof(size_t). The debug malloc asks for 4*S extra bytes and
fills them with useful stuff, here calling the underlying malloc's result p:
@@ -1819,7 +1885,7 @@
*/
static void *
-_PyMem_DebugAlloc(int use_calloc, void *ctx, size_t nbytes)
+_PyMem_DebugRawAlloc(int use_calloc, void *ctx, size_t nbytes)
{
debug_alloc_api_t *api = (debug_alloc_api_t *)ctx;
uchar *p; /* base address of malloc'ed block */
@@ -1856,18 +1922,18 @@
}
static void *
-_PyMem_DebugMalloc(void *ctx, size_t nbytes)
+_PyMem_DebugRawMalloc(void *ctx, size_t nbytes)
{
- return _PyMem_DebugAlloc(0, ctx, nbytes);
+ return _PyMem_DebugRawAlloc(0, ctx, nbytes);
}
static void *
-_PyMem_DebugCalloc(void *ctx, size_t nelem, size_t elsize)
+_PyMem_DebugRawCalloc(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);
+ return _PyMem_DebugRawAlloc(1, ctx, nbytes);
}
/* The debug free first checks the 2*SST bytes on each end for sanity (in
@@ -1876,7 +1942,7 @@
Then calls the underlying free.
*/
static void
-_PyMem_DebugFree(void *ctx, void *p)
+_PyMem_DebugRawFree(void *ctx, void *p)
{
debug_alloc_api_t *api = (debug_alloc_api_t *)ctx;
uchar *q = (uchar *)p - 2*SST; /* address returned from malloc */
@@ -1893,7 +1959,7 @@
}
static void *
-_PyMem_DebugRealloc(void *ctx, void *p, size_t nbytes)
+_PyMem_DebugRawRealloc(void *ctx, void *p, size_t nbytes)
{
debug_alloc_api_t *api = (debug_alloc_api_t *)ctx;
uchar *q = (uchar *)p, *oldq;
@@ -1903,7 +1969,7 @@
int i;
if (p == NULL)
- return _PyMem_DebugAlloc(0, ctx, nbytes);
+ return _PyMem_DebugRawAlloc(0, ctx, nbytes);
_PyMem_DebugCheckAddress(api->api_id, p);
bumpserialno();
@@ -1946,6 +2012,44 @@
return q;
}
+static void
+_PyMem_DebugCheckGIL(void)
+{
+#ifdef WITH_THREAD
+ if (!PyGILState_Check())
+ Py_FatalError("Python memory allocator called "
+ "without holding the GIL");
+#endif
+}
+
+static void *
+_PyMem_DebugMalloc(void *ctx, size_t nbytes)
+{
+ _PyMem_DebugCheckGIL();
+ return _PyMem_DebugRawMalloc(ctx, nbytes);
+}
+
+static void *
+_PyMem_DebugCalloc(void *ctx, size_t nelem, size_t elsize)
+{
+ _PyMem_DebugCheckGIL();
+ return _PyMem_DebugRawCalloc(ctx, nelem, elsize);
+}
+
+static void
+_PyMem_DebugFree(void *ctx, void *ptr)
+{
+ _PyMem_DebugCheckGIL();
+ _PyMem_DebugRawFree(ctx, ptr);
+}
+
+static void *
+_PyMem_DebugRealloc(void *ctx, void *ptr, size_t nbytes)
+{
+ _PyMem_DebugCheckGIL();
+ return _PyMem_DebugRawRealloc(ctx, ptr, nbytes);
+}
+
/* Check the forbidden bytes on both ends of the memory allocated for p.
* If anything is wrong, print info to stderr via _PyObject_DebugDumpAddress,
* and call Py_FatalError to kill the program.
@@ -2104,9 +2208,12 @@
}
fputc('\n', stderr);
}
+ fputc('\n', stderr);
+
+ fflush(stderr);
+ _PyMem_DumpTraceback(fileno(stderr), p);
}
-#endif /* PYMALLOC_DEBUG */
static size_t
printone(FILE *out, const char* msg, size_t value)
@@ -2158,8 +2265,30 @@
(void)printone(out, buf2, num_blocks * sizeof_block);
}
+
#ifdef WITH_PYMALLOC
+#ifdef Py_DEBUG
+/* Is target in the list? The list is traversed via the nextpool pointers.
+ * The list may be NULL-terminated, or circular. Return 1 if target is in
+ * list, else 0.
+ */
+static int
+pool_is_in_list(const poolp target, poolp list)
+{
+ poolp origlist = list;
+ assert(target != NULL);
+ if (list == NULL)
+ return 0;
+ do {
+ if (target == list)
+ return 1;
+ list = list->nextpool;
+ } while (list != NULL && list != origlist);
+ return 0;
+}
+#endif
+
/* Print summary info to "out" about the state of pymalloc's structures.
* In Py_DEBUG mode, also perform some expensive internal consistency
* checks.
@@ -2233,7 +2362,9 @@
if (p->ref.count == 0) {
/* currently unused */
+#ifdef Py_DEBUG
assert(pool_is_in_list(p, arenas[i].freepools));
+#endif
continue;
}
++numpools[sz];
@@ -2273,9 +2404,8 @@
quantization += p * ((POOL_SIZE - POOL_OVERHEAD) % size);
}
fputc('\n', out);
-#ifdef PYMALLOC_DEBUG
- (void)printone(out, "# times object malloc called", serialno);
-#endif
+ if (_PyMem_DebugEnabled())
+ (void)printone(out, "# times object malloc called", serialno);
(void)printone(out, "# arenas allocated total", ntimes_arena_allocated);
(void)printone(out, "# arenas reclaimed", ntimes_arena_allocated - narenas);
(void)printone(out, "# arenas highwater mark", narenas_highwater);
@@ -2303,6 +2433,7 @@
#endif /* #ifdef WITH_PYMALLOC */
+
#ifdef Py_USING_MEMORY_DEBUGGER
/* Make this function last so gcc won't inline it since the definition is
* after the reference.
diff --git a/Objects/odictobject.c b/Objects/odictobject.c
index 1abdd02..9af0b0e 100644
--- a/Objects/odictobject.c
+++ b/Objects/odictobject.c
@@ -1424,14 +1424,13 @@
* OrderedDict members
*/
-/* tp_members */
+/* tp_getset */
-static PyMemberDef odict_members[] = {
- {"__dict__", T_OBJECT, offsetof(PyODictObject, od_inst_dict), READONLY},
- {0}
+static PyGetSetDef odict_getset[] = {
+ {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict},
+ {NULL}
};
-
/* ----------------------------------------------
* OrderedDict type slot methods
*/
@@ -1463,7 +1462,7 @@
++tstate->trash_delete_nesting;
Py_TRASHCAN_SAFE_END(self)
-};
+}
/* tp_repr */
@@ -1540,7 +1539,7 @@
Py_XDECREF(pieces);
Py_ReprLeave((PyObject *)self);
return result;
-};
+}
/* tp_doc */
@@ -1612,7 +1611,7 @@
} else {
Py_RETURN_NOTIMPLEMENTED;
}
-};
+}
/* tp_iter */
@@ -1620,7 +1619,7 @@
odict_iter(PyODictObject *od)
{
return odictiter_new(od, _odict_ITER_KEYS);
-};
+}
/* tp_init */
@@ -1646,27 +1645,19 @@
Py_DECREF(res);
return 0;
}
-};
+}
/* tp_new */
static PyObject *
odict_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
- PyObject *dict;
PyODictObject *od;
- dict = PyDict_New();
- if (dict == NULL)
- return NULL;
-
od = (PyODictObject *)PyDict_Type.tp_new(type, args, kwds);
- if (od == NULL) {
- Py_DECREF(dict);
+ if (od == NULL)
return NULL;
- }
- od->od_inst_dict = dict;
/* type constructor fills the memory with zeros (see
PyType_GenericAlloc()), there is no need to set them to zero again */
if (_odict_resize(od) < 0) {
@@ -1708,8 +1699,8 @@
(getiterfunc)odict_iter, /* tp_iter */
0, /* tp_iternext */
odict_methods, /* tp_methods */
- odict_members, /* tp_members */
- 0, /* tp_getset */
+ 0, /* tp_members */
+ odict_getset, /* tp_getset */
&PyDict_Type, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
@@ -1729,7 +1720,7 @@
PyObject *
PyODict_New(void) {
return odict_new(&PyODict_Type, NULL, NULL);
-};
+}
static int
_PyODict_SetItem_KnownHash(PyObject *od, PyObject *key, PyObject *value,
@@ -1747,7 +1738,7 @@
}
}
return res;
-};
+}
int
PyODict_SetItem(PyObject *od, PyObject *key, PyObject *value)
@@ -1756,7 +1747,7 @@
if (hash == -1)
return -1;
return _PyODict_SetItem_KnownHash(od, key, value, hash);
-};
+}
int
PyODict_DelItem(PyObject *od, PyObject *key)
@@ -1769,7 +1760,7 @@
if (res < 0)
return -1;
return _PyDict_DelItem_KnownHash(od, key, hash);
-};
+}
/* -------------------------------------------
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
index 0e9eb20..284a100 100644
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -29,17 +29,10 @@
return PyLong_FromLong(1);
step = PyNumber_Index(step);
- if (step) {
- Py_ssize_t istep = PyNumber_AsSsize_t(step, NULL);
- if (istep == -1 && PyErr_Occurred()) {
- /* Ignore OverflowError, we know the value isn't 0. */
- PyErr_Clear();
- }
- else if (istep == 0) {
- PyErr_SetString(PyExc_ValueError,
- "range() arg 3 must not be zero");
- Py_CLEAR(step);
- }
+ if (step && _PyLong_Sign(step) == 0) {
+ PyErr_SetString(PyExc_ValueError,
+ "range() arg 3 must not be zero");
+ Py_CLEAR(step);
}
return step;
@@ -129,9 +122,9 @@
return (PyObject *) obj;
/* Failed to create object, release attributes */
- Py_XDECREF(start);
- Py_XDECREF(stop);
- Py_XDECREF(step);
+ Py_DECREF(start);
+ Py_DECREF(stop);
+ Py_DECREF(step);
return NULL;
}
@@ -196,7 +189,7 @@
/* if (lo >= hi), return length of 0. */
cmp_result = PyObject_RichCompareBool(lo, hi, Py_GE);
if (cmp_result != 0) {
- Py_XDECREF(step);
+ Py_DECREF(step);
if (cmp_result < 0)
return NULL;
return PyLong_FromLong(0);
@@ -225,9 +218,9 @@
return result;
Fail:
+ Py_DECREF(step);
Py_XDECREF(tmp2);
Py_XDECREF(diff);
- Py_XDECREF(step);
Py_XDECREF(tmp1);
Py_XDECREF(one);
return NULL;
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 4ef692d..6dd403f 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -26,7 +26,6 @@
#include "Python.h"
#include "structmember.h"
-#include "stringlib/eq.h"
/* Object used as dummy key to fill deleted entries */
static PyObject _dummy_struct;
@@ -48,19 +47,20 @@
static setentry *
set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash)
{
- setentry *table = so->table;
- setentry *freeslot = NULL;
+ setentry *table;
setentry *entry;
- size_t perturb = hash;
+ size_t perturb;
size_t mask = so->mask;
size_t i = (size_t)hash & mask; /* Unsigned for defined overflow behavior */
size_t j;
int cmp;
- entry = &table[i];
+ entry = &so->table[i];
if (entry->key == NULL)
return entry;
+ perturb = hash;
+
while (1) {
if (entry->hash == hash) {
PyObject *startkey = entry->key;
@@ -70,8 +70,9 @@
return entry;
if (PyUnicode_CheckExact(startkey)
&& PyUnicode_CheckExact(key)
- && unicode_eq(startkey, key))
+ && _PyUnicode_EQ(startkey, key))
return entry;
+ table = so->table;
Py_INCREF(startkey);
cmp = PyObject_RichCompareBool(startkey, key, Py_EQ);
Py_DECREF(startkey);
@@ -83,14 +84,12 @@
return entry;
mask = so->mask; /* help avoid a register spill */
}
- if (entry->hash == -1 && freeslot == NULL)
- freeslot = entry;
if (i + LINEAR_PROBES <= mask) {
for (j = 0 ; j < LINEAR_PROBES ; j++) {
entry++;
- if (entry->key == NULL)
- goto found_null;
+ if (entry->hash == 0 && entry->key == NULL)
+ return entry;
if (entry->hash == hash) {
PyObject *startkey = entry->key;
assert(startkey != dummy);
@@ -98,8 +97,9 @@
return entry;
if (PyUnicode_CheckExact(startkey)
&& PyUnicode_CheckExact(key)
- && unicode_eq(startkey, key))
+ && _PyUnicode_EQ(startkey, key))
return entry;
+ table = so->table;
Py_INCREF(startkey);
cmp = PyObject_RichCompareBool(startkey, key, Py_EQ);
Py_DECREF(startkey);
@@ -111,7 +111,104 @@
return entry;
mask = so->mask;
}
- if (entry->hash == -1 && freeslot == NULL)
+ }
+ }
+
+ perturb >>= PERTURB_SHIFT;
+ i = (i * 5 + 1 + perturb) & mask;
+
+ entry = &so->table[i];
+ if (entry->key == NULL)
+ return entry;
+ }
+}
+
+static int set_table_resize(PySetObject *, Py_ssize_t);
+
+static int
+set_add_entry(PySetObject *so, PyObject *key, Py_hash_t hash)
+{
+ setentry *table;
+ setentry *freeslot;
+ setentry *entry;
+ size_t perturb;
+ size_t mask;
+ size_t i; /* Unsigned for defined overflow behavior */
+ size_t j;
+ int cmp;
+
+ /* Pre-increment is necessary to prevent arbitrary code in the rich
+ comparison from deallocating the key just before the insertion. */
+ Py_INCREF(key);
+
+ restart:
+
+ mask = so->mask;
+ i = (size_t)hash & mask;
+
+ entry = &so->table[i];
+ if (entry->key == NULL)
+ goto found_unused;
+
+ freeslot = NULL;
+ perturb = hash;
+
+ while (1) {
+ if (entry->hash == hash) {
+ PyObject *startkey = entry->key;
+ /* startkey cannot be a dummy because the dummy hash field is -1 */
+ assert(startkey != dummy);
+ if (startkey == key)
+ goto found_active;
+ if (PyUnicode_CheckExact(startkey)
+ && PyUnicode_CheckExact(key)
+ && _PyUnicode_EQ(startkey, key))
+ goto found_active;
+ table = so->table;
+ Py_INCREF(startkey);
+ cmp = PyObject_RichCompareBool(startkey, key, Py_EQ);
+ Py_DECREF(startkey);
+ if (cmp > 0) /* likely */
+ goto found_active;
+ if (cmp < 0)
+ goto comparison_error;
+ /* Continuing the search from the current entry only makes
+ sense if the table and entry are unchanged; otherwise,
+ we have to restart from the beginning */
+ if (table != so->table || entry->key != startkey)
+ goto restart;
+ mask = so->mask; /* help avoid a register spill */
+ }
+ else if (entry->hash == -1 && freeslot == NULL)
+ freeslot = entry;
+
+ if (i + LINEAR_PROBES <= mask) {
+ for (j = 0 ; j < LINEAR_PROBES ; j++) {
+ entry++;
+ if (entry->hash == 0 && entry->key == NULL)
+ goto found_unused_or_dummy;
+ if (entry->hash == hash) {
+ PyObject *startkey = entry->key;
+ assert(startkey != dummy);
+ if (startkey == key)
+ goto found_active;
+ if (PyUnicode_CheckExact(startkey)
+ && PyUnicode_CheckExact(key)
+ && _PyUnicode_EQ(startkey, key))
+ goto found_active;
+ table = so->table;
+ Py_INCREF(startkey);
+ cmp = PyObject_RichCompareBool(startkey, key, Py_EQ);
+ Py_DECREF(startkey);
+ if (cmp > 0)
+ goto found_active;
+ if (cmp < 0)
+ goto comparison_error;
+ if (table != so->table || entry->key != startkey)
+ goto restart;
+ mask = so->mask;
+ }
+ else if (entry->hash == -1 && freeslot == NULL)
freeslot = entry;
}
}
@@ -119,29 +216,51 @@
perturb >>= PERTURB_SHIFT;
i = (i * 5 + 1 + perturb) & mask;
- entry = &table[i];
+ entry = &so->table[i];
if (entry->key == NULL)
- goto found_null;
+ goto found_unused_or_dummy;
}
- found_null:
- return freeslot == NULL ? entry : freeslot;
+
+ found_unused_or_dummy:
+ if (freeslot == NULL)
+ goto found_unused;
+ so->used++;
+ freeslot->key = key;
+ freeslot->hash = hash;
+ return 0;
+
+ found_unused:
+ so->fill++;
+ so->used++;
+ entry->key = key;
+ entry->hash = hash;
+ if ((size_t)so->fill*3 < mask*2)
+ return 0;
+ return set_table_resize(so, so->used);
+
+ found_active:
+ Py_DECREF(key);
+ return 0;
+
+ comparison_error:
+ Py_DECREF(key);
+ return -1;
}
/*
Internal routine used by set_table_resize() to insert an item which is
known to be absent from the set. This routine also assumes that
the set contains no deleted entries. Besides the performance benefit,
-using set_insert_clean() in set_table_resize() is dangerous (SF bug #1456209).
-Note that no refcounts are changed by this routine; if needed, the caller
-is responsible for incref'ing `key`.
+there is also safety benefit since using set_add_entry() risks making
+a callback in the middle of a set_table_resize(), see issue 1456209.
+The caller is responsible for updating the key's reference count and
+the setobject's fill and used fields.
*/
static void
-set_insert_clean(PySetObject *so, PyObject *key, Py_hash_t hash)
+set_insert_clean(setentry *table, size_t mask, PyObject *key, Py_hash_t hash)
{
- setentry *table = so->table;
setentry *entry;
size_t perturb = hash;
- size_t mask = (size_t)so->mask;
size_t i = (size_t)hash & mask;
size_t j;
@@ -162,45 +281,11 @@
found_null:
entry->key = key;
entry->hash = hash;
- so->fill++;
- so->used++;
}
/* ======== End logic for probing the hash table ========================== */
/* ======================================================================== */
-
-/*
-Internal routine to insert a new key into the table.
-Used by the public insert routine.
-Eats a reference to key.
-*/
-static int
-set_insert_key(PySetObject *so, PyObject *key, Py_hash_t hash)
-{
- setentry *entry;
-
- entry = set_lookkey(so, key, hash);
- if (entry == NULL)
- return -1;
- if (entry->key == NULL) {
- /* UNUSED */
- entry->key = key;
- entry->hash = hash;
- so->fill++;
- so->used++;
- } else if (entry->key == dummy) {
- /* DUMMY */
- entry->key = key;
- entry->hash = hash;
- so->used++;
- } else {
- /* ACTIVE */
- Py_DECREF(key);
- }
- return 0;
-}
-
/*
Restructure the table by allocating a new table and reinserting all
keys again. When entries have been deleted, the new table may
@@ -213,10 +298,13 @@
setentry *oldtable, *newtable, *entry;
Py_ssize_t oldfill = so->fill;
Py_ssize_t oldused = so->used;
+ Py_ssize_t oldmask = so->mask;
+ size_t newmask;
int is_oldtable_malloced;
setentry small_copy[PySet_MINSIZE];
assert(minused >= 0);
+ minused = (minused > 50000) ? minused * 2 : minused * 4;
/* Find the smallest table size > minused. */
/* XXX speed-up with intrinsics */
@@ -264,25 +352,24 @@
/* Make the set empty, using the new table. */
assert(newtable != oldtable);
memset(newtable, 0, sizeof(setentry) * newsize);
- so->fill = 0;
- so->used = 0;
+ so->fill = oldused;
+ so->used = oldused;
so->mask = newsize - 1;
so->table = newtable;
/* Copy the data over; this is refcount-neutral for active entries;
dummy entries aren't copied over, of course */
+ newmask = (size_t)so->mask;
if (oldfill == oldused) {
- for (entry = oldtable; oldused > 0; entry++) {
+ for (entry = oldtable; entry <= oldtable + oldmask; entry++) {
if (entry->key != NULL) {
- oldused--;
- set_insert_clean(so, entry->key, entry->hash);
+ set_insert_clean(newtable, newmask, entry->key, entry->hash);
}
}
} else {
- for (entry = oldtable; oldused > 0; entry++) {
+ for (entry = oldtable; entry <= oldtable + oldmask; entry++) {
if (entry->key != NULL && entry->key != dummy) {
- oldused--;
- set_insert_clean(so, entry->key, entry->hash);
+ set_insert_clean(newtable, newmask, entry->key, entry->hash);
}
}
}
@@ -292,57 +379,30 @@
return 0;
}
-/* CAUTION: set_add_key/entry() must guarantee it won't resize the table */
-
static int
-set_add_entry(PySetObject *so, setentry *entry)
+set_contains_entry(PySetObject *so, PyObject *key, Py_hash_t hash)
{
- Py_ssize_t n_used;
- PyObject *key = entry->key;
- Py_hash_t hash = entry->hash;
+ setentry *entry;
- assert(so->fill <= so->mask); /* at least one empty slot */
- n_used = so->used;
- Py_INCREF(key);
- if (set_insert_key(so, key, hash)) {
- Py_DECREF(key);
- return -1;
- }
- if (!(so->used > n_used && so->fill*3 >= (so->mask+1)*2))
- return 0;
- return set_table_resize(so, so->used>50000 ? so->used*2 : so->used*4);
-}
-
-static int
-set_add_key(PySetObject *so, PyObject *key)
-{
- setentry entry;
- Py_hash_t hash;
-
- if (!PyUnicode_CheckExact(key) ||
- (hash = ((PyASCIIObject *) key)->hash) == -1) {
- hash = PyObject_Hash(key);
- if (hash == -1)
- return -1;
- }
- entry.key = key;
- entry.hash = hash;
- return set_add_entry(so, &entry);
+ entry = set_lookkey(so, key, hash);
+ if (entry != NULL)
+ return entry->key != NULL;
+ return -1;
}
#define DISCARD_NOTFOUND 0
#define DISCARD_FOUND 1
static int
-set_discard_entry(PySetObject *so, setentry *oldentry)
+set_discard_entry(PySetObject *so, PyObject *key, Py_hash_t hash)
{
setentry *entry;
PyObject *old_key;
- entry = set_lookkey(so, oldentry->key, oldentry->hash);
+ entry = set_lookkey(so, key, hash);
if (entry == NULL)
return -1;
- if (entry->key == NULL || entry->key == dummy)
+ if (entry->key == NULL)
return DISCARD_NOTFOUND;
old_key = entry->key;
entry->key = dummy;
@@ -353,22 +413,45 @@
}
static int
-set_discard_key(PySetObject *so, PyObject *key)
+set_add_key(PySetObject *so, PyObject *key)
{
- setentry entry;
Py_hash_t hash;
- assert (PyAnySet_Check(so));
-
if (!PyUnicode_CheckExact(key) ||
(hash = ((PyASCIIObject *) key)->hash) == -1) {
hash = PyObject_Hash(key);
if (hash == -1)
return -1;
}
- entry.key = key;
- entry.hash = hash;
- return set_discard_entry(so, &entry);
+ return set_add_entry(so, key, hash);
+}
+
+static int
+set_contains_key(PySetObject *so, PyObject *key)
+{
+ Py_hash_t hash;
+
+ if (!PyUnicode_CheckExact(key) ||
+ (hash = ((PyASCIIObject *) key)->hash) == -1) {
+ hash = PyObject_Hash(key);
+ if (hash == -1)
+ return -1;
+ }
+ return set_contains_entry(so, key, hash);
+}
+
+static int
+set_discard_key(PySetObject *so, PyObject *key)
+{
+ Py_hash_t hash;
+
+ if (!PyUnicode_CheckExact(key) ||
+ (hash = ((PyASCIIObject *) key)->hash) == -1) {
+ hash = PyObject_Hash(key);
+ if (hash == -1)
+ return -1;
+ }
+ return set_discard_entry(so, key, hash);
}
static void
@@ -449,20 +532,22 @@
{
Py_ssize_t i;
Py_ssize_t mask;
- setentry *table;
+ setentry *entry;
assert (PyAnySet_Check(so));
i = *pos_ptr;
assert(i >= 0);
- table = so->table;
mask = so->mask;
- while (i <= mask && (table[i].key == NULL || table[i].key == dummy))
+ entry = &so->table[i];
+ while (i <= mask && (entry->key == NULL || entry->key == dummy)) {
i++;
+ entry++;
+ }
*pos_ptr = i+1;
if (i > mask)
return 0;
- assert(table[i].key != NULL);
- *entry_ptr = &table[i];
+ assert(entry != NULL);
+ *entry_ptr = entry;
return 1;
}
@@ -560,8 +645,8 @@
* incrementally resizing as we insert new keys. Expect
* that there will be no (or few) overlapping keys.
*/
- if ((so->fill + other->used)*3 >= (so->mask+1)*2) {
- if (set_table_resize(so, (so->used + other->used)*2) != 0)
+ if ((so->fill + other->used)*3 >= so->mask*2) {
+ if (set_table_resize(so, so->used + other->used) != 0)
return -1;
}
so_entry = so->table;
@@ -586,11 +671,15 @@
/* If our table is empty, we can use set_insert_clean() */
if (so->fill == 0) {
- for (i = 0; i <= other->mask; i++, other_entry++) {
+ setentry *newtable = so->table;
+ size_t newmask = (size_t)so->mask;
+ so->fill = other->used;
+ so->used = other->used;
+ for (i = other->mask + 1; i > 0 ; i--, other_entry++) {
key = other_entry->key;
if (key != NULL && key != dummy) {
Py_INCREF(key);
- set_insert_clean(so, key, other_entry->hash);
+ set_insert_clean(newtable, newmask, key, other_entry->hash);
}
}
return 0;
@@ -601,46 +690,13 @@
other_entry = &other->table[i];
key = other_entry->key;
if (key != NULL && key != dummy) {
- Py_INCREF(key);
- if (set_insert_key(so, key, other_entry->hash)) {
- Py_DECREF(key);
+ if (set_add_entry(so, key, other_entry->hash))
return -1;
- }
}
}
return 0;
}
-static int
-set_contains_entry(PySetObject *so, setentry *entry)
-{
- PyObject *key;
- setentry *lu_entry;
-
- lu_entry = set_lookkey(so, entry->key, entry->hash);
- if (lu_entry == NULL)
- return -1;
- key = lu_entry->key;
- return key != NULL && key != dummy;
-}
-
-static int
-set_contains_key(PySetObject *so, PyObject *key)
-{
- setentry entry;
- Py_hash_t hash;
-
- if (!PyUnicode_CheckExact(key) ||
- (hash = ((PyASCIIObject *) key)->hash) == -1) {
- hash = PyObject_Hash(key);
- if (hash == -1)
- return -1;
- }
- entry.key = key;
- entry.hash = hash;
- return set_contains_entry(so, &entry);
-}
-
static PyObject *
set_pop(PySetObject *so)
{
@@ -682,43 +738,64 @@
return 0;
}
+/* Work to increase the bit dispersion for closely spaced hash values.
+ This is important because some use cases have many combinations of a
+ small number of elements with nearby hashes so that many distinct
+ combinations collapse to only a handful of distinct hash values. */
+
+static Py_uhash_t
+_shuffle_bits(Py_uhash_t h)
+{
+ return ((h ^ 89869747UL) ^ (h << 16)) * 3644798167UL;
+}
+
+/* Most of the constants in this hash algorithm are randomly chosen
+ large primes with "interesting bit patterns" and that passed tests
+ for good collision statistics on a variety of problematic datasets
+ including powersets and graph structures (such as David Eppstein's
+ graph recipes in Lib/test/test_set.py) */
+
static Py_hash_t
frozenset_hash(PyObject *self)
{
- /* Most of the constants in this hash algorithm are randomly choosen
- large primes with "interesting bit patterns" and that passed
- tests for good collision statistics on a variety of problematic
- datasets such as:
-
- ps = []
- for r in range(21):
- ps += itertools.combinations(range(20), r)
- num_distinct_hashes = len({hash(frozenset(s)) for s in ps})
-
- */
PySetObject *so = (PySetObject *)self;
- Py_uhash_t h, hash = 1927868237UL;
+ Py_uhash_t hash = 0;
setentry *entry;
- Py_ssize_t pos = 0;
if (so->hash != -1)
return so->hash;
- hash *= (Py_uhash_t)PySet_GET_SIZE(self) + 1;
- while (set_next(so, &pos, &entry)) {
- /* Work to increase the bit dispersion for closely spaced hash
- values. This is important because some use cases have many
- combinations of a small number of elements with nearby
- hashes so that many distinct combinations collapse to only
- a handful of distinct hash values. */
- h = entry->hash;
- hash ^= ((h ^ 89869747UL) ^ (h << 16)) * 3644798167UL;
- }
- /* Make the final result spread-out in a different pattern
- than the algorithm for tuples or other python objects. */
+ /* Xor-in shuffled bits from every entry's hash field because xor is
+ commutative and a frozenset hash should be independent of order.
+
+ For speed, include null entries and dummy entries and then
+ subtract out their effect afterwards so that the final hash
+ depends only on active entries. This allows the code to be
+ vectorized by the compiler and it saves the unpredictable
+ branches that would arise when trying to exclude null and dummy
+ entries on every iteration. */
+
+ for (entry = so->table; entry <= &so->table[so->mask]; entry++)
+ hash ^= _shuffle_bits(entry->hash);
+
+ /* Remove the effect of an odd number of NULL entries */
+ if ((so->mask + 1 - so->fill) & 1)
+ hash ^= _shuffle_bits(0);
+
+ /* Remove the effect of an odd number of dummy entries */
+ if ((so->fill - so->used) & 1)
+ hash ^= _shuffle_bits(-1);
+
+ /* Factor in the number of active entries */
+ hash ^= ((Py_uhash_t)PySet_GET_SIZE(self) + 1) * 1927868237UL;
+
+ /* Disperse patterns arising in nested frozensets */
hash = hash * 69069U + 907133923UL;
+
+ /* -1 is reserved as an error code */
if (hash == (Py_uhash_t)-1)
hash = 590923713UL;
+
so->hash = hash;
return hash;
}
@@ -865,7 +942,7 @@
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
0, /* tp_doc */
(traverseproc)setiter_traverse, /* tp_traverse */
0, /* tp_clear */
@@ -910,18 +987,14 @@
* incrementally resizing as we insert new keys. Expect
* that there will be no (or few) overlapping keys.
*/
- if (dictsize == -1)
+ if (dictsize < 0)
return -1;
- if ((so->fill + dictsize)*3 >= (so->mask+1)*2) {
- if (set_table_resize(so, (so->used + dictsize)*2) != 0)
+ if ((so->fill + dictsize)*3 >= so->mask*2) {
+ if (set_table_resize(so, so->used + dictsize) != 0)
return -1;
}
while (_PyDict_Next(other, &pos, &key, &value, &hash)) {
- setentry an_entry;
-
- an_entry.hash = hash;
- an_entry.key = key;
- if (set_add_entry(so, &an_entry))
+ if (set_add_entry(so, key, hash))
return -1;
}
return 0;
@@ -970,9 +1043,8 @@
static PyObject *
make_new_set(PyTypeObject *type, PyObject *iterable)
{
- PySetObject *so = NULL;
+ PySetObject *so;
- /* create PySetObject structure */
so = (PySetObject *)type->tp_alloc(type, 0);
if (so == NULL)
return NULL;
@@ -1015,7 +1087,8 @@
{
PyObject *iterable = NULL, *result;
- if (type == &PyFrozenSet_Type && !_PyArg_NoKeywords("frozenset()", kwds))
+ if (kwds != NULL && type == &PyFrozenSet_Type
+ && !_PyArg_NoKeywords("frozenset()", kwds))
return NULL;
if (!PyArg_UnpackTuple(args, type->tp_name, 0, 1, &iterable))
@@ -1042,24 +1115,9 @@
return emptyfrozenset;
}
-int
-PySet_ClearFreeList(void)
-{
- return 0;
-}
-
-void
-PySet_Fini(void)
-{
- Py_CLEAR(emptyfrozenset);
-}
-
static PyObject *
set_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
- if (type == &PySet_Type && !_PyArg_NoKeywords("set()", kwds))
- return NULL;
-
return make_new_set(type, NULL);
}
@@ -1201,6 +1259,8 @@
{
PySetObject *result;
PyObject *key, *it, *tmp;
+ Py_hash_t hash;
+ int rv;
if ((PyObject *)so == other)
return set_copy(so);
@@ -1220,13 +1280,15 @@
}
while (set_next((PySetObject *)other, &pos, &entry)) {
- int rv = set_contains_entry(so, entry);
- if (rv == -1) {
+ key = entry->key;
+ hash = entry->hash;
+ rv = set_contains_entry(so, key, hash);
+ if (rv < 0) {
Py_DECREF(result);
return NULL;
}
if (rv) {
- if (set_add_entry(result, entry)) {
+ if (set_add_entry(result, key, hash)) {
Py_DECREF(result);
return NULL;
}
@@ -1242,32 +1304,15 @@
}
while ((key = PyIter_Next(it)) != NULL) {
- int rv;
- setentry entry;
- Py_hash_t hash = PyObject_Hash(key);
-
- if (hash == -1) {
- Py_DECREF(it);
- Py_DECREF(result);
- Py_DECREF(key);
- return NULL;
- }
- entry.hash = hash;
- entry.key = key;
- rv = set_contains_entry(so, &entry);
- if (rv == -1) {
- Py_DECREF(it);
- Py_DECREF(result);
- Py_DECREF(key);
- return NULL;
- }
+ hash = PyObject_Hash(key);
+ if (hash == -1)
+ goto error;
+ rv = set_contains_entry(so, key, hash);
+ if (rv < 0)
+ goto error;
if (rv) {
- if (set_add_entry(result, &entry)) {
- Py_DECREF(it);
- Py_DECREF(result);
- Py_DECREF(key);
- return NULL;
- }
+ if (set_add_entry(result, key, hash))
+ goto error;
}
Py_DECREF(key);
}
@@ -1277,6 +1322,11 @@
return NULL;
}
return (PyObject *)result;
+ error:
+ Py_DECREF(it);
+ Py_DECREF(result);
+ Py_DECREF(key);
+ return NULL;
}
static PyObject *
@@ -1363,6 +1413,7 @@
set_isdisjoint(PySetObject *so, PyObject *other)
{
PyObject *key, *it, *tmp;
+ int rv;
if ((PyObject *)so == other) {
if (PySet_GET_SIZE(so) == 0)
@@ -1381,8 +1432,8 @@
other = tmp;
}
while (set_next((PySetObject *)other, &pos, &entry)) {
- int rv = set_contains_entry(so, entry);
- if (rv == -1)
+ rv = set_contains_entry(so, entry->key, entry->hash);
+ if (rv < 0)
return NULL;
if (rv)
Py_RETURN_FALSE;
@@ -1395,8 +1446,6 @@
return NULL;
while ((key = PyIter_Next(it)) != NULL) {
- int rv;
- setentry entry;
Py_hash_t hash = PyObject_Hash(key);
if (hash == -1) {
@@ -1404,11 +1453,9 @@
Py_DECREF(it);
return NULL;
}
- entry.hash = hash;
- entry.key = key;
- rv = set_contains_entry(so, &entry);
+ rv = set_contains_entry(so, key, hash);
Py_DECREF(key);
- if (rv == -1) {
+ if (rv < 0) {
Py_DECREF(it);
return NULL;
}
@@ -1437,7 +1484,7 @@
Py_ssize_t pos = 0;
while (set_next((PySetObject *)other, &pos, &entry))
- if (set_discard_entry(so, entry) == -1)
+ if (set_discard_entry(so, entry->key, entry->hash) < 0)
return -1;
} else {
PyObject *key, *it;
@@ -1446,7 +1493,7 @@
return -1;
while ((key = PyIter_Next(it)) != NULL) {
- if (set_discard_key(so, key) == -1) {
+ if (set_discard_key(so, key) < 0) {
Py_DECREF(it);
Py_DECREF(key);
return -1;
@@ -1457,10 +1504,10 @@
if (PyErr_Occurred())
return -1;
}
- /* If more than 1/5 are dummies, then resize them away. */
- if ((so->fill - so->used) * 5 < so->mask)
+ /* If more than 1/4th are dummies, then resize them away. */
+ if ((size_t)(so->fill - so->used) <= (size_t)so->mask / 4)
return 0;
- return set_table_resize(so, so->used>50000 ? so->used*2 : so->used*4);
+ return set_table_resize(so, so->used);
}
static PyObject *
@@ -1487,7 +1534,7 @@
result = set_copy(so);
if (result == NULL)
return NULL;
- if (set_difference_update_internal((PySetObject *) result, other) != -1)
+ if (set_difference_update_internal((PySetObject *) result, other) == 0)
return result;
Py_DECREF(result);
return NULL;
@@ -1497,8 +1544,11 @@
set_difference(PySetObject *so, PyObject *other)
{
PyObject *result;
+ PyObject *key;
+ Py_hash_t hash;
setentry *entry;
Py_ssize_t pos = 0;
+ int rv;
if (!PyAnySet_Check(other) && !PyDict_CheckExact(other)) {
return set_copy_and_difference(so, other);
@@ -1516,17 +1566,15 @@
if (PyDict_CheckExact(other)) {
while (set_next(so, &pos, &entry)) {
- setentry entrycopy;
- int rv;
- entrycopy.hash = entry->hash;
- entrycopy.key = entry->key;
- rv = _PyDict_Contains(other, entry->key, entry->hash);
+ key = entry->key;
+ hash = entry->hash;
+ rv = _PyDict_Contains(other, key, hash);
if (rv < 0) {
Py_DECREF(result);
return NULL;
}
if (!rv) {
- if (set_add_entry((PySetObject *)result, &entrycopy)) {
+ if (set_add_entry((PySetObject *)result, key, hash)) {
Py_DECREF(result);
return NULL;
}
@@ -1537,13 +1585,15 @@
/* Iterate over so, checking for common elements in other. */
while (set_next(so, &pos, &entry)) {
- int rv = set_contains_entry((PySetObject *)other, entry);
- if (rv == -1) {
+ key = entry->key;
+ hash = entry->hash;
+ rv = set_contains_entry((PySetObject *)other, key, hash);
+ if (rv < 0) {
Py_DECREF(result);
return NULL;
}
if (!rv) {
- if (set_add_entry((PySetObject *)result, entry)) {
+ if (set_add_entry((PySetObject *)result, key, hash)) {
Py_DECREF(result);
return NULL;
}
@@ -1605,29 +1655,24 @@
PySetObject *otherset;
PyObject *key;
Py_ssize_t pos = 0;
+ Py_hash_t hash;
setentry *entry;
+ int rv;
if ((PyObject *)so == other)
return set_clear(so);
if (PyDict_CheckExact(other)) {
PyObject *value;
- int rv;
- Py_hash_t hash;
while (_PyDict_Next(other, &pos, &key, &value, &hash)) {
- setentry an_entry;
-
Py_INCREF(key);
- an_entry.hash = hash;
- an_entry.key = key;
-
- rv = set_discard_entry(so, &an_entry);
- if (rv == -1) {
+ rv = set_discard_entry(so, key, hash);
+ if (rv < 0) {
Py_DECREF(key);
return NULL;
}
if (rv == DISCARD_NOTFOUND) {
- if (set_add_entry(so, &an_entry)) {
+ if (set_add_entry(so, key, hash)) {
Py_DECREF(key);
return NULL;
}
@@ -1647,13 +1692,15 @@
}
while (set_next(otherset, &pos, &entry)) {
- int rv = set_discard_entry(so, entry);
- if (rv == -1) {
+ key = entry->key;
+ hash = entry->hash;
+ rv = set_discard_entry(so, key, hash);
+ if (rv < 0) {
Py_DECREF(otherset);
return NULL;
}
if (rv == DISCARD_NOTFOUND) {
- if (set_add_entry(so, entry)) {
+ if (set_add_entry(so, key, hash)) {
Py_DECREF(otherset);
return NULL;
}
@@ -1715,6 +1762,7 @@
{
setentry *entry;
Py_ssize_t pos = 0;
+ int rv;
if (!PyAnySet_Check(other)) {
PyObject *tmp, *result;
@@ -1729,8 +1777,8 @@
Py_RETURN_FALSE;
while (set_next(so, &pos, &entry)) {
- int rv = set_contains_entry((PySetObject *)other, entry);
- if (rv == -1)
+ rv = set_contains_entry((PySetObject *)other, entry->key, entry->hash);
+ if (rv < 0)
return NULL;
if (!rv)
Py_RETURN_FALSE;
@@ -1821,7 +1869,7 @@
int rv;
rv = set_contains_key(so, key);
- if (rv == -1) {
+ if (rv < 0) {
if (!PySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError))
return -1;
PyErr_Clear();
@@ -1840,7 +1888,7 @@
long result;
result = set_contains(so, key);
- if (result == -1)
+ if (result < 0)
return NULL;
return PyBool_FromLong(result);
}
@@ -1854,7 +1902,7 @@
int rv;
rv = set_discard_key(so, key);
- if (rv == -1) {
+ if (rv < 0) {
if (!PySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError))
return NULL;
PyErr_Clear();
@@ -1863,7 +1911,7 @@
return NULL;
rv = set_discard_key(so, tmpkey);
Py_DECREF(tmpkey);
- if (rv == -1)
+ if (rv < 0)
return NULL;
}
@@ -1886,7 +1934,7 @@
int rv;
rv = set_discard_key(so, key);
- if (rv == -1) {
+ if (rv < 0) {
if (!PySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError))
return NULL;
PyErr_Clear();
@@ -1895,7 +1943,7 @@
return NULL;
rv = set_discard_key(so, tmpkey);
Py_DECREF(tmpkey);
- if (rv == -1)
+ if (rv < 0)
return NULL;
}
Py_RETURN_NONE;
@@ -1949,13 +1997,12 @@
{
PyObject *iterable = NULL;
- if (!PyAnySet_Check(self))
- return -1;
- if (PySet_Check(self) && !_PyArg_NoKeywords("set()", kwds))
+ if (kwds != NULL && !_PyArg_NoKeywords("set()", kwds))
return -1;
if (!PyArg_UnpackTuple(args, Py_TYPE(self)->tp_name, 0, 1, &iterable))
return -1;
- set_clear_internal(self);
+ if (self->fill)
+ set_clear_internal(self);
self->hash = -1;
if (iterable == NULL)
return 0;
@@ -2122,7 +2169,7 @@
copy_doc},
{"difference", (PyCFunction)set_difference_multi, METH_VARARGS,
difference_doc},
- {"intersection",(PyCFunction)set_intersection_multi, METH_VARARGS,
+ {"intersection", (PyCFunction)set_intersection_multi, METH_VARARGS,
intersection_doc},
{"isdisjoint", (PyCFunction)set_isdisjoint, METH_O,
isdisjoint_doc},
@@ -2193,7 +2240,7 @@
(traverseproc)set_traverse, /* tp_traverse */
(inquiry)set_clear_internal, /* tp_clear */
(richcmpfunc)set_richcompare, /* tp_richcompare */
- offsetof(PySetObject, weakreflist), /* tp_weaklistoffset */
+ offsetof(PySetObject, weakreflist), /* tp_weaklistoffset */
(getiterfunc)set_iter, /* tp_iter */
0, /* tp_iternext */
frozenset_methods, /* tp_methods */
@@ -2277,6 +2324,18 @@
}
int
+PySet_ClearFreeList(void)
+{
+ return 0;
+}
+
+void
+PySet_Fini(void)
+{
+ Py_CLEAR(emptyfrozenset);
+}
+
+int
_PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, Py_hash_t *hash)
{
setentry *entry;
diff --git a/Objects/stringlib/codecs.h b/Objects/stringlib/codecs.h
index 0fc6b58..2846d7e 100644
--- a/Objects/stringlib/codecs.h
+++ b/Objects/stringlib/codecs.h
@@ -1,6 +1,8 @@
/* stringlib: codec implementations */
-#if STRINGLIB_IS_UNICODE
+#if !STRINGLIB_IS_UNICODE
+# error "codecs.h is specific to Unicode"
+#endif
/* Mask to quickly check whether a C 'long' contains a
non-ASCII, UTF8-encoded char. */
@@ -263,49 +265,33 @@
#define MAX_SHORT_UNICHARS 300 /* largest size we'll do on the stack */
Py_ssize_t i; /* index into s of next input byte */
- PyObject *result; /* result string object */
char *p; /* next free byte in output buffer */
- Py_ssize_t nallocated; /* number of result bytes allocated */
- Py_ssize_t nneeded; /* number of result bytes needed */
#if STRINGLIB_SIZEOF_CHAR > 1
- PyObject *errorHandler = NULL;
+ PyObject *error_handler_obj = NULL;
PyObject *exc = NULL;
PyObject *rep = NULL;
+ _Py_error_handler error_handler = _Py_ERROR_UNKNOWN;
#endif
#if STRINGLIB_SIZEOF_CHAR == 1
const Py_ssize_t max_char_size = 2;
- char stackbuf[MAX_SHORT_UNICHARS * 2];
#elif STRINGLIB_SIZEOF_CHAR == 2
const Py_ssize_t max_char_size = 3;
- char stackbuf[MAX_SHORT_UNICHARS * 3];
#else /* STRINGLIB_SIZEOF_CHAR == 4 */
const Py_ssize_t max_char_size = 4;
- char stackbuf[MAX_SHORT_UNICHARS * 4];
#endif
+ _PyBytesWriter writer;
assert(size >= 0);
+ _PyBytesWriter_Init(&writer);
- if (size <= MAX_SHORT_UNICHARS) {
- /* Write into the stack buffer; nallocated can't overflow.
- * At the end, we'll allocate exactly as much heap space as it
- * turns out we need.
- */
- nallocated = Py_SAFE_DOWNCAST(sizeof(stackbuf), size_t, int);
- result = NULL; /* will allocate after we're done */
- p = stackbuf;
+ if (size > PY_SSIZE_T_MAX / max_char_size) {
+ /* integer overflow */
+ return PyErr_NoMemory();
}
- else {
- if (size > PY_SSIZE_T_MAX / max_char_size) {
- /* integer overflow */
- return PyErr_NoMemory();
- }
- /* Overallocate on the heap, and give the excess back at the end. */
- nallocated = size * max_char_size;
- result = PyBytes_FromStringAndSize(NULL, nallocated);
- if (result == NULL)
- return NULL;
- p = PyBytes_AS_STRING(result);
- }
+
+ p = _PyBytesWriter_Alloc(&writer, size * max_char_size);
+ if (p == NULL)
+ return NULL;
for (i = 0; i < size;) {
Py_UCS4 ch = data[i++];
@@ -326,72 +312,118 @@
}
#if STRINGLIB_SIZEOF_CHAR > 1
else if (Py_UNICODE_IS_SURROGATE(ch)) {
- Py_ssize_t newpos;
- Py_ssize_t repsize, k, startpos;
+ Py_ssize_t startpos, endpos, newpos;
+ Py_ssize_t k;
+ if (error_handler == _Py_ERROR_UNKNOWN)
+ error_handler = get_error_handler(errors);
+
startpos = i-1;
- rep = unicode_encode_call_errorhandler(
- errors, &errorHandler, "utf-8", "surrogates not allowed",
- unicode, &exc, startpos, startpos+1, &newpos);
- if (!rep)
- goto error;
+ endpos = startpos+1;
- if (PyBytes_Check(rep))
- repsize = PyBytes_GET_SIZE(rep);
- else
- repsize = PyUnicode_GET_LENGTH(rep);
+ while ((endpos < size) && Py_UNICODE_IS_SURROGATE(data[endpos]))
+ endpos++;
- if (repsize > max_char_size) {
- Py_ssize_t offset;
+ /* Only overallocate the buffer if it's not the last write */
+ writer.overallocate = (endpos < size);
- if (result == NULL)
- offset = p - stackbuf;
- else
- offset = p - PyBytes_AS_STRING(result);
+ switch (error_handler)
+ {
+ case _Py_ERROR_REPLACE:
+ memset(p, '?', endpos - startpos);
+ p += (endpos - startpos);
+ /* fall through the ignore handler */
+ case _Py_ERROR_IGNORE:
+ i += (endpos - startpos - 1);
+ break;
- if (nallocated > PY_SSIZE_T_MAX - repsize + max_char_size) {
- /* integer overflow */
- PyErr_NoMemory();
- goto error;
+ case _Py_ERROR_SURROGATEPASS:
+ for (k=startpos; k<endpos; k++) {
+ ch = data[k];
+ *p++ = (char)(0xe0 | (ch >> 12));
+ *p++ = (char)(0x80 | ((ch >> 6) & 0x3f));
+ *p++ = (char)(0x80 | (ch & 0x3f));
}
- nallocated += repsize - max_char_size;
- if (result != NULL) {
- if (_PyBytes_Resize(&result, nallocated) < 0)
- goto error;
- } else {
- result = PyBytes_FromStringAndSize(NULL, nallocated);
- if (result == NULL)
- goto error;
- Py_MEMCPY(PyBytes_AS_STRING(result), stackbuf, offset);
- }
- p = PyBytes_AS_STRING(result) + offset;
- }
+ i += (endpos - startpos - 1);
+ break;
- if (PyBytes_Check(rep)) {
- char *prep = PyBytes_AS_STRING(rep);
- for(k = repsize; k > 0; k--)
- *p++ = *prep++;
- } else /* rep is unicode */ {
- enum PyUnicode_Kind repkind;
- void *repdata;
-
- if (PyUnicode_READY(rep) < 0)
+ case _Py_ERROR_BACKSLASHREPLACE:
+ /* substract preallocated bytes */
+ writer.min_size -= max_char_size * (endpos - startpos);
+ p = backslashreplace(&writer, p,
+ unicode, startpos, endpos);
+ if (p == NULL)
goto error;
- repkind = PyUnicode_KIND(rep);
- repdata = PyUnicode_DATA(rep);
+ i += (endpos - startpos - 1);
+ break;
- for(k=0; k<repsize; k++) {
- Py_UCS4 c = PyUnicode_READ(repkind, repdata, k);
- if (0x80 <= c) {
+ case _Py_ERROR_XMLCHARREFREPLACE:
+ /* substract preallocated bytes */
+ writer.min_size -= max_char_size * (endpos - startpos);
+ p = xmlcharrefreplace(&writer, p,
+ unicode, startpos, endpos);
+ if (p == NULL)
+ goto error;
+ i += (endpos - startpos - 1);
+ break;
+
+ case _Py_ERROR_SURROGATEESCAPE:
+ for (k=startpos; k<endpos; k++) {
+ ch = data[k];
+ if (!(0xDC80 <= ch && ch <= 0xDCFF))
+ break;
+ *p++ = (char)(ch & 0xff);
+ }
+ if (k >= endpos) {
+ i += (endpos - startpos - 1);
+ break;
+ }
+ startpos = k;
+ assert(startpos < endpos);
+ /* fall through the default handler */
+ default:
+ rep = unicode_encode_call_errorhandler(
+ errors, &error_handler_obj, "utf-8", "surrogates not allowed",
+ unicode, &exc, startpos, endpos, &newpos);
+ if (!rep)
+ goto error;
+
+ /* substract preallocated bytes */
+ writer.min_size -= max_char_size;
+
+ if (PyBytes_Check(rep)) {
+ p = _PyBytesWriter_WriteBytes(&writer, p,
+ PyBytes_AS_STRING(rep),
+ PyBytes_GET_SIZE(rep));
+ }
+ else {
+ /* rep is unicode */
+ if (PyUnicode_READY(rep) < 0)
+ goto error;
+
+ if (!PyUnicode_IS_ASCII(rep)) {
raise_encode_exception(&exc, "utf-8",
unicode,
i-1, i,
"surrogates not allowed");
goto error;
}
- *p++ = (char)c;
+
+ assert(PyUnicode_KIND(rep) == PyUnicode_1BYTE_KIND);
+ p = _PyBytesWriter_WriteBytes(&writer, p,
+ PyUnicode_DATA(rep),
+ PyUnicode_GET_LENGTH(rep));
}
+
+ if (p == NULL)
+ goto error;
+ Py_CLEAR(rep);
+
+ i = newpos;
}
- Py_CLEAR(rep);
+
+ /* If overallocation was disabled, ensure that it was the last
+ write. Otherwise, we missed an optimization */
+ assert(writer.overallocate || i == size);
}
else
#if STRINGLIB_SIZEOF_CHAR > 2
@@ -416,31 +448,18 @@
#endif /* STRINGLIB_SIZEOF_CHAR > 1 */
}
- if (result == NULL) {
- /* This was stack allocated. */
- nneeded = p - stackbuf;
- assert(nneeded <= nallocated);
- result = PyBytes_FromStringAndSize(stackbuf, nneeded);
- }
- else {
- /* Cut back to size actually needed. */
- nneeded = p - PyBytes_AS_STRING(result);
- assert(nneeded <= nallocated);
- _PyBytes_Resize(&result, nneeded);
- }
-
#if STRINGLIB_SIZEOF_CHAR > 1
- Py_XDECREF(errorHandler);
+ Py_XDECREF(error_handler_obj);
Py_XDECREF(exc);
#endif
- return result;
+ return _PyBytesWriter_Finish(&writer, p);
#if STRINGLIB_SIZEOF_CHAR > 1
error:
Py_XDECREF(rep);
- Py_XDECREF(errorHandler);
+ Py_XDECREF(error_handler_obj);
Py_XDECREF(exc);
- Py_XDECREF(result);
+ _PyBytesWriter_Dealloc(&writer);
return NULL;
#endif
@@ -806,5 +825,3 @@
#undef SWAB4
#endif
-
-#endif /* STRINGLIB_IS_UNICODE */
diff --git a/Objects/stringlib/ctype.h b/Objects/stringlib/ctype.h
index 739cf3d..f054625 100644
--- a/Objects/stringlib/ctype.h
+++ b/Objects/stringlib/ctype.h
@@ -1,5 +1,6 @@
-/* NOTE: this API is -ONLY- for use with single byte character strings. */
-/* Do not use it with Unicode. */
+#if STRINGLIB_IS_UNICODE
+# error "ctype.h only compatible with byte-wise strings"
+#endif
#include "bytes_methods.h"
diff --git a/Objects/stringlib/fastsearch.h b/Objects/stringlib/fastsearch.h
index cda68e7..98165ad 100644
--- a/Objects/stringlib/fastsearch.h
+++ b/Objects/stringlib/fastsearch.h
@@ -32,52 +32,98 @@
#define STRINGLIB_BLOOM(mask, ch) \
((mask & (1UL << ((ch) & (STRINGLIB_BLOOM_WIDTH -1)))))
+Py_LOCAL_INLINE(Py_ssize_t)
+STRINGLIB(find_char)(const STRINGLIB_CHAR* s, Py_ssize_t n, STRINGLIB_CHAR ch)
+{
+ const STRINGLIB_CHAR *p, *e;
+
+ p = s;
+ e = s + n;
+ if (n > 10) {
+#if STRINGLIB_SIZEOF_CHAR == 1
+ p = memchr(s, ch, n);
+ if (p != NULL)
+ return (p - s);
+ return -1;
+#else
+ /* use memchr if we can choose a needle without two many likely
+ false positives */
+ unsigned char needle = ch & 0xff;
+ /* If looking for a multiple of 256, we'd have too
+ many false positives looking for the '\0' byte in UCS2
+ and UCS4 representations. */
+ if (needle != 0) {
+ while (p < e) {
+ void *candidate = memchr(p, needle,
+ (e - p) * sizeof(STRINGLIB_CHAR));
+ if (candidate == NULL)
+ return -1;
+ p = (const STRINGLIB_CHAR *)
+ _Py_ALIGN_DOWN(candidate, sizeof(STRINGLIB_CHAR));
+ if (*p == ch)
+ return (p - s);
+ /* False positive */
+ p++;
+ }
+ return -1;
+ }
+#endif
+ }
+ while (p < e) {
+ if (*p == ch)
+ return (p - s);
+ p++;
+ }
+ return -1;
+}
Py_LOCAL_INLINE(Py_ssize_t)
-STRINGLIB(fastsearch_memchr_1char)(const STRINGLIB_CHAR* s, Py_ssize_t n,
- STRINGLIB_CHAR ch, unsigned char needle,
- int mode)
+STRINGLIB(rfind_char)(const STRINGLIB_CHAR* s, Py_ssize_t n, STRINGLIB_CHAR ch)
{
- if (mode == FAST_SEARCH) {
- const STRINGLIB_CHAR *ptr = s;
- const STRINGLIB_CHAR *e = s + n;
- while (ptr < e) {
- void *candidate = memchr((const void *) ptr, needle, (e - ptr) * sizeof(STRINGLIB_CHAR));
- if (candidate == NULL)
- return -1;
- ptr = (const STRINGLIB_CHAR *) _Py_ALIGN_DOWN(candidate, sizeof(STRINGLIB_CHAR));
- if (sizeof(STRINGLIB_CHAR) == 1 || *ptr == ch)
- return (ptr - s);
- /* False positive */
- ptr++;
- }
- return -1;
- }
+ const STRINGLIB_CHAR *p;
#ifdef HAVE_MEMRCHR
/* memrchr() is a GNU extension, available since glibc 2.1.91.
it doesn't seem as optimized as memchr(), but is still quite
- faster than our hand-written loop in FASTSEARCH below */
- else if (mode == FAST_RSEARCH) {
- while (n > 0) {
- const STRINGLIB_CHAR *found;
- void *candidate = memrchr((const void *) s, needle, n * sizeof(STRINGLIB_CHAR));
- if (candidate == NULL)
- return -1;
- found = (const STRINGLIB_CHAR *) _Py_ALIGN_DOWN(candidate, sizeof(STRINGLIB_CHAR));
- n = found - s;
- if (sizeof(STRINGLIB_CHAR) == 1 || *found == ch)
- return n;
- /* False positive */
- }
- return -1;
- }
-#endif
- else {
- assert(0); /* Should never get here */
- return 0;
- }
+ faster than our hand-written loop below */
-#undef DO_MEMCHR
+ if (n > 10) {
+#if STRINGLIB_SIZEOF_CHAR == 1
+ p = memrchr(s, ch, n);
+ if (p != NULL)
+ return (p - s);
+ return -1;
+#else
+ /* use memrchr if we can choose a needle without two many likely
+ false positives */
+ unsigned char needle = ch & 0xff;
+ /* If looking for a multiple of 256, we'd have too
+ many false positives looking for the '\0' byte in UCS2
+ and UCS4 representations. */
+ if (needle != 0) {
+ while (n > 0) {
+ void *candidate = memrchr(s, needle,
+ n * sizeof(STRINGLIB_CHAR));
+ if (candidate == NULL)
+ return -1;
+ p = (const STRINGLIB_CHAR *)
+ _Py_ALIGN_DOWN(candidate, sizeof(STRINGLIB_CHAR));
+ n = p - s;
+ if (*p == ch)
+ return n;
+ /* False positive */
+ }
+ return -1;
+ }
+#endif
+ }
+#endif /* HAVE_MEMRCHR */
+ p = s + n;
+ while (p > s) {
+ p--;
+ if (*p == ch)
+ return (p - s);
+ }
+ return -1;
}
Py_LOCAL_INLINE(Py_ssize_t)
@@ -99,25 +145,11 @@
if (m <= 0)
return -1;
/* use special case for 1-character strings */
- if (n > 10 && (mode == FAST_SEARCH
-#ifdef HAVE_MEMRCHR
- || mode == FAST_RSEARCH
-#endif
- )) {
- /* use memchr if we can choose a needle without two many likely
- false positives */
- unsigned char needle;
- needle = p[0] & 0xff;
-#if STRINGLIB_SIZEOF_CHAR > 1
- /* If looking for a multiple of 256, we'd have too
- many false positives looking for the '\0' byte in UCS2
- and UCS4 representations. */
- if (needle != 0)
-#endif
- return STRINGLIB(fastsearch_memchr_1char)
- (s, n, p[0], needle, mode);
- }
- if (mode == FAST_COUNT) {
+ if (mode == FAST_SEARCH)
+ return STRINGLIB(find_char)(s, n, p[0]);
+ else if (mode == FAST_RSEARCH)
+ return STRINGLIB(rfind_char)(s, n, p[0]);
+ else { /* FAST_COUNT */
for (i = 0; i < n; i++)
if (s[i] == p[0]) {
count++;
@@ -125,14 +157,6 @@
return maxcount;
}
return count;
- } else if (mode == FAST_SEARCH) {
- for (i = 0; i < n; i++)
- if (s[i] == p[0])
- return i;
- } else { /* FAST_RSEARCH */
- for (i = n - 1; i > -1; i--)
- if (s[i] == p[0])
- return i;
}
return -1;
}
diff --git a/Objects/stringlib/find.h b/Objects/stringlib/find.h
index 14815f6..509b929 100644
--- a/Objects/stringlib/find.h
+++ b/Objects/stringlib/find.h
@@ -117,85 +117,3 @@
}
#undef FORMAT_BUFFER_SIZE
-
-#if STRINGLIB_IS_UNICODE
-
-/*
-Wraps stringlib_parse_args_finds() and additionally ensures that the
-first argument is a unicode object.
-
-Note that we receive a pointer to the pointer of the substring object,
-so when we create that object in this function we don't DECREF it,
-because it continues living in the caller functions (those functions,
-after finishing using the substring, must DECREF it).
-*/
-
-Py_LOCAL_INLINE(int)
-STRINGLIB(parse_args_finds_unicode)(const char * function_name, PyObject *args,
- PyObject **substring,
- Py_ssize_t *start, Py_ssize_t *end)
-{
- PyObject *tmp_substring;
-
- if(STRINGLIB(parse_args_finds)(function_name, args, &tmp_substring,
- start, end)) {
- tmp_substring = PyUnicode_FromObject(tmp_substring);
- if (!tmp_substring)
- return 0;
- *substring = tmp_substring;
- return 1;
- }
- return 0;
-}
-
-#else /* !STRINGLIB_IS_UNICODE */
-
-/*
-Wraps stringlib_parse_args_finds() and additionally checks whether the
-first argument is an integer in range(0, 256).
-
-If this is the case, writes the integer value to the byte parameter
-and sets subobj to NULL. Otherwise, sets the first argument to subobj
-and doesn't touch byte. The other parameters are similar to those of
-stringlib_parse_args_finds().
-*/
-
-Py_LOCAL_INLINE(int)
-STRINGLIB(parse_args_finds_byte)(const char *function_name, PyObject *args,
- PyObject **subobj, char *byte,
- Py_ssize_t *start, Py_ssize_t *end)
-{
- PyObject *tmp_subobj;
- Py_ssize_t ival;
- PyObject *err;
-
- if(!STRINGLIB(parse_args_finds)(function_name, args, &tmp_subobj,
- start, end))
- return 0;
-
- if (!PyNumber_Check(tmp_subobj)) {
- *subobj = tmp_subobj;
- return 1;
- }
-
- ival = PyNumber_AsSsize_t(tmp_subobj, PyExc_OverflowError);
- if (ival == -1) {
- err = PyErr_Occurred();
- if (err && !PyErr_GivenExceptionMatches(err, PyExc_OverflowError)) {
- PyErr_Clear();
- *subobj = tmp_subobj;
- return 1;
- }
- }
-
- if (ival < 0 || ival > 255) {
- PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)");
- return 0;
- }
-
- *subobj = NULL;
- *byte = (char)ival;
- return 1;
-}
-
-#endif /* STRINGLIB_IS_UNICODE */
diff --git a/Objects/stringlib/find_max_char.h b/Objects/stringlib/find_max_char.h
index eb3fe88..8ccbc30 100644
--- a/Objects/stringlib/find_max_char.h
+++ b/Objects/stringlib/find_max_char.h
@@ -1,6 +1,8 @@
/* Finding the optimal width of unicode characters in a buffer */
-#if STRINGLIB_IS_UNICODE
+#if !STRINGLIB_IS_UNICODE
+# error "find_max_char.h is specific to Unicode"
+#endif
/* Mask to quickly check whether a C 'long' contains a
non-ASCII, UTF8-encoded char. */
@@ -129,5 +131,4 @@
#undef MAX_CHAR_UCS4
#endif /* STRINGLIB_SIZEOF_CHAR == 1 */
-#endif /* STRINGLIB_IS_UNICODE */
diff --git a/Objects/stringlib/join.h b/Objects/stringlib/join.h
index cbf81be..90f966d 100644
--- a/Objects/stringlib/join.h
+++ b/Objects/stringlib/join.h
@@ -1,6 +1,6 @@
/* stringlib: bytes joining implementation */
-#if STRINGLIB_SIZEOF_CHAR != 1
+#if STRINGLIB_IS_UNICODE
#error join.h only compatible with byte-wise strings
#endif
diff --git a/Objects/stringlib/localeutil.h b/Objects/stringlib/localeutil.h
index 6e2f073..df501ed 100644
--- a/Objects/stringlib/localeutil.h
+++ b/Objects/stringlib/localeutil.h
@@ -2,8 +2,8 @@
#include <locale.h>
-#ifndef STRINGLIB_IS_UNICODE
-# error "localeutil is specific to Unicode"
+#if !STRINGLIB_IS_UNICODE
+# error "localeutil.h is specific to Unicode"
#endif
typedef struct {
diff --git a/Objects/stringlib/transmogrify.h b/Objects/stringlib/transmogrify.h
index b559b53..625507d 100644
--- a/Objects/stringlib/transmogrify.h
+++ b/Objects/stringlib/transmogrify.h
@@ -1,14 +1,21 @@
-/* NOTE: this API is -ONLY- for use with single byte character strings. */
-/* Do not use it with Unicode. */
+#if STRINGLIB_IS_UNICODE
+# error "transmogrify.h only compatible with byte-wise strings"
+#endif
/* the more complicated methods. parts of these should be pulled out into the
shared code in bytes_methods.c to cut down on duplicate code bloat. */
-PyDoc_STRVAR(expandtabs__doc__,
-"B.expandtabs(tabsize=8) -> copy of B\n\
-\n\
-Return a copy of B where all tab characters are expanded using spaces.\n\
-If tabsize is not given, a tab size of 8 characters is assumed.");
+Py_LOCAL_INLINE(PyObject *)
+return_self(PyObject *self)
+{
+#if !STRINGLIB_MUTABLE
+ if (STRINGLIB_CHECK_EXACT(self)) {
+ Py_INCREF(self);
+ return self;
+ }
+#endif
+ return STRINGLIB_NEW(STRINGLIB_STR(self), STRINGLIB_LEN(self));
+}
static PyObject*
stringlib_expandtabs(PyObject *self, PyObject *args, PyObject *kwds)
@@ -93,39 +100,25 @@
if (right < 0)
right = 0;
- if (left == 0 && right == 0 && STRINGLIB_CHECK_EXACT(self)) {
-#if STRINGLIB_MUTABLE
- /* We're defined as returning a copy; If the object is mutable
- * that means we must make an identical copy. */
- return STRINGLIB_NEW(STRINGLIB_STR(self), STRINGLIB_LEN(self));
-#else
- Py_INCREF(self);
- return (PyObject *)self;
-#endif /* STRINGLIB_MUTABLE */
+ if (left == 0 && right == 0) {
+ return return_self(self);
}
- u = STRINGLIB_NEW(NULL,
- left + STRINGLIB_LEN(self) + right);
+ u = STRINGLIB_NEW(NULL, left + STRINGLIB_LEN(self) + right);
if (u) {
if (left)
memset(STRINGLIB_STR(u), fill, left);
Py_MEMCPY(STRINGLIB_STR(u) + left,
- STRINGLIB_STR(self),
- STRINGLIB_LEN(self));
+ STRINGLIB_STR(self),
+ STRINGLIB_LEN(self));
if (right)
memset(STRINGLIB_STR(u) + left + STRINGLIB_LEN(self),
- fill, right);
+ fill, right);
}
return u;
}
-PyDoc_STRVAR(ljust__doc__,
-"B.ljust(width[, fillchar]) -> copy of B\n"
-"\n"
-"Return B left justified in a string of length width. Padding is\n"
-"done using the specified fill character (default is a space).");
-
static PyObject *
stringlib_ljust(PyObject *self, PyObject *args)
{
@@ -135,27 +128,14 @@
if (!PyArg_ParseTuple(args, "n|c:ljust", &width, &fillchar))
return NULL;
- if (STRINGLIB_LEN(self) >= width && STRINGLIB_CHECK_EXACT(self)) {
-#if STRINGLIB_MUTABLE
- /* We're defined as returning a copy; If the object is mutable
- * that means we must make an identical copy. */
- return STRINGLIB_NEW(STRINGLIB_STR(self), STRINGLIB_LEN(self));
-#else
- Py_INCREF(self);
- return (PyObject*) self;
-#endif
+ if (STRINGLIB_LEN(self) >= width) {
+ return return_self(self);
}
return pad(self, 0, width - STRINGLIB_LEN(self), fillchar);
}
-PyDoc_STRVAR(rjust__doc__,
-"B.rjust(width[, fillchar]) -> copy of B\n"
-"\n"
-"Return B right justified in a string of length width. Padding is\n"
-"done using the specified fill character (default is a space)");
-
static PyObject *
stringlib_rjust(PyObject *self, PyObject *args)
{
@@ -165,27 +145,14 @@
if (!PyArg_ParseTuple(args, "n|c:rjust", &width, &fillchar))
return NULL;
- if (STRINGLIB_LEN(self) >= width && STRINGLIB_CHECK_EXACT(self)) {
-#if STRINGLIB_MUTABLE
- /* We're defined as returning a copy; If the object is mutable
- * that means we must make an identical copy. */
- return STRINGLIB_NEW(STRINGLIB_STR(self), STRINGLIB_LEN(self));
-#else
- Py_INCREF(self);
- return (PyObject*) self;
-#endif
+ if (STRINGLIB_LEN(self) >= width) {
+ return return_self(self);
}
return pad(self, width - STRINGLIB_LEN(self), 0, fillchar);
}
-PyDoc_STRVAR(center__doc__,
-"B.center(width[, fillchar]) -> copy of B\n"
-"\n"
-"Return B centered in a string of length width. Padding is\n"
-"done using the specified fill character (default is a space).");
-
static PyObject *
stringlib_center(PyObject *self, PyObject *args)
{
@@ -196,15 +163,8 @@
if (!PyArg_ParseTuple(args, "n|c:center", &width, &fillchar))
return NULL;
- if (STRINGLIB_LEN(self) >= width && STRINGLIB_CHECK_EXACT(self)) {
-#if STRINGLIB_MUTABLE
- /* We're defined as returning a copy; If the object is mutable
- * that means we must make an identical copy. */
- return STRINGLIB_NEW(STRINGLIB_STR(self), STRINGLIB_LEN(self));
-#else
- Py_INCREF(self);
- return (PyObject*) self;
-#endif
+ if (STRINGLIB_LEN(self) >= width) {
+ return return_self(self);
}
marg = width - STRINGLIB_LEN(self);
@@ -213,12 +173,6 @@
return pad(self, left, marg - left, fillchar);
}
-PyDoc_STRVAR(zfill__doc__,
-"B.zfill(width) -> copy of B\n"
-"\n"
-"Pad a numeric string B with zeros on the left, to fill a field\n"
-"of the specified width. B is never truncated.");
-
static PyObject *
stringlib_zfill(PyObject *self, PyObject *args)
{
@@ -231,21 +185,7 @@
return NULL;
if (STRINGLIB_LEN(self) >= width) {
- if (STRINGLIB_CHECK_EXACT(self)) {
-#if STRINGLIB_MUTABLE
- /* We're defined as returning a copy; If the object is mutable
- * that means we must make an identical copy. */
- return STRINGLIB_NEW(STRINGLIB_STR(self), STRINGLIB_LEN(self));
-#else
- Py_INCREF(self);
- return (PyObject*) self;
-#endif
- }
- else
- return STRINGLIB_NEW(
- STRINGLIB_STR(self),
- STRINGLIB_LEN(self)
- );
+ return return_self(self);
}
fill = width - STRINGLIB_LEN(self);
@@ -262,5 +202,500 @@
p[fill] = '0';
}
- return (PyObject*) s;
+ return s;
}
+
+
+/* find and count characters and substrings */
+
+#define findchar(target, target_len, c) \
+ ((char *)memchr((const void *)(target), c, target_len))
+
+
+Py_LOCAL_INLINE(Py_ssize_t)
+countchar(const char *target, Py_ssize_t target_len, char c,
+ Py_ssize_t maxcount)
+{
+ Py_ssize_t count = 0;
+ const char *start = target;
+ const char *end = target + target_len;
+
+ while ((start = findchar(start, end - start, c)) != NULL) {
+ count++;
+ if (count >= maxcount)
+ break;
+ start += 1;
+ }
+ return count;
+}
+
+
+/* Algorithms for different cases of string replacement */
+
+/* len(self)>=1, from="", len(to)>=1, maxcount>=1 */
+Py_LOCAL(PyObject *)
+stringlib_replace_interleave(PyObject *self,
+ const char *to_s, Py_ssize_t to_len,
+ Py_ssize_t maxcount)
+{
+ const char *self_s;
+ char *result_s;
+ Py_ssize_t self_len, result_len;
+ Py_ssize_t count, i;
+ PyObject *result;
+
+ self_len = STRINGLIB_LEN(self);
+
+ /* 1 at the end plus 1 after every character;
+ count = min(maxcount, self_len + 1) */
+ if (maxcount <= self_len) {
+ count = maxcount;
+ }
+ else {
+ /* Can't overflow: self_len + 1 <= maxcount <= PY_SSIZE_T_MAX. */
+ count = self_len + 1;
+ }
+
+ /* Check for overflow */
+ /* result_len = count * to_len + self_len; */
+ assert(count > 0);
+ if (to_len > (PY_SSIZE_T_MAX - self_len) / count) {
+ PyErr_SetString(PyExc_OverflowError,
+ "replace bytes are too long");
+ return NULL;
+ }
+ result_len = count * to_len + self_len;
+ result = STRINGLIB_NEW(NULL, result_len);
+ if (result == NULL) {
+ return NULL;
+ }
+
+ self_s = STRINGLIB_STR(self);
+ result_s = STRINGLIB_STR(result);
+
+ if (to_len > 1) {
+ /* Lay the first one down (guaranteed this will occur) */
+ Py_MEMCPY(result_s, to_s, to_len);
+ result_s += to_len;
+ count -= 1;
+
+ for (i = 0; i < count; i++) {
+ *result_s++ = *self_s++;
+ Py_MEMCPY(result_s, to_s, to_len);
+ result_s += to_len;
+ }
+ }
+ else {
+ result_s[0] = to_s[0];
+ result_s += to_len;
+ count -= 1;
+ for (i = 0; i < count; i++) {
+ *result_s++ = *self_s++;
+ result_s[0] = to_s[0];
+ result_s += to_len;
+ }
+ }
+
+ /* Copy the rest of the original string */
+ Py_MEMCPY(result_s, self_s, self_len - i);
+
+ return result;
+}
+
+/* Special case for deleting a single character */
+/* len(self)>=1, len(from)==1, to="", maxcount>=1 */
+Py_LOCAL(PyObject *)
+stringlib_replace_delete_single_character(PyObject *self,
+ char from_c, Py_ssize_t maxcount)
+{
+ const char *self_s, *start, *next, *end;
+ char *result_s;
+ Py_ssize_t self_len, result_len;
+ Py_ssize_t count;
+ PyObject *result;
+
+ self_len = STRINGLIB_LEN(self);
+ self_s = STRINGLIB_STR(self);
+
+ count = countchar(self_s, self_len, from_c, maxcount);
+ if (count == 0) {
+ return return_self(self);
+ }
+
+ result_len = self_len - count; /* from_len == 1 */
+ assert(result_len>=0);
+
+ result = STRINGLIB_NEW(NULL, result_len);
+ if (result == NULL) {
+ return NULL;
+ }
+ result_s = STRINGLIB_STR(result);
+
+ start = self_s;
+ end = self_s + self_len;
+ while (count-- > 0) {
+ next = findchar(start, end - start, from_c);
+ if (next == NULL)
+ break;
+ Py_MEMCPY(result_s, start, next - start);
+ result_s += (next - start);
+ start = next + 1;
+ }
+ Py_MEMCPY(result_s, start, end - start);
+
+ return result;
+}
+
+/* len(self)>=1, len(from)>=2, to="", maxcount>=1 */
+
+Py_LOCAL(PyObject *)
+stringlib_replace_delete_substring(PyObject *self,
+ const char *from_s, Py_ssize_t from_len,
+ Py_ssize_t maxcount)
+{
+ const char *self_s, *start, *next, *end;
+ char *result_s;
+ Py_ssize_t self_len, result_len;
+ Py_ssize_t count, offset;
+ PyObject *result;
+
+ self_len = STRINGLIB_LEN(self);
+ self_s = STRINGLIB_STR(self);
+
+ count = stringlib_count(self_s, self_len,
+ from_s, from_len,
+ maxcount);
+
+ if (count == 0) {
+ /* no matches */
+ return return_self(self);
+ }
+
+ result_len = self_len - (count * from_len);
+ assert (result_len>=0);
+
+ result = STRINGLIB_NEW(NULL, result_len);
+ if (result == NULL) {
+ return NULL;
+ }
+ result_s = STRINGLIB_STR(result);
+
+ start = self_s;
+ end = self_s + self_len;
+ while (count-- > 0) {
+ offset = stringlib_find(start, end - start,
+ from_s, from_len,
+ 0);
+ if (offset == -1)
+ break;
+ next = start + offset;
+
+ Py_MEMCPY(result_s, start, next - start);
+
+ result_s += (next - start);
+ start = next + from_len;
+ }
+ Py_MEMCPY(result_s, start, end - start);
+ return result;
+}
+
+/* len(self)>=1, len(from)==len(to)==1, maxcount>=1 */
+Py_LOCAL(PyObject *)
+stringlib_replace_single_character_in_place(PyObject *self,
+ char from_c, char to_c,
+ Py_ssize_t maxcount)
+{
+ const char *self_s, *end;
+ char *result_s, *start, *next;
+ Py_ssize_t self_len;
+ PyObject *result;
+
+ /* The result string will be the same size */
+ self_s = STRINGLIB_STR(self);
+ self_len = STRINGLIB_LEN(self);
+
+ next = findchar(self_s, self_len, from_c);
+
+ if (next == NULL) {
+ /* No matches; return the original bytes */
+ return return_self(self);
+ }
+
+ /* Need to make a new bytes */
+ result = STRINGLIB_NEW(NULL, self_len);
+ if (result == NULL) {
+ return NULL;
+ }
+ result_s = STRINGLIB_STR(result);
+ Py_MEMCPY(result_s, self_s, self_len);
+
+ /* change everything in-place, starting with this one */
+ start = result_s + (next - self_s);
+ *start = to_c;
+ start++;
+ end = result_s + self_len;
+
+ while (--maxcount > 0) {
+ next = findchar(start, end - start, from_c);
+ if (next == NULL)
+ break;
+ *next = to_c;
+ start = next + 1;
+ }
+
+ return result;
+}
+
+/* len(self)>=1, len(from)==len(to)>=2, maxcount>=1 */
+Py_LOCAL(PyObject *)
+stringlib_replace_substring_in_place(PyObject *self,
+ const char *from_s, Py_ssize_t from_len,
+ const char *to_s, Py_ssize_t to_len,
+ Py_ssize_t maxcount)
+{
+ const char *self_s, *end;
+ char *result_s, *start;
+ Py_ssize_t self_len, offset;
+ PyObject *result;
+
+ /* The result bytes will be the same size */
+
+ self_s = STRINGLIB_STR(self);
+ self_len = STRINGLIB_LEN(self);
+
+ offset = stringlib_find(self_s, self_len,
+ from_s, from_len,
+ 0);
+ if (offset == -1) {
+ /* No matches; return the original bytes */
+ return return_self(self);
+ }
+
+ /* Need to make a new bytes */
+ result = STRINGLIB_NEW(NULL, self_len);
+ if (result == NULL) {
+ return NULL;
+ }
+ result_s = STRINGLIB_STR(result);
+ Py_MEMCPY(result_s, self_s, self_len);
+
+ /* change everything in-place, starting with this one */
+ start = result_s + offset;
+ Py_MEMCPY(start, to_s, from_len);
+ start += from_len;
+ end = result_s + self_len;
+
+ while ( --maxcount > 0) {
+ offset = stringlib_find(start, end - start,
+ from_s, from_len,
+ 0);
+ if (offset == -1)
+ break;
+ Py_MEMCPY(start + offset, to_s, from_len);
+ start += offset + from_len;
+ }
+
+ return result;
+}
+
+/* len(self)>=1, len(from)==1, len(to)>=2, maxcount>=1 */
+Py_LOCAL(PyObject *)
+stringlib_replace_single_character(PyObject *self,
+ char from_c,
+ const char *to_s, Py_ssize_t to_len,
+ Py_ssize_t maxcount)
+{
+ const char *self_s, *start, *next, *end;
+ char *result_s;
+ Py_ssize_t self_len, result_len;
+ Py_ssize_t count;
+ PyObject *result;
+
+ self_s = STRINGLIB_STR(self);
+ self_len = STRINGLIB_LEN(self);
+
+ count = countchar(self_s, self_len, from_c, maxcount);
+ if (count == 0) {
+ /* no matches, return unchanged */
+ return return_self(self);
+ }
+
+ /* use the difference between current and new, hence the "-1" */
+ /* result_len = self_len + count * (to_len-1) */
+ assert(count > 0);
+ if (to_len - 1 > (PY_SSIZE_T_MAX - self_len) / count) {
+ PyErr_SetString(PyExc_OverflowError, "replace bytes is too long");
+ return NULL;
+ }
+ result_len = self_len + count * (to_len - 1);
+
+ result = STRINGLIB_NEW(NULL, result_len);
+ if (result == NULL) {
+ return NULL;
+ }
+ result_s = STRINGLIB_STR(result);
+
+ start = self_s;
+ end = self_s + self_len;
+ while (count-- > 0) {
+ next = findchar(start, end - start, from_c);
+ if (next == NULL)
+ break;
+
+ if (next == start) {
+ /* replace with the 'to' */
+ Py_MEMCPY(result_s, to_s, to_len);
+ result_s += to_len;
+ start += 1;
+ } else {
+ /* copy the unchanged old then the 'to' */
+ Py_MEMCPY(result_s, start, next - start);
+ result_s += (next - start);
+ Py_MEMCPY(result_s, to_s, to_len);
+ result_s += to_len;
+ start = next + 1;
+ }
+ }
+ /* Copy the remainder of the remaining bytes */
+ Py_MEMCPY(result_s, start, end - start);
+
+ return result;
+}
+
+/* len(self)>=1, len(from)>=2, len(to)>=2, maxcount>=1 */
+Py_LOCAL(PyObject *)
+stringlib_replace_substring(PyObject *self,
+ const char *from_s, Py_ssize_t from_len,
+ const char *to_s, Py_ssize_t to_len,
+ Py_ssize_t maxcount)
+{
+ const char *self_s, *start, *next, *end;
+ char *result_s;
+ Py_ssize_t self_len, result_len;
+ Py_ssize_t count, offset;
+ PyObject *result;
+
+ self_s = STRINGLIB_STR(self);
+ self_len = STRINGLIB_LEN(self);
+
+ count = stringlib_count(self_s, self_len,
+ from_s, from_len,
+ maxcount);
+
+ if (count == 0) {
+ /* no matches, return unchanged */
+ return return_self(self);
+ }
+
+ /* Check for overflow */
+ /* result_len = self_len + count * (to_len-from_len) */
+ assert(count > 0);
+ if (to_len - from_len > (PY_SSIZE_T_MAX - self_len) / count) {
+ PyErr_SetString(PyExc_OverflowError, "replace bytes is too long");
+ return NULL;
+ }
+ result_len = self_len + count * (to_len - from_len);
+
+ result = STRINGLIB_NEW(NULL, result_len);
+ if (result == NULL) {
+ return NULL;
+ }
+ result_s = STRINGLIB_STR(result);
+
+ start = self_s;
+ end = self_s + self_len;
+ while (count-- > 0) {
+ offset = stringlib_find(start, end - start,
+ from_s, from_len,
+ 0);
+ if (offset == -1)
+ break;
+ next = start + offset;
+ if (next == start) {
+ /* replace with the 'to' */
+ Py_MEMCPY(result_s, to_s, to_len);
+ result_s += to_len;
+ start += from_len;
+ } else {
+ /* copy the unchanged old then the 'to' */
+ Py_MEMCPY(result_s, start, next - start);
+ result_s += (next - start);
+ Py_MEMCPY(result_s, to_s, to_len);
+ result_s += to_len;
+ start = next + from_len;
+ }
+ }
+ /* Copy the remainder of the remaining bytes */
+ Py_MEMCPY(result_s, start, end - start);
+
+ return result;
+}
+
+
+Py_LOCAL(PyObject *)
+stringlib_replace(PyObject *self,
+ const char *from_s, Py_ssize_t from_len,
+ const char *to_s, Py_ssize_t to_len,
+ Py_ssize_t maxcount)
+{
+ if (maxcount < 0) {
+ maxcount = PY_SSIZE_T_MAX;
+ } else if (maxcount == 0 || STRINGLIB_LEN(self) == 0) {
+ /* nothing to do; return the original bytes */
+ return return_self(self);
+ }
+
+ /* Handle zero-length special cases */
+ if (from_len == 0) {
+ if (to_len == 0) {
+ /* nothing to do; return the original bytes */
+ return return_self(self);
+ }
+ /* insert the 'to' bytes everywhere. */
+ /* >>> b"Python".replace(b"", b".") */
+ /* b'.P.y.t.h.o.n.' */
+ return stringlib_replace_interleave(self, to_s, to_len, maxcount);
+ }
+
+ /* Except for b"".replace(b"", b"A") == b"A" there is no way beyond this */
+ /* point for an empty self bytes to generate a non-empty bytes */
+ /* Special case so the remaining code always gets a non-empty bytes */
+ if (STRINGLIB_LEN(self) == 0) {
+ return return_self(self);
+ }
+
+ if (to_len == 0) {
+ /* delete all occurrences of 'from' bytes */
+ if (from_len == 1) {
+ return stringlib_replace_delete_single_character(
+ self, from_s[0], maxcount);
+ } else {
+ return stringlib_replace_delete_substring(
+ self, from_s, from_len, maxcount);
+ }
+ }
+
+ /* Handle special case where both bytes have the same length */
+
+ if (from_len == to_len) {
+ if (from_len == 1) {
+ return stringlib_replace_single_character_in_place(
+ self, from_s[0], to_s[0], maxcount);
+ } else {
+ return stringlib_replace_substring_in_place(
+ self, from_s, from_len, to_s, to_len, maxcount);
+ }
+ }
+
+ /* Otherwise use the more generic algorithms */
+ if (from_len == 1) {
+ return stringlib_replace_single_character(
+ self, from_s[0], to_s, to_len, maxcount);
+ } else {
+ /* len('from')>=2, len('to')>=1 */
+ return stringlib_replace_substring(
+ self, from_s, from_len, to_s, to_len, maxcount);
+ }
+}
+
+#undef findchar
diff --git a/Objects/stringlib/unicode_format.h b/Objects/stringlib/unicode_format.h
index be09b5f..14fa28e 100644
--- a/Objects/stringlib/unicode_format.h
+++ b/Objects/stringlib/unicode_format.h
@@ -67,7 +67,7 @@
return PyUnicode_Substring(str->str, str->start, str->end);
}
-/* return a new string. if str->str is NULL, return None */
+/* return a new string. if str->str is NULL, return a new empty string */
Py_LOCAL_INLINE(PyObject *)
SubString_new_object_or_empty(SubString *str)
{
diff --git a/Objects/structseq.c b/Objects/structseq.c
index 664344b..e315cba 100644
--- a/Objects/structseq.c
+++ b/Objects/structseq.c
@@ -4,9 +4,9 @@
#include "Python.h"
#include "structmember.h"
-static char visible_length_key[] = "n_sequence_fields";
-static char real_length_key[] = "n_fields";
-static char unnamed_fields_key[] = "n_unnamed_fields";
+static const char visible_length_key[] = "n_sequence_fields";
+static const char real_length_key[] = "n_fields";
+static const char unnamed_fields_key[] = "n_unnamed_fields";
/* Fields with this name have only a field index, not a field name.
They are only allowed for indices < n_visible_fields. */
@@ -16,14 +16,14 @@
_Py_IDENTIFIER(n_unnamed_fields);
#define VISIBLE_SIZE(op) Py_SIZE(op)
-#define VISIBLE_SIZE_TP(tp) PyLong_AsLong( \
+#define VISIBLE_SIZE_TP(tp) PyLong_AsSsize_t( \
_PyDict_GetItemId((tp)->tp_dict, &PyId_n_sequence_fields))
-#define REAL_SIZE_TP(tp) PyLong_AsLong( \
+#define REAL_SIZE_TP(tp) PyLong_AsSsize_t( \
_PyDict_GetItemId((tp)->tp_dict, &PyId_n_fields))
#define REAL_SIZE(op) REAL_SIZE_TP(Py_TYPE(op))
-#define UNNAMED_FIELDS_TP(tp) PyLong_AsLong( \
+#define UNNAMED_FIELDS_TP(tp) PyLong_AsSsize_t( \
_PyDict_GetItemId((tp)->tp_dict, &PyId_n_unnamed_fields))
#define UNNAMED_FIELDS(op) UNNAMED_FIELDS_TP(Py_TYPE(op))
@@ -164,7 +164,8 @@
#define TYPE_MAXSIZE 100
PyTypeObject *typ = Py_TYPE(obj);
- int i, removelast = 0;
+ Py_ssize_t i;
+ int removelast = 0;
Py_ssize_t len;
char buf[REPR_BUFFER_SIZE];
char *endofbuf, *pbuf = buf;
@@ -236,8 +237,7 @@
PyObject* tup = NULL;
PyObject* dict = NULL;
PyObject* result;
- Py_ssize_t n_fields, n_visible_fields, n_unnamed_fields;
- int i;
+ Py_ssize_t n_fields, n_visible_fields, n_unnamed_fields, i;
n_fields = REAL_SIZE(self);
n_visible_fields = VISIBLE_SIZE(self);
@@ -325,7 +325,7 @@
{
PyObject *dict;
PyMemberDef* members;
- int n_members, n_unnamed_members, i, k;
+ Py_ssize_t n_members, n_unnamed_members, i, k;
PyObject *v;
#ifdef Py_TRACE_REFS
@@ -373,9 +373,9 @@
Py_INCREF(type);
dict = type->tp_dict;
-#define SET_DICT_FROM_INT(key, value) \
+#define SET_DICT_FROM_SIZE(key, value) \
do { \
- v = PyLong_FromLong((long) value); \
+ v = PyLong_FromSsize_t(value); \
if (v == NULL) \
return -1; \
if (PyDict_SetItemString(dict, key, v) < 0) { \
@@ -385,9 +385,9 @@
Py_DECREF(v); \
} while (0)
- SET_DICT_FROM_INT(visible_length_key, desc->n_in_sequence);
- SET_DICT_FROM_INT(real_length_key, n_members);
- SET_DICT_FROM_INT(unnamed_fields_key, n_unnamed_members);
+ SET_DICT_FROM_SIZE(visible_length_key, desc->n_in_sequence);
+ SET_DICT_FROM_SIZE(real_length_key, n_members);
+ SET_DICT_FROM_SIZE(unnamed_fields_key, n_unnamed_members);
return 0;
}
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index 7920fec..a7774e2 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -149,7 +149,6 @@
int
PyTuple_SetItem(PyObject *op, Py_ssize_t i, PyObject *newitem)
{
- PyObject *olditem;
PyObject **p;
if (!PyTuple_Check(op) || op->ob_refcnt != 1) {
Py_XDECREF(newitem);
@@ -163,9 +162,7 @@
return -1;
}
p = ((PyTupleObject *)op) -> ob_item + i;
- olditem = *p;
- *p = newitem;
- Py_XDECREF(olditem);
+ Py_XSETREF(*p, newitem);
return 0;
}
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 317334f..d42054a 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -460,7 +460,7 @@
PyErr_Format(PyExc_AttributeError, "__module__");
return 0;
}
- Py_XINCREF(mod);
+ Py_INCREF(mod);
return mod;
}
else {
@@ -500,7 +500,7 @@
PyErr_SetObject(PyExc_AttributeError, message);
return NULL;
}
- Py_XINCREF(mod);
+ Py_INCREF(mod);
return mod;
}
@@ -548,7 +548,7 @@
static PyTypeObject *best_base(PyObject *);
static int mro_internal(PyTypeObject *, PyObject **);
Py_LOCAL_INLINE(int) type_is_subtype_base_chain(PyTypeObject *, PyTypeObject *);
-static int compatible_for_assignment(PyTypeObject *, PyTypeObject *, char *);
+static int compatible_for_assignment(PyTypeObject *, PyTypeObject *, const char *);
static int add_subclass(PyTypeObject*, PyTypeObject*);
static int add_all_subclasses(PyTypeObject *type, PyObject *bases);
static void remove_subclass(PyTypeObject *, PyTypeObject *);
@@ -859,9 +859,9 @@
}
if (mod != NULL && _PyUnicode_CompareWithId(mod, &PyId_builtins))
- rtn = PyUnicode_FromFormat("<class '%U.%U'>", mod, name);
- else
- rtn = PyUnicode_FromFormat("<class '%s'>", type->tp_name);
+ rtn = PyUnicode_FromFormat("<class '%U.%U' at %p>", mod, name, type);
+ else
+ rtn = PyUnicode_FromFormat("<class '%s' at %p>", type->tp_name, type);
Py_XDECREF(mod);
Py_DECREF(name);
@@ -888,25 +888,33 @@
#endif
obj = type->tp_new(type, args, kwds);
- if (obj != NULL) {
- /* Ugly exception: when the call was type(something),
- don't call tp_init on the result. */
- if (type == &PyType_Type &&
- PyTuple_Check(args) && PyTuple_GET_SIZE(args) == 1 &&
- (kwds == NULL ||
- (PyDict_Check(kwds) && PyDict_Size(kwds) == 0)))
- return obj;
- /* If the returned object is not an instance of type,
- it won't be initialized. */
- if (!PyType_IsSubtype(Py_TYPE(obj), type))
- return obj;
- type = Py_TYPE(obj);
- if (type->tp_init != NULL) {
- int res = type->tp_init(obj, args, kwds);
- if (res < 0) {
- Py_DECREF(obj);
- obj = NULL;
- }
+ obj = _Py_CheckFunctionResult((PyObject*)type, obj, NULL);
+ if (obj == NULL)
+ return NULL;
+
+ /* Ugly exception: when the call was type(something),
+ don't call tp_init on the result. */
+ if (type == &PyType_Type &&
+ PyTuple_Check(args) && PyTuple_GET_SIZE(args) == 1 &&
+ (kwds == NULL ||
+ (PyDict_Check(kwds) && PyDict_Size(kwds) == 0)))
+ return obj;
+
+ /* If the returned object is not an instance of type,
+ it won't be initialized. */
+ if (!PyType_IsSubtype(Py_TYPE(obj), type))
+ return obj;
+
+ type = Py_TYPE(obj);
+ if (type->tp_init != NULL) {
+ int res = type->tp_init(obj, args, kwds);
+ if (res < 0) {
+ assert(PyErr_Occurred());
+ Py_DECREF(obj);
+ obj = NULL;
+ }
+ else {
+ assert(!PyErr_Occurred());
}
}
return obj;
@@ -1411,7 +1419,7 @@
as lookup_method to cache the interned name string object. */
static PyObject *
-call_method(PyObject *o, _Py_Identifier *nameid, char *format, ...)
+call_method(PyObject *o, _Py_Identifier *nameid, const char *format, ...)
{
va_list va;
PyObject *args, *func = 0, *retval;
@@ -1447,7 +1455,7 @@
/* Clone of call_method() that returns NotImplemented when the lookup fails. */
static PyObject *
-call_maybe(PyObject *o, _Py_Identifier *nameid, char *format, ...)
+call_maybe(PyObject *o, _Py_Identifier *nameid, const char *format, ...)
{
va_list va;
PyObject *args, *func = 0, *retval;
@@ -1526,7 +1534,6 @@
PyObject *name = _PyObject_GetAttrId(cls, &PyId___name__);
if (name == NULL) {
PyErr_Clear();
- Py_XDECREF(name);
name = PyObject_Repr(cls);
}
if (name == NULL)
@@ -2084,7 +2091,7 @@
static int
subtype_setdict(PyObject *obj, PyObject *value, void *context)
{
- PyObject *dict, **dictptr;
+ PyObject **dictptr;
PyTypeObject *base;
base = get_builtin_base_with_dict(Py_TYPE(obj));
@@ -2115,10 +2122,8 @@
"not a '%.200s'", Py_TYPE(value)->tp_name);
return -1;
}
- dict = *dictptr;
Py_XINCREF(value);
- *dictptr = value;
- Py_XDECREF(dict);
+ Py_XSETREF(*dictptr, value);
return 0;
}
@@ -2673,7 +2678,7 @@
return NULL;
}
-static short slotoffsets[] = {
+static const short slotoffsets[] = {
-1, /* invalid slot */
#include "typeslots.inc"
};
@@ -3592,7 +3597,7 @@
}
static int
-compatible_for_assignment(PyTypeObject* oldto, PyTypeObject* newto, char* attr)
+compatible_for_assignment(PyTypeObject* oldto, PyTypeObject* newto, const char* attr)
{
PyTypeObject *newbase, *oldbase;
@@ -3868,6 +3873,24 @@
}
assert(slotnames == Py_None || PyList_Check(slotnames));
+ if (required) {
+ Py_ssize_t basicsize = PyBaseObject_Type.tp_basicsize;
+ if (obj->ob_type->tp_dictoffset)
+ basicsize += sizeof(PyObject *);
+ if (obj->ob_type->tp_weaklistoffset)
+ basicsize += sizeof(PyObject *);
+ if (slotnames != Py_None)
+ basicsize += sizeof(PyObject *) * Py_SIZE(slotnames);
+ if (obj->ob_type->tp_basicsize > basicsize) {
+ Py_DECREF(slotnames);
+ Py_DECREF(state);
+ PyErr_Format(PyExc_TypeError,
+ "can't pickle %.200s objects",
+ Py_TYPE(obj)->tp_name);
+ return NULL;
+ }
+ }
+
if (slotnames != Py_None && Py_SIZE(slotnames) > 0) {
PyObject *slots;
Py_ssize_t slotnames_size, i;
@@ -3922,7 +3945,7 @@
}
/* If we found some slot attributes, pack them in a tuple along
- the orginal attribute dictionary. */
+ the original attribute dictionary. */
if (PyDict_Size(slots) > 0) {
PyObject *state2;
@@ -4091,7 +4114,7 @@
}
static PyObject *
-reduce_newobj(PyObject *obj, int proto)
+reduce_newobj(PyObject *obj)
{
PyObject *args = NULL, *kwargs = NULL;
PyObject *copyreg;
@@ -4144,7 +4167,7 @@
}
Py_XDECREF(args);
}
- else if (proto >= 4) {
+ else {
_Py_IDENTIFIER(__newobj_ex__);
newobj = _PyObject_GetAttrId(copyreg, &PyId___newobj_ex__);
@@ -4162,16 +4185,6 @@
return NULL;
}
}
- else {
- PyErr_SetString(PyExc_ValueError,
- "must use protocol 4 or greater to copy this "
- "object; since __getnewargs_ex__ returned "
- "keyword arguments.");
- Py_DECREF(args);
- Py_DECREF(kwargs);
- Py_DECREF(copyreg);
- return NULL;
- }
state = _PyObject_GetState(obj,
!hasargs && !PyList_Check(obj) && !PyDict_Check(obj));
@@ -4217,7 +4230,7 @@
PyObject *copyreg, *res;
if (proto >= 2)
- return reduce_newobj(self, proto);
+ return reduce_newobj(self);
copyreg = import_copyreg();
if (!copyreg)
@@ -5344,7 +5357,7 @@
/* Helper to check for object.__setattr__ or __delattr__ applied to a type.
This is called the Carlo Verre hack after its discoverer. */
static int
-hackcheck(PyObject *self, setattrofunc func, char *what)
+hackcheck(PyObject *self, setattrofunc func, const char *what)
{
PyTypeObject *type = Py_TYPE(self);
while (type && type->tp_flags & Py_TPFLAGS_HEAPTYPE)
@@ -5764,8 +5777,8 @@
if (args != NULL) {
PyTuple_SET_ITEM(args, 0, ival);
retval = PyObject_Call(func, args, NULL);
- Py_XDECREF(args);
- Py_XDECREF(func);
+ Py_DECREF(args);
+ Py_DECREF(func);
return retval;
}
}
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 1fcc83e..db6a51c 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -42,6 +42,7 @@
#include "Python.h"
#include "ucnhash.h"
#include "bytes_methods.h"
+#include "stringlib/eq.h"
#ifdef MS_WINDOWS
#include <windows.h>
@@ -162,6 +163,14 @@
*_to++ = (to_type) *_iter++; \
} while (0)
+#ifdef MS_WINDOWS
+ /* On Windows, overallocate by 50% is the best factor */
+# define OVERALLOCATE_FACTOR 2
+#else
+ /* On Linux, overallocate by 25% is the best factor */
+# define OVERALLOCATE_FACTOR 4
+#endif
+
/* This dictionary holds all interned unicode strings. Note that references
to strings in this dictionary are *not* counted in the string's ob_refcnt.
When the interned string reaches a refcnt of 0 the string deallocation
@@ -263,7 +272,7 @@
const char *reason);
/* Same for linebreaks */
-static unsigned char ascii_linebreak[] = {
+static const unsigned char ascii_linebreak[] = {
0, 0, 0, 0, 0, 0, 0, 0,
/* 0x000A, * LINE FEED */
/* 0x000B, * LINE TABULATION */
@@ -292,6 +301,38 @@
#include "clinic/unicodeobject.c.h"
+typedef enum {
+ _Py_ERROR_UNKNOWN=0,
+ _Py_ERROR_STRICT,
+ _Py_ERROR_SURROGATEESCAPE,
+ _Py_ERROR_REPLACE,
+ _Py_ERROR_IGNORE,
+ _Py_ERROR_BACKSLASHREPLACE,
+ _Py_ERROR_SURROGATEPASS,
+ _Py_ERROR_XMLCHARREFREPLACE,
+ _Py_ERROR_OTHER
+} _Py_error_handler;
+
+static _Py_error_handler
+get_error_handler(const char *errors)
+{
+ if (errors == NULL || strcmp(errors, "strict") == 0)
+ return _Py_ERROR_STRICT;
+ if (strcmp(errors, "surrogateescape") == 0)
+ return _Py_ERROR_SURROGATEESCAPE;
+ if (strcmp(errors, "replace") == 0)
+ return _Py_ERROR_REPLACE;
+ if (strcmp(errors, "ignore") == 0)
+ return _Py_ERROR_IGNORE;
+ if (strcmp(errors, "backslashreplace") == 0)
+ return _Py_ERROR_BACKSLASHREPLACE;
+ if (strcmp(errors, "surrogatepass") == 0)
+ return _Py_ERROR_SURROGATEPASS;
+ if (strcmp(errors, "xmlcharrefreplace") == 0)
+ return _Py_ERROR_XMLCHARREFREPLACE;
+ return _Py_ERROR_OTHER;
+}
+
/* The max unicode value is always 0x10FFFF while using the PEP-393 API.
This function is kept for backward compatibility with the old API. */
Py_UNICODE
@@ -521,6 +562,129 @@
return _PyUnicode_Copy(unicode);
}
+/* Implementation of the "backslashreplace" error handler for 8-bit encodings:
+ ASCII, Latin1, UTF-8, etc. */
+static char*
+backslashreplace(_PyBytesWriter *writer, char *str,
+ PyObject *unicode, Py_ssize_t collstart, Py_ssize_t collend)
+{
+ Py_ssize_t size, i;
+ Py_UCS4 ch;
+ enum PyUnicode_Kind kind;
+ void *data;
+
+ assert(PyUnicode_IS_READY(unicode));
+ kind = PyUnicode_KIND(unicode);
+ data = PyUnicode_DATA(unicode);
+
+ size = 0;
+ /* determine replacement size */
+ for (i = collstart; i < collend; ++i) {
+ Py_ssize_t incr;
+
+ ch = PyUnicode_READ(kind, data, i);
+ if (ch < 0x100)
+ incr = 2+2;
+ else if (ch < 0x10000)
+ incr = 2+4;
+ else {
+ assert(ch <= MAX_UNICODE);
+ incr = 2+8;
+ }
+ if (size > PY_SSIZE_T_MAX - incr) {
+ PyErr_SetString(PyExc_OverflowError,
+ "encoded result is too long for a Python string");
+ return NULL;
+ }
+ size += incr;
+ }
+
+ str = _PyBytesWriter_Prepare(writer, str, size);
+ if (str == NULL)
+ return NULL;
+
+ /* generate replacement */
+ for (i = collstart; i < collend; ++i) {
+ ch = PyUnicode_READ(kind, data, i);
+ *str++ = '\\';
+ if (ch >= 0x00010000) {
+ *str++ = 'U';
+ *str++ = Py_hexdigits[(ch>>28)&0xf];
+ *str++ = Py_hexdigits[(ch>>24)&0xf];
+ *str++ = Py_hexdigits[(ch>>20)&0xf];
+ *str++ = Py_hexdigits[(ch>>16)&0xf];
+ *str++ = Py_hexdigits[(ch>>12)&0xf];
+ *str++ = Py_hexdigits[(ch>>8)&0xf];
+ }
+ else if (ch >= 0x100) {
+ *str++ = 'u';
+ *str++ = Py_hexdigits[(ch>>12)&0xf];
+ *str++ = Py_hexdigits[(ch>>8)&0xf];
+ }
+ else
+ *str++ = 'x';
+ *str++ = Py_hexdigits[(ch>>4)&0xf];
+ *str++ = Py_hexdigits[ch&0xf];
+ }
+ return str;
+}
+
+/* Implementation of the "xmlcharrefreplace" error handler for 8-bit encodings:
+ ASCII, Latin1, UTF-8, etc. */
+static char*
+xmlcharrefreplace(_PyBytesWriter *writer, char *str,
+ PyObject *unicode, Py_ssize_t collstart, Py_ssize_t collend)
+{
+ Py_ssize_t size, i;
+ Py_UCS4 ch;
+ enum PyUnicode_Kind kind;
+ void *data;
+
+ assert(PyUnicode_IS_READY(unicode));
+ kind = PyUnicode_KIND(unicode);
+ data = PyUnicode_DATA(unicode);
+
+ size = 0;
+ /* determine replacement size */
+ for (i = collstart; i < collend; ++i) {
+ Py_ssize_t incr;
+
+ ch = PyUnicode_READ(kind, data, i);
+ if (ch < 10)
+ incr = 2+1+1;
+ else if (ch < 100)
+ incr = 2+2+1;
+ else if (ch < 1000)
+ incr = 2+3+1;
+ else if (ch < 10000)
+ incr = 2+4+1;
+ else if (ch < 100000)
+ incr = 2+5+1;
+ else if (ch < 1000000)
+ incr = 2+6+1;
+ else {
+ assert(ch <= MAX_UNICODE);
+ incr = 2+7+1;
+ }
+ if (size > PY_SSIZE_T_MAX - incr) {
+ PyErr_SetString(PyExc_OverflowError,
+ "encoded result is too long for a Python string");
+ return NULL;
+ }
+ size += incr;
+ }
+
+ str = _PyBytesWriter_Prepare(writer, str, size);
+ if (str == NULL)
+ return NULL;
+
+ /* generate replacement */
+ for (i = collstart; i < collend; ++i) {
+ str += sprintf(str, "&#%d;", PyUnicode_READ(kind, data, i));
+ }
+ return str;
+}
+
/* --- Bloom Filters ----------------------------------------------------- */
/* stuff to implement simple "bloom filters" for Unicode characters.
@@ -587,6 +751,18 @@
#undef BLOOM_UPDATE
}
+static int
+ensure_unicode(PyObject *obj)
+{
+ if (!PyUnicode_Check(obj)) {
+ PyErr_Format(PyExc_TypeError,
+ "must be str, not %.100s",
+ Py_TYPE(obj)->tp_name);
+ return -1;
+ }
+ return PyUnicode_READY(obj);
+}
+
/* Compilation of templated routines */
#include "stringlib/asciilib.h"
@@ -647,27 +823,26 @@
Py_ssize_t size, Py_UCS4 ch,
int direction)
{
- int mode = (direction == 1) ? FAST_SEARCH : FAST_RSEARCH;
-
switch (kind) {
case PyUnicode_1BYTE_KIND:
- {
- Py_UCS1 ch1 = (Py_UCS1) ch;
- if (ch1 == ch)
- return ucs1lib_fastsearch((Py_UCS1 *) s, size, &ch1, 1, 0, mode);
- else
- return -1;
- }
+ if ((Py_UCS1) ch != ch)
+ return -1;
+ if (direction > 0)
+ return ucs1lib_find_char((Py_UCS1 *) s, size, (Py_UCS1) ch);
+ else
+ return ucs1lib_rfind_char((Py_UCS1 *) s, size, (Py_UCS1) ch);
case PyUnicode_2BYTE_KIND:
- {
- Py_UCS2 ch2 = (Py_UCS2) ch;
- if (ch2 == ch)
- return ucs2lib_fastsearch((Py_UCS2 *) s, size, &ch2, 1, 0, mode);
- else
- return -1;
- }
+ if ((Py_UCS2) ch != ch)
+ return -1;
+ if (direction > 0)
+ return ucs2lib_find_char((Py_UCS2 *) s, size, (Py_UCS2) ch);
+ else
+ return ucs2lib_rfind_char((Py_UCS2 *) s, size, (Py_UCS2) ch);
case PyUnicode_4BYTE_KIND:
- return ucs4lib_fastsearch((Py_UCS4 *) s, size, &ch, 1, 0, mode);
+ if (direction > 0)
+ return ucs4lib_find_char((Py_UCS4 *) s, size, ch);
+ else
+ return ucs4lib_rfind_char((Py_UCS4 *) s, size, ch);
default:
assert(0);
return -1;
@@ -2903,7 +3078,7 @@
/* Retrieve a bytes buffer view through the PEP 3118 buffer interface */
if (PyObject_GetBuffer(obj, &buffer, PyBUF_SIMPLE) < 0) {
PyErr_Format(PyExc_TypeError,
- "coercing to str: need a bytes-like object, %.80s found",
+ "decoding to str: need a bytes-like object, %.80s found",
Py_TYPE(obj)->tp_name);
return NULL;
}
@@ -3167,24 +3342,22 @@
static int
locale_error_handler(const char *errors, int *surrogateescape)
{
- if (errors == NULL) {
+ _Py_error_handler error_handler = get_error_handler(errors);
+ switch (error_handler)
+ {
+ case _Py_ERROR_STRICT:
*surrogateescape = 0;
return 0;
- }
-
- if (strcmp(errors, "strict") == 0) {
- *surrogateescape = 0;
- return 0;
- }
- if (strcmp(errors, "surrogateescape") == 0) {
+ case _Py_ERROR_SURROGATEESCAPE:
*surrogateescape = 1;
return 0;
+ default:
+ PyErr_Format(PyExc_ValueError,
+ "only 'strict' and 'surrogateescape' error handlers "
+ "are supported, not '%s'",
+ errors);
+ return -1;
}
- PyErr_Format(PyExc_ValueError,
- "only 'strict' and 'surrogateescape' error handlers "
- "are supported, not '%s'",
- errors);
- return -1;
}
PyObject *
@@ -3626,19 +3799,17 @@
output = arg;
Py_INCREF(output);
}
- else {
- arg = PyUnicode_FromObject(arg);
- if (!arg)
- return 0;
+ else if (PyUnicode_Check(arg)) {
output = PyUnicode_EncodeFSDefault(arg);
- Py_DECREF(arg);
if (!output)
return 0;
- if (!PyBytes_Check(output)) {
- Py_DECREF(output);
- PyErr_SetString(PyExc_TypeError, "encoder failed to return bytes");
- return 0;
- }
+ assert(PyBytes_Check(output));
+ }
+ else {
+ PyErr_Format(PyExc_TypeError,
+ "must be str or bytes, not %.100s",
+ Py_TYPE(arg)->tp_name);
+ return 0;
}
size = PyBytes_GET_SIZE(output);
data = PyBytes_AS_STRING(output);
@@ -3716,7 +3887,7 @@
if (PyUnicode_UTF8(unicode) == NULL) {
assert(!PyUnicode_IS_COMPACT_ASCII(unicode));
- bytes = _PyUnicode_AsUTF8String(unicode, "strict");
+ bytes = _PyUnicode_AsUTF8String(unicode, NULL);
if (bytes == NULL)
return NULL;
_PyUnicode_UTF8(unicode) = PyObject_MALLOC(PyBytes_GET_SIZE(bytes) + 1);
@@ -3982,7 +4153,7 @@
Py_ssize_t *endinpos, PyObject **exceptionObject, const char **inptr,
PyObject **output, Py_ssize_t *outpos)
{
- static char *argparse = "O!n;decoding error handler must return (str, int) tuple";
+ static const char *argparse = "O!n;decoding error handler must return (str, int) tuple";
PyObject *restuple = NULL;
PyObject *repunicode = NULL;
@@ -4090,7 +4261,7 @@
Py_ssize_t *endinpos, PyObject **exceptionObject, const char **inptr,
_PyUnicodeWriter *writer /* PyObject **output, Py_ssize_t *outpos */)
{
- static char *argparse = "O!n;decoding error handler must return (str, int) tuple";
+ static const char *argparse = "O!n;decoding error handler must return (str, int) tuple";
PyObject *restuple = NULL;
PyObject *repunicode = NULL;
@@ -4696,8 +4867,9 @@
Py_ssize_t startinpos;
Py_ssize_t endinpos;
const char *errmsg = "";
- PyObject *errorHandler = NULL;
+ PyObject *error_handler_obj = NULL;
PyObject *exc = NULL;
+ _Py_error_handler error_handler = _Py_ERROR_UNKNOWN;
if (size == 0) {
if (consumed)
@@ -4722,6 +4894,7 @@
while (s < end) {
Py_UCS4 ch;
int kind = writer.kind;
+
if (kind == PyUnicode_1BYTE_KIND) {
if (PyUnicode_IS_ASCII(writer.buffer))
ch = asciilib_utf8_decode(&s, end, writer.data, &writer.pos);
@@ -4760,24 +4933,56 @@
continue;
}
- if (unicode_decode_call_errorhandler_writer(
- errors, &errorHandler,
- "utf-8", errmsg,
- &starts, &end, &startinpos, &endinpos, &exc, &s,
- &writer))
- goto onError;
+ if (error_handler == _Py_ERROR_UNKNOWN)
+ error_handler = get_error_handler(errors);
+
+ switch (error_handler) {
+ case _Py_ERROR_IGNORE:
+ s += (endinpos - startinpos);
+ break;
+
+ case _Py_ERROR_REPLACE:
+ if (_PyUnicodeWriter_WriteCharInline(&writer, 0xfffd) < 0)
+ goto onError;
+ s += (endinpos - startinpos);
+ break;
+
+ case _Py_ERROR_SURROGATEESCAPE:
+ {
+ Py_ssize_t i;
+
+ if (_PyUnicodeWriter_PrepareKind(&writer, PyUnicode_2BYTE_KIND) < 0)
+ goto onError;
+ for (i=startinpos; i<endinpos; i++) {
+ ch = (Py_UCS4)(unsigned char)(starts[i]);
+ PyUnicode_WRITE(writer.kind, writer.data, writer.pos,
+ ch + 0xdc00);
+ writer.pos++;
+ }
+ s += (endinpos - startinpos);
+ break;
+ }
+
+ default:
+ if (unicode_decode_call_errorhandler_writer(
+ errors, &error_handler_obj,
+ "utf-8", errmsg,
+ &starts, &end, &startinpos, &endinpos, &exc, &s,
+ &writer))
+ goto onError;
+ }
}
End:
if (consumed)
*consumed = s - starts;
- Py_XDECREF(errorHandler);
+ Py_XDECREF(error_handler_obj);
Py_XDECREF(exc);
return _PyUnicodeWriter_Finish(&writer);
onError:
- Py_XDECREF(errorHandler);
+ Py_XDECREF(error_handler_obj);
Py_XDECREF(exc);
_PyUnicodeWriter_Dealloc(&writer);
return NULL;
@@ -5868,11 +6073,10 @@
PyUnicode_AsUnicodeEscapeString(PyObject *unicode)
{
Py_ssize_t i, len;
- PyObject *repr;
char *p;
int kind;
void *data;
- Py_ssize_t expandsize = 0;
+ _PyBytesWriter writer;
/* Initial allocation is based on the longest-possible character
escape.
@@ -5888,35 +6092,28 @@
}
if (PyUnicode_READY(unicode) == -1)
return NULL;
+
+ _PyBytesWriter_Init(&writer);
+
len = PyUnicode_GET_LENGTH(unicode);
kind = PyUnicode_KIND(unicode);
data = PyUnicode_DATA(unicode);
- switch (kind) {
- case PyUnicode_1BYTE_KIND: expandsize = 4; break;
- case PyUnicode_2BYTE_KIND: expandsize = 6; break;
- case PyUnicode_4BYTE_KIND: expandsize = 10; break;
- }
- if (len == 0)
- return PyBytes_FromStringAndSize(NULL, 0);
-
- if (len > (PY_SSIZE_T_MAX - 2 - 1) / expandsize)
- return PyErr_NoMemory();
-
- repr = PyBytes_FromStringAndSize(NULL,
- 2
- + expandsize*len
- + 1);
- if (repr == NULL)
- return NULL;
-
- p = PyBytes_AS_STRING(repr);
+ p = _PyBytesWriter_Alloc(&writer, len);
+ if (p == NULL)
+ goto error;
+ writer.overallocate = 1;
for (i = 0; i < len; i++) {
Py_UCS4 ch = PyUnicode_READ(kind, data, i);
/* Escape backslashes */
if (ch == '\\') {
+ /* -1: substract 1 preallocated byte */
+ p = _PyBytesWriter_Prepare(&writer, p, 2-1);
+ if (p == NULL)
+ goto error;
+
*p++ = '\\';
*p++ = (char) ch;
continue;
@@ -5925,6 +6122,11 @@
/* Map 21-bit characters to '\U00xxxxxx' */
else if (ch >= 0x10000) {
assert(ch <= MAX_UNICODE);
+
+ p = _PyBytesWriter_Prepare(&writer, p, 10-1);
+ if (p == NULL)
+ goto error;
+
*p++ = '\\';
*p++ = 'U';
*p++ = Py_hexdigits[(ch >> 28) & 0x0000000F];
@@ -5940,6 +6142,10 @@
/* Map 16-bit characters to '\uxxxx' */
if (ch >= 256) {
+ p = _PyBytesWriter_Prepare(&writer, p, 6-1);
+ if (p == NULL)
+ goto error;
+
*p++ = '\\';
*p++ = 'u';
*p++ = Py_hexdigits[(ch >> 12) & 0x000F];
@@ -5950,20 +6156,37 @@
/* Map special whitespace to '\t', \n', '\r' */
else if (ch == '\t') {
+ p = _PyBytesWriter_Prepare(&writer, p, 2-1);
+ if (p == NULL)
+ goto error;
+
*p++ = '\\';
*p++ = 't';
}
else if (ch == '\n') {
+ p = _PyBytesWriter_Prepare(&writer, p, 2-1);
+ if (p == NULL)
+ goto error;
+
*p++ = '\\';
*p++ = 'n';
}
else if (ch == '\r') {
+ p = _PyBytesWriter_Prepare(&writer, p, 2-1);
+ if (p == NULL)
+ goto error;
+
*p++ = '\\';
*p++ = 'r';
}
/* Map non-printable US ASCII to '\xhh' */
else if (ch < ' ' || ch >= 0x7F) {
+ /* -1: substract 1 preallocated byte */
+ p = _PyBytesWriter_Prepare(&writer, p, 4-1);
+ if (p == NULL)
+ goto error;
+
*p++ = '\\';
*p++ = 'x';
*p++ = Py_hexdigits[(ch >> 4) & 0x000F];
@@ -5975,10 +6198,11 @@
*p++ = (char) ch;
}
- assert(p - PyBytes_AS_STRING(repr) > 0);
- if (_PyBytes_Resize(&repr, p - PyBytes_AS_STRING(repr)) < 0)
- return NULL;
- return repr;
+ return _PyBytesWriter_Finish(&writer, p);
+
+error:
+ _PyBytesWriter_Dealloc(&writer);
+ return NULL;
}
PyObject *
@@ -6107,13 +6331,12 @@
PyObject *
PyUnicode_AsRawUnicodeEscapeString(PyObject *unicode)
{
- PyObject *repr;
char *p;
- char *q;
- Py_ssize_t expandsize, pos;
+ Py_ssize_t pos;
int kind;
void *data;
Py_ssize_t len;
+ _PyBytesWriter writer;
if (!PyUnicode_Check(unicode)) {
PyErr_BadArgument();
@@ -6121,28 +6344,29 @@
}
if (PyUnicode_READY(unicode) == -1)
return NULL;
+
+ _PyBytesWriter_Init(&writer);
+
kind = PyUnicode_KIND(unicode);
data = PyUnicode_DATA(unicode);
len = PyUnicode_GET_LENGTH(unicode);
- /* 4 byte characters can take up 10 bytes, 2 byte characters can take up 6
- bytes, and 1 byte characters 4. */
- expandsize = kind * 2 + 2;
- if (len > PY_SSIZE_T_MAX / expandsize)
- return PyErr_NoMemory();
+ p = _PyBytesWriter_Alloc(&writer, len);
+ if (p == NULL)
+ goto error;
+ writer.overallocate = 1;
- repr = PyBytes_FromStringAndSize(NULL, expandsize * len);
- if (repr == NULL)
- return NULL;
- if (len == 0)
- return repr;
-
- p = q = PyBytes_AS_STRING(repr);
for (pos = 0; pos < len; pos++) {
Py_UCS4 ch = PyUnicode_READ(kind, data, pos);
/* Map 32-bit characters to '\Uxxxxxxxx' */
if (ch >= 0x10000) {
assert(ch <= MAX_UNICODE);
+
+ /* -1: substract 1 preallocated byte */
+ p = _PyBytesWriter_Prepare(&writer, p, 10-1);
+ if (p == NULL)
+ goto error;
+
*p++ = '\\';
*p++ = 'U';
*p++ = Py_hexdigits[(ch >> 28) & 0xf];
@@ -6156,6 +6380,11 @@
}
/* Map 16-bit characters to '\uxxxx' */
else if (ch >= 256) {
+ /* -1: substract 1 preallocated byte */
+ p = _PyBytesWriter_Prepare(&writer, p, 6-1);
+ if (p == NULL)
+ goto error;
+
*p++ = '\\';
*p++ = 'u';
*p++ = Py_hexdigits[(ch >> 12) & 0xf];
@@ -6168,10 +6397,11 @@
*p++ = (char) ch;
}
- assert(p > q);
- if (_PyBytes_Resize(&repr, p - q) < 0)
- return NULL;
- return repr;
+ return _PyBytesWriter_Finish(&writer, p);
+
+error:
+ _PyBytesWriter_Dealloc(&writer);
+ return NULL;
}
PyObject *
@@ -6348,7 +6578,7 @@
Py_ssize_t startpos, Py_ssize_t endpos,
Py_ssize_t *newpos)
{
- static char *argparse = "On;encoding error handler must return (str/bytes, int) tuple";
+ static const char *argparse = "On;encoding error handler must return (str/bytes, int) tuple";
Py_ssize_t len;
PyObject *restuple;
PyObject *resunicode;
@@ -6402,25 +6632,22 @@
static PyObject *
unicode_encode_ucs1(PyObject *unicode,
const char *errors,
- unsigned int limit)
+ const Py_UCS4 limit)
{
/* input state */
Py_ssize_t pos=0, size;
int kind;
void *data;
- /* output object */
- PyObject *res;
/* pointer into the output */
char *str;
- /* current output position */
- Py_ssize_t ressize;
const char *encoding = (limit == 256) ? "latin-1" : "ascii";
const char *reason = (limit == 256) ? "ordinal not in range(256)" : "ordinal not in range(128)";
- PyObject *errorHandler = NULL;
+ PyObject *error_handler_obj = NULL;
PyObject *exc = NULL;
- /* 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;
+ _Py_error_handler error_handler = _Py_ERROR_UNKNOWN;
+ PyObject *rep = NULL;
+ /* output object */
+ _PyBytesWriter writer;
if (PyUnicode_READY(unicode) == -1)
return NULL;
@@ -6431,186 +6658,157 @@
replacements, if we need more, we'll resize */
if (size == 0)
return PyBytes_FromStringAndSize(NULL, 0);
- res = PyBytes_FromStringAndSize(NULL, size);
- if (res == NULL)
+
+ _PyBytesWriter_Init(&writer);
+ str = _PyBytesWriter_Alloc(&writer, size);
+ if (str == NULL)
return NULL;
- str = PyBytes_AS_STRING(res);
- ressize = size;
while (pos < size) {
- Py_UCS4 c = PyUnicode_READ(kind, data, pos);
+ Py_UCS4 ch = PyUnicode_READ(kind, data, pos);
/* can we encode this? */
- if (c<limit) {
+ if (ch < limit) {
/* no overflow check, because we know that the space is enough */
- *str++ = (char)c;
+ *str++ = (char)ch;
++pos;
}
else {
- Py_ssize_t requiredsize;
- PyObject *repunicode;
- Py_ssize_t repsize, newpos, respos, i;
+ Py_ssize_t newpos, i;
/* startpos for collecting unencodable chars */
Py_ssize_t collstart = pos;
- Py_ssize_t collend = pos;
+ Py_ssize_t collend = collstart + 1;
/* find all unecodable characters */
+
while ((collend < size) && (PyUnicode_READ(kind, data, collend) >= limit))
++collend;
+
+ /* Only overallocate the buffer if it's not the last write */
+ writer.overallocate = (collend < size);
+
/* 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 */
+ if (error_handler == _Py_ERROR_UNKNOWN)
+ error_handler = get_error_handler(errors);
+
+ switch (error_handler) {
+ case _Py_ERROR_STRICT:
raise_encode_exception(&exc, encoding, unicode, collstart, collend, reason);
goto onError;
- case 2: /* replace */
- while (collstart++ < collend)
- *str++ = '?'; /* fall through */
- case 3: /* ignore */
+
+ case _Py_ERROR_REPLACE:
+ memset(str, '?', collend - collstart);
+ str += (collend - collstart);
+ /* fall through ignore error handler */
+ case _Py_ERROR_IGNORE:
pos = collend;
break;
- case 4: /* xmlcharrefreplace */
- respos = str - PyBytes_AS_STRING(res);
- requiredsize = respos;
- /* determine replacement size */
- for (i = collstart; i < collend; ++i) {
- Py_UCS4 ch = PyUnicode_READ(kind, data, i);
- Py_ssize_t incr;
- if (ch < 10)
- incr = 2+1+1;
- else if (ch < 100)
- incr = 2+2+1;
- else if (ch < 1000)
- incr = 2+3+1;
- else if (ch < 10000)
- incr = 2+4+1;
- else if (ch < 100000)
- incr = 2+5+1;
- else if (ch < 1000000)
- incr = 2+6+1;
- else {
- assert(ch <= MAX_UNICODE);
- incr = 2+7+1;
- }
- if (requiredsize > PY_SSIZE_T_MAX - incr)
- goto overflow;
- requiredsize += incr;
- }
- if (requiredsize > PY_SSIZE_T_MAX - (size - collend))
- goto overflow;
- requiredsize += size - collend;
- if (requiredsize > ressize) {
- if (ressize <= PY_SSIZE_T_MAX/2 && requiredsize < 2*ressize)
- requiredsize = 2*ressize;
- if (_PyBytes_Resize(&res, requiredsize))
- goto onError;
- str = PyBytes_AS_STRING(res) + respos;
- ressize = requiredsize;
- }
- /* generate replacement */
- for (i = collstart; i < collend; ++i) {
- str += sprintf(str, "&#%d;", PyUnicode_READ(kind, data, i));
- }
- pos = collend;
- break;
- default:
- repunicode = unicode_encode_call_errorhandler(errors, &errorHandler,
- encoding, reason, unicode, &exc,
- collstart, collend, &newpos);
- if (repunicode == NULL || (PyUnicode_Check(repunicode) &&
- PyUnicode_READY(repunicode) == -1))
+
+ case _Py_ERROR_BACKSLASHREPLACE:
+ /* substract preallocated bytes */
+ writer.min_size -= (collend - collstart);
+ str = backslashreplace(&writer, str,
+ unicode, collstart, collend);
+ if (str == NULL)
goto onError;
- if (PyBytes_Check(repunicode)) {
- /* Directly copy bytes result to output. */
- repsize = PyBytes_Size(repunicode);
- if (repsize > 1) {
- /* Make room for all additional bytes. */
- respos = str - PyBytes_AS_STRING(res);
- if (ressize > PY_SSIZE_T_MAX - repsize - 1) {
- Py_DECREF(repunicode);
- goto overflow;
- }
- if (_PyBytes_Resize(&res, ressize+repsize-1)) {
- Py_DECREF(repunicode);
- goto onError;
- }
- str = PyBytes_AS_STRING(res) + respos;
- ressize += repsize-1;
+ pos = collend;
+ break;
+
+ case _Py_ERROR_XMLCHARREFREPLACE:
+ /* substract preallocated bytes */
+ writer.min_size -= (collend - collstart);
+ str = xmlcharrefreplace(&writer, str,
+ unicode, collstart, collend);
+ if (str == NULL)
+ goto onError;
+ pos = collend;
+ break;
+
+ case _Py_ERROR_SURROGATEESCAPE:
+ for (i = collstart; i < collend; ++i) {
+ ch = PyUnicode_READ(kind, data, i);
+ if (ch < 0xdc80 || 0xdcff < ch) {
+ /* Not a UTF-8b surrogate */
+ break;
}
- memcpy(str, PyBytes_AsString(repunicode), repsize);
- str += repsize;
- pos = newpos;
- Py_DECREF(repunicode);
+ *str++ = (char)(ch - 0xdc00);
+ ++pos;
+ }
+ if (i >= collend)
break;
- }
- /* need more space? (at least enough for what we
- have+the replacement+the rest of the string, so
- we won't have to check space for encodable characters) */
- respos = str - PyBytes_AS_STRING(res);
- repsize = PyUnicode_GET_LENGTH(repunicode);
- requiredsize = respos;
- if (requiredsize > PY_SSIZE_T_MAX - repsize)
- goto overflow;
- requiredsize += repsize;
- if (requiredsize > PY_SSIZE_T_MAX - (size - collend))
- goto overflow;
- requiredsize += size - collend;
- if (requiredsize > ressize) {
- if (ressize <= PY_SSIZE_T_MAX/2 && requiredsize < 2*ressize)
- requiredsize = 2*ressize;
- if (_PyBytes_Resize(&res, requiredsize)) {
- Py_DECREF(repunicode);
+ collstart = pos;
+ assert(collstart != collend);
+ /* fallback to general error handling */
+
+ default:
+ rep = unicode_encode_call_errorhandler(errors, &error_handler_obj,
+ encoding, reason, unicode, &exc,
+ collstart, collend, &newpos);
+ if (rep == NULL)
+ goto onError;
+
+ /* substract preallocated bytes */
+ writer.min_size -= 1;
+
+ if (PyBytes_Check(rep)) {
+ /* Directly copy bytes result to output. */
+ str = _PyBytesWriter_WriteBytes(&writer, str,
+ PyBytes_AS_STRING(rep),
+ PyBytes_GET_SIZE(rep));
+ if (str == NULL)
goto onError;
- }
- str = PyBytes_AS_STRING(res) + respos;
- ressize = requiredsize;
}
- /* check if there is anything unencodable in the replacement
- and copy it to the output */
- for (i = 0; repsize-->0; ++i, ++str) {
- c = PyUnicode_READ_CHAR(repunicode, i);
- if (c >= limit) {
- raise_encode_exception(&exc, encoding, unicode,
- pos, pos+1, reason);
- Py_DECREF(repunicode);
+ else {
+ assert(PyUnicode_Check(rep));
+
+ if (PyUnicode_READY(rep) < 0)
goto onError;
+
+ if (PyUnicode_IS_ASCII(rep)) {
+ /* Fast path: all characters are smaller than limit */
+ assert(limit >= 128);
+ assert(PyUnicode_KIND(rep) == PyUnicode_1BYTE_KIND);
+ str = _PyBytesWriter_WriteBytes(&writer, str,
+ PyUnicode_DATA(rep),
+ PyUnicode_GET_LENGTH(rep));
}
- *str = (char)c;
+ else {
+ Py_ssize_t repsize = PyUnicode_GET_LENGTH(rep);
+
+ str = _PyBytesWriter_Prepare(&writer, str, repsize);
+ if (str == NULL)
+ goto onError;
+
+ /* check if there is anything unencodable in the
+ replacement and copy it to the output */
+ for (i = 0; repsize-->0; ++i, ++str) {
+ ch = PyUnicode_READ_CHAR(rep, i);
+ if (ch >= limit) {
+ raise_encode_exception(&exc, encoding, unicode,
+ pos, pos+1, reason);
+ goto onError;
+ }
+ *str = (char)ch;
+ }
+ }
}
pos = newpos;
- Py_DECREF(repunicode);
+ Py_CLEAR(rep);
}
+
+ /* If overallocation was disabled, ensure that it was the last
+ write. Otherwise, we missed an optimization */
+ assert(writer.overallocate || pos == size);
}
}
- /* Resize if we allocated to much */
- size = str - PyBytes_AS_STRING(res);
- if (size < ressize) { /* If this falls res will be NULL */
- assert(size >= 0);
- if (_PyBytes_Resize(&res, size) < 0)
- goto onError;
- }
- Py_XDECREF(errorHandler);
+ Py_XDECREF(error_handler_obj);
Py_XDECREF(exc);
- return res;
-
- overflow:
- PyErr_SetString(PyExc_OverflowError,
- "encoded result is too long for a Python string");
+ return _PyBytesWriter_Finish(&writer, str);
onError:
- Py_XDECREF(res);
- Py_XDECREF(errorHandler);
+ Py_XDECREF(rep);
+ _PyBytesWriter_Dealloc(&writer);
+ Py_XDECREF(error_handler_obj);
Py_XDECREF(exc);
return NULL;
}
@@ -6670,8 +6868,9 @@
Py_ssize_t endinpos;
Py_ssize_t outpos;
const char *e;
- PyObject *errorHandler = NULL;
+ PyObject *error_handler_obj = NULL;
PyObject *exc = NULL;
+ _Py_error_handler error_handler = _Py_ERROR_UNKNOWN;
if (size == 0)
_Py_RETURN_UNICODE_EMPTY();
@@ -6700,12 +6899,42 @@
PyUnicode_WRITE(kind, data, writer.pos, c);
writer.pos++;
++s;
+ continue;
}
- else {
+
+ /* byte outsize range 0x00..0x7f: call the error handler */
+
+ if (error_handler == _Py_ERROR_UNKNOWN)
+ error_handler = get_error_handler(errors);
+
+ switch (error_handler)
+ {
+ case _Py_ERROR_REPLACE:
+ case _Py_ERROR_SURROGATEESCAPE:
+ /* Fast-path: the error handler only writes one character,
+ but we may switch to UCS2 at the first write */
+ if (_PyUnicodeWriter_PrepareKind(&writer, PyUnicode_2BYTE_KIND) < 0)
+ goto onError;
+ kind = writer.kind;
+ data = writer.data;
+
+ if (error_handler == _Py_ERROR_REPLACE)
+ PyUnicode_WRITE(kind, data, writer.pos, 0xfffd);
+ else
+ PyUnicode_WRITE(kind, data, writer.pos, c + 0xdc00);
+ writer.pos++;
+ ++s;
+ break;
+
+ case _Py_ERROR_IGNORE:
+ ++s;
+ break;
+
+ default:
startinpos = s-starts;
endinpos = startinpos + 1;
if (unicode_decode_call_errorhandler_writer(
- errors, &errorHandler,
+ errors, &error_handler_obj,
"ascii", "ordinal not in range(128)",
&starts, &e, &startinpos, &endinpos, &exc, &s,
&writer))
@@ -6714,13 +6943,13 @@
data = writer.data;
}
}
- Py_XDECREF(errorHandler);
+ Py_XDECREF(error_handler_obj);
Py_XDECREF(exc);
return _PyUnicodeWriter_Finish(&writer);
onError:
_PyUnicodeWriter_Dealloc(&writer);
- Py_XDECREF(errorHandler);
+ Py_XDECREF(error_handler_obj);
Py_XDECREF(exc);
return NULL;
}
@@ -6775,7 +7004,7 @@
# define WC_ERR_INVALID_CHARS 0x0080
#endif
-static char*
+static const char*
code_page_name(UINT code_page, PyObject **obj)
{
*obj = NULL;
@@ -6883,7 +7112,7 @@
PyObject *errorHandler = NULL;
PyObject *exc = NULL;
PyObject *encoding_obj = NULL;
- char *encoding;
+ const char *encoding;
DWORD err;
int ret = -1;
@@ -7119,7 +7348,6 @@
BOOL usedDefaultChar = FALSE;
BOOL *pusedDefaultChar = &usedDefaultChar;
int outsize;
- PyObject *exc = NULL;
wchar_t *p;
Py_ssize_t size;
const DWORD flags = encode_code_page_flags(code_page, NULL);
@@ -7228,7 +7456,7 @@
PyObject *errorHandler = NULL;
PyObject *exc = NULL;
PyObject *encoding_obj = NULL;
- char *encoding;
+ const char *encoding;
Py_ssize_t newpos, newoutsize;
PyObject *rep;
int ret = -1;
@@ -8086,7 +8314,7 @@
charmap_encoding_error(
PyObject *unicode, Py_ssize_t *inpos, PyObject *mapping,
PyObject **exceptionObject,
- int *known_errorHandler, PyObject **errorHandler, const char *errors,
+ _Py_error_handler *error_handler, PyObject **error_handler_obj, const char *errors,
PyObject **res, Py_ssize_t *respos)
{
PyObject *repunicode = NULL; /* initialize to prevent gcc warning */
@@ -8133,23 +8361,15 @@
}
/* 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 */
+ if (*error_handler == _Py_ERROR_UNKNOWN)
+ *error_handler = get_error_handler(errors);
+
+ switch (*error_handler) {
+ case _Py_ERROR_STRICT:
raise_encode_exception(exceptionObject, encoding, unicode, collstartpos, collendpos, reason);
return -1;
- case 2: /* replace */
+
+ case _Py_ERROR_REPLACE:
for (collpos = collstartpos; collpos<collendpos; ++collpos) {
x = charmapencode_output('?', mapping, res, respos);
if (x==enc_EXCEPTION) {
@@ -8161,10 +8381,11 @@
}
}
/* fall through */
- case 3: /* ignore */
+ case _Py_ERROR_IGNORE:
*inpos = collendpos;
break;
- case 4: /* xmlcharrefreplace */
+
+ case _Py_ERROR_XMLCHARREFREPLACE:
/* generate replacement (temporarily (mis)uses p) */
for (collpos = collstartpos; collpos < collendpos; ++collpos) {
char buffer[2+29+1+1];
@@ -8182,8 +8403,9 @@
}
*inpos = collendpos;
break;
+
default:
- repunicode = unicode_encode_call_errorhandler(errors, errorHandler,
+ repunicode = unicode_encode_call_errorhandler(errors, error_handler_obj,
encoding, reason, unicode, exceptionObject,
collstartpos, collendpos, &newpos);
if (repunicode == NULL)
@@ -8246,12 +8468,9 @@
Py_ssize_t size;
/* current output position */
Py_ssize_t respos = 0;
- PyObject *errorHandler = NULL;
+ PyObject *error_handler_obj = NULL;
PyObject *exc = NULL;
- /* 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;
+ _Py_error_handler error_handler = _Py_ERROR_UNKNOWN;
void *data;
int kind;
@@ -8282,7 +8501,7 @@
if (x==enc_FAILED) { /* unencodable character */
if (charmap_encoding_error(unicode, &inpos, mapping,
&exc,
- &known_errorHandler, &errorHandler, errors,
+ &error_handler, &error_handler_obj, errors,
&res, &respos)) {
goto onError;
}
@@ -8298,13 +8517,13 @@
goto onError;
Py_XDECREF(exc);
- Py_XDECREF(errorHandler);
+ Py_XDECREF(error_handler_obj);
return res;
onError:
Py_XDECREF(res);
Py_XDECREF(exc);
- Py_XDECREF(errorHandler);
+ Py_XDECREF(error_handler_obj);
return NULL;
}
@@ -8371,7 +8590,7 @@
Py_ssize_t startpos, Py_ssize_t endpos,
Py_ssize_t *newpos)
{
- static char *argparse = "O!n;translating error handler must return (str, int) tuple";
+ static const char *argparse = "O!n;translating error handler must return (str, int) tuple";
Py_ssize_t i_newpos;
PyObject *restuple;
@@ -8628,7 +8847,7 @@
return res;
}
-PyObject *
+static PyObject *
_PyUnicode_TranslateCharmap(PyObject *input,
PyObject *mapping,
const char *errors)
@@ -8657,10 +8876,8 @@
kind = PyUnicode_KIND(input);
size = PyUnicode_GET_LENGTH(input);
- if (size == 0) {
- Py_INCREF(input);
- return input;
- }
+ if (size == 0)
+ return PyUnicode_FromObject(input);
/* allocate enough for a simple 1:1 translation without
replacements, if we need more, we'll resize */
@@ -8771,14 +8988,9 @@
PyObject *mapping,
const char *errors)
{
- PyObject *result;
-
- str = PyUnicode_FromObject(str);
- if (str == NULL)
+ if (ensure_unicode(str) < 0)
return NULL;
- result = _PyUnicode_TranslateCharmap(str, mapping, errors);
- Py_DECREF(str);
- return result;
+ return _PyUnicode_TranslateCharmap(str, mapping, errors);
}
static Py_UCS4
@@ -8960,9 +9172,10 @@
}
static Py_ssize_t
-any_find_slice(int direction, PyObject* s1, PyObject* s2,
+any_find_slice(PyObject* s1, PyObject* s2,
Py_ssize_t start,
- Py_ssize_t end)
+ Py_ssize_t end,
+ int direction)
{
int kind1, kind2;
void *buf1, *buf2;
@@ -9131,54 +9344,35 @@
Py_ssize_t end)
{
Py_ssize_t result;
- PyObject* str_obj;
- PyObject* sub_obj;
int kind1, kind2;
void *buf1 = NULL, *buf2 = NULL;
Py_ssize_t len1, len2;
- str_obj = PyUnicode_FromObject(str);
- if (!str_obj)
+ if (ensure_unicode(str) < 0 || ensure_unicode(substr) < 0)
return -1;
- sub_obj = PyUnicode_FromObject(substr);
- if (!sub_obj) {
- Py_DECREF(str_obj);
- return -1;
- }
- if (PyUnicode_READY(sub_obj) == -1 || PyUnicode_READY(str_obj) == -1) {
- Py_DECREF(sub_obj);
- Py_DECREF(str_obj);
- return -1;
- }
- kind1 = PyUnicode_KIND(str_obj);
- kind2 = PyUnicode_KIND(sub_obj);
- if (kind1 < kind2) {
- Py_DECREF(sub_obj);
- Py_DECREF(str_obj);
+ kind1 = PyUnicode_KIND(str);
+ kind2 = PyUnicode_KIND(substr);
+ if (kind1 < kind2)
return 0;
- }
- len1 = PyUnicode_GET_LENGTH(str_obj);
- len2 = PyUnicode_GET_LENGTH(sub_obj);
+ len1 = PyUnicode_GET_LENGTH(str);
+ len2 = PyUnicode_GET_LENGTH(substr);
ADJUST_INDICES(start, end, len1);
- if (end - start < len2) {
- Py_DECREF(sub_obj);
- Py_DECREF(str_obj);
+ if (end - start < len2)
return 0;
- }
- buf1 = PyUnicode_DATA(str_obj);
- buf2 = PyUnicode_DATA(sub_obj);
+ buf1 = PyUnicode_DATA(str);
+ buf2 = PyUnicode_DATA(substr);
if (kind2 != kind1) {
- buf2 = _PyUnicode_AsKind(sub_obj, kind1);
+ buf2 = _PyUnicode_AsKind(substr, kind1);
if (!buf2)
goto onError;
}
switch (kind1) {
case PyUnicode_1BYTE_KIND:
- if (PyUnicode_IS_ASCII(str_obj) && PyUnicode_IS_ASCII(sub_obj))
+ if (PyUnicode_IS_ASCII(str) && PyUnicode_IS_ASCII(substr))
result = asciilib_count(
((Py_UCS1*)buf1) + start, end - start,
buf2, len2, PY_SSIZE_T_MAX
@@ -9205,16 +9399,11 @@
assert(0); result = 0;
}
- Py_DECREF(sub_obj);
- Py_DECREF(str_obj);
-
if (kind2 != kind1)
PyMem_Free(buf2);
return result;
onError:
- Py_DECREF(sub_obj);
- Py_DECREF(str_obj);
if (kind2 != kind1 && buf2)
PyMem_Free(buf2);
return -1;
@@ -9222,35 +9411,15 @@
Py_ssize_t
PyUnicode_Find(PyObject *str,
- PyObject *sub,
+ PyObject *substr,
Py_ssize_t start,
Py_ssize_t end,
int direction)
{
- Py_ssize_t result;
-
- str = PyUnicode_FromObject(str);
- if (!str)
+ if (ensure_unicode(str) < 0 || ensure_unicode(substr) < 0)
return -2;
- sub = PyUnicode_FromObject(sub);
- if (!sub) {
- Py_DECREF(str);
- return -2;
- }
- if (PyUnicode_READY(sub) == -1 || PyUnicode_READY(str) == -1) {
- Py_DECREF(sub);
- Py_DECREF(str);
- return -2;
- }
- result = any_find_slice(direction,
- str, sub, start, end
- );
-
- Py_DECREF(str);
- Py_DECREF(sub);
-
- return result;
+ return any_find_slice(str, substr, start, end, direction);
}
Py_ssize_t
@@ -9353,22 +9522,10 @@
Py_ssize_t end,
int direction)
{
- Py_ssize_t result;
-
- str = PyUnicode_FromObject(str);
- if (str == NULL)
+ if (ensure_unicode(str) < 0 || ensure_unicode(substr) < 0)
return -1;
- substr = PyUnicode_FromObject(substr);
- if (substr == NULL) {
- Py_DECREF(str);
- return -1;
- }
- result = tailmatch(str, substr,
- start, end, direction);
- Py_DECREF(str);
- Py_DECREF(substr);
- return result;
+ return tailmatch(str, substr, start, end, direction);
}
/* Apply fixfct filter to the Unicode object self and return a
@@ -9974,13 +10131,8 @@
{
PyObject *list;
- string = PyUnicode_FromObject(string);
- if (string == NULL)
+ if (ensure_unicode(string) < 0)
return NULL;
- if (PyUnicode_READY(string) == -1) {
- Py_DECREF(string);
- return NULL;
- }
switch (PyUnicode_KIND(string)) {
case PyUnicode_1BYTE_KIND:
@@ -10007,7 +10159,6 @@
assert(0);
list = 0;
}
- Py_DECREF(string);
return list;
}
@@ -10568,28 +10719,27 @@
}
-/* Argument converter. Coerces to a single unicode character */
+/* Argument converter. Accepts a single Unicode character. */
static int
convert_uc(PyObject *obj, void *addr)
{
Py_UCS4 *fillcharloc = (Py_UCS4 *)addr;
- PyObject *uniobj;
- uniobj = PyUnicode_FromObject(obj);
- if (uniobj == NULL) {
- PyErr_SetString(PyExc_TypeError,
- "The fill character cannot be converted to Unicode");
+ if (!PyUnicode_Check(obj)) {
+ PyErr_Format(PyExc_TypeError,
+ "The fill character must be a unicode character, "
+ "not %.100s", Py_TYPE(obj)->tp_name);
return 0;
}
- if (PyUnicode_GET_LENGTH(uniobj) != 1) {
+ if (PyUnicode_READY(obj) < 0)
+ return 0;
+ if (PyUnicode_GET_LENGTH(obj) != 1) {
PyErr_SetString(PyExc_TypeError,
"The fill character must be exactly one character long");
- Py_DECREF(uniobj);
return 0;
}
- *fillcharloc = PyUnicode_READ_CHAR(uniobj, 0);
- Py_DECREF(uniobj);
+ *fillcharloc = PyUnicode_READ_CHAR(obj, 0);
return 1;
}
@@ -10905,59 +11055,49 @@
}
int
-PyUnicode_Contains(PyObject *container, PyObject *element)
+_PyUnicode_EQ(PyObject *aa, PyObject *bb)
{
- PyObject *str, *sub;
+ return unicode_eq(aa, bb);
+}
+
+int
+PyUnicode_Contains(PyObject *str, PyObject *substr)
+{
int kind1, kind2;
void *buf1, *buf2;
Py_ssize_t len1, len2;
int result;
- /* Coerce the two arguments */
- sub = PyUnicode_FromObject(element);
- if (!sub) {
+ if (!PyUnicode_Check(substr)) {
PyErr_Format(PyExc_TypeError,
- "'in <string>' requires string as left operand, not %s",
- element->ob_type->tp_name);
+ "'in <string>' requires string as left operand, not %.100s",
+ Py_TYPE(substr)->tp_name);
return -1;
}
-
- str = PyUnicode_FromObject(container);
- if (!str) {
- Py_DECREF(sub);
+ if (PyUnicode_READY(substr) == -1)
return -1;
- }
+ if (ensure_unicode(str) < 0)
+ return -1;
kind1 = PyUnicode_KIND(str);
- kind2 = PyUnicode_KIND(sub);
- if (kind1 < kind2) {
- Py_DECREF(sub);
- Py_DECREF(str);
+ kind2 = PyUnicode_KIND(substr);
+ if (kind1 < kind2)
return 0;
- }
len1 = PyUnicode_GET_LENGTH(str);
- len2 = PyUnicode_GET_LENGTH(sub);
- if (len1 < len2) {
- Py_DECREF(sub);
- Py_DECREF(str);
+ len2 = PyUnicode_GET_LENGTH(substr);
+ if (len1 < len2)
return 0;
- }
buf1 = PyUnicode_DATA(str);
- buf2 = PyUnicode_DATA(sub);
+ buf2 = PyUnicode_DATA(substr);
if (len2 == 1) {
Py_UCS4 ch = PyUnicode_READ(kind2, buf2, 0);
result = findchar((const char *)buf1, kind1, len1, ch, 1) != -1;
- Py_DECREF(sub);
- Py_DECREF(str);
return result;
}
if (kind2 != kind1) {
- buf2 = _PyUnicode_AsKind(sub, kind1);
- if (!buf2) {
- Py_DECREF(sub);
- Py_DECREF(str);
+ buf2 = _PyUnicode_AsKind(substr, kind1);
+ if (!buf2)
return -1;
- }
}
switch (kind1) {
@@ -10975,9 +11115,6 @@
assert(0);
}
- Py_DECREF(str);
- Py_DECREF(sub);
-
if (kind2 != kind1)
PyMem_Free(buf2);
@@ -10989,56 +11126,40 @@
PyObject *
PyUnicode_Concat(PyObject *left, PyObject *right)
{
- PyObject *u = NULL, *v = NULL, *w;
+ PyObject *result;
Py_UCS4 maxchar, maxchar2;
- Py_ssize_t u_len, v_len, new_len;
+ Py_ssize_t left_len, right_len, new_len;
- /* Coerce the two arguments */
- u = PyUnicode_FromObject(left);
- if (u == NULL)
- goto onError;
- v = PyUnicode_FromObject(right);
- if (v == NULL)
- goto onError;
+ if (ensure_unicode(left) < 0 || ensure_unicode(right) < 0)
+ return NULL;
/* Shortcuts */
- if (v == unicode_empty) {
- Py_DECREF(v);
- return u;
- }
- if (u == unicode_empty) {
- Py_DECREF(u);
- return v;
- }
+ if (left == unicode_empty)
+ return PyUnicode_FromObject(right);
+ if (right == unicode_empty)
+ return PyUnicode_FromObject(left);
- u_len = PyUnicode_GET_LENGTH(u);
- v_len = PyUnicode_GET_LENGTH(v);
- if (u_len > PY_SSIZE_T_MAX - v_len) {
+ left_len = PyUnicode_GET_LENGTH(left);
+ right_len = PyUnicode_GET_LENGTH(right);
+ if (left_len > PY_SSIZE_T_MAX - right_len) {
PyErr_SetString(PyExc_OverflowError,
"strings are too large to concat");
- goto onError;
+ return NULL;
}
- new_len = u_len + v_len;
+ new_len = left_len + right_len;
- maxchar = PyUnicode_MAX_CHAR_VALUE(u);
- maxchar2 = PyUnicode_MAX_CHAR_VALUE(v);
+ maxchar = PyUnicode_MAX_CHAR_VALUE(left);
+ maxchar2 = PyUnicode_MAX_CHAR_VALUE(right);
maxchar = Py_MAX(maxchar, maxchar2);
/* Concat the two Unicode strings */
- w = PyUnicode_New(new_len, maxchar);
- if (w == NULL)
- goto onError;
- _PyUnicode_FastCopyCharacters(w, 0, u, 0, u_len);
- _PyUnicode_FastCopyCharacters(w, u_len, v, 0, v_len);
- Py_DECREF(u);
- Py_DECREF(v);
- assert(_PyUnicode_CheckConsistency(w, 1));
- return w;
-
- onError:
- Py_XDECREF(u);
- Py_XDECREF(v);
- return NULL;
+ result = PyUnicode_New(new_len, maxchar);
+ if (result == NULL)
+ return NULL;
+ _PyUnicode_FastCopyCharacters(result, 0, left, 0, left_len);
+ _PyUnicode_FastCopyCharacters(result, left_len, right, 0, right_len);
+ assert(_PyUnicode_CheckConsistency(result, 1));
+ return result;
}
void
@@ -11129,6 +11250,25 @@
Py_XDECREF(right);
}
+/*
+Wraps stringlib_parse_args_finds() and additionally ensures that the
+first argument is a unicode object.
+*/
+
+Py_LOCAL_INLINE(int)
+parse_args_finds_unicode(const char * function_name, PyObject *args,
+ PyObject **substring,
+ Py_ssize_t *start, Py_ssize_t *end)
+{
+ if(stringlib_parse_args_finds(function_name, args, substring,
+ start, end)) {
+ if (ensure_unicode(*substring) < 0)
+ return 0;
+ return 1;
+ }
+ return 0;
+}
+
PyDoc_STRVAR(count__doc__,
"S.count(sub[, start[, end]]) -> int\n\
\n\
@@ -11147,31 +11287,26 @@
void *buf1, *buf2;
Py_ssize_t len1, len2, iresult;
- if (!stringlib_parse_args_finds_unicode("count", args, &substring,
- &start, &end))
+ if (!parse_args_finds_unicode("count", args, &substring, &start, &end))
return NULL;
kind1 = PyUnicode_KIND(self);
kind2 = PyUnicode_KIND(substring);
- if (kind1 < kind2) {
- Py_DECREF(substring);
+ if (kind1 < kind2)
return PyLong_FromLong(0);
- }
+
len1 = PyUnicode_GET_LENGTH(self);
len2 = PyUnicode_GET_LENGTH(substring);
ADJUST_INDICES(start, end, len1);
- if (end - start < len2) {
- Py_DECREF(substring);
+ if (end - start < len2)
return PyLong_FromLong(0);
- }
+
buf1 = PyUnicode_DATA(self);
buf2 = PyUnicode_DATA(substring);
if (kind2 != kind1) {
buf2 = _PyUnicode_AsKind(substring, kind1);
- if (!buf2) {
- Py_DECREF(substring);
+ if (!buf2)
return NULL;
- }
}
switch (kind1) {
case PyUnicode_1BYTE_KIND:
@@ -11201,8 +11336,6 @@
if (kind2 != kind1)
PyMem_Free(buf2);
- Py_DECREF(substring);
-
return result;
}
@@ -11336,22 +11469,13 @@
Py_ssize_t end = 0;
Py_ssize_t result;
- if (!stringlib_parse_args_finds_unicode("find", args, &substring,
- &start, &end))
+ if (!parse_args_finds_unicode("find", args, &substring, &start, &end))
return NULL;
- if (PyUnicode_READY(self) == -1) {
- Py_DECREF(substring);
+ if (PyUnicode_READY(self) == -1)
return NULL;
- }
- if (PyUnicode_READY(substring) == -1) {
- Py_DECREF(substring);
- return NULL;
- }
- result = any_find_slice(1, self, substring, start, end);
-
- Py_DECREF(substring);
+ result = any_find_slice(self, substring, start, end, 1);
if (result == -2)
return NULL;
@@ -11424,22 +11548,13 @@
Py_ssize_t start = 0;
Py_ssize_t end = 0;
- if (!stringlib_parse_args_finds_unicode("index", args, &substring,
- &start, &end))
+ if (!parse_args_finds_unicode("index", args, &substring, &start, &end))
return NULL;
- if (PyUnicode_READY(self) == -1) {
- Py_DECREF(substring);
+ if (PyUnicode_READY(self) == -1)
return NULL;
- }
- if (PyUnicode_READY(substring) == -1) {
- Py_DECREF(substring);
- return NULL;
- }
- result = any_find_slice(1, self, substring, start, end);
-
- Py_DECREF(substring);
+ result = any_find_slice(self, substring, start, end, 1);
if (result == -2)
return NULL;
@@ -11953,7 +12068,7 @@
#define BOTHSTRIP 2
/* Arrays indexed by above */
-static const char *stripformat[] = {"|O:lstrip", "|O:rstrip", "|O:strip"};
+static const char * const stripformat[] = {"|O:lstrip", "|O:rstrip", "|O:strip"};
#define STRIPNAME(i) (stripformat[i]+3)
@@ -12248,40 +12363,15 @@
}
PyObject *
-PyUnicode_Replace(PyObject *obj,
- PyObject *subobj,
- PyObject *replobj,
+PyUnicode_Replace(PyObject *str,
+ PyObject *substr,
+ PyObject *replstr,
Py_ssize_t maxcount)
{
- PyObject *self;
- PyObject *str1;
- PyObject *str2;
- PyObject *result;
-
- self = PyUnicode_FromObject(obj);
- if (self == NULL)
+ if (ensure_unicode(str) < 0 || ensure_unicode(substr) < 0 ||
+ ensure_unicode(replstr) < 0)
return NULL;
- str1 = PyUnicode_FromObject(subobj);
- if (str1 == NULL) {
- Py_DECREF(self);
- return NULL;
- }
- str2 = PyUnicode_FromObject(replobj);
- if (str2 == NULL) {
- Py_DECREF(self);
- Py_DECREF(str1);
- return NULL;
- }
- if (PyUnicode_READY(self) == -1 ||
- PyUnicode_READY(str1) == -1 ||
- PyUnicode_READY(str2) == -1)
- result = NULL;
- else
- result = replace(self, str1, str2, maxcount);
- Py_DECREF(self);
- Py_DECREF(str1);
- Py_DECREF(str2);
- return result;
+ return replace(str, substr, replstr, maxcount);
}
PyDoc_STRVAR(replace__doc__,
@@ -12297,28 +12387,12 @@
PyObject *str1;
PyObject *str2;
Py_ssize_t maxcount = -1;
- PyObject *result;
- if (!PyArg_ParseTuple(args, "OO|n:replace", &str1, &str2, &maxcount))
+ if (!PyArg_ParseTuple(args, "UU|n:replace", &str1, &str2, &maxcount))
return NULL;
if (PyUnicode_READY(self) == -1)
return NULL;
- str1 = PyUnicode_FromObject(str1);
- if (str1 == NULL)
- return NULL;
- str2 = PyUnicode_FromObject(str2);
- if (str2 == NULL) {
- Py_DECREF(str1);
- return NULL;
- }
- if (PyUnicode_READY(str1) == -1 || PyUnicode_READY(str2) == -1)
- result = NULL;
- else
- result = replace(self, str1, str2, maxcount);
-
- Py_DECREF(str1);
- Py_DECREF(str2);
- return result;
+ return replace(self, str1, str2, maxcount);
}
static PyObject *
@@ -12503,22 +12577,13 @@
Py_ssize_t end = 0;
Py_ssize_t result;
- if (!stringlib_parse_args_finds_unicode("rfind", args, &substring,
- &start, &end))
+ if (!parse_args_finds_unicode("rfind", args, &substring, &start, &end))
return NULL;
- if (PyUnicode_READY(self) == -1) {
- Py_DECREF(substring);
+ if (PyUnicode_READY(self) == -1)
return NULL;
- }
- if (PyUnicode_READY(substring) == -1) {
- Py_DECREF(substring);
- return NULL;
- }
- result = any_find_slice(-1, self, substring, start, end);
-
- Py_DECREF(substring);
+ result = any_find_slice(self, substring, start, end, -1);
if (result == -2)
return NULL;
@@ -12540,22 +12605,13 @@
Py_ssize_t end = 0;
Py_ssize_t result;
- if (!stringlib_parse_args_finds_unicode("rindex", args, &substring,
- &start, &end))
+ if (!parse_args_finds_unicode("rindex", args, &substring, &start, &end))
return NULL;
- if (PyUnicode_READY(self) == -1) {
- Py_DECREF(substring);
+ if (PyUnicode_READY(self) == -1)
return NULL;
- }
- if (PyUnicode_READY(substring) == -1) {
- Py_DECREF(substring);
- return NULL;
- }
- result = any_find_slice(-1, self, substring, start, end);
-
- Py_DECREF(substring);
+ result = any_find_slice(self, substring, start, end, -1);
if (result == -2)
return NULL;
@@ -12595,24 +12651,10 @@
PyObject *
PyUnicode_Split(PyObject *s, PyObject *sep, Py_ssize_t maxsplit)
{
- PyObject *result;
-
- s = PyUnicode_FromObject(s);
- if (s == NULL)
+ if (ensure_unicode(s) < 0 || (sep != NULL && ensure_unicode(sep) < 0))
return NULL;
- if (sep != NULL) {
- sep = PyUnicode_FromObject(sep);
- if (sep == NULL) {
- Py_DECREF(s);
- return NULL;
- }
- }
- result = split(s, sep, maxsplit);
-
- Py_DECREF(s);
- Py_XDECREF(sep);
- return result;
+ return split(s, sep, maxsplit);
}
PyDoc_STRVAR(split__doc__,
@@ -12637,35 +12679,26 @@
if (substring == Py_None)
return split(self, NULL, maxcount);
- else if (PyUnicode_Check(substring))
+
+ if (PyUnicode_Check(substring))
return split(self, substring, maxcount);
- else
- return PyUnicode_Split(self, substring, maxcount);
+
+ PyErr_Format(PyExc_TypeError,
+ "must be str or None, not %.100s",
+ Py_TYPE(substring)->tp_name);
+ return NULL;
}
PyObject *
-PyUnicode_Partition(PyObject *str_in, PyObject *sep_in)
+PyUnicode_Partition(PyObject *str_obj, PyObject *sep_obj)
{
- PyObject* str_obj;
- PyObject* sep_obj;
PyObject* out;
int kind1, kind2;
void *buf1, *buf2;
Py_ssize_t len1, len2;
- str_obj = PyUnicode_FromObject(str_in);
- if (!str_obj)
+ if (ensure_unicode(str_obj) < 0 || ensure_unicode(sep_obj) < 0)
return NULL;
- sep_obj = PyUnicode_FromObject(sep_in);
- if (!sep_obj) {
- Py_DECREF(str_obj);
- return NULL;
- }
- if (PyUnicode_READY(sep_obj) == -1 || PyUnicode_READY(str_obj) == -1) {
- Py_DECREF(sep_obj);
- Py_DECREF(str_obj);
- return NULL;
- }
kind1 = PyUnicode_KIND(str_obj);
kind2 = PyUnicode_KIND(sep_obj);
@@ -12679,8 +12712,6 @@
out = PyTuple_Pack(3, str_obj, unicode_empty, unicode_empty);
Py_DECREF(unicode_empty);
}
- Py_DECREF(sep_obj);
- Py_DECREF(str_obj);
return out;
}
buf1 = PyUnicode_DATA(str_obj);
@@ -12688,7 +12719,7 @@
if (kind2 != kind1) {
buf2 = _PyUnicode_AsKind(sep_obj, kind1);
if (!buf2)
- goto onError;
+ return NULL;
}
switch (kind1) {
@@ -12709,39 +12740,23 @@
out = 0;
}
- Py_DECREF(sep_obj);
- Py_DECREF(str_obj);
if (kind2 != kind1)
PyMem_Free(buf2);
return out;
- onError:
- Py_DECREF(sep_obj);
- Py_DECREF(str_obj);
- if (kind2 != kind1 && buf2)
- PyMem_Free(buf2);
- return NULL;
}
PyObject *
-PyUnicode_RPartition(PyObject *str_in, PyObject *sep_in)
+PyUnicode_RPartition(PyObject *str_obj, PyObject *sep_obj)
{
- PyObject* str_obj;
- PyObject* sep_obj;
PyObject* out;
int kind1, kind2;
void *buf1, *buf2;
Py_ssize_t len1, len2;
- str_obj = PyUnicode_FromObject(str_in);
- if (!str_obj)
+ if (ensure_unicode(str_obj) < 0 || ensure_unicode(sep_obj) < 0)
return NULL;
- sep_obj = PyUnicode_FromObject(sep_in);
- if (!sep_obj) {
- Py_DECREF(str_obj);
- return NULL;
- }
kind1 = PyUnicode_KIND(str_obj);
kind2 = PyUnicode_KIND(sep_obj);
@@ -12755,8 +12770,6 @@
out = PyTuple_Pack(3, unicode_empty, unicode_empty, str_obj);
Py_DECREF(unicode_empty);
}
- Py_DECREF(sep_obj);
- Py_DECREF(str_obj);
return out;
}
buf1 = PyUnicode_DATA(str_obj);
@@ -12764,7 +12777,7 @@
if (kind2 != kind1) {
buf2 = _PyUnicode_AsKind(sep_obj, kind1);
if (!buf2)
- goto onError;
+ return NULL;
}
switch (kind1) {
@@ -12785,18 +12798,10 @@
out = 0;
}
- Py_DECREF(sep_obj);
- Py_DECREF(str_obj);
if (kind2 != kind1)
PyMem_Free(buf2);
return out;
- onError:
- Py_DECREF(sep_obj);
- Py_DECREF(str_obj);
- if (kind2 != kind1 && buf2)
- PyMem_Free(buf2);
- return NULL;
}
PyDoc_STRVAR(partition__doc__,
@@ -12828,24 +12833,10 @@
PyObject *
PyUnicode_RSplit(PyObject *s, PyObject *sep, Py_ssize_t maxsplit)
{
- PyObject *result;
-
- s = PyUnicode_FromObject(s);
- if (s == NULL)
+ if (ensure_unicode(s) < 0 || (sep != NULL && ensure_unicode(sep) < 0))
return NULL;
- if (sep != NULL) {
- sep = PyUnicode_FromObject(sep);
- if (sep == NULL) {
- Py_DECREF(s);
- return NULL;
- }
- }
- result = rsplit(s, sep, maxsplit);
-
- Py_DECREF(s);
- Py_XDECREF(sep);
- return result;
+ return rsplit(s, sep, maxsplit);
}
PyDoc_STRVAR(rsplit__doc__,
@@ -12870,10 +12861,14 @@
if (substring == Py_None)
return rsplit(self, NULL, maxcount);
- else if (PyUnicode_Check(substring))
+
+ if (PyUnicode_Check(substring))
return rsplit(self, substring, maxcount);
- else
- return PyUnicode_RSplit(self, substring, maxcount);
+
+ PyErr_Format(PyExc_TypeError,
+ "must be str or None, not %.100s",
+ Py_TYPE(substring)->tp_name);
+ return NULL;
}
PyDoc_STRVAR(splitlines__doc__,
@@ -13154,11 +13149,15 @@
if (PyTuple_Check(subobj)) {
Py_ssize_t i;
for (i = 0; i < PyTuple_GET_SIZE(subobj); i++) {
- substring = PyUnicode_FromObject(PyTuple_GET_ITEM(subobj, i));
- if (substring == NULL)
+ substring = PyTuple_GET_ITEM(subobj, i);
+ if (!PyUnicode_Check(substring)) {
+ PyErr_Format(PyExc_TypeError,
+ "tuple for startswith must only contain str, "
+ "not %.100s",
+ Py_TYPE(substring)->tp_name);
return NULL;
+ }
result = tailmatch(self, substring, start, end, -1);
- Py_DECREF(substring);
if (result == -1)
return NULL;
if (result) {
@@ -13168,15 +13167,13 @@
/* nothing matched */
Py_RETURN_FALSE;
}
- substring = PyUnicode_FromObject(subobj);
- if (substring == NULL) {
- if (PyErr_ExceptionMatches(PyExc_TypeError))
- PyErr_Format(PyExc_TypeError, "startswith first arg must be str or "
- "a tuple of str, not %s", Py_TYPE(subobj)->tp_name);
+ if (!PyUnicode_Check(subobj)) {
+ PyErr_Format(PyExc_TypeError,
+ "startswith first arg must be str or "
+ "a tuple of str, not %.100s", Py_TYPE(subobj)->tp_name);
return NULL;
}
- result = tailmatch(self, substring, start, end, -1);
- Py_DECREF(substring);
+ result = tailmatch(self, subobj, start, end, -1);
if (result == -1)
return NULL;
return PyBool_FromLong(result);
@@ -13206,12 +13203,15 @@
if (PyTuple_Check(subobj)) {
Py_ssize_t i;
for (i = 0; i < PyTuple_GET_SIZE(subobj); i++) {
- substring = PyUnicode_FromObject(
- PyTuple_GET_ITEM(subobj, i));
- if (substring == NULL)
+ substring = PyTuple_GET_ITEM(subobj, i);
+ if (!PyUnicode_Check(substring)) {
+ PyErr_Format(PyExc_TypeError,
+ "tuple for endswith must only contain str, "
+ "not %.100s",
+ Py_TYPE(substring)->tp_name);
return NULL;
+ }
result = tailmatch(self, substring, start, end, +1);
- Py_DECREF(substring);
if (result == -1)
return NULL;
if (result) {
@@ -13220,15 +13220,13 @@
}
Py_RETURN_FALSE;
}
- substring = PyUnicode_FromObject(subobj);
- if (substring == NULL) {
- if (PyErr_ExceptionMatches(PyExc_TypeError))
- PyErr_Format(PyExc_TypeError, "endswith first arg must be str or "
- "a tuple of str, not %s", Py_TYPE(subobj)->tp_name);
+ if (!PyUnicode_Check(subobj)) {
+ PyErr_Format(PyExc_TypeError,
+ "endswith first arg must be str or "
+ "a tuple of str, not %.100s", Py_TYPE(subobj)->tp_name);
return NULL;
}
- result = tailmatch(self, substring, start, end, +1);
- Py_DECREF(substring);
+ result = tailmatch(self, subobj, start, end, +1);
if (result == -1)
return NULL;
return PyBool_FromLong(result);
@@ -13237,44 +13235,50 @@
Py_LOCAL_INLINE(void)
_PyUnicodeWriter_Update(_PyUnicodeWriter *writer)
{
- if (!writer->readonly)
+ writer->maxchar = PyUnicode_MAX_CHAR_VALUE(writer->buffer);
+ writer->data = PyUnicode_DATA(writer->buffer);
+
+ if (!writer->readonly) {
+ writer->kind = PyUnicode_KIND(writer->buffer);
writer->size = PyUnicode_GET_LENGTH(writer->buffer);
+ }
else {
+ /* use a value smaller than PyUnicode_1BYTE_KIND() so
+ _PyUnicodeWriter_PrepareKind() will copy the buffer. */
+ writer->kind = PyUnicode_WCHAR_KIND;
+ assert(writer->kind <= PyUnicode_1BYTE_KIND);
+
/* Copy-on-write mode: set buffer size to 0 so
* _PyUnicodeWriter_Prepare() will copy (and enlarge) the buffer on
* next write. */
writer->size = 0;
}
- writer->maxchar = PyUnicode_MAX_CHAR_VALUE(writer->buffer);
- writer->data = PyUnicode_DATA(writer->buffer);
- writer->kind = PyUnicode_KIND(writer->buffer);
}
void
_PyUnicodeWriter_Init(_PyUnicodeWriter *writer)
{
memset(writer, 0, sizeof(*writer));
-#ifdef Py_DEBUG
- writer->kind = 5; /* invalid kind */
-#endif
+
+ /* ASCII is the bare minimum */
writer->min_char = 127;
+
+ /* use a value smaller than PyUnicode_1BYTE_KIND() so
+ _PyUnicodeWriter_PrepareKind() will copy the buffer. */
+ writer->kind = PyUnicode_WCHAR_KIND;
+ assert(writer->kind <= PyUnicode_1BYTE_KIND);
}
int
_PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter *writer,
Py_ssize_t length, Py_UCS4 maxchar)
{
-#ifdef MS_WINDOWS
- /* On Windows, overallocate by 50% is the best factor */
-# define OVERALLOCATE_FACTOR 2
-#else
- /* On Linux, overallocate by 25% is the best factor */
-# define OVERALLOCATE_FACTOR 4
-#endif
Py_ssize_t newlen;
PyObject *newbuffer;
- assert(length > 0);
+ /* ensure that the _PyUnicodeWriter_Prepare macro was used */
+ assert((maxchar > writer->maxchar && length >= 0)
+ || length > 0);
if (length > PY_SSIZE_T_MAX - writer->pos) {
PyErr_NoMemory();
@@ -13340,6 +13344,28 @@
#undef OVERALLOCATE_FACTOR
}
+int
+_PyUnicodeWriter_PrepareKindInternal(_PyUnicodeWriter *writer,
+ enum PyUnicode_Kind kind)
+{
+ Py_UCS4 maxchar;
+
+ /* ensure that the _PyUnicodeWriter_PrepareKind macro was used */
+ assert(writer->kind < kind);
+
+ switch (kind)
+ {
+ case PyUnicode_1BYTE_KIND: maxchar = 0xff; break;
+ case PyUnicode_2BYTE_KIND: maxchar = 0xffff; break;
+ case PyUnicode_4BYTE_KIND: maxchar = 0x10ffff; break;
+ default:
+ assert(0 && "invalid kind");
+ return -1;
+ }
+
+ return _PyUnicodeWriter_PrepareInternal(writer, 0, maxchar);
+}
+
Py_LOCAL_INLINE(int)
_PyUnicodeWriter_WriteCharInline(_PyUnicodeWriter *writer, Py_UCS4 ch)
{
@@ -13510,17 +13536,26 @@
assert(PyUnicode_GET_LENGTH(str) == writer->pos);
return str;
}
- if (PyUnicode_GET_LENGTH(writer->buffer) != writer->pos) {
- PyObject *newbuffer;
- newbuffer = resize_compact(writer->buffer, writer->pos);
- if (newbuffer == NULL) {
- Py_CLEAR(writer->buffer);
- return NULL;
- }
- writer->buffer = newbuffer;
+ if (writer->pos == 0) {
+ Py_CLEAR(writer->buffer);
+
+ /* Get the empty Unicode string singleton ('') */
+ _Py_INCREF_UNICODE_EMPTY();
+ str = unicode_empty;
}
- str = writer->buffer;
- writer->buffer = NULL;
+ else {
+ str = writer->buffer;
+ writer->buffer = NULL;
+
+ if (PyUnicode_GET_LENGTH(str) != writer->pos) {
+ PyObject *str2;
+ str2 = resize_compact(str, writer->pos);
+ if (str2 == NULL)
+ return NULL;
+ str = str2;
+ }
+ }
+
assert(_PyUnicode_CheckConsistency(str, 1));
return unicode_result_ready(str);
}
@@ -14661,13 +14696,10 @@
return NULL;
}
- ctx.fmtstr = PyUnicode_FromObject(format);
- if (ctx.fmtstr == NULL)
+ if (ensure_unicode(format) < 0)
return NULL;
- if (PyUnicode_READY(ctx.fmtstr) == -1) {
- Py_DECREF(ctx.fmtstr);
- return NULL;
- }
+
+ ctx.fmtstr = format;
ctx.fmtdata = PyUnicode_DATA(ctx.fmtstr);
ctx.fmtkind = PyUnicode_KIND(ctx.fmtstr);
ctx.fmtcnt = PyUnicode_GET_LENGTH(ctx.fmtstr);
@@ -14727,11 +14759,9 @@
if (ctx.args_owned) {
Py_DECREF(ctx.args);
}
- Py_DECREF(ctx.fmtstr);
return _PyUnicodeWriter_Finish(&ctx.writer);
onError:
- Py_DECREF(ctx.fmtstr);
_PyUnicodeWriter_Dealloc(&ctx.writer);
if (ctx.args_owned) {
Py_DECREF(ctx.args);
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index 7e6f364..f75b1e8 100644
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -265,7 +265,7 @@
}
static int
-parse_weakref_init_args(char *funcname, PyObject *args, PyObject *kwargs,
+parse_weakref_init_args(const char *funcname, PyObject *args, PyObject *kwargs,
PyObject **obp, PyObject **callbackp)
{
return PyArg_UnpackTuple(args, funcname, 1, 2, obp, callbackp);
diff --git a/PC/_msi.c b/PC/_msi.c
index 86a5943..b66b18b 100644
--- a/PC/_msi.c
+++ b/PC/_msi.c
@@ -1032,12 +1032,12 @@
if (m == NULL)
return NULL;
- PyModule_AddIntConstant(m, "MSIDBOPEN_CREATEDIRECT", (int)MSIDBOPEN_CREATEDIRECT);
- PyModule_AddIntConstant(m, "MSIDBOPEN_CREATE", (int)MSIDBOPEN_CREATE);
- PyModule_AddIntConstant(m, "MSIDBOPEN_DIRECT", (int)MSIDBOPEN_DIRECT);
- PyModule_AddIntConstant(m, "MSIDBOPEN_READONLY", (int)MSIDBOPEN_READONLY);
- PyModule_AddIntConstant(m, "MSIDBOPEN_TRANSACT", (int)MSIDBOPEN_TRANSACT);
- PyModule_AddIntConstant(m, "MSIDBOPEN_PATCHFILE", (int)MSIDBOPEN_PATCHFILE);
+ PyModule_AddIntConstant(m, "MSIDBOPEN_CREATEDIRECT", (long)MSIDBOPEN_CREATEDIRECT);
+ PyModule_AddIntConstant(m, "MSIDBOPEN_CREATE", (long)MSIDBOPEN_CREATE);
+ PyModule_AddIntConstant(m, "MSIDBOPEN_DIRECT", (long)MSIDBOPEN_DIRECT);
+ PyModule_AddIntConstant(m, "MSIDBOPEN_READONLY", (long)MSIDBOPEN_READONLY);
+ PyModule_AddIntConstant(m, "MSIDBOPEN_TRANSACT", (long)MSIDBOPEN_TRANSACT);
+ PyModule_AddIntConstant(m, "MSIDBOPEN_PATCHFILE", (long)MSIDBOPEN_PATCHFILE);
PyModule_AddIntMacro(m, MSICOLINFO_NAMES);
PyModule_AddIntMacro(m, MSICOLINFO_TYPES);
diff --git a/PC/bdist_wininst/install.c b/PC/bdist_wininst/install.c
index cb037ff..e01dba6 100644
--- a/PC/bdist_wininst/install.c
+++ b/PC/bdist_wininst/install.c
@@ -718,7 +718,7 @@
* 1 if the Python-dll does not export the functions we need
* 2 if no install-script is specified in pathname
* 3 if the install-script file could not be opened
- * the return value of PyRun_SimpleString() otherwise,
+ * the return value of PyRun_SimpleString() or Py_FinalizeEx() otherwise,
* which is 0 if everything is ok, -1 if an exception had occurred
* in the install-script.
*/
@@ -731,7 +731,7 @@
DECLPROC(hPython, void, Py_Initialize, (void));
DECLPROC(hPython, int, PySys_SetArgv, (int, wchar_t **));
DECLPROC(hPython, int, PyRun_SimpleString, (char *));
- DECLPROC(hPython, void, Py_Finalize, (void));
+ DECLPROC(hPython, int, Py_FinalizeEx, (void));
DECLPROC(hPython, PyObject *, Py_BuildValue, (char *, ...));
DECLPROC(hPython, PyObject *, PyCFunction_New,
(PyMethodDef *, PyObject *));
@@ -739,7 +739,7 @@
DECLPROC(hPython, PyObject *, PyErr_Format, (PyObject *, char *));
if (!Py_Initialize || !PySys_SetArgv
- || !PyRun_SimpleString || !Py_Finalize)
+ || !PyRun_SimpleString || !Py_FinalizeEx)
return 1;
if (!Py_BuildValue || !PyArg_ParseTuple || !PyErr_Format)
@@ -786,7 +786,9 @@
}
}
}
- Py_Finalize();
+ if (Py_FinalizeEx() < 0) {
+ result = -1;
+ }
close(fh);
return result;
@@ -848,11 +850,11 @@
int rc;
DECLPROC(hPython, void, Py_Initialize, (void));
DECLPROC(hPython, void, Py_SetProgramName, (wchar_t *));
- DECLPROC(hPython, void, Py_Finalize, (void));
+ DECLPROC(hPython, int, Py_FinalizeEx, (void));
DECLPROC(hPython, int, PyRun_SimpleString, (char *));
DECLPROC(hPython, void, PyErr_Print, (void));
- if (!Py_Initialize || !Py_SetProgramName || !Py_Finalize ||
+ if (!Py_Initialize || !Py_SetProgramName || !Py_FinalizeEx ||
!PyRun_SimpleString || !PyErr_Print)
return -1;
@@ -862,7 +864,9 @@
rc = PyRun_SimpleString(script);
if (rc)
PyErr_Print();
- Py_Finalize();
+ if (Py_FinalizeEx() < 0) {
+ rc = -1;
+ }
return rc;
}
diff --git a/PC/clinic/msvcrtmodule.c.h b/PC/clinic/msvcrtmodule.c.h
index c8e6ed8..24e18cd 100644
--- a/PC/clinic/msvcrtmodule.c.h
+++ b/PC/clinic/msvcrtmodule.c.h
@@ -51,8 +51,9 @@
long nbytes;
if (!PyArg_ParseTuple(args, "iil:locking",
- &fd, &mode, &nbytes))
+ &fd, &mode, &nbytes)) {
goto exit;
+ }
return_value = msvcrt_locking_impl(module, fd, mode, nbytes);
exit:
@@ -85,11 +86,13 @@
long _return_value;
if (!PyArg_ParseTuple(args, "ii:setmode",
- &fd, &flags))
+ &fd, &flags)) {
goto exit;
+ }
_return_value = msvcrt_setmode_impl(module, fd, flags);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong(_return_value);
exit:
@@ -122,11 +125,13 @@
long _return_value;
if (!PyArg_ParseTuple(args, ""_Py_PARSE_INTPTR"i:open_osfhandle",
- &handle, &flags))
+ &handle, &flags)) {
goto exit;
+ }
_return_value = msvcrt_open_osfhandle_impl(module, handle, flags);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong(_return_value);
exit:
@@ -154,11 +159,13 @@
int fd;
Py_intptr_t _return_value;
- if (!PyArg_Parse(arg, "i:get_osfhandle", &fd))
+ if (!PyArg_Parse(arg, "i:get_osfhandle", &fd)) {
goto exit;
+ }
_return_value = msvcrt_get_osfhandle_impl(module, fd);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromVoidPtr((void *)_return_value);
exit:
@@ -184,8 +191,9 @@
long _return_value;
_return_value = msvcrt_kbhit_impl(module);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong(_return_value);
exit:
@@ -312,8 +320,9 @@
PyObject *return_value = NULL;
char char_value;
- if (!PyArg_Parse(arg, "c:putch", &char_value))
+ if (!PyArg_Parse(arg, "c:putch", &char_value)) {
goto exit;
+ }
return_value = msvcrt_putch_impl(module, char_value);
exit:
@@ -338,8 +347,9 @@
PyObject *return_value = NULL;
int unicode_char;
- if (!PyArg_Parse(arg, "C:putwch", &unicode_char))
+ if (!PyArg_Parse(arg, "C:putwch", &unicode_char)) {
goto exit;
+ }
return_value = msvcrt_putwch_impl(module, unicode_char);
exit:
@@ -368,8 +378,9 @@
PyObject *return_value = NULL;
char char_value;
- if (!PyArg_Parse(arg, "c:ungetch", &char_value))
+ if (!PyArg_Parse(arg, "c:ungetch", &char_value)) {
goto exit;
+ }
return_value = msvcrt_ungetch_impl(module, char_value);
exit:
@@ -394,8 +405,9 @@
PyObject *return_value = NULL;
int unicode_char;
- if (!PyArg_Parse(arg, "C:ungetwch", &unicode_char))
+ if (!PyArg_Parse(arg, "C:ungetwch", &unicode_char)) {
goto exit;
+ }
return_value = msvcrt_ungetwch_impl(module, unicode_char);
exit:
@@ -427,11 +439,13 @@
long _return_value;
if (!PyArg_ParseTuple(args, "ii:CrtSetReportFile",
- &type, &file))
+ &type, &file)) {
goto exit;
+ }
_return_value = msvcrt_CrtSetReportFile_impl(module, type, file);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong(_return_value);
exit:
@@ -465,11 +479,13 @@
long _return_value;
if (!PyArg_ParseTuple(args, "ii:CrtSetReportMode",
- &type, &mode))
+ &type, &mode)) {
goto exit;
+ }
_return_value = msvcrt_CrtSetReportMode_impl(module, type, mode);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong(_return_value);
exit:
@@ -501,11 +517,13 @@
int mode;
long _return_value;
- if (!PyArg_Parse(arg, "i:set_error_mode", &mode))
+ if (!PyArg_Parse(arg, "i:set_error_mode", &mode)) {
goto exit;
+ }
_return_value = msvcrt_set_error_mode_impl(module, mode);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong(_return_value);
exit:
@@ -532,8 +550,9 @@
PyObject *return_value = NULL;
unsigned int mode;
- if (!PyArg_Parse(arg, "I:SetErrorMode", &mode))
+ if (!PyArg_Parse(arg, "I:SetErrorMode", &mode)) {
goto exit;
+ }
return_value = msvcrt_SetErrorMode_impl(module, mode);
exit:
@@ -551,4 +570,4 @@
#ifndef MSVCRT_SET_ERROR_MODE_METHODDEF
#define MSVCRT_SET_ERROR_MODE_METHODDEF
#endif /* !defined(MSVCRT_SET_ERROR_MODE_METHODDEF) */
-/*[clinic end generated code: output=16613d3119a1fd44 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=636de3460aecbca7 input=a9049054013a1b77]*/
diff --git a/PC/clinic/winreg.c.h b/PC/clinic/winreg.c.h
index 338e33d..f3a4cd1 100644
--- a/PC/clinic/winreg.c.h
+++ b/PC/clinic/winreg.c.h
@@ -93,8 +93,9 @@
PyObject *traceback;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO:__exit__", _keywords,
- &exc_type, &exc_value, &traceback))
+ &exc_type, &exc_value, &traceback)) {
goto exit;
+ }
return_value = winreg_HKEYType___exit___impl(self, exc_type, exc_value, traceback);
exit:
@@ -147,11 +148,13 @@
HKEY _return_value;
if (!PyArg_ParseTuple(args, "ZO&:ConnectRegistry",
- &computer_name, clinic_HKEY_converter, &key))
+ &computer_name, clinic_HKEY_converter, &key)) {
goto exit;
+ }
_return_value = winreg_ConnectRegistry_impl(module, computer_name, key);
- if (_return_value == NULL)
+ if (_return_value == NULL) {
goto exit;
+ }
return_value = PyHKEY_FromHKEY(_return_value);
exit:
@@ -192,11 +195,13 @@
HKEY _return_value;
if (!PyArg_ParseTuple(args, "O&Z:CreateKey",
- clinic_HKEY_converter, &key, &sub_key))
+ clinic_HKEY_converter, &key, &sub_key)) {
goto exit;
+ }
_return_value = winreg_CreateKey_impl(module, key, sub_key);
- if (_return_value == NULL)
+ if (_return_value == NULL) {
goto exit;
+ }
return_value = PyHKEY_FromHKEY(_return_value);
exit:
@@ -247,11 +252,13 @@
HKEY _return_value;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&Z|ii:CreateKeyEx", _keywords,
- clinic_HKEY_converter, &key, &sub_key, &reserved, &access))
+ clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) {
goto exit;
+ }
_return_value = winreg_CreateKeyEx_impl(module, key, sub_key, reserved, access);
- if (_return_value == NULL)
+ if (_return_value == NULL) {
goto exit;
+ }
return_value = PyHKEY_FromHKEY(_return_value);
exit:
@@ -290,8 +297,9 @@
Py_UNICODE *sub_key;
if (!PyArg_ParseTuple(args, "O&u:DeleteKey",
- clinic_HKEY_converter, &key, &sub_key))
+ clinic_HKEY_converter, &key, &sub_key)) {
goto exit;
+ }
return_value = winreg_DeleteKey_impl(module, key, sub_key);
exit:
@@ -341,8 +349,9 @@
int reserved = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&u|ii:DeleteKeyEx", _keywords,
- clinic_HKEY_converter, &key, &sub_key, &access, &reserved))
+ clinic_HKEY_converter, &key, &sub_key, &access, &reserved)) {
goto exit;
+ }
return_value = winreg_DeleteKeyEx_impl(module, key, sub_key, access, reserved);
exit:
@@ -374,8 +383,9 @@
Py_UNICODE *value;
if (!PyArg_ParseTuple(args, "O&Z:DeleteValue",
- clinic_HKEY_converter, &key, &value))
+ clinic_HKEY_converter, &key, &value)) {
goto exit;
+ }
return_value = winreg_DeleteValue_impl(module, key, value);
exit:
@@ -411,8 +421,9 @@
int index;
if (!PyArg_ParseTuple(args, "O&i:EnumKey",
- clinic_HKEY_converter, &key, &index))
+ clinic_HKEY_converter, &key, &index)) {
goto exit;
+ }
return_value = winreg_EnumKey_impl(module, key, index);
exit:
@@ -457,8 +468,9 @@
int index;
if (!PyArg_ParseTuple(args, "O&i:EnumValue",
- clinic_HKEY_converter, &key, &index))
+ clinic_HKEY_converter, &key, &index)) {
goto exit;
+ }
return_value = winreg_EnumValue_impl(module, key, index);
exit:
@@ -483,8 +495,9 @@
PyObject *return_value = NULL;
Py_UNICODE *string;
- if (!PyArg_Parse(arg, "u:ExpandEnvironmentStrings", &string))
+ if (!PyArg_Parse(arg, "u:ExpandEnvironmentStrings", &string)) {
goto exit;
+ }
return_value = winreg_ExpandEnvironmentStrings_impl(module, string);
exit:
@@ -522,8 +535,9 @@
PyObject *return_value = NULL;
HKEY key;
- if (!PyArg_Parse(arg, "O&:FlushKey", clinic_HKEY_converter, &key))
+ if (!PyArg_Parse(arg, "O&:FlushKey", clinic_HKEY_converter, &key)) {
goto exit;
+ }
return_value = winreg_FlushKey_impl(module, key);
exit:
@@ -574,8 +588,9 @@
Py_UNICODE *file_name;
if (!PyArg_ParseTuple(args, "O&uu:LoadKey",
- clinic_HKEY_converter, &key, &sub_key, &file_name))
+ clinic_HKEY_converter, &key, &sub_key, &file_name)) {
goto exit;
+ }
return_value = winreg_LoadKey_impl(module, key, sub_key, file_name);
exit:
@@ -620,11 +635,13 @@
HKEY _return_value;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&Z|ii:OpenKey", _keywords,
- clinic_HKEY_converter, &key, &sub_key, &reserved, &access))
+ clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) {
goto exit;
+ }
_return_value = winreg_OpenKey_impl(module, key, sub_key, reserved, access);
- if (_return_value == NULL)
+ if (_return_value == NULL) {
goto exit;
+ }
return_value = PyHKEY_FromHKEY(_return_value);
exit:
@@ -669,11 +686,13 @@
HKEY _return_value;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&Z|ii:OpenKeyEx", _keywords,
- clinic_HKEY_converter, &key, &sub_key, &reserved, &access))
+ clinic_HKEY_converter, &key, &sub_key, &reserved, &access)) {
goto exit;
+ }
_return_value = winreg_OpenKeyEx_impl(module, key, sub_key, reserved, access);
- if (_return_value == NULL)
+ if (_return_value == NULL) {
goto exit;
+ }
return_value = PyHKEY_FromHKEY(_return_value);
exit:
@@ -707,8 +726,9 @@
PyObject *return_value = NULL;
HKEY key;
- if (!PyArg_Parse(arg, "O&:QueryInfoKey", clinic_HKEY_converter, &key))
+ if (!PyArg_Parse(arg, "O&:QueryInfoKey", clinic_HKEY_converter, &key)) {
goto exit;
+ }
return_value = winreg_QueryInfoKey_impl(module, key);
exit:
@@ -749,8 +769,9 @@
Py_UNICODE *sub_key;
if (!PyArg_ParseTuple(args, "O&Z:QueryValue",
- clinic_HKEY_converter, &key, &sub_key))
+ clinic_HKEY_converter, &key, &sub_key)) {
goto exit;
+ }
return_value = winreg_QueryValue_impl(module, key, sub_key);
exit:
@@ -787,8 +808,9 @@
Py_UNICODE *name;
if (!PyArg_ParseTuple(args, "O&Z:QueryValueEx",
- clinic_HKEY_converter, &key, &name))
+ clinic_HKEY_converter, &key, &name)) {
goto exit;
+ }
return_value = winreg_QueryValueEx_impl(module, key, name);
exit:
@@ -830,8 +852,9 @@
Py_UNICODE *file_name;
if (!PyArg_ParseTuple(args, "O&u:SaveKey",
- clinic_HKEY_converter, &key, &file_name))
+ clinic_HKEY_converter, &key, &file_name)) {
goto exit;
+ }
return_value = winreg_SaveKey_impl(module, key, file_name);
exit:
@@ -883,8 +906,9 @@
Py_ssize_clean_t value_length;
if (!PyArg_ParseTuple(args, "O&Zku#:SetValue",
- clinic_HKEY_converter, &key, &sub_key, &type, &value, &value_length))
+ clinic_HKEY_converter, &key, &sub_key, &type, &value, &value_length)) {
goto exit;
+ }
return_value = winreg_SetValue_impl(module, key, sub_key, type, value, value_length);
exit:
@@ -907,7 +931,7 @@
" An integer that specifies the type of the data, one of:\n"
" REG_BINARY -- Binary data in any form.\n"
" REG_DWORD -- A 32-bit number.\n"
-" REG_DWORD_LITTLE_ENDIAN -- A 32-bit number in little-endian format.\n"
+" REG_DWORD_LITTLE_ENDIAN -- A 32-bit number in little-endian format. Equivalent to REG_DWORD\n"
" REG_DWORD_BIG_ENDIAN -- A 32-bit number in big-endian format.\n"
" REG_EXPAND_SZ -- A null-terminated string that contains unexpanded\n"
" references to environment variables (for example,\n"
@@ -917,6 +941,8 @@
" by two null characters. Note that Python handles\n"
" this termination automatically.\n"
" REG_NONE -- No defined value type.\n"
+" REG_QWORD -- A 64-bit number.\n"
+" REG_QWORD_LITTLE_ENDIAN -- A 64-bit number in little-endian format. Equivalent to REG_QWORD.\n"
" REG_RESOURCE_LIST -- A device-driver resource list.\n"
" REG_SZ -- A null-terminated string.\n"
" value\n"
@@ -950,8 +976,9 @@
PyObject *value;
if (!PyArg_ParseTuple(args, "O&ZOkO:SetValueEx",
- clinic_HKEY_converter, &key, &value_name, &reserved, &type, &value))
+ clinic_HKEY_converter, &key, &value_name, &reserved, &type, &value)) {
goto exit;
+ }
return_value = winreg_SetValueEx_impl(module, key, value_name, reserved, type, value);
exit:
@@ -985,8 +1012,9 @@
PyObject *return_value = NULL;
HKEY key;
- if (!PyArg_Parse(arg, "O&:DisableReflectionKey", clinic_HKEY_converter, &key))
+ if (!PyArg_Parse(arg, "O&:DisableReflectionKey", clinic_HKEY_converter, &key)) {
goto exit;
+ }
return_value = winreg_DisableReflectionKey_impl(module, key);
exit:
@@ -1018,8 +1046,9 @@
PyObject *return_value = NULL;
HKEY key;
- if (!PyArg_Parse(arg, "O&:EnableReflectionKey", clinic_HKEY_converter, &key))
+ if (!PyArg_Parse(arg, "O&:EnableReflectionKey", clinic_HKEY_converter, &key)) {
goto exit;
+ }
return_value = winreg_EnableReflectionKey_impl(module, key);
exit:
@@ -1049,11 +1078,12 @@
PyObject *return_value = NULL;
HKEY key;
- if (!PyArg_Parse(arg, "O&:QueryReflectionKey", clinic_HKEY_converter, &key))
+ if (!PyArg_Parse(arg, "O&:QueryReflectionKey", clinic_HKEY_converter, &key)) {
goto exit;
+ }
return_value = winreg_QueryReflectionKey_impl(module, key);
exit:
return return_value;
}
-/*[clinic end generated code: output=5e346dccc296f9f1 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ca128bfa212d8d1f input=a9049054013a1b77]*/
diff --git a/PC/clinic/winsound.c.h b/PC/clinic/winsound.c.h
index dca5a42..e649363 100644
--- a/PC/clinic/winsound.c.h
+++ b/PC/clinic/winsound.c.h
@@ -27,8 +27,9 @@
int flags;
if (!PyArg_ParseTuple(args, "Zi:PlaySound",
- &sound, &flags))
+ &sound, &flags)) {
goto exit;
+ }
return_value = winsound_PlaySound_impl(module, sound, flags);
exit:
@@ -61,8 +62,9 @@
int duration;
if (!PyArg_ParseTuple(args, "ii:Beep",
- &frequency, &duration))
+ &frequency, &duration)) {
goto exit;
+ }
return_value = winsound_Beep_impl(module, frequency, duration);
exit:
@@ -90,11 +92,12 @@
int x = MB_OK;
if (!PyArg_ParseTuple(args, "|i:MessageBeep",
- &x))
+ &x)) {
goto exit;
+ }
return_value = winsound_MessageBeep_impl(module, x);
exit:
return return_value;
}
-/*[clinic end generated code: output=c5b018ac9dc1f500 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a5f53e42d4396bb4 input=a9049054013a1b77]*/
diff --git a/PC/getpathp.c b/PC/getpathp.c
index c7ddf1e..cb9f1db 100644
--- a/PC/getpathp.c
+++ b/PC/getpathp.c
@@ -135,7 +135,7 @@
static int
ismodule(wchar_t *filename, int update_filename) /* Is module -- check for .pyc/.pyo too */
{
- int n;
+ size_t n;
if (exists(filename))
return 1;
@@ -553,7 +553,7 @@
envpath = NULL;
pythonhome = argv0_path;
}
-
+
/* Look for a 'home' variable and set argv0_path to it, if found */
if (find_env_config_value(env_file, L"home", tmpbuffer)) {
wcscpy_s(argv0_path, MAXPATHLEN+1, tmpbuffer);
diff --git a/PC/launcher.c b/PC/launcher.c
index 40d4cb5..fa69438 100644
--- a/PC/launcher.c
+++ b/PC/launcher.c
@@ -98,7 +98,7 @@
MessageBox(NULL, message, TEXT("Python Launcher is sorry to say ..."),
MB_OK);
#endif
- ExitProcess(rc);
+ exit(rc);
}
/*
@@ -465,7 +465,7 @@
}
static INSTALLED_PYTHON *
-locate_python(wchar_t * wanted_ver)
+locate_python(wchar_t * wanted_ver, BOOL from_shebang)
{
static wchar_t config_key [] = { L"pythonX" };
static wchar_t * last_char = &config_key[sizeof(config_key) /
@@ -497,10 +497,17 @@
configured_value = get_configured_value(config_key);
if (configured_value)
result = find_python_by_version(configured_value);
+ /* Not found a value yet - try by major version.
+ * If we're looking for an interpreter specified in a shebang line,
+ * we want to try Python 2 first, then Python 3 (for Unix and backward
+ * compatibility). If we're being called interactively, assume the user
+ * wants the latest version available, so try Python 3 first, then
+ * Python 2.
+ */
if (result == NULL)
- result = find_python_by_version(L"2");
+ result = find_python_by_version(from_shebang ? L"2" : L"3");
if (result == NULL)
- result = find_python_by_version(L"3");
+ result = find_python_by_version(from_shebang ? L"3" : L"2");
debug(L"search for default Python found ");
if (result) {
debug(L"version %ls at '%ls'\n",
@@ -655,7 +662,7 @@
if (!ok)
error(RC_CREATE_PROCESS, L"Failed to get exit code of process");
debug(L"child process exit code: %d\n", rc);
- ExitProcess(rc);
+ exit(rc);
}
static void
@@ -1082,7 +1089,7 @@
{ 3190, 3230, L"3.3" },
{ 3250, 3310, L"3.4" },
{ 3320, 3351, L"3.5" },
- { 3360, 3361, L"3.6" },
+ { 3360, 3371, L"3.6" },
{ 0 }
};
@@ -1094,7 +1101,7 @@
for (mp = magic_values; mp->min; mp++) {
if ((magic >= mp->min) && (magic <= mp->max)) {
- result = locate_python(mp->version);
+ result = locate_python(mp->version, FALSE);
if (result != NULL)
break;
}
@@ -1114,7 +1121,7 @@
*/
FILE * fp;
errno_t rc = _wfopen_s(&fp, *argv, L"rb");
- unsigned char buffer[BUFSIZE];
+ char buffer[BUFSIZE];
wchar_t shebang_line[BUFSIZE + 1];
size_t read;
char *p;
@@ -1136,7 +1143,8 @@
fclose(fp);
if ((read >= 4) && (buffer[3] == '\n') && (buffer[2] == '\r')) {
- ip = find_by_magic((buffer[1] << 8 | buffer[0]) & 0xFFFF);
+ ip = find_by_magic((((unsigned char)buffer[1]) << 8 |
+ (unsigned char)buffer[0]) & 0xFFFF);
if (ip != NULL) {
debug(L"script file is compiled against Python %ls\n",
ip->version);
@@ -1278,7 +1286,7 @@
followed by a valid version specifier.\nPlease check the documentation.",
command);
/* TODO could call validate_version(command) */
- ip = locate_python(command);
+ ip = locate_python(command, TRUE);
if (ip == NULL) {
error(RC_NO_PYTHON, L"Requested Python version \
(%ls) is not installed", command);
@@ -1362,6 +1370,7 @@
wchar_t * av[2];
#endif
+ setvbuf(stderr, (char *)NULL, _IONBF, 0);
wp = get_env(L"PYLAUNCH_DEBUG");
if ((wp != NULL) && (*wp != L'\0'))
log_fp = stderr;
@@ -1483,7 +1492,7 @@
plen = wcslen(p);
valid = (*p == L'-') && validate_version(&p[1]);
if (valid) {
- ip = locate_python(&p[1]);
+ ip = locate_python(&p[1], FALSE);
if (ip == NULL)
error(RC_NO_PYTHON, L"Requested Python version (%ls) not \
installed", &p[1]);
@@ -1510,7 +1519,7 @@
/* If we didn't find one, look for the default Python */
if (executable == NULL) {
- ip = locate_python(L"");
+ ip = locate_python(L"", FALSE);
if (ip == NULL)
error(RC_NO_PYTHON, L"Can't find a default Python.");
executable = ip->executable;
diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c
index 52d4100..d73ce79 100644
--- a/PC/msvcrtmodule.c
+++ b/PC/msvcrtmodule.c
@@ -541,7 +541,6 @@
#endif
/* constants for the crt versions */
- (void)st;
#ifdef _VC_ASSEMBLY_PUBLICKEYTOKEN
st = PyModule_AddStringConstant(m, "VC_ASSEMBLY_PUBLICKEYTOKEN",
_VC_ASSEMBLY_PUBLICKEYTOKEN);
@@ -567,6 +566,8 @@
st = PyModule_AddObject(m, "CRT_ASSEMBLY_VERSION", version);
if (st < 0) return NULL;
#endif
+ /* make compiler warning quiet if st is unused */
+ (void)st;
return m;
}
diff --git a/PC/pyconfig.h b/PC/pyconfig.h
index ac4f8f2..1463ee6 100644
--- a/PC/pyconfig.h
+++ b/PC/pyconfig.h
@@ -312,11 +312,11 @@
their Makefile (other compilers are generally
taken care of by distutils.) */
# if defined(_DEBUG)
-# pragma comment(lib,"python35_d.lib")
+# pragma comment(lib,"python36_d.lib")
# elif defined(Py_LIMITED_API)
# pragma comment(lib,"python3.lib")
# else
-# pragma comment(lib,"python35.lib")
+# pragma comment(lib,"python36.lib")
# endif /* _DEBUG */
# endif /* _MSC_VER */
# endif /* Py_BUILD_CORE */
diff --git a/PC/python3.def b/PC/python3.def
index 88c0742..e8d2d8c 100644
--- a/PC/python3.def
+++ b/PC/python3.def
@@ -2,712 +2,713 @@
; It is used when building python3dll.vcxproj
LIBRARY "python3"
EXPORTS
- PyArg_Parse=python35.PyArg_Parse
- PyArg_ParseTuple=python35.PyArg_ParseTuple
- PyArg_ParseTupleAndKeywords=python35.PyArg_ParseTupleAndKeywords
- PyArg_UnpackTuple=python35.PyArg_UnpackTuple
- PyArg_VaParse=python35.PyArg_VaParse
- PyArg_VaParseTupleAndKeywords=python35.PyArg_VaParseTupleAndKeywords
- PyArg_ValidateKeywordArguments=python35.PyArg_ValidateKeywordArguments
- PyBaseObject_Type=python35.PyBaseObject_Type DATA
- PyBool_FromLong=python35.PyBool_FromLong
- PyBool_Type=python35.PyBool_Type DATA
- PyByteArrayIter_Type=python35.PyByteArrayIter_Type DATA
- PyByteArray_AsString=python35.PyByteArray_AsString
- PyByteArray_Concat=python35.PyByteArray_Concat
- PyByteArray_FromObject=python35.PyByteArray_FromObject
- PyByteArray_FromStringAndSize=python35.PyByteArray_FromStringAndSize
- PyByteArray_Resize=python35.PyByteArray_Resize
- PyByteArray_Size=python35.PyByteArray_Size
- PyByteArray_Type=python35.PyByteArray_Type DATA
- PyBytesIter_Type=python35.PyBytesIter_Type DATA
- PyBytes_AsString=python35.PyBytes_AsString
- PyBytes_AsStringAndSize=python35.PyBytes_AsStringAndSize
- PyBytes_Concat=python35.PyBytes_Concat
- PyBytes_ConcatAndDel=python35.PyBytes_ConcatAndDel
- PyBytes_DecodeEscape=python35.PyBytes_DecodeEscape
- PyBytes_FromFormat=python35.PyBytes_FromFormat
- PyBytes_FromFormatV=python35.PyBytes_FromFormatV
- PyBytes_FromObject=python35.PyBytes_FromObject
- PyBytes_FromString=python35.PyBytes_FromString
- PyBytes_FromStringAndSize=python35.PyBytes_FromStringAndSize
- PyBytes_Repr=python35.PyBytes_Repr
- PyBytes_Size=python35.PyBytes_Size
- PyBytes_Type=python35.PyBytes_Type DATA
- PyCFunction_Call=python35.PyCFunction_Call
- PyCFunction_ClearFreeList=python35.PyCFunction_ClearFreeList
- PyCFunction_GetFlags=python35.PyCFunction_GetFlags
- PyCFunction_GetFunction=python35.PyCFunction_GetFunction
- PyCFunction_GetSelf=python35.PyCFunction_GetSelf
- PyCFunction_New=python35.PyCFunction_New
- PyCFunction_NewEx=python35.PyCFunction_NewEx
- PyCFunction_Type=python35.PyCFunction_Type DATA
- PyCallIter_New=python35.PyCallIter_New
- PyCallIter_Type=python35.PyCallIter_Type DATA
- PyCallable_Check=python35.PyCallable_Check
- PyCapsule_GetContext=python35.PyCapsule_GetContext
- PyCapsule_GetDestructor=python35.PyCapsule_GetDestructor
- PyCapsule_GetName=python35.PyCapsule_GetName
- PyCapsule_GetPointer=python35.PyCapsule_GetPointer
- PyCapsule_Import=python35.PyCapsule_Import
- PyCapsule_IsValid=python35.PyCapsule_IsValid
- PyCapsule_New=python35.PyCapsule_New
- PyCapsule_SetContext=python35.PyCapsule_SetContext
- PyCapsule_SetDestructor=python35.PyCapsule_SetDestructor
- PyCapsule_SetName=python35.PyCapsule_SetName
- PyCapsule_SetPointer=python35.PyCapsule_SetPointer
- PyCapsule_Type=python35.PyCapsule_Type DATA
- PyClassMethodDescr_Type=python35.PyClassMethodDescr_Type DATA
- PyCodec_BackslashReplaceErrors=python35.PyCodec_BackslashReplaceErrors
- PyCodec_Decode=python35.PyCodec_Decode
- PyCodec_Decoder=python35.PyCodec_Decoder
- PyCodec_Encode=python35.PyCodec_Encode
- PyCodec_Encoder=python35.PyCodec_Encoder
- PyCodec_IgnoreErrors=python35.PyCodec_IgnoreErrors
- PyCodec_IncrementalDecoder=python35.PyCodec_IncrementalDecoder
- PyCodec_IncrementalEncoder=python35.PyCodec_IncrementalEncoder
- PyCodec_KnownEncoding=python35.PyCodec_KnownEncoding
- PyCodec_LookupError=python35.PyCodec_LookupError
- PyCodec_Register=python35.PyCodec_Register
- PyCodec_RegisterError=python35.PyCodec_RegisterError
- PyCodec_ReplaceErrors=python35.PyCodec_ReplaceErrors
- PyCodec_StreamReader=python35.PyCodec_StreamReader
- PyCodec_StreamWriter=python35.PyCodec_StreamWriter
- PyCodec_StrictErrors=python35.PyCodec_StrictErrors
- PyCodec_XMLCharRefReplaceErrors=python35.PyCodec_XMLCharRefReplaceErrors
- PyComplex_FromDoubles=python35.PyComplex_FromDoubles
- PyComplex_ImagAsDouble=python35.PyComplex_ImagAsDouble
- PyComplex_RealAsDouble=python35.PyComplex_RealAsDouble
- PyComplex_Type=python35.PyComplex_Type DATA
- PyDescr_NewClassMethod=python35.PyDescr_NewClassMethod
- PyDescr_NewGetSet=python35.PyDescr_NewGetSet
- PyDescr_NewMember=python35.PyDescr_NewMember
- PyDescr_NewMethod=python35.PyDescr_NewMethod
- PyDictItems_Type=python35.PyDictItems_Type DATA
- PyDictIterItem_Type=python35.PyDictIterItem_Type DATA
- PyDictIterKey_Type=python35.PyDictIterKey_Type DATA
- PyDictIterValue_Type=python35.PyDictIterValue_Type DATA
- PyDictKeys_Type=python35.PyDictKeys_Type DATA
- PyDictProxy_New=python35.PyDictProxy_New
- PyDictProxy_Type=python35.PyDictProxy_Type DATA
- PyDictValues_Type=python35.PyDictValues_Type DATA
- PyDict_Clear=python35.PyDict_Clear
- PyDict_Contains=python35.PyDict_Contains
- PyDict_Copy=python35.PyDict_Copy
- PyDict_DelItem=python35.PyDict_DelItem
- PyDict_DelItemString=python35.PyDict_DelItemString
- PyDict_GetItem=python35.PyDict_GetItem
- PyDict_GetItemString=python35.PyDict_GetItemString
- PyDict_GetItemWithError=python35.PyDict_GetItemWithError
- PyDict_Items=python35.PyDict_Items
- PyDict_Keys=python35.PyDict_Keys
- PyDict_Merge=python35.PyDict_Merge
- PyDict_MergeFromSeq2=python35.PyDict_MergeFromSeq2
- PyDict_New=python35.PyDict_New
- PyDict_Next=python35.PyDict_Next
- PyDict_SetItem=python35.PyDict_SetItem
- PyDict_SetItemString=python35.PyDict_SetItemString
- PyDict_Size=python35.PyDict_Size
- PyDict_Type=python35.PyDict_Type DATA
- PyDict_Update=python35.PyDict_Update
- PyDict_Values=python35.PyDict_Values
- PyEllipsis_Type=python35.PyEllipsis_Type DATA
- PyEnum_Type=python35.PyEnum_Type DATA
- PyErr_BadArgument=python35.PyErr_BadArgument
- PyErr_BadInternalCall=python35.PyErr_BadInternalCall
- PyErr_CheckSignals=python35.PyErr_CheckSignals
- PyErr_Clear=python35.PyErr_Clear
- PyErr_Display=python35.PyErr_Display
- PyErr_ExceptionMatches=python35.PyErr_ExceptionMatches
- PyErr_Fetch=python35.PyErr_Fetch
- PyErr_Format=python35.PyErr_Format
- PyErr_FormatV=python35.PyErr_FormatV
- PyErr_GivenExceptionMatches=python35.PyErr_GivenExceptionMatches
- PyErr_NewException=python35.PyErr_NewException
- PyErr_NewExceptionWithDoc=python35.PyErr_NewExceptionWithDoc
- PyErr_NoMemory=python35.PyErr_NoMemory
- PyErr_NormalizeException=python35.PyErr_NormalizeException
- PyErr_Occurred=python35.PyErr_Occurred
- PyErr_Print=python35.PyErr_Print
- PyErr_PrintEx=python35.PyErr_PrintEx
- PyErr_ProgramText=python35.PyErr_ProgramText
- PyErr_Restore=python35.PyErr_Restore
- PyErr_SetFromErrno=python35.PyErr_SetFromErrno
- PyErr_SetFromErrnoWithFilename=python35.PyErr_SetFromErrnoWithFilename
- PyErr_SetFromErrnoWithFilenameObject=python35.PyErr_SetFromErrnoWithFilenameObject
- PyErr_SetInterrupt=python35.PyErr_SetInterrupt
- PyErr_SetNone=python35.PyErr_SetNone
- PyErr_SetObject=python35.PyErr_SetObject
- PyErr_SetString=python35.PyErr_SetString
- PyErr_SyntaxLocation=python35.PyErr_SyntaxLocation
- PyErr_WarnEx=python35.PyErr_WarnEx
- PyErr_WarnExplicit=python35.PyErr_WarnExplicit
- PyErr_WarnFormat=python35.PyErr_WarnFormat
- PyErr_WriteUnraisable=python35.PyErr_WriteUnraisable
- PyEval_AcquireLock=python35.PyEval_AcquireLock
- PyEval_AcquireThread=python35.PyEval_AcquireThread
- PyEval_CallFunction=python35.PyEval_CallFunction
- PyEval_CallMethod=python35.PyEval_CallMethod
- PyEval_CallObjectWithKeywords=python35.PyEval_CallObjectWithKeywords
- PyEval_EvalCode=python35.PyEval_EvalCode
- PyEval_EvalCodeEx=python35.PyEval_EvalCodeEx
- PyEval_EvalFrame=python35.PyEval_EvalFrame
- PyEval_EvalFrameEx=python35.PyEval_EvalFrameEx
- PyEval_GetBuiltins=python35.PyEval_GetBuiltins
- PyEval_GetCallStats=python35.PyEval_GetCallStats
- PyEval_GetFrame=python35.PyEval_GetFrame
- PyEval_GetFuncDesc=python35.PyEval_GetFuncDesc
- PyEval_GetFuncName=python35.PyEval_GetFuncName
- PyEval_GetGlobals=python35.PyEval_GetGlobals
- PyEval_GetLocals=python35.PyEval_GetLocals
- PyEval_InitThreads=python35.PyEval_InitThreads
- PyEval_ReInitThreads=python35.PyEval_ReInitThreads
- PyEval_ReleaseLock=python35.PyEval_ReleaseLock
- PyEval_ReleaseThread=python35.PyEval_ReleaseThread
- PyEval_RestoreThread=python35.PyEval_RestoreThread
- PyEval_SaveThread=python35.PyEval_SaveThread
- PyEval_ThreadsInitialized=python35.PyEval_ThreadsInitialized
- PyExc_ArithmeticError=python35.PyExc_ArithmeticError DATA
- PyExc_AssertionError=python35.PyExc_AssertionError DATA
- PyExc_AttributeError=python35.PyExc_AttributeError DATA
- PyExc_BaseException=python35.PyExc_BaseException DATA
- PyExc_BufferError=python35.PyExc_BufferError DATA
- PyExc_BytesWarning=python35.PyExc_BytesWarning DATA
- PyExc_DeprecationWarning=python35.PyExc_DeprecationWarning DATA
- PyExc_EOFError=python35.PyExc_EOFError DATA
- PyExc_EnvironmentError=python35.PyExc_EnvironmentError DATA
- PyExc_Exception=python35.PyExc_Exception DATA
- PyExc_FloatingPointError=python35.PyExc_FloatingPointError DATA
- PyExc_FutureWarning=python35.PyExc_FutureWarning DATA
- PyExc_GeneratorExit=python35.PyExc_GeneratorExit DATA
- PyExc_IOError=python35.PyExc_IOError DATA
- PyExc_ImportError=python35.PyExc_ImportError DATA
- PyExc_ImportWarning=python35.PyExc_ImportWarning DATA
- PyExc_IndentationError=python35.PyExc_IndentationError DATA
- PyExc_IndexError=python35.PyExc_IndexError DATA
- PyExc_KeyError=python35.PyExc_KeyError DATA
- PyExc_KeyboardInterrupt=python35.PyExc_KeyboardInterrupt DATA
- PyExc_LookupError=python35.PyExc_LookupError DATA
- PyExc_MemoryError=python35.PyExc_MemoryError DATA
- PyExc_MemoryErrorInst=python35.PyExc_MemoryErrorInst DATA
- PyExc_NameError=python35.PyExc_NameError DATA
- PyExc_NotImplementedError=python35.PyExc_NotImplementedError DATA
- PyExc_OSError=python35.PyExc_OSError DATA
- PyExc_OverflowError=python35.PyExc_OverflowError DATA
- PyExc_PendingDeprecationWarning=python35.PyExc_PendingDeprecationWarning DATA
- PyExc_RecursionErrorInst=python35.PyExc_RecursionErrorInst DATA
- PyExc_ReferenceError=python35.PyExc_ReferenceError DATA
- PyExc_RuntimeError=python35.PyExc_RuntimeError DATA
- PyExc_RuntimeWarning=python35.PyExc_RuntimeWarning DATA
- PyExc_StopIteration=python35.PyExc_StopIteration DATA
- PyExc_SyntaxError=python35.PyExc_SyntaxError DATA
- PyExc_SyntaxWarning=python35.PyExc_SyntaxWarning DATA
- PyExc_SystemError=python35.PyExc_SystemError DATA
- PyExc_SystemExit=python35.PyExc_SystemExit DATA
- PyExc_TabError=python35.PyExc_TabError DATA
- PyExc_TypeError=python35.PyExc_TypeError DATA
- PyExc_UnboundLocalError=python35.PyExc_UnboundLocalError DATA
- PyExc_UnicodeDecodeError=python35.PyExc_UnicodeDecodeError DATA
- PyExc_UnicodeEncodeError=python35.PyExc_UnicodeEncodeError DATA
- PyExc_UnicodeError=python35.PyExc_UnicodeError DATA
- PyExc_UnicodeTranslateError=python35.PyExc_UnicodeTranslateError DATA
- PyExc_UnicodeWarning=python35.PyExc_UnicodeWarning DATA
- PyExc_UserWarning=python35.PyExc_UserWarning DATA
- PyExc_ValueError=python35.PyExc_ValueError DATA
- PyExc_Warning=python35.PyExc_Warning DATA
- PyExc_ZeroDivisionError=python35.PyExc_ZeroDivisionError DATA
- PyException_GetCause=python35.PyException_GetCause
- PyException_GetContext=python35.PyException_GetContext
- PyException_GetTraceback=python35.PyException_GetTraceback
- PyException_SetCause=python35.PyException_SetCause
- PyException_SetContext=python35.PyException_SetContext
- PyException_SetTraceback=python35.PyException_SetTraceback
- PyFile_FromFd=python35.PyFile_FromFd
- PyFile_GetLine=python35.PyFile_GetLine
- PyFile_WriteObject=python35.PyFile_WriteObject
- PyFile_WriteString=python35.PyFile_WriteString
- PyFilter_Type=python35.PyFilter_Type DATA
- PyFloat_AsDouble=python35.PyFloat_AsDouble
- PyFloat_FromDouble=python35.PyFloat_FromDouble
- PyFloat_FromString=python35.PyFloat_FromString
- PyFloat_GetInfo=python35.PyFloat_GetInfo
- PyFloat_GetMax=python35.PyFloat_GetMax
- PyFloat_GetMin=python35.PyFloat_GetMin
- PyFloat_Type=python35.PyFloat_Type DATA
- PyFrozenSet_New=python35.PyFrozenSet_New
- PyFrozenSet_Type=python35.PyFrozenSet_Type DATA
- PyGC_Collect=python35.PyGC_Collect
- PyGILState_Ensure=python35.PyGILState_Ensure
- PyGILState_GetThisThreadState=python35.PyGILState_GetThisThreadState
- PyGILState_Release=python35.PyGILState_Release
- PyGetSetDescr_Type=python35.PyGetSetDescr_Type DATA
- PyImport_AddModule=python35.PyImport_AddModule
- PyImport_AppendInittab=python35.PyImport_AppendInittab
- PyImport_Cleanup=python35.PyImport_Cleanup
- PyImport_ExecCodeModule=python35.PyImport_ExecCodeModule
- PyImport_ExecCodeModuleEx=python35.PyImport_ExecCodeModuleEx
- PyImport_ExecCodeModuleWithPathnames=python35.PyImport_ExecCodeModuleWithPathnames
- PyImport_GetImporter=python35.PyImport_GetImporter
- PyImport_GetMagicNumber=python35.PyImport_GetMagicNumber
- PyImport_GetMagicTag=python35.PyImport_GetMagicTag
- PyImport_GetModuleDict=python35.PyImport_GetModuleDict
- PyImport_Import=python35.PyImport_Import
- PyImport_ImportFrozenModule=python35.PyImport_ImportFrozenModule
- PyImport_ImportModule=python35.PyImport_ImportModule
- PyImport_ImportModuleLevel=python35.PyImport_ImportModuleLevel
- PyImport_ImportModuleNoBlock=python35.PyImport_ImportModuleNoBlock
- PyImport_ReloadModule=python35.PyImport_ReloadModule
- PyInterpreterState_Clear=python35.PyInterpreterState_Clear
- PyInterpreterState_Delete=python35.PyInterpreterState_Delete
- PyInterpreterState_New=python35.PyInterpreterState_New
- PyIter_Next=python35.PyIter_Next
- PyListIter_Type=python35.PyListIter_Type DATA
- PyListRevIter_Type=python35.PyListRevIter_Type DATA
- PyList_Append=python35.PyList_Append
- PyList_AsTuple=python35.PyList_AsTuple
- PyList_GetItem=python35.PyList_GetItem
- PyList_GetSlice=python35.PyList_GetSlice
- PyList_Insert=python35.PyList_Insert
- PyList_New=python35.PyList_New
- PyList_Reverse=python35.PyList_Reverse
- PyList_SetItem=python35.PyList_SetItem
- PyList_SetSlice=python35.PyList_SetSlice
- PyList_Size=python35.PyList_Size
- PyList_Sort=python35.PyList_Sort
- PyList_Type=python35.PyList_Type DATA
- PyLongRangeIter_Type=python35.PyLongRangeIter_Type DATA
- PyLong_AsDouble=python35.PyLong_AsDouble
- PyLong_AsLong=python35.PyLong_AsLong
- PyLong_AsLongAndOverflow=python35.PyLong_AsLongAndOverflow
- PyLong_AsLongLong=python35.PyLong_AsLongLong
- PyLong_AsLongLongAndOverflow=python35.PyLong_AsLongLongAndOverflow
- PyLong_AsSize_t=python35.PyLong_AsSize_t
- PyLong_AsSsize_t=python35.PyLong_AsSsize_t
- PyLong_AsUnsignedLong=python35.PyLong_AsUnsignedLong
- PyLong_AsUnsignedLongLong=python35.PyLong_AsUnsignedLongLong
- PyLong_AsUnsignedLongLongMask=python35.PyLong_AsUnsignedLongLongMask
- PyLong_AsUnsignedLongMask=python35.PyLong_AsUnsignedLongMask
- PyLong_AsVoidPtr=python35.PyLong_AsVoidPtr
- PyLong_FromDouble=python35.PyLong_FromDouble
- PyLong_FromLong=python35.PyLong_FromLong
- PyLong_FromLongLong=python35.PyLong_FromLongLong
- PyLong_FromSize_t=python35.PyLong_FromSize_t
- PyLong_FromSsize_t=python35.PyLong_FromSsize_t
- PyLong_FromString=python35.PyLong_FromString
- PyLong_FromUnsignedLong=python35.PyLong_FromUnsignedLong
- PyLong_FromUnsignedLongLong=python35.PyLong_FromUnsignedLongLong
- PyLong_FromVoidPtr=python35.PyLong_FromVoidPtr
- PyLong_GetInfo=python35.PyLong_GetInfo
- PyLong_Type=python35.PyLong_Type DATA
- PyMap_Type=python35.PyMap_Type DATA
- PyMapping_Check=python35.PyMapping_Check
- PyMapping_GetItemString=python35.PyMapping_GetItemString
- PyMapping_HasKey=python35.PyMapping_HasKey
- PyMapping_HasKeyString=python35.PyMapping_HasKeyString
- PyMapping_Items=python35.PyMapping_Items
- PyMapping_Keys=python35.PyMapping_Keys
- PyMapping_Length=python35.PyMapping_Length
- PyMapping_SetItemString=python35.PyMapping_SetItemString
- PyMapping_Size=python35.PyMapping_Size
- PyMapping_Values=python35.PyMapping_Values
- PyMem_Free=python35.PyMem_Free
- PyMem_Malloc=python35.PyMem_Malloc
- PyMem_Realloc=python35.PyMem_Realloc
- PyMemberDescr_Type=python35.PyMemberDescr_Type DATA
- PyMemoryView_FromObject=python35.PyMemoryView_FromObject
- PyMemoryView_GetContiguous=python35.PyMemoryView_GetContiguous
- PyMemoryView_Type=python35.PyMemoryView_Type DATA
- PyMethodDescr_Type=python35.PyMethodDescr_Type DATA
- PyModule_AddIntConstant=python35.PyModule_AddIntConstant
- PyModule_AddObject=python35.PyModule_AddObject
- PyModule_AddStringConstant=python35.PyModule_AddStringConstant
- PyModule_Create2=python35.PyModule_Create2
- PyModule_GetDef=python35.PyModule_GetDef
- PyModule_GetDict=python35.PyModule_GetDict
- PyModule_GetFilename=python35.PyModule_GetFilename
- PyModule_GetFilenameObject=python35.PyModule_GetFilenameObject
- PyModule_GetName=python35.PyModule_GetName
- PyModule_GetState=python35.PyModule_GetState
- PyModule_New=python35.PyModule_New
- PyModule_Type=python35.PyModule_Type DATA
- PyModuleDef_Init=python35.PyModuleDef_Init
- PyModuleDef_Type=python35.PyModuleDef_Type DATA
- PyNullImporter_Type=python35.PyNullImporter_Type DATA
- PyNumber_Absolute=python35.PyNumber_Absolute
- PyNumber_Add=python35.PyNumber_Add
- PyNumber_And=python35.PyNumber_And
- PyNumber_AsSsize_t=python35.PyNumber_AsSsize_t
- PyNumber_Check=python35.PyNumber_Check
- PyNumber_Divmod=python35.PyNumber_Divmod
- PyNumber_Float=python35.PyNumber_Float
- PyNumber_FloorDivide=python35.PyNumber_FloorDivide
- PyNumber_InPlaceAdd=python35.PyNumber_InPlaceAdd
- PyNumber_InPlaceAnd=python35.PyNumber_InPlaceAnd
- PyNumber_InPlaceFloorDivide=python35.PyNumber_InPlaceFloorDivide
- PyNumber_InPlaceLshift=python35.PyNumber_InPlaceLshift
- PyNumber_InPlaceMultiply=python35.PyNumber_InPlaceMultiply
- PyNumber_InPlaceOr=python35.PyNumber_InPlaceOr
- PyNumber_InPlacePower=python35.PyNumber_InPlacePower
- PyNumber_InPlaceRemainder=python35.PyNumber_InPlaceRemainder
- PyNumber_InPlaceRshift=python35.PyNumber_InPlaceRshift
- PyNumber_InPlaceSubtract=python35.PyNumber_InPlaceSubtract
- PyNumber_InPlaceTrueDivide=python35.PyNumber_InPlaceTrueDivide
- PyNumber_InPlaceXor=python35.PyNumber_InPlaceXor
- PyNumber_Index=python35.PyNumber_Index
- PyNumber_Invert=python35.PyNumber_Invert
- PyNumber_Long=python35.PyNumber_Long
- PyNumber_Lshift=python35.PyNumber_Lshift
- PyNumber_Multiply=python35.PyNumber_Multiply
- PyNumber_Negative=python35.PyNumber_Negative
- PyNumber_Or=python35.PyNumber_Or
- PyNumber_Positive=python35.PyNumber_Positive
- PyNumber_Power=python35.PyNumber_Power
- PyNumber_Remainder=python35.PyNumber_Remainder
- PyNumber_Rshift=python35.PyNumber_Rshift
- PyNumber_Subtract=python35.PyNumber_Subtract
- PyNumber_ToBase=python35.PyNumber_ToBase
- PyNumber_TrueDivide=python35.PyNumber_TrueDivide
- PyNumber_Xor=python35.PyNumber_Xor
- PyOS_AfterFork=python35.PyOS_AfterFork
- PyOS_InitInterrupts=python35.PyOS_InitInterrupts
- PyOS_InputHook=python35.PyOS_InputHook DATA
- PyOS_InterruptOccurred=python35.PyOS_InterruptOccurred
- PyOS_ReadlineFunctionPointer=python35.PyOS_ReadlineFunctionPointer DATA
- PyOS_double_to_string=python35.PyOS_double_to_string
- PyOS_getsig=python35.PyOS_getsig
- PyOS_mystricmp=python35.PyOS_mystricmp
- PyOS_mystrnicmp=python35.PyOS_mystrnicmp
- PyOS_setsig=python35.PyOS_setsig
- PyOS_snprintf=python35.PyOS_snprintf
- PyOS_string_to_double=python35.PyOS_string_to_double
- PyOS_strtol=python35.PyOS_strtol
- PyOS_strtoul=python35.PyOS_strtoul
- PyOS_vsnprintf=python35.PyOS_vsnprintf
- PyObject_ASCII=python35.PyObject_ASCII
- PyObject_AsCharBuffer=python35.PyObject_AsCharBuffer
- PyObject_AsFileDescriptor=python35.PyObject_AsFileDescriptor
- PyObject_AsReadBuffer=python35.PyObject_AsReadBuffer
- PyObject_AsWriteBuffer=python35.PyObject_AsWriteBuffer
- PyObject_Bytes=python35.PyObject_Bytes
- PyObject_Call=python35.PyObject_Call
- PyObject_CallFunction=python35.PyObject_CallFunction
- PyObject_CallFunctionObjArgs=python35.PyObject_CallFunctionObjArgs
- PyObject_CallMethod=python35.PyObject_CallMethod
- PyObject_CallMethodObjArgs=python35.PyObject_CallMethodObjArgs
- PyObject_CallObject=python35.PyObject_CallObject
- PyObject_CheckReadBuffer=python35.PyObject_CheckReadBuffer
- PyObject_ClearWeakRefs=python35.PyObject_ClearWeakRefs
- PyObject_DelItem=python35.PyObject_DelItem
- PyObject_DelItemString=python35.PyObject_DelItemString
- PyObject_Dir=python35.PyObject_Dir
- PyObject_Format=python35.PyObject_Format
- PyObject_Free=python35.PyObject_Free
- PyObject_GC_Del=python35.PyObject_GC_Del
- PyObject_GC_Track=python35.PyObject_GC_Track
- PyObject_GC_UnTrack=python35.PyObject_GC_UnTrack
- PyObject_GenericGetAttr=python35.PyObject_GenericGetAttr
- PyObject_GenericSetAttr=python35.PyObject_GenericSetAttr
- PyObject_GetAttr=python35.PyObject_GetAttr
- PyObject_GetAttrString=python35.PyObject_GetAttrString
- PyObject_GetItem=python35.PyObject_GetItem
- PyObject_GetIter=python35.PyObject_GetIter
- PyObject_HasAttr=python35.PyObject_HasAttr
- PyObject_HasAttrString=python35.PyObject_HasAttrString
- PyObject_Hash=python35.PyObject_Hash
- PyObject_HashNotImplemented=python35.PyObject_HashNotImplemented
- PyObject_Init=python35.PyObject_Init
- PyObject_InitVar=python35.PyObject_InitVar
- PyObject_IsInstance=python35.PyObject_IsInstance
- PyObject_IsSubclass=python35.PyObject_IsSubclass
- PyObject_IsTrue=python35.PyObject_IsTrue
- PyObject_Length=python35.PyObject_Length
- PyObject_Malloc=python35.PyObject_Malloc
- PyObject_Not=python35.PyObject_Not
- PyObject_Realloc=python35.PyObject_Realloc
- PyObject_Repr=python35.PyObject_Repr
- PyObject_RichCompare=python35.PyObject_RichCompare
- PyObject_RichCompareBool=python35.PyObject_RichCompareBool
- PyObject_SelfIter=python35.PyObject_SelfIter
- PyObject_SetAttr=python35.PyObject_SetAttr
- PyObject_SetAttrString=python35.PyObject_SetAttrString
- PyObject_SetItem=python35.PyObject_SetItem
- PyObject_Size=python35.PyObject_Size
- PyObject_Str=python35.PyObject_Str
- PyObject_Type=python35.PyObject_Type DATA
- PyODict_DelItem=python35.PyODict_DelItem
- PyODict_New=python35.PyODict_New
- PyODict_SetItem=python35.PyODict_SetItem
- PyODict_Type=python35.PyODict_Type DATA
- PyODictItems_Type=python35.PyODictItems_Type DATA
- PyODictIter_Type=python35.PyODictIter_Type DATA
- PyODictKeys_Type=python35.PyODictKeys_Type DATA
- PyODictValues_Type=python35.PyODictValues_Type DATA
- PyParser_SimpleParseFileFlags=python35.PyParser_SimpleParseFileFlags
- PyParser_SimpleParseStringFlags=python35.PyParser_SimpleParseStringFlags
- PyProperty_Type=python35.PyProperty_Type DATA
- PyRangeIter_Type=python35.PyRangeIter_Type DATA
- PyRange_Type=python35.PyRange_Type DATA
- PyReversed_Type=python35.PyReversed_Type DATA
- PySeqIter_New=python35.PySeqIter_New
- PySeqIter_Type=python35.PySeqIter_Type DATA
- PySequence_Check=python35.PySequence_Check
- PySequence_Concat=python35.PySequence_Concat
- PySequence_Contains=python35.PySequence_Contains
- PySequence_Count=python35.PySequence_Count
- PySequence_DelItem=python35.PySequence_DelItem
- PySequence_DelSlice=python35.PySequence_DelSlice
- PySequence_Fast=python35.PySequence_Fast
- PySequence_GetItem=python35.PySequence_GetItem
- PySequence_GetSlice=python35.PySequence_GetSlice
- PySequence_In=python35.PySequence_In
- PySequence_InPlaceConcat=python35.PySequence_InPlaceConcat
- PySequence_InPlaceRepeat=python35.PySequence_InPlaceRepeat
- PySequence_Index=python35.PySequence_Index
- PySequence_Length=python35.PySequence_Length
- PySequence_List=python35.PySequence_List
- PySequence_Repeat=python35.PySequence_Repeat
- PySequence_SetItem=python35.PySequence_SetItem
- PySequence_SetSlice=python35.PySequence_SetSlice
- PySequence_Size=python35.PySequence_Size
- PySequence_Tuple=python35.PySequence_Tuple
- PySetIter_Type=python35.PySetIter_Type DATA
- PySet_Add=python35.PySet_Add
- PySet_Clear=python35.PySet_Clear
- PySet_Contains=python35.PySet_Contains
- PySet_Discard=python35.PySet_Discard
- PySet_New=python35.PySet_New
- PySet_Pop=python35.PySet_Pop
- PySet_Size=python35.PySet_Size
- PySet_Type=python35.PySet_Type DATA
- PySlice_GetIndices=python35.PySlice_GetIndices
- PySlice_GetIndicesEx=python35.PySlice_GetIndicesEx
- PySlice_New=python35.PySlice_New
- PySlice_Type=python35.PySlice_Type DATA
- PySortWrapper_Type=python35.PySortWrapper_Type DATA
- PyState_FindModule=python35.PyState_FindModule
- PyState_AddModule=python35.PyState_AddModule
- PyState_RemoveModule=python35.PyState_RemoveModule
- PyStructSequence_GetItem=python35.PyStructSequence_GetItem
- PyStructSequence_New=python35.PyStructSequence_New
- PyStructSequence_NewType=python35.PyStructSequence_NewType
- PyStructSequence_SetItem=python35.PyStructSequence_SetItem
- PySuper_Type=python35.PySuper_Type DATA
- PySys_AddWarnOption=python35.PySys_AddWarnOption
- PySys_AddWarnOptionUnicode=python35.PySys_AddWarnOptionUnicode
- PySys_FormatStderr=python35.PySys_FormatStderr
- PySys_FormatStdout=python35.PySys_FormatStdout
- PySys_GetObject=python35.PySys_GetObject
- PySys_HasWarnOptions=python35.PySys_HasWarnOptions
- PySys_ResetWarnOptions=python35.PySys_ResetWarnOptions
- PySys_SetArgv=python35.PySys_SetArgv
- PySys_SetArgvEx=python35.PySys_SetArgvEx
- PySys_SetObject=python35.PySys_SetObject
- PySys_SetPath=python35.PySys_SetPath
- PySys_WriteStderr=python35.PySys_WriteStderr
- PySys_WriteStdout=python35.PySys_WriteStdout
- PyThreadState_Clear=python35.PyThreadState_Clear
- PyThreadState_Delete=python35.PyThreadState_Delete
- PyThreadState_DeleteCurrent=python35.PyThreadState_DeleteCurrent
- PyThreadState_Get=python35.PyThreadState_Get
- PyThreadState_GetDict=python35.PyThreadState_GetDict
- PyThreadState_New=python35.PyThreadState_New
- PyThreadState_SetAsyncExc=python35.PyThreadState_SetAsyncExc
- PyThreadState_Swap=python35.PyThreadState_Swap
- PyTraceBack_Here=python35.PyTraceBack_Here
- PyTraceBack_Print=python35.PyTraceBack_Print
- PyTraceBack_Type=python35.PyTraceBack_Type DATA
- PyTupleIter_Type=python35.PyTupleIter_Type DATA
- PyTuple_ClearFreeList=python35.PyTuple_ClearFreeList
- PyTuple_GetItem=python35.PyTuple_GetItem
- PyTuple_GetSlice=python35.PyTuple_GetSlice
- PyTuple_New=python35.PyTuple_New
- PyTuple_Pack=python35.PyTuple_Pack
- PyTuple_SetItem=python35.PyTuple_SetItem
- PyTuple_Size=python35.PyTuple_Size
- PyTuple_Type=python35.PyTuple_Type DATA
- PyType_ClearCache=python35.PyType_ClearCache
- PyType_FromSpec=python35.PyType_FromSpec
- PyType_FromSpecWithBases=python35.PyType_FromSpecWithBases
- PyType_GenericAlloc=python35.PyType_GenericAlloc
- PyType_GenericNew=python35.PyType_GenericNew
- PyType_GetFlags=python35.PyType_GetFlags
- PyType_GetSlot=python35.PyType_GetSlot
- PyType_IsSubtype=python35.PyType_IsSubtype
- PyType_Modified=python35.PyType_Modified
- PyType_Ready=python35.PyType_Ready
- PyType_Type=python35.PyType_Type DATA
- PyUnicodeDecodeError_Create=python35.PyUnicodeDecodeError_Create
- PyUnicodeDecodeError_GetEncoding=python35.PyUnicodeDecodeError_GetEncoding
- PyUnicodeDecodeError_GetEnd=python35.PyUnicodeDecodeError_GetEnd
- PyUnicodeDecodeError_GetObject=python35.PyUnicodeDecodeError_GetObject
- PyUnicodeDecodeError_GetReason=python35.PyUnicodeDecodeError_GetReason
- PyUnicodeDecodeError_GetStart=python35.PyUnicodeDecodeError_GetStart
- PyUnicodeDecodeError_SetEnd=python35.PyUnicodeDecodeError_SetEnd
- PyUnicodeDecodeError_SetReason=python35.PyUnicodeDecodeError_SetReason
- PyUnicodeDecodeError_SetStart=python35.PyUnicodeDecodeError_SetStart
- PyUnicodeEncodeError_GetEncoding=python35.PyUnicodeEncodeError_GetEncoding
- PyUnicodeEncodeError_GetEnd=python35.PyUnicodeEncodeError_GetEnd
- PyUnicodeEncodeError_GetObject=python35.PyUnicodeEncodeError_GetObject
- PyUnicodeEncodeError_GetReason=python35.PyUnicodeEncodeError_GetReason
- PyUnicodeEncodeError_GetStart=python35.PyUnicodeEncodeError_GetStart
- PyUnicodeEncodeError_SetEnd=python35.PyUnicodeEncodeError_SetEnd
- PyUnicodeEncodeError_SetReason=python35.PyUnicodeEncodeError_SetReason
- PyUnicodeEncodeError_SetStart=python35.PyUnicodeEncodeError_SetStart
- PyUnicodeIter_Type=python35.PyUnicodeIter_Type DATA
- PyUnicodeTranslateError_GetEnd=python35.PyUnicodeTranslateError_GetEnd
- PyUnicodeTranslateError_GetObject=python35.PyUnicodeTranslateError_GetObject
- PyUnicodeTranslateError_GetReason=python35.PyUnicodeTranslateError_GetReason
- PyUnicodeTranslateError_GetStart=python35.PyUnicodeTranslateError_GetStart
- PyUnicodeTranslateError_SetEnd=python35.PyUnicodeTranslateError_SetEnd
- PyUnicodeTranslateError_SetReason=python35.PyUnicodeTranslateError_SetReason
- PyUnicodeTranslateError_SetStart=python35.PyUnicodeTranslateError_SetStart
- PyUnicode_Append=python35.PyUnicode_Append
- PyUnicode_AppendAndDel=python35.PyUnicode_AppendAndDel
- PyUnicode_AsASCIIString=python35.PyUnicode_AsASCIIString
- PyUnicode_AsCharmapString=python35.PyUnicode_AsCharmapString
- PyUnicode_AsDecodedObject=python35.PyUnicode_AsDecodedObject
- PyUnicode_AsDecodedUnicode=python35.PyUnicode_AsDecodedUnicode
- PyUnicode_AsEncodedObject=python35.PyUnicode_AsEncodedObject
- PyUnicode_AsEncodedString=python35.PyUnicode_AsEncodedString
- PyUnicode_AsEncodedUnicode=python35.PyUnicode_AsEncodedUnicode
- PyUnicode_AsLatin1String=python35.PyUnicode_AsLatin1String
- PyUnicode_AsRawUnicodeEscapeString=python35.PyUnicode_AsRawUnicodeEscapeString
- PyUnicode_AsUTF16String=python35.PyUnicode_AsUTF16String
- PyUnicode_AsUTF32String=python35.PyUnicode_AsUTF32String
- PyUnicode_AsUTF8String=python35.PyUnicode_AsUTF8String
- PyUnicode_AsUnicodeEscapeString=python35.PyUnicode_AsUnicodeEscapeString
- PyUnicode_AsWideChar=python35.PyUnicode_AsWideChar
- PyUnicode_ClearFreelist=python35.PyUnicode_ClearFreelist
- PyUnicode_Compare=python35.PyUnicode_Compare
- PyUnicode_Concat=python35.PyUnicode_Concat
- PyUnicode_Contains=python35.PyUnicode_Contains
- PyUnicode_Count=python35.PyUnicode_Count
- PyUnicode_Decode=python35.PyUnicode_Decode
- PyUnicode_DecodeASCII=python35.PyUnicode_DecodeASCII
- PyUnicode_DecodeCharmap=python35.PyUnicode_DecodeCharmap
- PyUnicode_DecodeFSDefault=python35.PyUnicode_DecodeFSDefault
- PyUnicode_DecodeFSDefaultAndSize=python35.PyUnicode_DecodeFSDefaultAndSize
- PyUnicode_DecodeLatin1=python35.PyUnicode_DecodeLatin1
- PyUnicode_DecodeRawUnicodeEscape=python35.PyUnicode_DecodeRawUnicodeEscape
- PyUnicode_DecodeUTF16=python35.PyUnicode_DecodeUTF16
- PyUnicode_DecodeUTF16Stateful=python35.PyUnicode_DecodeUTF16Stateful
- PyUnicode_DecodeUTF32=python35.PyUnicode_DecodeUTF32
- PyUnicode_DecodeUTF32Stateful=python35.PyUnicode_DecodeUTF32Stateful
- PyUnicode_DecodeUTF8=python35.PyUnicode_DecodeUTF8
- PyUnicode_DecodeUTF8Stateful=python35.PyUnicode_DecodeUTF8Stateful
- PyUnicode_DecodeUnicodeEscape=python35.PyUnicode_DecodeUnicodeEscape
- PyUnicode_FSConverter=python35.PyUnicode_FSConverter
- PyUnicode_FSDecoder=python35.PyUnicode_FSDecoder
- PyUnicode_Find=python35.PyUnicode_Find
- PyUnicode_Format=python35.PyUnicode_Format
- PyUnicode_FromEncodedObject=python35.PyUnicode_FromEncodedObject
- PyUnicode_FromFormat=python35.PyUnicode_FromFormat
- PyUnicode_FromFormatV=python35.PyUnicode_FromFormatV
- PyUnicode_FromObject=python35.PyUnicode_FromObject
- PyUnicode_FromOrdinal=python35.PyUnicode_FromOrdinal
- PyUnicode_FromString=python35.PyUnicode_FromString
- PyUnicode_FromStringAndSize=python35.PyUnicode_FromStringAndSize
- PyUnicode_FromWideChar=python35.PyUnicode_FromWideChar
- PyUnicode_GetDefaultEncoding=python35.PyUnicode_GetDefaultEncoding
- PyUnicode_GetSize=python35.PyUnicode_GetSize
- PyUnicode_IsIdentifier=python35.PyUnicode_IsIdentifier
- PyUnicode_Join=python35.PyUnicode_Join
- PyUnicode_Partition=python35.PyUnicode_Partition
- PyUnicode_RPartition=python35.PyUnicode_RPartition
- PyUnicode_RSplit=python35.PyUnicode_RSplit
- PyUnicode_Replace=python35.PyUnicode_Replace
- PyUnicode_Resize=python35.PyUnicode_Resize
- PyUnicode_RichCompare=python35.PyUnicode_RichCompare
- PyUnicode_SetDefaultEncoding=python35.PyUnicode_SetDefaultEncoding
- PyUnicode_Split=python35.PyUnicode_Split
- PyUnicode_Splitlines=python35.PyUnicode_Splitlines
- PyUnicode_Tailmatch=python35.PyUnicode_Tailmatch
- PyUnicode_Translate=python35.PyUnicode_Translate
- PyUnicode_BuildEncodingMap=python35.PyUnicode_BuildEncodingMap
- PyUnicode_CompareWithASCIIString=python35.PyUnicode_CompareWithASCIIString
- PyUnicode_DecodeUTF7=python35.PyUnicode_DecodeUTF7
- PyUnicode_DecodeUTF7Stateful=python35.PyUnicode_DecodeUTF7Stateful
- PyUnicode_EncodeFSDefault=python35.PyUnicode_EncodeFSDefault
- PyUnicode_InternFromString=python35.PyUnicode_InternFromString
- PyUnicode_InternImmortal=python35.PyUnicode_InternImmortal
- PyUnicode_InternInPlace=python35.PyUnicode_InternInPlace
- PyUnicode_Type=python35.PyUnicode_Type DATA
- PyWeakref_GetObject=python35.PyWeakref_GetObject DATA
- PyWeakref_NewProxy=python35.PyWeakref_NewProxy
- PyWeakref_NewRef=python35.PyWeakref_NewRef
- PyWrapperDescr_Type=python35.PyWrapperDescr_Type DATA
- PyWrapper_New=python35.PyWrapper_New
- PyZip_Type=python35.PyZip_Type DATA
- Py_AddPendingCall=python35.Py_AddPendingCall
- Py_AtExit=python35.Py_AtExit
- Py_BuildValue=python35.Py_BuildValue
- Py_CompileString=python35.Py_CompileString
- Py_DecRef=python35.Py_DecRef
- Py_EndInterpreter=python35.Py_EndInterpreter
- Py_Exit=python35.Py_Exit
- Py_FatalError=python35.Py_FatalError
- Py_FileSystemDefaultEncoding=python35.Py_FileSystemDefaultEncoding DATA
- Py_Finalize=python35.Py_Finalize
- Py_GetBuildInfo=python35.Py_GetBuildInfo
- Py_GetCompiler=python35.Py_GetCompiler
- Py_GetCopyright=python35.Py_GetCopyright
- Py_GetExecPrefix=python35.Py_GetExecPrefix
- Py_GetPath=python35.Py_GetPath
- Py_GetPlatform=python35.Py_GetPlatform
- Py_GetPrefix=python35.Py_GetPrefix
- Py_GetProgramFullPath=python35.Py_GetProgramFullPath
- Py_GetProgramName=python35.Py_GetProgramName
- Py_GetPythonHome=python35.Py_GetPythonHome
- Py_GetRecursionLimit=python35.Py_GetRecursionLimit
- Py_GetVersion=python35.Py_GetVersion
- Py_HasFileSystemDefaultEncoding=python35.Py_HasFileSystemDefaultEncoding DATA
- Py_IncRef=python35.Py_IncRef
- Py_Initialize=python35.Py_Initialize
- Py_InitializeEx=python35.Py_InitializeEx
- Py_IsInitialized=python35.Py_IsInitialized
- Py_Main=python35.Py_Main
- Py_MakePendingCalls=python35.Py_MakePendingCalls
- Py_NewInterpreter=python35.Py_NewInterpreter
- Py_ReprEnter=python35.Py_ReprEnter
- Py_ReprLeave=python35.Py_ReprLeave
- Py_SetProgramName=python35.Py_SetProgramName
- Py_SetPythonHome=python35.Py_SetPythonHome
- Py_SetRecursionLimit=python35.Py_SetRecursionLimit
- Py_SymtableString=python35.Py_SymtableString
- Py_VaBuildValue=python35.Py_VaBuildValue
- _PyErr_BadInternalCall=python35._PyErr_BadInternalCall
- _PyObject_CallFunction_SizeT=python35._PyObject_CallFunction_SizeT
- _PyObject_CallMethod_SizeT=python35._PyObject_CallMethod_SizeT
- _PyObject_GC_Malloc=python35._PyObject_GC_Malloc
- _PyObject_GC_New=python35._PyObject_GC_New
- _PyObject_GC_NewVar=python35._PyObject_GC_NewVar
- _PyObject_GC_Resize=python35._PyObject_GC_Resize
- _PyObject_New=python35._PyObject_New
- _PyObject_NewVar=python35._PyObject_NewVar
- _PyState_AddModule=python35._PyState_AddModule
- _PyThreadState_Init=python35._PyThreadState_Init
- _PyThreadState_Prealloc=python35._PyThreadState_Prealloc
- _PyTrash_delete_later=python35._PyTrash_delete_later DATA
- _PyTrash_delete_nesting=python35._PyTrash_delete_nesting DATA
- _PyTrash_deposit_object=python35._PyTrash_deposit_object
- _PyTrash_destroy_chain=python35._PyTrash_destroy_chain
- _PyWeakref_CallableProxyType=python35._PyWeakref_CallableProxyType DATA
- _PyWeakref_ProxyType=python35._PyWeakref_ProxyType DATA
- _PyWeakref_RefType=python35._PyWeakref_RefType DATA
- _Py_BuildValue_SizeT=python35._Py_BuildValue_SizeT
- _Py_CheckRecursionLimit=python35._Py_CheckRecursionLimit DATA
- _Py_CheckRecursiveCall=python35._Py_CheckRecursiveCall
- _Py_Dealloc=python35._Py_Dealloc
- _Py_EllipsisObject=python35._Py_EllipsisObject DATA
- _Py_FalseStruct=python35._Py_FalseStruct DATA
- _Py_NoneStruct=python35._Py_NoneStruct DATA
- _Py_NotImplementedStruct=python35._Py_NotImplementedStruct DATA
- _Py_SwappedOp=python35._Py_SwappedOp DATA
- _Py_TrueStruct=python35._Py_TrueStruct DATA
- _Py_VaBuildValue_SizeT=python35._Py_VaBuildValue_SizeT
- _PyArg_Parse_SizeT=python35._PyArg_Parse_SizeT
- _PyArg_ParseTuple_SizeT=python35._PyArg_ParseTuple_SizeT
- _PyArg_ParseTupleAndKeywords_SizeT=python35._PyArg_ParseTupleAndKeywords_SizeT
- _PyArg_VaParse_SizeT=python35._PyArg_VaParse_SizeT
- _PyArg_VaParseTupleAndKeywords_SizeT=python35._PyArg_VaParseTupleAndKeywords_SizeT
- _Py_BuildValue_SizeT=python35._Py_BuildValue_SizeT
+ PyArg_Parse=python36.PyArg_Parse
+ PyArg_ParseTuple=python36.PyArg_ParseTuple
+ PyArg_ParseTupleAndKeywords=python36.PyArg_ParseTupleAndKeywords
+ PyArg_UnpackTuple=python36.PyArg_UnpackTuple
+ PyArg_VaParse=python36.PyArg_VaParse
+ PyArg_VaParseTupleAndKeywords=python36.PyArg_VaParseTupleAndKeywords
+ PyArg_ValidateKeywordArguments=python36.PyArg_ValidateKeywordArguments
+ PyBaseObject_Type=python36.PyBaseObject_Type DATA
+ PyBool_FromLong=python36.PyBool_FromLong
+ PyBool_Type=python36.PyBool_Type DATA
+ PyByteArrayIter_Type=python36.PyByteArrayIter_Type DATA
+ PyByteArray_AsString=python36.PyByteArray_AsString
+ PyByteArray_Concat=python36.PyByteArray_Concat
+ PyByteArray_FromObject=python36.PyByteArray_FromObject
+ PyByteArray_FromStringAndSize=python36.PyByteArray_FromStringAndSize
+ PyByteArray_Resize=python36.PyByteArray_Resize
+ PyByteArray_Size=python36.PyByteArray_Size
+ PyByteArray_Type=python36.PyByteArray_Type DATA
+ PyBytesIter_Type=python36.PyBytesIter_Type DATA
+ PyBytes_AsString=python36.PyBytes_AsString
+ PyBytes_AsStringAndSize=python36.PyBytes_AsStringAndSize
+ PyBytes_Concat=python36.PyBytes_Concat
+ PyBytes_ConcatAndDel=python36.PyBytes_ConcatAndDel
+ PyBytes_DecodeEscape=python36.PyBytes_DecodeEscape
+ PyBytes_FromFormat=python36.PyBytes_FromFormat
+ PyBytes_FromFormatV=python36.PyBytes_FromFormatV
+ PyBytes_FromObject=python36.PyBytes_FromObject
+ PyBytes_FromString=python36.PyBytes_FromString
+ PyBytes_FromStringAndSize=python36.PyBytes_FromStringAndSize
+ PyBytes_Repr=python36.PyBytes_Repr
+ PyBytes_Size=python36.PyBytes_Size
+ PyBytes_Type=python36.PyBytes_Type DATA
+ PyCFunction_Call=python36.PyCFunction_Call
+ PyCFunction_ClearFreeList=python36.PyCFunction_ClearFreeList
+ PyCFunction_GetFlags=python36.PyCFunction_GetFlags
+ PyCFunction_GetFunction=python36.PyCFunction_GetFunction
+ PyCFunction_GetSelf=python36.PyCFunction_GetSelf
+ PyCFunction_New=python36.PyCFunction_New
+ PyCFunction_NewEx=python36.PyCFunction_NewEx
+ PyCFunction_Type=python36.PyCFunction_Type DATA
+ PyCallIter_New=python36.PyCallIter_New
+ PyCallIter_Type=python36.PyCallIter_Type DATA
+ PyCallable_Check=python36.PyCallable_Check
+ PyCapsule_GetContext=python36.PyCapsule_GetContext
+ PyCapsule_GetDestructor=python36.PyCapsule_GetDestructor
+ PyCapsule_GetName=python36.PyCapsule_GetName
+ PyCapsule_GetPointer=python36.PyCapsule_GetPointer
+ PyCapsule_Import=python36.PyCapsule_Import
+ PyCapsule_IsValid=python36.PyCapsule_IsValid
+ PyCapsule_New=python36.PyCapsule_New
+ PyCapsule_SetContext=python36.PyCapsule_SetContext
+ PyCapsule_SetDestructor=python36.PyCapsule_SetDestructor
+ PyCapsule_SetName=python36.PyCapsule_SetName
+ PyCapsule_SetPointer=python36.PyCapsule_SetPointer
+ PyCapsule_Type=python36.PyCapsule_Type DATA
+ PyClassMethodDescr_Type=python36.PyClassMethodDescr_Type DATA
+ PyCodec_BackslashReplaceErrors=python36.PyCodec_BackslashReplaceErrors
+ PyCodec_Decode=python36.PyCodec_Decode
+ PyCodec_Decoder=python36.PyCodec_Decoder
+ PyCodec_Encode=python36.PyCodec_Encode
+ PyCodec_Encoder=python36.PyCodec_Encoder
+ PyCodec_IgnoreErrors=python36.PyCodec_IgnoreErrors
+ PyCodec_IncrementalDecoder=python36.PyCodec_IncrementalDecoder
+ PyCodec_IncrementalEncoder=python36.PyCodec_IncrementalEncoder
+ PyCodec_KnownEncoding=python36.PyCodec_KnownEncoding
+ PyCodec_LookupError=python36.PyCodec_LookupError
+ PyCodec_Register=python36.PyCodec_Register
+ PyCodec_RegisterError=python36.PyCodec_RegisterError
+ PyCodec_ReplaceErrors=python36.PyCodec_ReplaceErrors
+ PyCodec_StreamReader=python36.PyCodec_StreamReader
+ PyCodec_StreamWriter=python36.PyCodec_StreamWriter
+ PyCodec_StrictErrors=python36.PyCodec_StrictErrors
+ PyCodec_XMLCharRefReplaceErrors=python36.PyCodec_XMLCharRefReplaceErrors
+ PyComplex_FromDoubles=python36.PyComplex_FromDoubles
+ PyComplex_ImagAsDouble=python36.PyComplex_ImagAsDouble
+ PyComplex_RealAsDouble=python36.PyComplex_RealAsDouble
+ PyComplex_Type=python36.PyComplex_Type DATA
+ PyDescr_NewClassMethod=python36.PyDescr_NewClassMethod
+ PyDescr_NewGetSet=python36.PyDescr_NewGetSet
+ PyDescr_NewMember=python36.PyDescr_NewMember
+ PyDescr_NewMethod=python36.PyDescr_NewMethod
+ PyDictItems_Type=python36.PyDictItems_Type DATA
+ PyDictIterItem_Type=python36.PyDictIterItem_Type DATA
+ PyDictIterKey_Type=python36.PyDictIterKey_Type DATA
+ PyDictIterValue_Type=python36.PyDictIterValue_Type DATA
+ PyDictKeys_Type=python36.PyDictKeys_Type DATA
+ PyDictProxy_New=python36.PyDictProxy_New
+ PyDictProxy_Type=python36.PyDictProxy_Type DATA
+ PyDictValues_Type=python36.PyDictValues_Type DATA
+ PyDict_Clear=python36.PyDict_Clear
+ PyDict_Contains=python36.PyDict_Contains
+ PyDict_Copy=python36.PyDict_Copy
+ PyDict_DelItem=python36.PyDict_DelItem
+ PyDict_DelItemString=python36.PyDict_DelItemString
+ PyDict_GetItem=python36.PyDict_GetItem
+ PyDict_GetItemString=python36.PyDict_GetItemString
+ PyDict_GetItemWithError=python36.PyDict_GetItemWithError
+ PyDict_Items=python36.PyDict_Items
+ PyDict_Keys=python36.PyDict_Keys
+ PyDict_Merge=python36.PyDict_Merge
+ PyDict_MergeFromSeq2=python36.PyDict_MergeFromSeq2
+ PyDict_New=python36.PyDict_New
+ PyDict_Next=python36.PyDict_Next
+ PyDict_SetItem=python36.PyDict_SetItem
+ PyDict_SetItemString=python36.PyDict_SetItemString
+ PyDict_Size=python36.PyDict_Size
+ PyDict_Type=python36.PyDict_Type DATA
+ PyDict_Update=python36.PyDict_Update
+ PyDict_Values=python36.PyDict_Values
+ PyEllipsis_Type=python36.PyEllipsis_Type DATA
+ PyEnum_Type=python36.PyEnum_Type DATA
+ PyErr_BadArgument=python36.PyErr_BadArgument
+ PyErr_BadInternalCall=python36.PyErr_BadInternalCall
+ PyErr_CheckSignals=python36.PyErr_CheckSignals
+ PyErr_Clear=python36.PyErr_Clear
+ PyErr_Display=python36.PyErr_Display
+ PyErr_ExceptionMatches=python36.PyErr_ExceptionMatches
+ PyErr_Fetch=python36.PyErr_Fetch
+ PyErr_Format=python36.PyErr_Format
+ PyErr_FormatV=python36.PyErr_FormatV
+ PyErr_GivenExceptionMatches=python36.PyErr_GivenExceptionMatches
+ PyErr_NewException=python36.PyErr_NewException
+ PyErr_NewExceptionWithDoc=python36.PyErr_NewExceptionWithDoc
+ PyErr_NoMemory=python36.PyErr_NoMemory
+ PyErr_NormalizeException=python36.PyErr_NormalizeException
+ PyErr_Occurred=python36.PyErr_Occurred
+ PyErr_Print=python36.PyErr_Print
+ PyErr_PrintEx=python36.PyErr_PrintEx
+ PyErr_ProgramText=python36.PyErr_ProgramText
+ PyErr_Restore=python36.PyErr_Restore
+ PyErr_SetFromErrno=python36.PyErr_SetFromErrno
+ PyErr_SetFromErrnoWithFilename=python36.PyErr_SetFromErrnoWithFilename
+ PyErr_SetFromErrnoWithFilenameObject=python36.PyErr_SetFromErrnoWithFilenameObject
+ PyErr_SetInterrupt=python36.PyErr_SetInterrupt
+ PyErr_SetNone=python36.PyErr_SetNone
+ PyErr_SetObject=python36.PyErr_SetObject
+ PyErr_SetString=python36.PyErr_SetString
+ PyErr_SyntaxLocation=python36.PyErr_SyntaxLocation
+ PyErr_WarnEx=python36.PyErr_WarnEx
+ PyErr_WarnExplicit=python36.PyErr_WarnExplicit
+ PyErr_WarnFormat=python36.PyErr_WarnFormat
+ PyErr_WriteUnraisable=python36.PyErr_WriteUnraisable
+ PyEval_AcquireLock=python36.PyEval_AcquireLock
+ PyEval_AcquireThread=python36.PyEval_AcquireThread
+ PyEval_CallFunction=python36.PyEval_CallFunction
+ PyEval_CallMethod=python36.PyEval_CallMethod
+ PyEval_CallObjectWithKeywords=python36.PyEval_CallObjectWithKeywords
+ PyEval_EvalCode=python36.PyEval_EvalCode
+ PyEval_EvalCodeEx=python36.PyEval_EvalCodeEx
+ PyEval_EvalFrame=python36.PyEval_EvalFrame
+ PyEval_EvalFrameEx=python36.PyEval_EvalFrameEx
+ PyEval_GetBuiltins=python36.PyEval_GetBuiltins
+ PyEval_GetCallStats=python36.PyEval_GetCallStats
+ PyEval_GetFrame=python36.PyEval_GetFrame
+ PyEval_GetFuncDesc=python36.PyEval_GetFuncDesc
+ PyEval_GetFuncName=python36.PyEval_GetFuncName
+ PyEval_GetGlobals=python36.PyEval_GetGlobals
+ PyEval_GetLocals=python36.PyEval_GetLocals
+ PyEval_InitThreads=python36.PyEval_InitThreads
+ PyEval_ReInitThreads=python36.PyEval_ReInitThreads
+ PyEval_ReleaseLock=python36.PyEval_ReleaseLock
+ PyEval_ReleaseThread=python36.PyEval_ReleaseThread
+ PyEval_RestoreThread=python36.PyEval_RestoreThread
+ PyEval_SaveThread=python36.PyEval_SaveThread
+ PyEval_ThreadsInitialized=python36.PyEval_ThreadsInitialized
+ PyExc_ArithmeticError=python36.PyExc_ArithmeticError DATA
+ PyExc_AssertionError=python36.PyExc_AssertionError DATA
+ PyExc_AttributeError=python36.PyExc_AttributeError DATA
+ PyExc_BaseException=python36.PyExc_BaseException DATA
+ PyExc_BufferError=python36.PyExc_BufferError DATA
+ PyExc_BytesWarning=python36.PyExc_BytesWarning DATA
+ PyExc_DeprecationWarning=python36.PyExc_DeprecationWarning DATA
+ PyExc_EOFError=python36.PyExc_EOFError DATA
+ PyExc_EnvironmentError=python36.PyExc_EnvironmentError DATA
+ PyExc_Exception=python36.PyExc_Exception DATA
+ PyExc_FloatingPointError=python36.PyExc_FloatingPointError DATA
+ PyExc_FutureWarning=python36.PyExc_FutureWarning DATA
+ PyExc_GeneratorExit=python36.PyExc_GeneratorExit DATA
+ PyExc_IOError=python36.PyExc_IOError DATA
+ PyExc_ImportError=python36.PyExc_ImportError DATA
+ PyExc_ImportWarning=python36.PyExc_ImportWarning DATA
+ PyExc_IndentationError=python36.PyExc_IndentationError DATA
+ PyExc_IndexError=python36.PyExc_IndexError DATA
+ PyExc_KeyError=python36.PyExc_KeyError DATA
+ PyExc_KeyboardInterrupt=python36.PyExc_KeyboardInterrupt DATA
+ PyExc_LookupError=python36.PyExc_LookupError DATA
+ PyExc_MemoryError=python36.PyExc_MemoryError DATA
+ PyExc_MemoryErrorInst=python36.PyExc_MemoryErrorInst DATA
+ PyExc_NameError=python36.PyExc_NameError DATA
+ PyExc_NotImplementedError=python36.PyExc_NotImplementedError DATA
+ PyExc_OSError=python36.PyExc_OSError DATA
+ PyExc_OverflowError=python36.PyExc_OverflowError DATA
+ PyExc_PendingDeprecationWarning=python36.PyExc_PendingDeprecationWarning DATA
+ PyExc_RecursionErrorInst=python36.PyExc_RecursionErrorInst DATA
+ PyExc_ReferenceError=python36.PyExc_ReferenceError DATA
+ PyExc_RuntimeError=python36.PyExc_RuntimeError DATA
+ PyExc_RuntimeWarning=python36.PyExc_RuntimeWarning DATA
+ PyExc_StopIteration=python36.PyExc_StopIteration DATA
+ PyExc_SyntaxError=python36.PyExc_SyntaxError DATA
+ PyExc_SyntaxWarning=python36.PyExc_SyntaxWarning DATA
+ PyExc_SystemError=python36.PyExc_SystemError DATA
+ PyExc_SystemExit=python36.PyExc_SystemExit DATA
+ PyExc_TabError=python36.PyExc_TabError DATA
+ PyExc_TypeError=python36.PyExc_TypeError DATA
+ PyExc_UnboundLocalError=python36.PyExc_UnboundLocalError DATA
+ PyExc_UnicodeDecodeError=python36.PyExc_UnicodeDecodeError DATA
+ PyExc_UnicodeEncodeError=python36.PyExc_UnicodeEncodeError DATA
+ PyExc_UnicodeError=python36.PyExc_UnicodeError DATA
+ PyExc_UnicodeTranslateError=python36.PyExc_UnicodeTranslateError DATA
+ PyExc_UnicodeWarning=python36.PyExc_UnicodeWarning DATA
+ PyExc_UserWarning=python36.PyExc_UserWarning DATA
+ PyExc_ValueError=python36.PyExc_ValueError DATA
+ PyExc_Warning=python36.PyExc_Warning DATA
+ PyExc_ZeroDivisionError=python36.PyExc_ZeroDivisionError DATA
+ PyException_GetCause=python36.PyException_GetCause
+ PyException_GetContext=python36.PyException_GetContext
+ PyException_GetTraceback=python36.PyException_GetTraceback
+ PyException_SetCause=python36.PyException_SetCause
+ PyException_SetContext=python36.PyException_SetContext
+ PyException_SetTraceback=python36.PyException_SetTraceback
+ PyFile_FromFd=python36.PyFile_FromFd
+ PyFile_GetLine=python36.PyFile_GetLine
+ PyFile_WriteObject=python36.PyFile_WriteObject
+ PyFile_WriteString=python36.PyFile_WriteString
+ PyFilter_Type=python36.PyFilter_Type DATA
+ PyFloat_AsDouble=python36.PyFloat_AsDouble
+ PyFloat_FromDouble=python36.PyFloat_FromDouble
+ PyFloat_FromString=python36.PyFloat_FromString
+ PyFloat_GetInfo=python36.PyFloat_GetInfo
+ PyFloat_GetMax=python36.PyFloat_GetMax
+ PyFloat_GetMin=python36.PyFloat_GetMin
+ PyFloat_Type=python36.PyFloat_Type DATA
+ PyFrozenSet_New=python36.PyFrozenSet_New
+ PyFrozenSet_Type=python36.PyFrozenSet_Type DATA
+ PyGC_Collect=python36.PyGC_Collect
+ PyGILState_Ensure=python36.PyGILState_Ensure
+ PyGILState_GetThisThreadState=python36.PyGILState_GetThisThreadState
+ PyGILState_Release=python36.PyGILState_Release
+ PyGetSetDescr_Type=python36.PyGetSetDescr_Type DATA
+ PyImport_AddModule=python36.PyImport_AddModule
+ PyImport_AppendInittab=python36.PyImport_AppendInittab
+ PyImport_Cleanup=python36.PyImport_Cleanup
+ PyImport_ExecCodeModule=python36.PyImport_ExecCodeModule
+ PyImport_ExecCodeModuleEx=python36.PyImport_ExecCodeModuleEx
+ PyImport_ExecCodeModuleWithPathnames=python36.PyImport_ExecCodeModuleWithPathnames
+ PyImport_GetImporter=python36.PyImport_GetImporter
+ PyImport_GetMagicNumber=python36.PyImport_GetMagicNumber
+ PyImport_GetMagicTag=python36.PyImport_GetMagicTag
+ PyImport_GetModuleDict=python36.PyImport_GetModuleDict
+ PyImport_Import=python36.PyImport_Import
+ PyImport_ImportFrozenModule=python36.PyImport_ImportFrozenModule
+ PyImport_ImportModule=python36.PyImport_ImportModule
+ PyImport_ImportModuleLevel=python36.PyImport_ImportModuleLevel
+ PyImport_ImportModuleNoBlock=python36.PyImport_ImportModuleNoBlock
+ PyImport_ReloadModule=python36.PyImport_ReloadModule
+ PyInterpreterState_Clear=python36.PyInterpreterState_Clear
+ PyInterpreterState_Delete=python36.PyInterpreterState_Delete
+ PyInterpreterState_New=python36.PyInterpreterState_New
+ PyIter_Next=python36.PyIter_Next
+ PyListIter_Type=python36.PyListIter_Type DATA
+ PyListRevIter_Type=python36.PyListRevIter_Type DATA
+ PyList_Append=python36.PyList_Append
+ PyList_AsTuple=python36.PyList_AsTuple
+ PyList_GetItem=python36.PyList_GetItem
+ PyList_GetSlice=python36.PyList_GetSlice
+ PyList_Insert=python36.PyList_Insert
+ PyList_New=python36.PyList_New
+ PyList_Reverse=python36.PyList_Reverse
+ PyList_SetItem=python36.PyList_SetItem
+ PyList_SetSlice=python36.PyList_SetSlice
+ PyList_Size=python36.PyList_Size
+ PyList_Sort=python36.PyList_Sort
+ PyList_Type=python36.PyList_Type DATA
+ PyLongRangeIter_Type=python36.PyLongRangeIter_Type DATA
+ PyLong_AsDouble=python36.PyLong_AsDouble
+ PyLong_AsLong=python36.PyLong_AsLong
+ PyLong_AsLongAndOverflow=python36.PyLong_AsLongAndOverflow
+ PyLong_AsLongLong=python36.PyLong_AsLongLong
+ PyLong_AsLongLongAndOverflow=python36.PyLong_AsLongLongAndOverflow
+ PyLong_AsSize_t=python36.PyLong_AsSize_t
+ PyLong_AsSsize_t=python36.PyLong_AsSsize_t
+ PyLong_AsUnsignedLong=python36.PyLong_AsUnsignedLong
+ PyLong_AsUnsignedLongLong=python36.PyLong_AsUnsignedLongLong
+ PyLong_AsUnsignedLongLongMask=python36.PyLong_AsUnsignedLongLongMask
+ PyLong_AsUnsignedLongMask=python36.PyLong_AsUnsignedLongMask
+ PyLong_AsVoidPtr=python36.PyLong_AsVoidPtr
+ PyLong_FromDouble=python36.PyLong_FromDouble
+ PyLong_FromLong=python36.PyLong_FromLong
+ PyLong_FromLongLong=python36.PyLong_FromLongLong
+ PyLong_FromSize_t=python36.PyLong_FromSize_t
+ PyLong_FromSsize_t=python36.PyLong_FromSsize_t
+ PyLong_FromString=python36.PyLong_FromString
+ PyLong_FromUnsignedLong=python36.PyLong_FromUnsignedLong
+ PyLong_FromUnsignedLongLong=python36.PyLong_FromUnsignedLongLong
+ PyLong_FromVoidPtr=python36.PyLong_FromVoidPtr
+ PyLong_GetInfo=python36.PyLong_GetInfo
+ PyLong_Type=python36.PyLong_Type DATA
+ PyMap_Type=python36.PyMap_Type DATA
+ PyMapping_Check=python36.PyMapping_Check
+ PyMapping_GetItemString=python36.PyMapping_GetItemString
+ PyMapping_HasKey=python36.PyMapping_HasKey
+ PyMapping_HasKeyString=python36.PyMapping_HasKeyString
+ PyMapping_Items=python36.PyMapping_Items
+ PyMapping_Keys=python36.PyMapping_Keys
+ PyMapping_Length=python36.PyMapping_Length
+ PyMapping_SetItemString=python36.PyMapping_SetItemString
+ PyMapping_Size=python36.PyMapping_Size
+ PyMapping_Values=python36.PyMapping_Values
+ PyMem_Free=python36.PyMem_Free
+ PyMem_Malloc=python36.PyMem_Malloc
+ PyMem_Realloc=python36.PyMem_Realloc
+ PyMemberDescr_Type=python36.PyMemberDescr_Type DATA
+ PyMemoryView_FromObject=python36.PyMemoryView_FromObject
+ PyMemoryView_GetContiguous=python36.PyMemoryView_GetContiguous
+ PyMemoryView_Type=python36.PyMemoryView_Type DATA
+ PyMethodDescr_Type=python36.PyMethodDescr_Type DATA
+ PyModule_AddIntConstant=python36.PyModule_AddIntConstant
+ PyModule_AddObject=python36.PyModule_AddObject
+ PyModule_AddStringConstant=python36.PyModule_AddStringConstant
+ PyModule_Create2=python36.PyModule_Create2
+ PyModule_GetDef=python36.PyModule_GetDef
+ PyModule_GetDict=python36.PyModule_GetDict
+ PyModule_GetFilename=python36.PyModule_GetFilename
+ PyModule_GetFilenameObject=python36.PyModule_GetFilenameObject
+ PyModule_GetName=python36.PyModule_GetName
+ PyModule_GetState=python36.PyModule_GetState
+ PyModule_New=python36.PyModule_New
+ PyModule_Type=python36.PyModule_Type DATA
+ PyModuleDef_Init=python36.PyModuleDef_Init
+ PyModuleDef_Type=python36.PyModuleDef_Type DATA
+ PyNullImporter_Type=python36.PyNullImporter_Type DATA
+ PyNumber_Absolute=python36.PyNumber_Absolute
+ PyNumber_Add=python36.PyNumber_Add
+ PyNumber_And=python36.PyNumber_And
+ PyNumber_AsSsize_t=python36.PyNumber_AsSsize_t
+ PyNumber_Check=python36.PyNumber_Check
+ PyNumber_Divmod=python36.PyNumber_Divmod
+ PyNumber_Float=python36.PyNumber_Float
+ PyNumber_FloorDivide=python36.PyNumber_FloorDivide
+ PyNumber_InPlaceAdd=python36.PyNumber_InPlaceAdd
+ PyNumber_InPlaceAnd=python36.PyNumber_InPlaceAnd
+ PyNumber_InPlaceFloorDivide=python36.PyNumber_InPlaceFloorDivide
+ PyNumber_InPlaceLshift=python36.PyNumber_InPlaceLshift
+ PyNumber_InPlaceMultiply=python36.PyNumber_InPlaceMultiply
+ PyNumber_InPlaceOr=python36.PyNumber_InPlaceOr
+ PyNumber_InPlacePower=python36.PyNumber_InPlacePower
+ PyNumber_InPlaceRemainder=python36.PyNumber_InPlaceRemainder
+ PyNumber_InPlaceRshift=python36.PyNumber_InPlaceRshift
+ PyNumber_InPlaceSubtract=python36.PyNumber_InPlaceSubtract
+ PyNumber_InPlaceTrueDivide=python36.PyNumber_InPlaceTrueDivide
+ PyNumber_InPlaceXor=python36.PyNumber_InPlaceXor
+ PyNumber_Index=python36.PyNumber_Index
+ PyNumber_Invert=python36.PyNumber_Invert
+ PyNumber_Long=python36.PyNumber_Long
+ PyNumber_Lshift=python36.PyNumber_Lshift
+ PyNumber_Multiply=python36.PyNumber_Multiply
+ PyNumber_Negative=python36.PyNumber_Negative
+ PyNumber_Or=python36.PyNumber_Or
+ PyNumber_Positive=python36.PyNumber_Positive
+ PyNumber_Power=python36.PyNumber_Power
+ PyNumber_Remainder=python36.PyNumber_Remainder
+ PyNumber_Rshift=python36.PyNumber_Rshift
+ PyNumber_Subtract=python36.PyNumber_Subtract
+ PyNumber_ToBase=python36.PyNumber_ToBase
+ PyNumber_TrueDivide=python36.PyNumber_TrueDivide
+ PyNumber_Xor=python36.PyNumber_Xor
+ PyOS_AfterFork=python36.PyOS_AfterFork
+ PyOS_InitInterrupts=python36.PyOS_InitInterrupts
+ PyOS_InputHook=python36.PyOS_InputHook DATA
+ PyOS_InterruptOccurred=python36.PyOS_InterruptOccurred
+ PyOS_ReadlineFunctionPointer=python36.PyOS_ReadlineFunctionPointer DATA
+ PyOS_double_to_string=python36.PyOS_double_to_string
+ PyOS_getsig=python36.PyOS_getsig
+ PyOS_mystricmp=python36.PyOS_mystricmp
+ PyOS_mystrnicmp=python36.PyOS_mystrnicmp
+ PyOS_setsig=python36.PyOS_setsig
+ PyOS_snprintf=python36.PyOS_snprintf
+ PyOS_string_to_double=python36.PyOS_string_to_double
+ PyOS_strtol=python36.PyOS_strtol
+ PyOS_strtoul=python36.PyOS_strtoul
+ PyOS_vsnprintf=python36.PyOS_vsnprintf
+ PyObject_ASCII=python36.PyObject_ASCII
+ PyObject_AsCharBuffer=python36.PyObject_AsCharBuffer
+ PyObject_AsFileDescriptor=python36.PyObject_AsFileDescriptor
+ PyObject_AsReadBuffer=python36.PyObject_AsReadBuffer
+ PyObject_AsWriteBuffer=python36.PyObject_AsWriteBuffer
+ PyObject_Bytes=python36.PyObject_Bytes
+ PyObject_Call=python36.PyObject_Call
+ PyObject_CallFunction=python36.PyObject_CallFunction
+ PyObject_CallFunctionObjArgs=python36.PyObject_CallFunctionObjArgs
+ PyObject_CallMethod=python36.PyObject_CallMethod
+ PyObject_CallMethodObjArgs=python36.PyObject_CallMethodObjArgs
+ PyObject_CallObject=python36.PyObject_CallObject
+ PyObject_CheckReadBuffer=python36.PyObject_CheckReadBuffer
+ PyObject_ClearWeakRefs=python36.PyObject_ClearWeakRefs
+ PyObject_DelItem=python36.PyObject_DelItem
+ PyObject_DelItemString=python36.PyObject_DelItemString
+ PyObject_Dir=python36.PyObject_Dir
+ PyObject_Format=python36.PyObject_Format
+ PyObject_Free=python36.PyObject_Free
+ PyObject_GC_Del=python36.PyObject_GC_Del
+ PyObject_GC_Track=python36.PyObject_GC_Track
+ PyObject_GC_UnTrack=python36.PyObject_GC_UnTrack
+ PyObject_GenericGetAttr=python36.PyObject_GenericGetAttr
+ PyObject_GenericSetAttr=python36.PyObject_GenericSetAttr
+ PyObject_GetAttr=python36.PyObject_GetAttr
+ PyObject_GetAttrString=python36.PyObject_GetAttrString
+ PyObject_GetItem=python36.PyObject_GetItem
+ PyObject_GetIter=python36.PyObject_GetIter
+ PyObject_HasAttr=python36.PyObject_HasAttr
+ PyObject_HasAttrString=python36.PyObject_HasAttrString
+ PyObject_Hash=python36.PyObject_Hash
+ PyObject_HashNotImplemented=python36.PyObject_HashNotImplemented
+ PyObject_Init=python36.PyObject_Init
+ PyObject_InitVar=python36.PyObject_InitVar
+ PyObject_IsInstance=python36.PyObject_IsInstance
+ PyObject_IsSubclass=python36.PyObject_IsSubclass
+ PyObject_IsTrue=python36.PyObject_IsTrue
+ PyObject_Length=python36.PyObject_Length
+ PyObject_Malloc=python36.PyObject_Malloc
+ PyObject_Not=python36.PyObject_Not
+ PyObject_Realloc=python36.PyObject_Realloc
+ PyObject_Repr=python36.PyObject_Repr
+ PyObject_RichCompare=python36.PyObject_RichCompare
+ PyObject_RichCompareBool=python36.PyObject_RichCompareBool
+ PyObject_SelfIter=python36.PyObject_SelfIter
+ PyObject_SetAttr=python36.PyObject_SetAttr
+ PyObject_SetAttrString=python36.PyObject_SetAttrString
+ PyObject_SetItem=python36.PyObject_SetItem
+ PyObject_Size=python36.PyObject_Size
+ PyObject_Str=python36.PyObject_Str
+ PyObject_Type=python36.PyObject_Type DATA
+ PyODict_DelItem=python36.PyODict_DelItem
+ PyODict_New=python36.PyODict_New
+ PyODict_SetItem=python36.PyODict_SetItem
+ PyODict_Type=python36.PyODict_Type DATA
+ PyODictItems_Type=python36.PyODictItems_Type DATA
+ PyODictIter_Type=python36.PyODictIter_Type DATA
+ PyODictKeys_Type=python36.PyODictKeys_Type DATA
+ PyODictValues_Type=python36.PyODictValues_Type DATA
+ PyParser_SimpleParseFileFlags=python36.PyParser_SimpleParseFileFlags
+ PyParser_SimpleParseStringFlags=python36.PyParser_SimpleParseStringFlags
+ PyProperty_Type=python36.PyProperty_Type DATA
+ PyRangeIter_Type=python36.PyRangeIter_Type DATA
+ PyRange_Type=python36.PyRange_Type DATA
+ PyReversed_Type=python36.PyReversed_Type DATA
+ PySeqIter_New=python36.PySeqIter_New
+ PySeqIter_Type=python36.PySeqIter_Type DATA
+ PySequence_Check=python36.PySequence_Check
+ PySequence_Concat=python36.PySequence_Concat
+ PySequence_Contains=python36.PySequence_Contains
+ PySequence_Count=python36.PySequence_Count
+ PySequence_DelItem=python36.PySequence_DelItem
+ PySequence_DelSlice=python36.PySequence_DelSlice
+ PySequence_Fast=python36.PySequence_Fast
+ PySequence_GetItem=python36.PySequence_GetItem
+ PySequence_GetSlice=python36.PySequence_GetSlice
+ PySequence_In=python36.PySequence_In
+ PySequence_InPlaceConcat=python36.PySequence_InPlaceConcat
+ PySequence_InPlaceRepeat=python36.PySequence_InPlaceRepeat
+ PySequence_Index=python36.PySequence_Index
+ PySequence_Length=python36.PySequence_Length
+ PySequence_List=python36.PySequence_List
+ PySequence_Repeat=python36.PySequence_Repeat
+ PySequence_SetItem=python36.PySequence_SetItem
+ PySequence_SetSlice=python36.PySequence_SetSlice
+ PySequence_Size=python36.PySequence_Size
+ PySequence_Tuple=python36.PySequence_Tuple
+ PySetIter_Type=python36.PySetIter_Type DATA
+ PySet_Add=python36.PySet_Add
+ PySet_Clear=python36.PySet_Clear
+ PySet_Contains=python36.PySet_Contains
+ PySet_Discard=python36.PySet_Discard
+ PySet_New=python36.PySet_New
+ PySet_Pop=python36.PySet_Pop
+ PySet_Size=python36.PySet_Size
+ PySet_Type=python36.PySet_Type DATA
+ PySlice_GetIndices=python36.PySlice_GetIndices
+ PySlice_GetIndicesEx=python36.PySlice_GetIndicesEx
+ PySlice_New=python36.PySlice_New
+ PySlice_Type=python36.PySlice_Type DATA
+ PySortWrapper_Type=python36.PySortWrapper_Type DATA
+ PyState_FindModule=python36.PyState_FindModule
+ PyState_AddModule=python36.PyState_AddModule
+ PyState_RemoveModule=python36.PyState_RemoveModule
+ PyStructSequence_GetItem=python36.PyStructSequence_GetItem
+ PyStructSequence_New=python36.PyStructSequence_New
+ PyStructSequence_NewType=python36.PyStructSequence_NewType
+ PyStructSequence_SetItem=python36.PyStructSequence_SetItem
+ PySuper_Type=python36.PySuper_Type DATA
+ PySys_AddWarnOption=python36.PySys_AddWarnOption
+ PySys_AddWarnOptionUnicode=python36.PySys_AddWarnOptionUnicode
+ PySys_FormatStderr=python36.PySys_FormatStderr
+ PySys_FormatStdout=python36.PySys_FormatStdout
+ PySys_GetObject=python36.PySys_GetObject
+ PySys_HasWarnOptions=python36.PySys_HasWarnOptions
+ PySys_ResetWarnOptions=python36.PySys_ResetWarnOptions
+ PySys_SetArgv=python36.PySys_SetArgv
+ PySys_SetArgvEx=python36.PySys_SetArgvEx
+ PySys_SetObject=python36.PySys_SetObject
+ PySys_SetPath=python36.PySys_SetPath
+ PySys_WriteStderr=python36.PySys_WriteStderr
+ PySys_WriteStdout=python36.PySys_WriteStdout
+ PyThreadState_Clear=python36.PyThreadState_Clear
+ PyThreadState_Delete=python36.PyThreadState_Delete
+ PyThreadState_DeleteCurrent=python36.PyThreadState_DeleteCurrent
+ PyThreadState_Get=python36.PyThreadState_Get
+ PyThreadState_GetDict=python36.PyThreadState_GetDict
+ PyThreadState_New=python36.PyThreadState_New
+ PyThreadState_SetAsyncExc=python36.PyThreadState_SetAsyncExc
+ PyThreadState_Swap=python36.PyThreadState_Swap
+ PyTraceBack_Here=python36.PyTraceBack_Here
+ PyTraceBack_Print=python36.PyTraceBack_Print
+ PyTraceBack_Type=python36.PyTraceBack_Type DATA
+ PyTupleIter_Type=python36.PyTupleIter_Type DATA
+ PyTuple_ClearFreeList=python36.PyTuple_ClearFreeList
+ PyTuple_GetItem=python36.PyTuple_GetItem
+ PyTuple_GetSlice=python36.PyTuple_GetSlice
+ PyTuple_New=python36.PyTuple_New
+ PyTuple_Pack=python36.PyTuple_Pack
+ PyTuple_SetItem=python36.PyTuple_SetItem
+ PyTuple_Size=python36.PyTuple_Size
+ PyTuple_Type=python36.PyTuple_Type DATA
+ PyType_ClearCache=python36.PyType_ClearCache
+ PyType_FromSpec=python36.PyType_FromSpec
+ PyType_FromSpecWithBases=python36.PyType_FromSpecWithBases
+ PyType_GenericAlloc=python36.PyType_GenericAlloc
+ PyType_GenericNew=python36.PyType_GenericNew
+ PyType_GetFlags=python36.PyType_GetFlags
+ PyType_GetSlot=python36.PyType_GetSlot
+ PyType_IsSubtype=python36.PyType_IsSubtype
+ PyType_Modified=python36.PyType_Modified
+ PyType_Ready=python36.PyType_Ready
+ PyType_Type=python36.PyType_Type DATA
+ PyUnicodeDecodeError_Create=python36.PyUnicodeDecodeError_Create
+ PyUnicodeDecodeError_GetEncoding=python36.PyUnicodeDecodeError_GetEncoding
+ PyUnicodeDecodeError_GetEnd=python36.PyUnicodeDecodeError_GetEnd
+ PyUnicodeDecodeError_GetObject=python36.PyUnicodeDecodeError_GetObject
+ PyUnicodeDecodeError_GetReason=python36.PyUnicodeDecodeError_GetReason
+ PyUnicodeDecodeError_GetStart=python36.PyUnicodeDecodeError_GetStart
+ PyUnicodeDecodeError_SetEnd=python36.PyUnicodeDecodeError_SetEnd
+ PyUnicodeDecodeError_SetReason=python36.PyUnicodeDecodeError_SetReason
+ PyUnicodeDecodeError_SetStart=python36.PyUnicodeDecodeError_SetStart
+ PyUnicodeEncodeError_GetEncoding=python36.PyUnicodeEncodeError_GetEncoding
+ PyUnicodeEncodeError_GetEnd=python36.PyUnicodeEncodeError_GetEnd
+ PyUnicodeEncodeError_GetObject=python36.PyUnicodeEncodeError_GetObject
+ PyUnicodeEncodeError_GetReason=python36.PyUnicodeEncodeError_GetReason
+ PyUnicodeEncodeError_GetStart=python36.PyUnicodeEncodeError_GetStart
+ PyUnicodeEncodeError_SetEnd=python36.PyUnicodeEncodeError_SetEnd
+ PyUnicodeEncodeError_SetReason=python36.PyUnicodeEncodeError_SetReason
+ PyUnicodeEncodeError_SetStart=python36.PyUnicodeEncodeError_SetStart
+ PyUnicodeIter_Type=python36.PyUnicodeIter_Type DATA
+ PyUnicodeTranslateError_GetEnd=python36.PyUnicodeTranslateError_GetEnd
+ PyUnicodeTranslateError_GetObject=python36.PyUnicodeTranslateError_GetObject
+ PyUnicodeTranslateError_GetReason=python36.PyUnicodeTranslateError_GetReason
+ PyUnicodeTranslateError_GetStart=python36.PyUnicodeTranslateError_GetStart
+ PyUnicodeTranslateError_SetEnd=python36.PyUnicodeTranslateError_SetEnd
+ PyUnicodeTranslateError_SetReason=python36.PyUnicodeTranslateError_SetReason
+ PyUnicodeTranslateError_SetStart=python36.PyUnicodeTranslateError_SetStart
+ PyUnicode_Append=python36.PyUnicode_Append
+ PyUnicode_AppendAndDel=python36.PyUnicode_AppendAndDel
+ PyUnicode_AsASCIIString=python36.PyUnicode_AsASCIIString
+ PyUnicode_AsCharmapString=python36.PyUnicode_AsCharmapString
+ PyUnicode_AsDecodedObject=python36.PyUnicode_AsDecodedObject
+ PyUnicode_AsDecodedUnicode=python36.PyUnicode_AsDecodedUnicode
+ PyUnicode_AsEncodedObject=python36.PyUnicode_AsEncodedObject
+ PyUnicode_AsEncodedString=python36.PyUnicode_AsEncodedString
+ PyUnicode_AsEncodedUnicode=python36.PyUnicode_AsEncodedUnicode
+ PyUnicode_AsLatin1String=python36.PyUnicode_AsLatin1String
+ PyUnicode_AsRawUnicodeEscapeString=python36.PyUnicode_AsRawUnicodeEscapeString
+ PyUnicode_AsUTF16String=python36.PyUnicode_AsUTF16String
+ PyUnicode_AsUTF32String=python36.PyUnicode_AsUTF32String
+ PyUnicode_AsUTF8String=python36.PyUnicode_AsUTF8String
+ PyUnicode_AsUnicodeEscapeString=python36.PyUnicode_AsUnicodeEscapeString
+ PyUnicode_AsWideChar=python36.PyUnicode_AsWideChar
+ PyUnicode_ClearFreelist=python36.PyUnicode_ClearFreelist
+ PyUnicode_Compare=python36.PyUnicode_Compare
+ PyUnicode_Concat=python36.PyUnicode_Concat
+ PyUnicode_Contains=python36.PyUnicode_Contains
+ PyUnicode_Count=python36.PyUnicode_Count
+ PyUnicode_Decode=python36.PyUnicode_Decode
+ PyUnicode_DecodeASCII=python36.PyUnicode_DecodeASCII
+ PyUnicode_DecodeCharmap=python36.PyUnicode_DecodeCharmap
+ PyUnicode_DecodeFSDefault=python36.PyUnicode_DecodeFSDefault
+ PyUnicode_DecodeFSDefaultAndSize=python36.PyUnicode_DecodeFSDefaultAndSize
+ PyUnicode_DecodeLatin1=python36.PyUnicode_DecodeLatin1
+ PyUnicode_DecodeRawUnicodeEscape=python36.PyUnicode_DecodeRawUnicodeEscape
+ PyUnicode_DecodeUTF16=python36.PyUnicode_DecodeUTF16
+ PyUnicode_DecodeUTF16Stateful=python36.PyUnicode_DecodeUTF16Stateful
+ PyUnicode_DecodeUTF32=python36.PyUnicode_DecodeUTF32
+ PyUnicode_DecodeUTF32Stateful=python36.PyUnicode_DecodeUTF32Stateful
+ PyUnicode_DecodeUTF8=python36.PyUnicode_DecodeUTF8
+ PyUnicode_DecodeUTF8Stateful=python36.PyUnicode_DecodeUTF8Stateful
+ PyUnicode_DecodeUnicodeEscape=python36.PyUnicode_DecodeUnicodeEscape
+ PyUnicode_FSConverter=python36.PyUnicode_FSConverter
+ PyUnicode_FSDecoder=python36.PyUnicode_FSDecoder
+ PyUnicode_Find=python36.PyUnicode_Find
+ PyUnicode_Format=python36.PyUnicode_Format
+ PyUnicode_FromEncodedObject=python36.PyUnicode_FromEncodedObject
+ PyUnicode_FromFormat=python36.PyUnicode_FromFormat
+ PyUnicode_FromFormatV=python36.PyUnicode_FromFormatV
+ PyUnicode_FromObject=python36.PyUnicode_FromObject
+ PyUnicode_FromOrdinal=python36.PyUnicode_FromOrdinal
+ PyUnicode_FromString=python36.PyUnicode_FromString
+ PyUnicode_FromStringAndSize=python36.PyUnicode_FromStringAndSize
+ PyUnicode_FromWideChar=python36.PyUnicode_FromWideChar
+ PyUnicode_GetDefaultEncoding=python36.PyUnicode_GetDefaultEncoding
+ PyUnicode_GetSize=python36.PyUnicode_GetSize
+ PyUnicode_IsIdentifier=python36.PyUnicode_IsIdentifier
+ PyUnicode_Join=python36.PyUnicode_Join
+ PyUnicode_Partition=python36.PyUnicode_Partition
+ PyUnicode_RPartition=python36.PyUnicode_RPartition
+ PyUnicode_RSplit=python36.PyUnicode_RSplit
+ PyUnicode_Replace=python36.PyUnicode_Replace
+ PyUnicode_Resize=python36.PyUnicode_Resize
+ PyUnicode_RichCompare=python36.PyUnicode_RichCompare
+ PyUnicode_SetDefaultEncoding=python36.PyUnicode_SetDefaultEncoding
+ PyUnicode_Split=python36.PyUnicode_Split
+ PyUnicode_Splitlines=python36.PyUnicode_Splitlines
+ PyUnicode_Tailmatch=python36.PyUnicode_Tailmatch
+ PyUnicode_Translate=python36.PyUnicode_Translate
+ PyUnicode_BuildEncodingMap=python36.PyUnicode_BuildEncodingMap
+ PyUnicode_CompareWithASCIIString=python36.PyUnicode_CompareWithASCIIString
+ PyUnicode_DecodeUTF7=python36.PyUnicode_DecodeUTF7
+ PyUnicode_DecodeUTF7Stateful=python36.PyUnicode_DecodeUTF7Stateful
+ PyUnicode_EncodeFSDefault=python36.PyUnicode_EncodeFSDefault
+ PyUnicode_InternFromString=python36.PyUnicode_InternFromString
+ PyUnicode_InternImmortal=python36.PyUnicode_InternImmortal
+ PyUnicode_InternInPlace=python36.PyUnicode_InternInPlace
+ PyUnicode_Type=python36.PyUnicode_Type DATA
+ PyWeakref_GetObject=python36.PyWeakref_GetObject DATA
+ PyWeakref_NewProxy=python36.PyWeakref_NewProxy
+ PyWeakref_NewRef=python36.PyWeakref_NewRef
+ PyWrapperDescr_Type=python36.PyWrapperDescr_Type DATA
+ PyWrapper_New=python36.PyWrapper_New
+ PyZip_Type=python36.PyZip_Type DATA
+ Py_AddPendingCall=python36.Py_AddPendingCall
+ Py_AtExit=python36.Py_AtExit
+ Py_BuildValue=python36.Py_BuildValue
+ Py_CompileString=python36.Py_CompileString
+ Py_DecRef=python36.Py_DecRef
+ Py_EndInterpreter=python36.Py_EndInterpreter
+ Py_Exit=python36.Py_Exit
+ Py_FatalError=python36.Py_FatalError
+ Py_FileSystemDefaultEncoding=python36.Py_FileSystemDefaultEncoding DATA
+ Py_Finalize=python36.Py_Finalize
+ Py_FinalizeEx=python36.Py_FinalizeEx
+ Py_GetBuildInfo=python36.Py_GetBuildInfo
+ Py_GetCompiler=python36.Py_GetCompiler
+ Py_GetCopyright=python36.Py_GetCopyright
+ Py_GetExecPrefix=python36.Py_GetExecPrefix
+ Py_GetPath=python36.Py_GetPath
+ Py_GetPlatform=python36.Py_GetPlatform
+ Py_GetPrefix=python36.Py_GetPrefix
+ Py_GetProgramFullPath=python36.Py_GetProgramFullPath
+ Py_GetProgramName=python36.Py_GetProgramName
+ Py_GetPythonHome=python36.Py_GetPythonHome
+ Py_GetRecursionLimit=python36.Py_GetRecursionLimit
+ Py_GetVersion=python36.Py_GetVersion
+ Py_HasFileSystemDefaultEncoding=python36.Py_HasFileSystemDefaultEncoding DATA
+ Py_IncRef=python36.Py_IncRef
+ Py_Initialize=python36.Py_Initialize
+ Py_InitializeEx=python36.Py_InitializeEx
+ Py_IsInitialized=python36.Py_IsInitialized
+ Py_Main=python36.Py_Main
+ Py_MakePendingCalls=python36.Py_MakePendingCalls
+ Py_NewInterpreter=python36.Py_NewInterpreter
+ Py_ReprEnter=python36.Py_ReprEnter
+ Py_ReprLeave=python36.Py_ReprLeave
+ Py_SetProgramName=python36.Py_SetProgramName
+ Py_SetPythonHome=python36.Py_SetPythonHome
+ Py_SetRecursionLimit=python36.Py_SetRecursionLimit
+ Py_SymtableString=python36.Py_SymtableString
+ Py_VaBuildValue=python36.Py_VaBuildValue
+ _PyErr_BadInternalCall=python36._PyErr_BadInternalCall
+ _PyObject_CallFunction_SizeT=python36._PyObject_CallFunction_SizeT
+ _PyObject_CallMethod_SizeT=python36._PyObject_CallMethod_SizeT
+ _PyObject_GC_Malloc=python36._PyObject_GC_Malloc
+ _PyObject_GC_New=python36._PyObject_GC_New
+ _PyObject_GC_NewVar=python36._PyObject_GC_NewVar
+ _PyObject_GC_Resize=python36._PyObject_GC_Resize
+ _PyObject_New=python36._PyObject_New
+ _PyObject_NewVar=python36._PyObject_NewVar
+ _PyState_AddModule=python36._PyState_AddModule
+ _PyThreadState_Init=python36._PyThreadState_Init
+ _PyThreadState_Prealloc=python36._PyThreadState_Prealloc
+ _PyTrash_delete_later=python36._PyTrash_delete_later DATA
+ _PyTrash_delete_nesting=python36._PyTrash_delete_nesting DATA
+ _PyTrash_deposit_object=python36._PyTrash_deposit_object
+ _PyTrash_destroy_chain=python36._PyTrash_destroy_chain
+ _PyWeakref_CallableProxyType=python36._PyWeakref_CallableProxyType DATA
+ _PyWeakref_ProxyType=python36._PyWeakref_ProxyType DATA
+ _PyWeakref_RefType=python36._PyWeakref_RefType DATA
+ _Py_BuildValue_SizeT=python36._Py_BuildValue_SizeT
+ _Py_CheckRecursionLimit=python36._Py_CheckRecursionLimit DATA
+ _Py_CheckRecursiveCall=python36._Py_CheckRecursiveCall
+ _Py_Dealloc=python36._Py_Dealloc
+ _Py_EllipsisObject=python36._Py_EllipsisObject DATA
+ _Py_FalseStruct=python36._Py_FalseStruct DATA
+ _Py_NoneStruct=python36._Py_NoneStruct DATA
+ _Py_NotImplementedStruct=python36._Py_NotImplementedStruct DATA
+ _Py_SwappedOp=python36._Py_SwappedOp DATA
+ _Py_TrueStruct=python36._Py_TrueStruct DATA
+ _Py_VaBuildValue_SizeT=python36._Py_VaBuildValue_SizeT
+ _PyArg_Parse_SizeT=python36._PyArg_Parse_SizeT
+ _PyArg_ParseTuple_SizeT=python36._PyArg_ParseTuple_SizeT
+ _PyArg_ParseTupleAndKeywords_SizeT=python36._PyArg_ParseTupleAndKeywords_SizeT
+ _PyArg_VaParse_SizeT=python36._PyArg_VaParse_SizeT
+ _PyArg_VaParseTupleAndKeywords_SizeT=python36._PyArg_VaParseTupleAndKeywords_SizeT
+ _Py_BuildValue_SizeT=python36._Py_BuildValue_SizeT
diff --git a/PC/testpy.py b/PC/testpy.py
index 4ef3d4f..709f35c 100644
--- a/PC/testpy.py
+++ b/PC/testpy.py
@@ -26,5 +26,5 @@
# Add the "test" directory to PYTHONPATH.
sys.path = sys.path + [test]
-import regrtest # Standard Python tester.
-regrtest.main()
+import libregrtest # Standard Python tester.
+libregrtest.main()
diff --git a/PC/winreg.c b/PC/winreg.c
index d1c3f39..293825d 100644
--- a/PC/winreg.c
+++ b/PC/winreg.c
@@ -549,7 +549,7 @@
if (value != Py_None && !PyLong_Check(value))
return FALSE;
*retDataBuf = (BYTE *)PyMem_NEW(DWORD, 1);
- if (*retDataBuf==NULL){
+ if (*retDataBuf == NULL){
PyErr_NoMemory();
return FALSE;
}
@@ -563,6 +563,24 @@
memcpy(*retDataBuf, &d, sizeof(DWORD));
}
break;
+ case REG_QWORD:
+ if (value != Py_None && !PyLong_Check(value))
+ return FALSE;
+ *retDataBuf = (BYTE *)PyMem_NEW(DWORD64, 1);
+ if (*retDataBuf == NULL){
+ PyErr_NoMemory();
+ return FALSE;
+ }
+ *retDataSize = sizeof(DWORD64);
+ if (value == Py_None) {
+ DWORD64 zero = 0;
+ memcpy(*retDataBuf, &zero, sizeof(DWORD64));
+ }
+ else {
+ DWORD64 d = PyLong_AsUnsignedLongLong(value);
+ memcpy(*retDataBuf, &d, sizeof(DWORD64));
+ }
+ break;
case REG_SZ:
case REG_EXPAND_SZ:
{
@@ -619,7 +637,7 @@
*retDataSize = size + 2;
*retDataBuf = (BYTE *)PyMem_NEW(char,
*retDataSize);
- if (*retDataBuf==NULL){
+ if (*retDataBuf == NULL){
PyErr_NoMemory();
return FALSE;
}
@@ -665,7 +683,7 @@
return FALSE;
*retDataBuf = (BYTE *)PyMem_NEW(char, view.len);
- if (*retDataBuf==NULL){
+ if (*retDataBuf == NULL){
PyBuffer_Release(&view);
PyErr_NoMemory();
return FALSE;
@@ -690,7 +708,13 @@
if (retDataSize == 0)
obData = PyLong_FromUnsignedLong(0);
else
- obData = PyLong_FromUnsignedLong(*(int *)retDataBuf);
+ obData = PyLong_FromUnsignedLong(*(DWORD *)retDataBuf);
+ break;
+ case REG_QWORD:
+ if (retDataSize == 0)
+ obData = PyLong_FromUnsignedLongLong(0);
+ else
+ obData = PyLong_FromUnsignedLongLong(*(DWORD64 *)retDataBuf);
break;
case REG_SZ:
case REG_EXPAND_SZ:
@@ -1599,7 +1623,7 @@
An integer that specifies the type of the data, one of:
REG_BINARY -- Binary data in any form.
REG_DWORD -- A 32-bit number.
- REG_DWORD_LITTLE_ENDIAN -- A 32-bit number in little-endian format.
+ REG_DWORD_LITTLE_ENDIAN -- A 32-bit number in little-endian format. Equivalent to REG_DWORD
REG_DWORD_BIG_ENDIAN -- A 32-bit number in big-endian format.
REG_EXPAND_SZ -- A null-terminated string that contains unexpanded
references to environment variables (for example,
@@ -1609,6 +1633,8 @@
by two null characters. Note that Python handles
this termination automatically.
REG_NONE -- No defined value type.
+ REG_QWORD -- A 64-bit number.
+ REG_QWORD_LITTLE_ENDIAN -- A 64-bit number in little-endian format. Equivalent to REG_QWORD.
REG_RESOURCE_LIST -- A device-driver resource list.
REG_SZ -- A null-terminated string.
value: object
@@ -1631,7 +1657,7 @@
static PyObject *
winreg_SetValueEx_impl(PyModuleDef *module, HKEY key, Py_UNICODE *value_name,
PyObject *reserved, DWORD type, PyObject *value)
-/*[clinic end generated code: output=ea092a935c361582 input=f1b16cbcc3ed4101]*/
+/*[clinic end generated code: output=ea092a935c361582 input=900a9e3990bfb196]*/
{
BYTE *data;
DWORD len;
@@ -1918,6 +1944,8 @@
ADD_INT(REG_DWORD);
ADD_INT(REG_DWORD_LITTLE_ENDIAN);
ADD_INT(REG_DWORD_BIG_ENDIAN);
+ ADD_INT(REG_QWORD);
+ ADD_INT(REG_QWORD_LITTLE_ENDIAN);
ADD_INT(REG_LINK);
ADD_INT(REG_MULTI_SZ);
ADD_INT(REG_RESOURCE_LIST);
diff --git a/PCbuild/build_pgo.bat b/PCbuild/build_pgo.bat
deleted file mode 100644
index 872c382..0000000
--- a/PCbuild/build_pgo.bat
+++ /dev/null
@@ -1,6 +0,0 @@
-@echo off
-echo.DeprecationWarning:
-echo. This script is deprecated, use `build.bat --pgo` instead.
-echo.
-
-call "%~dp0build.bat" --pgo %*
diff --git a/PCbuild/prepare_ssl.bat b/PCbuild/prepare_ssl.bat
index 1be73e6..2f41ae8 100644
--- a/PCbuild/prepare_ssl.bat
+++ b/PCbuild/prepare_ssl.bat
@@ -3,10 +3,10 @@
if "%1" EQU "Debug" (
shift
set HOST_PYTHON=python_d.exe
- if not exist python35_d.dll exit 1
+ if not exist python36_d.dll exit 1
) ELSE (
set HOST_PYTHON=python.exe
- if not exist python35.dll exit 1
+ if not exist python36.dll exit 1
)
)
%HOST_PYTHON% "%~dp0prepare_ssl.py" %1
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index 3a1b5ba..9dfe9e3 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -124,6 +124,7 @@
<ClInclude Include="..\Include\odictobject.h" />
<ClInclude Include="..\Include\opcode.h" />
<ClInclude Include="..\Include\osdefs.h" />
+ <ClInclude Include="..\Include\osmodule.h" />
<ClInclude Include="..\Include\parsetok.h" />
<ClInclude Include="..\Include\patchlevel.h" />
<ClInclude Include="..\Include\pgen.h" />
@@ -209,6 +210,7 @@
<ClInclude Include="..\Python\condvar.h" />
<ClInclude Include="..\Python\importdl.h" />
<ClInclude Include="..\Python\thread_nt.h" />
+ <ClInclude Include="..\Python\wordcode_helpers.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\Modules\_bisectmodule.c" />
@@ -416,4 +418,4 @@
<Target Name="_WarnAboutToolset" BeforeTargets="PrepareForBuild" Condition="$(PlatformToolset) != 'v140'">
<Warning Text="Toolset $(PlatformToolset) is not used for official builds. Your build may have errors or incompatibilities." />
</Target>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters
index 837b736..ce2ea60 100644
--- a/PCbuild/pythoncore.vcxproj.filters
+++ b/PCbuild/pythoncore.vcxproj.filters
@@ -177,6 +177,9 @@
<ClInclude Include="..\Include\osdefs.h">
<Filter>Include</Filter>
</ClInclude>
+ <ClInclude Include="..\Include\osmodule.h">
+ <Filter>Include</Filter>
+ </ClInclude>
<ClInclude Include="..\Include\parsetok.h">
<Filter>Include</Filter>
</ClInclude>
@@ -420,6 +423,9 @@
<ClInclude Include="..\Python\thread_nt.h">
<Filter>Python</Filter>
</ClInclude>
+ <ClInclude Include="..\Python\wordcode_helpers.h">
+ <Filter>Python</Filter>
+ </ClInclude>
<ClInclude Include="..\Python\condvar.h">
<Filter>Python</Filter>
</ClInclude>
@@ -980,4 +986,4 @@
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/PCbuild/readme.txt b/PCbuild/readme.txt
index d45eb27..2046af9 100644
--- a/PCbuild/readme.txt
+++ b/PCbuild/readme.txt
@@ -48,7 +48,7 @@
Used to build Python with extra debugging capabilities, equivalent
to using ./configure --with-pydebug on UNIX. All binaries built
using this configuration have "_d" added to their name:
- python35_d.dll, python_d.exe, parser_d.pyd, and so on. Both the
+ python36_d.dll, python_d.exe, parser_d.pyd, and so on. Both the
build and rt (run test) batch files in this directory accept a -d
option for debug builds. If you are building Python to help with
development of CPython, you will most likely use this configuration.
diff --git a/PCbuild/rt.bat b/PCbuild/rt.bat
index 2d93b80..7d4d071 100644
--- a/PCbuild/rt.bat
+++ b/PCbuild/rt.bat
@@ -42,7 +42,7 @@
if NOT "%1"=="" (set regrtestargs=%regrtestargs% %1) & shift & goto CheckOpts
set exe=%prefix%python%suffix%.exe
-set cmd="%exe%" %dashO% -Wd -E -bb "%pcbuild%..\lib\test\regrtest.py" %regrtestargs%
+set cmd="%exe%" %dashO% -Wd -E -bb -m test %regrtestargs%
if defined qmode goto Qmode
echo Deleting .pyc/.pyo files ...
diff --git a/PCbuild/xxlimited.vcxproj b/PCbuild/xxlimited.vcxproj
index 0144fa9..9dbdc77 100644
--- a/PCbuild/xxlimited.vcxproj
+++ b/PCbuild/xxlimited.vcxproj
@@ -62,7 +62,7 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
- <PreprocessorDefinitions>%(PreprocessorDefinitions);Py_LIMITED_API=0x03050000</PreprocessorDefinitions>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);Py_LIMITED_API=0x03060000</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>wsock32.lib;%(AdditionalDependencies)</AdditionalDependencies>
diff --git a/Parser/Python.asdl b/Parser/Python.asdl
index cd0832d..aaddf61 100644
--- a/Parser/Python.asdl
+++ b/Parser/Python.asdl
@@ -1,4 +1,8 @@
--- ASDL's six builtin types are identifier, int, string, bytes, object, singleton
+-- ASDL's 7 builtin types are:
+-- identifier, int, string, bytes, object, singleton, constant
+--
+-- singleton: None, True or False
+-- constant can be None, whereas None means "no value" for object.
module Python
{
@@ -71,9 +75,12 @@
| Call(expr func, expr* args, keyword* keywords)
| Num(object n) -- a number as a PyObject.
| Str(string s) -- need to specify raw, unicode, etc?
+ | FormattedValue(expr value, int? conversion, expr? format_spec)
+ | JoinedStr(expr* values)
| Bytes(bytes s)
| NameConstant(singleton value)
| Ellipsis
+ | Constant(constant value)
-- the following expression can appear in assignment context
| Attribute(expr value, identifier attr, expr_context ctx)
diff --git a/Parser/asdl.py b/Parser/asdl.py
index 121cdab..62f5c19 100644
--- a/Parser/asdl.py
+++ b/Parser/asdl.py
@@ -33,7 +33,8 @@
# See the EBNF at the top of the file to understand the logical connection
# between the various node types.
-builtin_types = {'identifier', 'string', 'bytes', 'int', 'object', 'singleton'}
+builtin_types = {'identifier', 'string', 'bytes', 'int', 'object', 'singleton',
+ 'constant'}
class AST:
def __repr__(self):
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
old mode 100755
new mode 100644
index f38c253..17c8517
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -834,6 +834,7 @@
return (PyObject*)o;
}
#define ast2obj_singleton ast2obj_object
+#define ast2obj_constant ast2obj_object
#define ast2obj_identifier ast2obj_object
#define ast2obj_string ast2obj_object
#define ast2obj_bytes ast2obj_object
@@ -871,6 +872,19 @@
return 0;
}
+static int obj2ast_constant(PyObject* obj, PyObject** out, PyArena* arena)
+{
+ if (obj) {
+ if (PyArena_AddPyObject(arena, obj) < 0) {
+ *out = NULL;
+ return -1;
+ }
+ Py_INCREF(obj);
+ }
+ *out = obj;
+ return 0;
+}
+
static int obj2ast_identifier(PyObject* obj, PyObject** out, PyArena* arena)
{
if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
@@ -906,7 +920,7 @@
return 1;
}
- i = (int)PyLong_AsLong(obj);
+ i = _PyLong_AsInt(obj);
if (i == -1 && PyErr_Occurred())
return 1;
*out = i;
diff --git a/Parser/parser.c b/Parser/parser.c
index 56ec514..41072c4 100644
--- a/Parser/parser.c
+++ b/Parser/parser.c
@@ -140,21 +140,20 @@
int n = g->g_ll.ll_nlabels;
if (type == NAME) {
- const char *s = str;
label *l = g->g_ll.ll_label;
int i;
for (i = n; i > 0; i--, l++) {
if (l->lb_type != NAME || l->lb_str == NULL ||
- l->lb_str[0] != s[0] ||
- strcmp(l->lb_str, s) != 0)
+ l->lb_str[0] != str[0] ||
+ strcmp(l->lb_str, str) != 0)
continue;
#ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD
#if 0
/* Leaving this in as an example */
if (!(ps->p_flags & CO_FUTURE_WITH_STATEMENT)) {
- if (s[0] == 'w' && strcmp(s, "with") == 0)
+ if (str[0] == 'w' && strcmp(str, "with") == 0)
break; /* not a keyword yet */
- else if (s[0] == 'a' && strcmp(s, "as") == 0)
+ else if (str[0] == 'a' && strcmp(str, "as") == 0)
break; /* not a keyword yet */
}
#endif
diff --git a/Parser/parsetok.c b/Parser/parsetok.c
index 629dee5..ebe9495 100644
--- a/Parser/parsetok.c
+++ b/Parser/parsetok.c
@@ -161,10 +161,10 @@
#ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD
#if 0
-static char with_msg[] =
+static const char with_msg[] =
"%s:%d: Warning: 'with' will become a reserved keyword in Python 2.6\n";
-static char as_msg[] =
+static const char as_msg[] =
"%s:%d: Warning: 'as' will become a reserved keyword in Python 2.6\n";
static void
diff --git a/Parser/pgen.c b/Parser/pgen.c
index f3031ae..be35e02 100644
--- a/Parser/pgen.c
+++ b/Parser/pgen.c
@@ -134,7 +134,7 @@
#ifdef Py_DEBUG
-static char REQNFMT[] = "metacompile: less than %d children\n";
+static const char REQNFMT[] = "metacompile: less than %d children\n";
#define REQN(i, count) do { \
if (i < count) { \
@@ -379,7 +379,7 @@
/* Forward */
static void printssdfa(int xx_nstates, ss_state *xx_state, int nbits,
- labellist *ll, char *msg);
+ labellist *ll, const char *msg);
static void simplify(int xx_nstates, ss_state *xx_state);
static void convert(dfa *d, int xx_nstates, ss_state *xx_state);
@@ -494,7 +494,7 @@
static void
printssdfa(int xx_nstates, ss_state *xx_state, int nbits,
- labellist *ll, char *msg)
+ labellist *ll, const char *msg)
{
int i, ibit, iarc;
ss_state *yy;
diff --git a/Parser/pgenmain.c b/Parser/pgenmain.c
index 0f055d6..e9d3082 100644
--- a/Parser/pgenmain.c
+++ b/Parser/pgenmain.c
@@ -27,7 +27,7 @@
int Py_IgnoreEnvironmentFlag;
/* Forward */
-grammar *getgrammar(char *filename);
+grammar *getgrammar(const char *filename);
void Py_Exit(int) _Py_NO_RETURN;
@@ -37,6 +37,15 @@
exit(sts);
}
+#ifdef WITH_THREAD
+/* Needed by obmalloc.c */
+int PyGILState_Check(void)
+{ return 1; }
+#endif
+
+void _PyMem_DumpTraceback(int fd, const void *ptr)
+{}
+
int
main(int argc, char **argv)
{
@@ -76,7 +85,7 @@
}
grammar *
-getgrammar(char *filename)
+getgrammar(const char *filename)
{
FILE *fp;
node *n;
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 184ffe7..90a8270 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -202,8 +202,8 @@
}
-static char *
-get_normal_name(char *s) /* for utf-8 and latin-1 */
+static const char *
+get_normal_name(const char *s) /* for utf-8 and latin-1 */
{
char buf[13];
int i;
@@ -264,7 +264,7 @@
if (begin < t) {
char* r = new_string(begin, t - begin, tok);
- char* q;
+ const char* q;
if (!r)
return 0;
q = get_normal_name(r);
@@ -1475,17 +1475,19 @@
nonascii = 0;
if (is_potential_identifier_start(c)) {
/* Process b"", r"", u"", br"" and rb"" */
- int saw_b = 0, saw_r = 0, saw_u = 0;
+ int saw_b = 0, saw_r = 0, saw_u = 0, saw_f = 0;
while (1) {
- if (!(saw_b || saw_u) && (c == 'b' || c == 'B'))
+ if (!(saw_b || saw_u || saw_f) && (c == 'b' || c == 'B'))
saw_b = 1;
/* Since this is a backwards compatibility support literal we don't
want to support it in arbitrary order like byte literals. */
- else if (!(saw_b || saw_u || saw_r) && (c == 'u' || c == 'U'))
+ else if (!(saw_b || saw_u || saw_r || saw_f) && (c == 'u' || c == 'U'))
saw_u = 1;
/* ur"" and ru"" are not supported */
else if (!(saw_r || saw_u) && (c == 'r' || c == 'R'))
saw_r = 1;
+ else if (!(saw_f || saw_b || saw_u) && (c == 'f' || c == 'F'))
+ saw_f = 1;
else
break;
c = tok_nextc(tok);
@@ -1585,10 +1587,6 @@
if (c == '0') {
/* Hex, octal or binary -- maybe. */
c = tok_nextc(tok);
- if (c == '.')
- goto fraction;
- if (c == 'j' || c == 'J')
- goto imaginary;
if (c == 'x' || c == 'X') {
/* Hex */
@@ -1739,7 +1737,7 @@
else {
end_quote_size = 0;
if (c == '\\')
- c = tok_nextc(tok); /* skip escaped char */
+ c = tok_nextc(tok); /* skip escaped char */
}
}
diff --git a/Programs/python.c b/Programs/python.c
index 37b10b8..a7afbc7 100644
--- a/Programs/python.c
+++ b/Programs/python.c
@@ -24,6 +24,9 @@
int i, res;
char *oldloc;
+ /* Force malloc() allocator to bootstrap Python */
+ (void)_PyMem_SetupAllocators("malloc");
+
argv_copy = (wchar_t **)PyMem_RawMalloc(sizeof(wchar_t*) * (argc+1));
argv_copy2 = (wchar_t **)PyMem_RawMalloc(sizeof(wchar_t*) * (argc+1));
if (!argv_copy || !argv_copy2) {
@@ -62,7 +65,13 @@
setlocale(LC_ALL, oldloc);
PyMem_RawFree(oldloc);
+
res = Py_Main(argc, argv_copy);
+
+ /* Force again malloc() allocator to release memory blocks allocated
+ before Py_Main() */
+ (void)_PyMem_SetupAllocators("malloc");
+
for (i = 0; i < argc; i++) {
PyMem_RawFree(argv_copy2[i]);
}
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index edfcbad..1193c7c 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -285,6 +285,18 @@
static char *Str_fields[]={
"s",
};
+static PyTypeObject *FormattedValue_type;
+_Py_IDENTIFIER(conversion);
+_Py_IDENTIFIER(format_spec);
+static char *FormattedValue_fields[]={
+ "value",
+ "conversion",
+ "format_spec",
+};
+static PyTypeObject *JoinedStr_type;
+static char *JoinedStr_fields[]={
+ "values",
+};
static PyTypeObject *Bytes_type;
static char *Bytes_fields[]={
"s",
@@ -294,6 +306,10 @@
"value",
};
static PyTypeObject *Ellipsis_type;
+static PyTypeObject *Constant_type;
+static char *Constant_fields[]={
+ "value",
+};
static PyTypeObject *Attribute_type;
_Py_IDENTIFIER(attr);
_Py_IDENTIFIER(ctx);
@@ -697,6 +713,7 @@
return (PyObject*)o;
}
#define ast2obj_singleton ast2obj_object
+#define ast2obj_constant ast2obj_object
#define ast2obj_identifier ast2obj_object
#define ast2obj_string ast2obj_object
#define ast2obj_bytes ast2obj_object
@@ -734,6 +751,19 @@
return 0;
}
+static int obj2ast_constant(PyObject* obj, PyObject** out, PyArena* arena)
+{
+ if (obj) {
+ if (PyArena_AddPyObject(arena, obj) < 0) {
+ *out = NULL;
+ return -1;
+ }
+ Py_INCREF(obj);
+ }
+ *out = obj;
+ return 0;
+}
+
static int obj2ast_identifier(PyObject* obj, PyObject** out, PyArena* arena)
{
if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
@@ -769,7 +799,7 @@
return 1;
}
- i = (int)PyLong_AsLong(obj);
+ i = _PyLong_AsInt(obj);
if (i == -1 && PyErr_Occurred())
return 1;
*out = i;
@@ -917,6 +947,11 @@
if (!Num_type) return 0;
Str_type = make_type("Str", expr_type, Str_fields, 1);
if (!Str_type) return 0;
+ FormattedValue_type = make_type("FormattedValue", expr_type,
+ FormattedValue_fields, 3);
+ if (!FormattedValue_type) return 0;
+ JoinedStr_type = make_type("JoinedStr", expr_type, JoinedStr_fields, 1);
+ if (!JoinedStr_type) return 0;
Bytes_type = make_type("Bytes", expr_type, Bytes_fields, 1);
if (!Bytes_type) return 0;
NameConstant_type = make_type("NameConstant", expr_type,
@@ -924,6 +959,8 @@
if (!NameConstant_type) return 0;
Ellipsis_type = make_type("Ellipsis", expr_type, NULL, 0);
if (!Ellipsis_type) return 0;
+ Constant_type = make_type("Constant", expr_type, Constant_fields, 1);
+ if (!Constant_type) return 0;
Attribute_type = make_type("Attribute", expr_type, Attribute_fields, 3);
if (!Attribute_type) return 0;
Subscript_type = make_type("Subscript", expr_type, Subscript_fields, 3);
@@ -2063,6 +2100,42 @@
}
expr_ty
+FormattedValue(expr_ty value, int conversion, expr_ty format_spec, int lineno,
+ int col_offset, PyArena *arena)
+{
+ expr_ty p;
+ if (!value) {
+ PyErr_SetString(PyExc_ValueError,
+ "field value is required for FormattedValue");
+ return NULL;
+ }
+ p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ if (!p)
+ return NULL;
+ p->kind = FormattedValue_kind;
+ p->v.FormattedValue.value = value;
+ p->v.FormattedValue.conversion = conversion;
+ p->v.FormattedValue.format_spec = format_spec;
+ p->lineno = lineno;
+ p->col_offset = col_offset;
+ return p;
+}
+
+expr_ty
+JoinedStr(asdl_seq * values, int lineno, int col_offset, PyArena *arena)
+{
+ expr_ty p;
+ p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ if (!p)
+ return NULL;
+ p->kind = JoinedStr_kind;
+ p->v.JoinedStr.values = values;
+ p->lineno = lineno;
+ p->col_offset = col_offset;
+ return p;
+}
+
+expr_ty
Bytes(bytes s, int lineno, int col_offset, PyArena *arena)
{
expr_ty p;
@@ -2114,6 +2187,25 @@
}
expr_ty
+Constant(constant value, int lineno, int col_offset, PyArena *arena)
+{
+ expr_ty p;
+ if (!value) {
+ PyErr_SetString(PyExc_ValueError,
+ "field value is required for Constant");
+ return NULL;
+ }
+ p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ if (!p)
+ return NULL;
+ p->kind = Constant_kind;
+ p->v.Constant.value = value;
+ p->lineno = lineno;
+ p->col_offset = col_offset;
+ return p;
+}
+
+expr_ty
Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int lineno, int
col_offset, PyArena *arena)
{
@@ -3164,6 +3256,34 @@
goto failed;
Py_DECREF(value);
break;
+ case FormattedValue_kind:
+ result = PyType_GenericNew(FormattedValue_type, NULL, NULL);
+ if (!result) goto failed;
+ value = ast2obj_expr(o->v.FormattedValue.value);
+ if (!value) goto failed;
+ if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ value = ast2obj_int(o->v.FormattedValue.conversion);
+ if (!value) goto failed;
+ if (_PyObject_SetAttrId(result, &PyId_conversion, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ value = ast2obj_expr(o->v.FormattedValue.format_spec);
+ if (!value) goto failed;
+ if (_PyObject_SetAttrId(result, &PyId_format_spec, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ break;
+ case JoinedStr_kind:
+ result = PyType_GenericNew(JoinedStr_type, NULL, NULL);
+ if (!result) goto failed;
+ value = ast2obj_list(o->v.JoinedStr.values, ast2obj_expr);
+ if (!value) goto failed;
+ if (_PyObject_SetAttrId(result, &PyId_values, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ break;
case Bytes_kind:
result = PyType_GenericNew(Bytes_type, NULL, NULL);
if (!result) goto failed;
@@ -3186,6 +3306,15 @@
result = PyType_GenericNew(Ellipsis_type, NULL, NULL);
if (!result) goto failed;
break;
+ case Constant_kind:
+ result = PyType_GenericNew(Constant_type, NULL, NULL);
+ if (!result) goto failed;
+ value = ast2obj_constant(o->v.Constant.value);
+ if (!value) goto failed;
+ if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ break;
case Attribute_kind:
result = PyType_GenericNew(Attribute_type, NULL, NULL);
if (!result) goto failed;
@@ -6025,6 +6154,86 @@
if (*out == NULL) goto failed;
return 0;
}
+ isinstance = PyObject_IsInstance(obj, (PyObject*)FormattedValue_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
+ expr_ty value;
+ int conversion;
+ expr_ty format_spec;
+
+ if (_PyObject_HasAttrId(obj, &PyId_value)) {
+ int res;
+ tmp = _PyObject_GetAttrId(obj, &PyId_value);
+ if (tmp == NULL) goto failed;
+ res = obj2ast_expr(tmp, &value, arena);
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ } else {
+ PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from FormattedValue");
+ return 1;
+ }
+ if (exists_not_none(obj, &PyId_conversion)) {
+ int res;
+ tmp = _PyObject_GetAttrId(obj, &PyId_conversion);
+ if (tmp == NULL) goto failed;
+ res = obj2ast_int(tmp, &conversion, arena);
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ } else {
+ conversion = 0;
+ }
+ if (exists_not_none(obj, &PyId_format_spec)) {
+ int res;
+ tmp = _PyObject_GetAttrId(obj, &PyId_format_spec);
+ if (tmp == NULL) goto failed;
+ res = obj2ast_expr(tmp, &format_spec, arena);
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ } else {
+ format_spec = NULL;
+ }
+ *out = FormattedValue(value, conversion, format_spec, lineno,
+ col_offset, arena);
+ if (*out == NULL) goto failed;
+ return 0;
+ }
+ isinstance = PyObject_IsInstance(obj, (PyObject*)JoinedStr_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
+ asdl_seq* values;
+
+ if (_PyObject_HasAttrId(obj, &PyId_values)) {
+ int res;
+ Py_ssize_t len;
+ Py_ssize_t i;
+ tmp = _PyObject_GetAttrId(obj, &PyId_values);
+ if (tmp == NULL) goto failed;
+ if (!PyList_Check(tmp)) {
+ PyErr_Format(PyExc_TypeError, "JoinedStr field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name);
+ goto failed;
+ }
+ len = PyList_GET_SIZE(tmp);
+ values = _Py_asdl_seq_new(len, arena);
+ if (values == NULL) goto failed;
+ for (i = 0; i < len; i++) {
+ expr_ty value;
+ res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
+ if (res != 0) goto failed;
+ asdl_seq_SET(values, i, value);
+ }
+ Py_CLEAR(tmp);
+ } else {
+ PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from JoinedStr");
+ return 1;
+ }
+ *out = JoinedStr(values, lineno, col_offset, arena);
+ if (*out == NULL) goto failed;
+ return 0;
+ }
isinstance = PyObject_IsInstance(obj, (PyObject*)Bytes_type);
if (isinstance == -1) {
return 1;
@@ -6079,6 +6288,28 @@
if (*out == NULL) goto failed;
return 0;
}
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Constant_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
+ constant value;
+
+ if (_PyObject_HasAttrId(obj, &PyId_value)) {
+ int res;
+ tmp = _PyObject_GetAttrId(obj, &PyId_value);
+ if (tmp == NULL) goto failed;
+ res = obj2ast_constant(tmp, &value, arena);
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ } else {
+ PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Constant");
+ return 1;
+ }
+ *out = Constant(value, lineno, col_offset, arena);
+ if (*out == NULL) goto failed;
+ return 0;
+ }
isinstance = PyObject_IsInstance(obj, (PyObject*)Attribute_type);
if (isinstance == -1) {
return 1;
@@ -7346,12 +7577,18 @@
if (PyDict_SetItemString(d, "Call", (PyObject*)Call_type) < 0) return NULL;
if (PyDict_SetItemString(d, "Num", (PyObject*)Num_type) < 0) return NULL;
if (PyDict_SetItemString(d, "Str", (PyObject*)Str_type) < 0) return NULL;
+ if (PyDict_SetItemString(d, "FormattedValue",
+ (PyObject*)FormattedValue_type) < 0) return NULL;
+ if (PyDict_SetItemString(d, "JoinedStr", (PyObject*)JoinedStr_type) < 0)
+ return NULL;
if (PyDict_SetItemString(d, "Bytes", (PyObject*)Bytes_type) < 0) return
NULL;
if (PyDict_SetItemString(d, "NameConstant", (PyObject*)NameConstant_type) <
0) return NULL;
if (PyDict_SetItemString(d, "Ellipsis", (PyObject*)Ellipsis_type) < 0)
return NULL;
+ if (PyDict_SetItemString(d, "Constant", (PyObject*)Constant_type) < 0)
+ return NULL;
if (PyDict_SetItemString(d, "Attribute", (PyObject*)Attribute_type) < 0)
return NULL;
if (PyDict_SetItemString(d, "Subscript", (PyObject*)Subscript_type) < 0)
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 978bad1..40f5c8e 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -40,12 +40,11 @@
A NULL return value can mean false or an error.
*/
static PyObject *
-get_warnings_attr(const char *attr)
+get_warnings_attr(const char *attr, int try_import)
{
static PyObject *warnings_str = NULL;
PyObject *all_modules;
- PyObject *warnings_module;
- int result;
+ PyObject *warnings_module, *obj;
if (warnings_str == NULL) {
warnings_str = PyUnicode_InternFromString("warnings");
@@ -53,15 +52,34 @@
return NULL;
}
- all_modules = PyImport_GetModuleDict();
- result = PyDict_Contains(all_modules, warnings_str);
- if (result == -1 || result == 0)
- return NULL;
-
- warnings_module = PyDict_GetItem(all_modules, warnings_str);
- if (!PyObject_HasAttrString(warnings_module, attr))
+ /* don't try to import after the start of the Python finallization */
+ if (try_import && _Py_Finalizing == NULL) {
+ warnings_module = PyImport_Import(warnings_str);
+ if (warnings_module == NULL) {
+ /* Fallback to the C implementation if we cannot get
+ the Python implementation */
+ PyErr_Clear();
return NULL;
- return PyObject_GetAttrString(warnings_module, attr);
+ }
+ }
+ else {
+ all_modules = PyImport_GetModuleDict();
+
+ warnings_module = PyDict_GetItem(all_modules, warnings_str);
+ if (warnings_module == NULL)
+ return NULL;
+
+ Py_INCREF(warnings_module);
+ }
+
+ if (!PyObject_HasAttrString(warnings_module, attr)) {
+ Py_DECREF(warnings_module);
+ return NULL;
+ }
+
+ obj = PyObject_GetAttrString(warnings_module, attr);
+ Py_DECREF(warnings_module);
+ return obj;
}
@@ -70,7 +88,7 @@
{
PyObject *registry;
- registry = get_warnings_attr("onceregistry");
+ registry = get_warnings_attr("onceregistry", 0);
if (registry == NULL) {
if (PyErr_Occurred())
return NULL;
@@ -87,7 +105,7 @@
{
PyObject *default_action;
- default_action = get_warnings_attr("defaultaction");
+ default_action = get_warnings_attr("defaultaction", 0);
if (default_action == NULL) {
if (PyErr_Occurred()) {
return NULL;
@@ -110,7 +128,7 @@
Py_ssize_t i;
PyObject *warnings_filters;
- warnings_filters = get_warnings_attr("filters");
+ warnings_filters = get_warnings_attr("filters", 0);
if (warnings_filters == NULL) {
if (PyErr_Occurred())
return NULL;
@@ -287,8 +305,8 @@
}
static void
-show_warning(PyObject *filename, int lineno, PyObject *text, PyObject
- *category, PyObject *sourceline)
+show_warning(PyObject *filename, int lineno, PyObject *text,
+ PyObject *category, PyObject *sourceline)
{
PyObject *f_stderr;
PyObject *name;
@@ -359,10 +377,64 @@
PyErr_Clear();
}
+static int
+call_show_warning(PyObject *category, PyObject *text, PyObject *message,
+ PyObject *filename, int lineno, PyObject *lineno_obj,
+ PyObject *sourceline, PyObject *source)
+{
+ PyObject *show_fn, *msg, *res, *warnmsg_cls = NULL;
+
+ /* If the source parameter is set, try to get the Python implementation.
+ The Python implementation is able to log the traceback where the source
+ was allocated, whereas the C implementation doesnt. */
+ show_fn = get_warnings_attr("_showwarnmsg", source != NULL);
+ if (show_fn == NULL) {
+ if (PyErr_Occurred())
+ return -1;
+ show_warning(filename, lineno, text, category, sourceline);
+ return 0;
+ }
+
+ if (!PyCallable_Check(show_fn)) {
+ PyErr_SetString(PyExc_TypeError,
+ "warnings._showwarnmsg() must be set to a callable");
+ goto error;
+ }
+
+ warnmsg_cls = get_warnings_attr("WarningMessage", 0);
+ if (warnmsg_cls == NULL) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "unable to get warnings.WarningMessage");
+ goto error;
+ }
+
+ msg = PyObject_CallFunctionObjArgs(warnmsg_cls, message, category,
+ filename, lineno_obj, Py_None, Py_None, source,
+ NULL);
+ Py_DECREF(warnmsg_cls);
+ if (msg == NULL)
+ goto error;
+
+ res = PyObject_CallFunctionObjArgs(show_fn, msg, NULL);
+ Py_DECREF(show_fn);
+ Py_DECREF(msg);
+
+ if (res == NULL)
+ return -1;
+
+ Py_DECREF(res);
+ return 0;
+
+error:
+ Py_XDECREF(show_fn);
+ return -1;
+}
+
static PyObject *
warn_explicit(PyObject *category, PyObject *message,
PyObject *filename, int lineno,
- PyObject *module, PyObject *registry, PyObject *sourceline)
+ PyObject *module, PyObject *registry, PyObject *sourceline,
+ PyObject *source)
{
PyObject *key = NULL, *text = NULL, *result = NULL, *lineno_obj = NULL;
PyObject *item = NULL;
@@ -470,31 +542,9 @@
if (rc == 1) /* Already warned for this module. */
goto return_none;
if (rc == 0) {
- PyObject *show_fxn = get_warnings_attr("showwarning");
- if (show_fxn == NULL) {
- if (PyErr_Occurred())
- goto cleanup;
- show_warning(filename, lineno, text, category, sourceline);
- }
- else {
- PyObject *res;
-
- if (!PyCallable_Check(show_fxn)) {
- PyErr_SetString(PyExc_TypeError,
- "warnings.showwarning() must be set to a "
- "callable");
- Py_DECREF(show_fxn);
- goto cleanup;
- }
-
- res = PyObject_CallFunctionObjArgs(show_fxn, message, category,
- filename, lineno_obj,
- NULL);
- Py_DECREF(show_fxn);
- Py_XDECREF(res);
- if (res == NULL)
- goto cleanup;
- }
+ if (call_show_warning(category, text, message, filename, lineno,
+ lineno_obj, sourceline, source) < 0)
+ goto cleanup;
}
else /* if (rc == -1) */
goto cleanup;
@@ -738,7 +788,8 @@
}
static PyObject *
-do_warn(PyObject *message, PyObject *category, Py_ssize_t stack_level)
+do_warn(PyObject *message, PyObject *category, Py_ssize_t stack_level,
+ PyObject *source)
{
PyObject *filename, *module, *registry, *res;
int lineno;
@@ -747,7 +798,7 @@
return NULL;
res = warn_explicit(category, message, filename, lineno, module, registry,
- NULL);
+ NULL, source);
Py_DECREF(filename);
Py_DECREF(registry);
Py_DECREF(module);
@@ -757,25 +808,27 @@
static PyObject *
warnings_warn(PyObject *self, PyObject *args, PyObject *kwds)
{
- static char *kw_list[] = { "message", "category", "stacklevel", 0 };
- PyObject *message, *category = NULL;
+ static char *kw_list[] = {"message", "category", "stacklevel",
+ "source", NULL};
+ PyObject *message, *category = NULL, *source = NULL;
Py_ssize_t stack_level = 1;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|On:warn", kw_list,
- &message, &category, &stack_level))
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|OnO:warn", kw_list,
+ &message, &category, &stack_level, &source))
return NULL;
category = get_category(message, category);
if (category == NULL)
return NULL;
- return do_warn(message, category, stack_level);
+ return do_warn(message, category, stack_level, source);
}
static PyObject *
warnings_warn_explicit(PyObject *self, PyObject *args, PyObject *kwds)
{
static char *kwd_list[] = {"message", "category", "filename", "lineno",
- "module", "registry", "module_globals", 0};
+ "module", "registry", "module_globals",
+ "source", 0};
PyObject *message;
PyObject *category;
PyObject *filename;
@@ -783,10 +836,11 @@
PyObject *module = NULL;
PyObject *registry = NULL;
PyObject *module_globals = NULL;
+ PyObject *sourceobj = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOUi|OOO:warn_explicit",
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOUi|OOOO:warn_explicit",
kwd_list, &message, &category, &filename, &lineno, &module,
- ®istry, &module_globals))
+ ®istry, &module_globals, &sourceobj))
return NULL;
if (module_globals) {
@@ -842,14 +896,14 @@
/* Handle the warning. */
returned = warn_explicit(category, message, filename, lineno, module,
- registry, source_line);
+ registry, source_line, sourceobj);
Py_DECREF(source_list);
return returned;
}
standard_call:
return warn_explicit(category, message, filename, lineno, module,
- registry, NULL);
+ registry, NULL, sourceobj);
}
static PyObject *
@@ -864,14 +918,14 @@
static int
warn_unicode(PyObject *category, PyObject *message,
- Py_ssize_t stack_level)
+ Py_ssize_t stack_level, PyObject *source)
{
PyObject *res;
if (category == NULL)
category = PyExc_RuntimeWarning;
- res = do_warn(message, category, stack_level);
+ res = do_warn(message, category, stack_level, source);
if (res == NULL)
return -1;
Py_DECREF(res);
@@ -879,12 +933,28 @@
return 0;
}
+static int
+_PyErr_WarnFormatV(PyObject *source,
+ PyObject *category, Py_ssize_t stack_level,
+ const char *format, va_list vargs)
+{
+ PyObject *message;
+ int res;
+
+ message = PyUnicode_FromFormatV(format, vargs);
+ if (message == NULL)
+ return -1;
+
+ res = warn_unicode(category, message, stack_level, source);
+ Py_DECREF(message);
+ return res;
+}
+
int
PyErr_WarnFormat(PyObject *category, Py_ssize_t stack_level,
const char *format, ...)
{
- int ret;
- PyObject *message;
+ int res;
va_list vargs;
#ifdef HAVE_STDARG_PROTOTYPES
@@ -892,25 +962,38 @@
#else
va_start(vargs);
#endif
- message = PyUnicode_FromFormatV(format, vargs);
- if (message != NULL) {
- ret = warn_unicode(category, message, stack_level);
- Py_DECREF(message);
- }
- else
- ret = -1;
+ res = _PyErr_WarnFormatV(NULL, category, stack_level, format, vargs);
va_end(vargs);
- return ret;
+ return res;
}
int
+PyErr_ResourceWarning(PyObject *source, Py_ssize_t stack_level,
+ const char *format, ...)
+{
+ int res;
+ va_list vargs;
+
+#ifdef HAVE_STDARG_PROTOTYPES
+ va_start(vargs, format);
+#else
+ va_start(vargs);
+#endif
+ res = _PyErr_WarnFormatV(source, PyExc_ResourceWarning,
+ stack_level, format, vargs);
+ va_end(vargs);
+ return res;
+}
+
+
+int
PyErr_WarnEx(PyObject *category, const char *text, Py_ssize_t stack_level)
{
int ret;
PyObject *message = PyUnicode_FromString(text);
if (message == NULL)
return -1;
- ret = warn_unicode(category, message, stack_level);
+ ret = warn_unicode(category, message, stack_level, NULL);
Py_DECREF(message);
return ret;
}
@@ -921,7 +1004,7 @@
#undef PyErr_Warn
PyAPI_FUNC(int)
-PyErr_Warn(PyObject *category, char *text)
+PyErr_Warn(PyObject *category, const char *text)
{
return PyErr_WarnEx(category, text, 1);
}
@@ -936,7 +1019,7 @@
if (category == NULL)
category = PyExc_RuntimeWarning;
res = warn_explicit(category, message, filename, lineno,
- module, registry, NULL);
+ module, registry, NULL, NULL);
if (res == NULL)
return -1;
Py_DECREF(res);
@@ -1000,7 +1083,7 @@
if (message != NULL) {
PyObject *res;
res = warn_explicit(category, message, filename, lineno,
- module, registry, NULL);
+ module, registry, NULL, NULL);
Py_DECREF(message);
if (res != NULL) {
Py_DECREF(res);
diff --git a/Python/ast.c b/Python/ast.c
index 7743c31..8c13e0b 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -132,6 +132,52 @@
}
static int
+validate_constant(PyObject *value)
+{
+ if (value == Py_None || value == Py_Ellipsis)
+ return 1;
+
+ if (PyLong_CheckExact(value)
+ || PyFloat_CheckExact(value)
+ || PyComplex_CheckExact(value)
+ || PyBool_Check(value)
+ || PyUnicode_CheckExact(value)
+ || PyBytes_CheckExact(value))
+ return 1;
+
+ if (PyTuple_CheckExact(value) || PyFrozenSet_CheckExact(value)) {
+ PyObject *it;
+
+ it = PyObject_GetIter(value);
+ if (it == NULL)
+ return 0;
+
+ while (1) {
+ PyObject *item = PyIter_Next(it);
+ if (item == NULL) {
+ if (PyErr_Occurred()) {
+ Py_DECREF(it);
+ return 0;
+ }
+ break;
+ }
+
+ if (!validate_constant(item)) {
+ Py_DECREF(it);
+ Py_DECREF(item);
+ return 0;
+ }
+ Py_DECREF(item);
+ }
+
+ Py_DECREF(it);
+ return 1;
+ }
+
+ return 0;
+}
+
+static int
validate_expr(expr_ty exp, expr_context_ty ctx)
{
int check_ctx = 1;
@@ -240,6 +286,14 @@
return validate_expr(exp->v.Call.func, Load) &&
validate_exprs(exp->v.Call.args, Load, 0) &&
validate_keywords(exp->v.Call.keywords);
+ case Constant_kind:
+ if (!validate_constant(exp->v.Constant.value)) {
+ PyErr_Format(PyExc_TypeError,
+ "got an invalid type in Constant: %s",
+ Py_TYPE(exp->v.Constant.value)->tp_name);
+ return 0;
+ }
+ return 1;
case Num_kind: {
PyObject *n = exp->v.Num.n;
if (!PyLong_CheckExact(n) && !PyFloat_CheckExact(n) &&
@@ -257,6 +311,14 @@
}
return 1;
}
+ case JoinedStr_kind:
+ return validate_exprs(exp->v.JoinedStr.values, Load, 0);
+ case FormattedValue_kind:
+ if (validate_expr(exp->v.FormattedValue.value, Load) == 0)
+ return 0;
+ if (exp->v.FormattedValue.format_spec)
+ return validate_expr(exp->v.FormattedValue.format_spec, Load);
+ return 1;
case Bytes_kind: {
PyObject *b = exp->v.Bytes.s;
if (!PyBytes_CheckExact(b)) {
@@ -413,8 +475,8 @@
case Import_kind:
return validate_nonempty_seq(stmt->v.Import.names, "names", "Import");
case ImportFrom_kind:
- if (stmt->v.ImportFrom.level < -1) {
- PyErr_SetString(PyExc_ValueError, "ImportFrom level less than -1");
+ if (stmt->v.ImportFrom.level < 0) {
+ PyErr_SetString(PyExc_ValueError, "Negative ImportFrom level");
return 0;
}
return validate_nonempty_seq(stmt->v.ImportFrom.names, "names", "ImportFrom");
@@ -512,8 +574,7 @@
/* Data structure used internally */
struct compiling {
- char *c_encoding; /* source encoding */
- PyArena *c_arena; /* arena for allocating memeory */
+ PyArena *c_arena; /* Arena for allocating memory. */
PyObject *c_filename; /* filename */
PyObject *c_normalize; /* Normalization function from unicodedata. */
PyObject *c_normalize_args; /* Normalization argument tuple. */
@@ -535,9 +596,7 @@
static expr_ty ast_for_call(struct compiling *, const node *, expr_ty);
static PyObject *parsenumber(struct compiling *, const char *);
-static PyObject *parsestr(struct compiling *, const node *n, int *bytesmode);
-static PyObject *parsestrplus(struct compiling *, const node *n,
- int *bytesmode);
+static expr_ty parsestrplus(struct compiling *, const node *n);
#define COMP_GENEXP 0
#define COMP_LISTCOMP 1
@@ -701,23 +760,11 @@
c.c_arena = arena;
/* borrowed reference */
c.c_filename = filename;
- c.c_normalize = c.c_normalize_args = NULL;
- if (flags && flags->cf_flags & PyCF_SOURCE_IS_UTF8) {
- c.c_encoding = "utf-8";
- if (TYPE(n) == encoding_decl) {
-#if 0
- ast_error(c, n, "encoding declaration in Unicode string");
- goto out;
-#endif
- n = CHILD(n, 0);
- }
- } else if (TYPE(n) == encoding_decl) {
- c.c_encoding = STR(n);
+ c.c_normalize = NULL;
+ c.c_normalize_args = NULL;
+
+ if (TYPE(n) == encoding_decl)
n = CHILD(n, 0);
- } else {
- /* PEP 3120 */
- c.c_encoding = "utf-8";
- }
k = 0;
switch (TYPE(n)) {
@@ -864,7 +911,7 @@
}
}
-static const char* FORBIDDEN[] = {
+static const char * const FORBIDDEN[] = {
"None",
"True",
"False",
@@ -881,7 +928,7 @@
return 1;
}
if (full_checks) {
- const char **p;
+ const char * const *p;
for (p = FORBIDDEN; *p; p++) {
if (PyUnicode_CompareWithASCIIString(name, *p) == 0) {
ast_error(c, n, "assignment to keyword");
@@ -943,13 +990,8 @@
s = e->v.List.elts;
break;
case Tuple_kind:
- if (asdl_seq_LEN(e->v.Tuple.elts)) {
- e->v.Tuple.ctx = ctx;
- s = e->v.Tuple.elts;
- }
- else {
- expr_name = "()";
- }
+ e->v.Tuple.ctx = ctx;
+ s = e->v.Tuple.elts;
break;
case Lambda_kind:
expr_name = "lambda";
@@ -986,6 +1028,8 @@
case Num_kind:
case Str_kind:
case Bytes_kind:
+ case JoinedStr_kind:
+ case FormattedValue_kind:
expr_name = "literal";
break;
case NameConstant_kind:
@@ -1259,16 +1303,20 @@
and varargslist (lambda definition).
parameters: '(' [typedargslist] ')'
- typedargslist: ((tfpdef ['=' test] ',')*
- ('*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef]
- | '**' tfpdef)
- | tfpdef ['=' test] (',' tfpdef ['=' test])* [','])
+ typedargslist: (tfpdef ['=' test] (',' tfpdef ['=' test])* [',' [
+ '*' [tfpdef] (',' tfpdef ['=' test])* [',' ['**' tfpdef [',']]]
+ | '**' tfpdef [',']]]
+ | '*' [tfpdef] (',' tfpdef ['=' test])* [',' ['**' tfpdef [',']]]
+ | '**' tfpdef [','])
tfpdef: NAME [':' test]
- varargslist: ((vfpdef ['=' test] ',')*
- ('*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef]
- | '**' vfpdef)
- | vfpdef ['=' test] (',' vfpdef ['=' test])* [','])
+ varargslist: (vfpdef ['=' test] (',' vfpdef ['=' test])* [',' [
+ '*' [vfpdef] (',' vfpdef ['=' test])* [',' ['**' vfpdef [',']]]
+ | '**' vfpdef [',']]]
+ | '*' [vfpdef] (',' vfpdef ['=' test])* [',' ['**' vfpdef [',']]]
+ | '**' vfpdef [',']
+ )
vfpdef: NAME
+
*/
int i, j, k, nposargs = 0, nkwonlyargs = 0;
int nposdefaults = 0, found_default = 0;
@@ -1370,7 +1418,8 @@
i += 2; /* the name and the comma */
break;
case STAR:
- if (i+1 >= NCH(n)) {
+ if (i+1 >= NCH(n) ||
+ (i+2 == NCH(n) && TYPE(CHILD(n, i+1)) == COMMA)) {
ast_error(c, CHILD(n, i),
"named arguments must follow bare *");
return NULL;
@@ -1993,7 +2042,6 @@
| '...' | 'None' | 'True' | 'False'
*/
node *ch = CHILD(n, 0);
- int bytesmode = 0;
switch (TYPE(ch)) {
case NAME: {
@@ -2015,7 +2063,7 @@
return Name(name, Load, LINENO(n), n->n_col_offset, c->c_arena);
}
case STRING: {
- PyObject *str = parsestrplus(c, n, &bytesmode);
+ expr_ty str = parsestrplus(c, n);
if (!str) {
const char *errtype = NULL;
if (PyErr_ExceptionMatches(PyExc_UnicodeError))
@@ -2032,6 +2080,7 @@
PyOS_snprintf(buf, sizeof(buf), "(%s) %s", errtype, s);
Py_DECREF(errstr);
} else {
+ PyErr_Clear();
PyOS_snprintf(buf, sizeof(buf), "(%s) unknown error", errtype);
}
ast_error(c, n, buf);
@@ -2041,14 +2090,7 @@
}
return NULL;
}
- if (PyArena_AddPyObject(c->c_arena, str) < 0) {
- Py_DECREF(str);
- return NULL;
- }
- if (bytesmode)
- return Bytes(str, LINENO(n), n->n_col_offset, c->c_arena);
- else
- return Str(str, LINENO(n), n->n_col_offset, c->c_arena);
+ return str;
}
case NUMBER: {
PyObject *pynum = parsenumber(c, STR(ch));
@@ -3208,14 +3250,14 @@
alias_ty import_alias = alias_for_import_name(c, n, 1);
if (!import_alias)
return NULL;
- asdl_seq_SET(aliases, 0, import_alias);
+ asdl_seq_SET(aliases, 0, import_alias);
}
else {
for (i = 0; i < NCH(n); i += 2) {
alias_ty import_alias = alias_for_import_name(c, CHILD(n, i), 1);
if (!import_alias)
return NULL;
- asdl_seq_SET(aliases, i / 2, import_alias);
+ asdl_seq_SET(aliases, i / 2, import_alias);
}
}
if (mod != NULL)
@@ -3935,82 +3977,932 @@
}
static PyObject *
-decode_unicode(struct compiling *c, const char *s, size_t len, int rawmode, const char *encoding)
+decode_unicode_with_escapes(struct compiling *c, const char *s, size_t len)
{
PyObject *v, *u;
char *buf;
char *p;
const char *end;
- if (encoding == NULL) {
- u = NULL;
- } else {
- /* check for integer overflow */
- if (len > PY_SIZE_MAX / 6)
- return NULL;
- /* "ä" (2 bytes) may become "\U000000E4" (10 bytes), or 1:5
- "\ä" (3 bytes) may become "\u005c\U000000E4" (16 bytes), or ~1:6 */
- u = PyBytes_FromStringAndSize((char *)NULL, len * 6);
- if (u == NULL)
- return NULL;
- p = buf = PyBytes_AsString(u);
- end = s + len;
- while (s < end) {
- if (*s == '\\') {
- *p++ = *s++;
- if (*s & 0x80) {
- strcpy(p, "u005c");
- p += 5;
- }
- }
- if (*s & 0x80) { /* XXX inefficient */
- PyObject *w;
- int kind;
- void *data;
- Py_ssize_t len, i;
- w = decode_utf8(c, &s, end);
- if (w == NULL) {
- Py_DECREF(u);
- return NULL;
- }
- kind = PyUnicode_KIND(w);
- data = PyUnicode_DATA(w);
- len = PyUnicode_GET_LENGTH(w);
- for (i = 0; i < len; i++) {
- Py_UCS4 chr = PyUnicode_READ(kind, data, i);
- sprintf(p, "\\U%08x", chr);
- p += 10;
- }
- /* Should be impossible to overflow */
- assert(p - buf <= Py_SIZE(u));
- Py_DECREF(w);
- } else {
- *p++ = *s++;
+ /* check for integer overflow */
+ if (len > PY_SIZE_MAX / 6)
+ return NULL;
+ /* "ä" (2 bytes) may become "\U000000E4" (10 bytes), or 1:5
+ "\ä" (3 bytes) may become "\u005c\U000000E4" (16 bytes), or ~1:6 */
+ u = PyBytes_FromStringAndSize((char *)NULL, len * 6);
+ if (u == NULL)
+ return NULL;
+ p = buf = PyBytes_AsString(u);
+ end = s + len;
+ while (s < end) {
+ if (*s == '\\') {
+ *p++ = *s++;
+ if (*s & 0x80) {
+ strcpy(p, "u005c");
+ p += 5;
}
}
- len = p - buf;
- s = buf;
+ if (*s & 0x80) { /* XXX inefficient */
+ PyObject *w;
+ int kind;
+ void *data;
+ Py_ssize_t len, i;
+ w = decode_utf8(c, &s, end);
+ if (w == NULL) {
+ Py_DECREF(u);
+ return NULL;
+ }
+ kind = PyUnicode_KIND(w);
+ data = PyUnicode_DATA(w);
+ len = PyUnicode_GET_LENGTH(w);
+ for (i = 0; i < len; i++) {
+ Py_UCS4 chr = PyUnicode_READ(kind, data, i);
+ sprintf(p, "\\U%08x", chr);
+ p += 10;
+ }
+ /* Should be impossible to overflow */
+ assert(p - buf <= Py_SIZE(u));
+ Py_DECREF(w);
+ } else {
+ *p++ = *s++;
+ }
}
- if (rawmode)
- v = PyUnicode_DecodeRawUnicodeEscape(s, len, NULL);
- else
- v = PyUnicode_DecodeUnicodeEscape(s, len, NULL);
+ len = p - buf;
+ s = buf;
+
+ v = PyUnicode_DecodeUnicodeEscape(s, len, NULL);
Py_XDECREF(u);
return v;
}
-/* s is a Python string literal, including the bracketing quote characters,
- * and r &/or b prefixes (if any), and embedded escape sequences (if any).
- * parsestr parses it, and returns the decoded Python string object.
- */
+/* Compile this expression in to an expr_ty. We know that we can
+ temporarily modify the character before the start of this string
+ (it's '{'), and we know we can temporarily modify the character
+ after this string (it is a '}'). Leverage this to create a
+ sub-string with enough room for us to add parens around the
+ expression. This is to allow strings with embedded newlines, for
+ example. */
+static expr_ty
+fstring_compile_expr(PyObject *str, Py_ssize_t expr_start,
+ Py_ssize_t expr_end, struct compiling *c, const node *n)
+
+{
+ PyCompilerFlags cf;
+ mod_ty mod;
+ char *utf_expr;
+ Py_ssize_t i;
+ Py_UCS4 end_ch = -1;
+ int all_whitespace;
+ PyObject *sub = NULL;
+
+ /* We only decref sub if we allocated it with a PyUnicode_Substring.
+ decref_sub records that. */
+ int decref_sub = 0;
+
+ assert(str);
+
+ assert(expr_start >= 0 && expr_start < PyUnicode_GET_LENGTH(str));
+ assert(expr_end >= 0 && expr_end < PyUnicode_GET_LENGTH(str));
+ assert(expr_end >= expr_start);
+
+ /* There has to be at least one character on each side of the
+ expression inside this str. This will have been caught before
+ we're called. */
+ assert(expr_start >= 1);
+ assert(expr_end <= PyUnicode_GET_LENGTH(str)-1);
+
+ /* If the substring is all whitespace, it's an error. We need to
+ catch this here, and not when we call PyParser_ASTFromString,
+ because turning the expression '' in to '()' would go from
+ being invalid to valid. */
+ /* Note that this code says an empty string is all
+ whitespace. That's important. There's a test for it: f'{}'. */
+ all_whitespace = 1;
+ for (i = expr_start; i < expr_end; i++) {
+ if (!Py_UNICODE_ISSPACE(PyUnicode_READ_CHAR(str, i))) {
+ all_whitespace = 0;
+ break;
+ }
+ }
+ if (all_whitespace) {
+ ast_error(c, n, "f-string: empty expression not allowed");
+ goto error;
+ }
+
+ /* If the substring will be the entire source string, we can't use
+ PyUnicode_Substring, since it will return another reference to
+ our original string. Because we're modifying the string in
+ place, that's a no-no. So, detect that case and just use our
+ string directly. */
+
+ if (expr_start-1 == 0 && expr_end+1 == PyUnicode_GET_LENGTH(str)) {
+ /* If str is well formed, then the first and last chars must
+ be '{' and '}', respectively. But, if there's a syntax
+ error, for example f'{3!', then the last char won't be a
+ closing brace. So, remember the last character we read in
+ order for us to restore it. */
+ end_ch = PyUnicode_ReadChar(str, expr_end-expr_start+1);
+ assert(end_ch != (Py_UCS4)-1);
+
+ /* In all cases, however, start_ch must be '{'. */
+ assert(PyUnicode_ReadChar(str, 0) == '{');
+
+ sub = str;
+ } else {
+ /* Create a substring object. It must be a new object, with
+ refcount==1, so that we can modify it. */
+ sub = PyUnicode_Substring(str, expr_start-1, expr_end+1);
+ if (!sub)
+ goto error;
+ assert(sub != str); /* Make sure it's a new string. */
+ decref_sub = 1; /* Remember to deallocate it on error. */
+ }
+
+ /* Put () around the expression. */
+ if (PyUnicode_WriteChar(sub, 0, '(') < 0 ||
+ PyUnicode_WriteChar(sub, expr_end-expr_start+1, ')') < 0)
+ goto error;
+
+ /* No need to free the memory returned here: it's managed by the
+ string. */
+ utf_expr = PyUnicode_AsUTF8(sub);
+ if (!utf_expr)
+ goto error;
+
+ cf.cf_flags = PyCF_ONLY_AST;
+ mod = PyParser_ASTFromString(utf_expr, "<fstring>",
+ Py_eval_input, &cf, c->c_arena);
+ if (!mod)
+ goto error;
+
+ if (sub != str)
+ /* Clear instead of decref in case we ever modify this code to change
+ the error handling: this is safest because the XDECREF won't try
+ and decref it when it's NULL. */
+ /* No need to restore the chars in sub, since we know it's getting
+ ready to get deleted (refcount must be 1, since we got a new string
+ in PyUnicode_Substring). */
+ Py_CLEAR(sub);
+ else {
+ assert(!decref_sub);
+ assert(end_ch != (Py_UCS4)-1);
+ /* Restore str, which we earlier modified directly. */
+ if (PyUnicode_WriteChar(str, 0, '{') < 0 ||
+ PyUnicode_WriteChar(str, expr_end-expr_start+1, end_ch) < 0)
+ goto error;
+ }
+ return mod->v.Expression.body;
+
+error:
+ /* Only decref sub if it was the result of a call to SubString. */
+ if (decref_sub)
+ Py_XDECREF(sub);
+
+ if (end_ch != (Py_UCS4)-1) {
+ /* We only get here if we modified str. Make sure that's the
+ case: str will be equal to sub. */
+ if (str == sub) {
+ /* Don't check the error, because we've already set the
+ error state (that's why we're in 'error', after
+ all). */
+ PyUnicode_WriteChar(str, 0, '{');
+ PyUnicode_WriteChar(str, expr_end-expr_start+1, end_ch);
+ }
+ }
+ return NULL;
+}
+
+/* Return -1 on error.
+
+ Return 0 if we reached the end of the literal.
+
+ Return 1 if we haven't reached the end of the literal, but we want
+ the caller to process the literal up to this point. Used for
+ doubled braces.
+*/
+static int
+fstring_find_literal(PyObject *str, Py_ssize_t *ofs, PyObject **literal,
+ int recurse_lvl, struct compiling *c, const node *n)
+{
+ /* Get any literal string. It ends when we hit an un-doubled brace, or the
+ end of the string. */
+
+ Py_ssize_t literal_start, literal_end;
+ int result = 0;
+
+ enum PyUnicode_Kind kind = PyUnicode_KIND(str);
+ void *data = PyUnicode_DATA(str);
+
+ assert(*literal == NULL);
+
+ literal_start = *ofs;
+ for (; *ofs < PyUnicode_GET_LENGTH(str); *ofs += 1) {
+ Py_UCS4 ch = PyUnicode_READ(kind, data, *ofs);
+ if (ch == '{' || ch == '}') {
+ /* Check for doubled braces, but only at the top level. If
+ we checked at every level, then f'{0:{3}}' would fail
+ with the two closing braces. */
+ if (recurse_lvl == 0) {
+ if (*ofs + 1 < PyUnicode_GET_LENGTH(str) &&
+ PyUnicode_READ(kind, data, *ofs + 1) == ch) {
+ /* We're going to tell the caller that the literal ends
+ here, but that they should continue scanning. But also
+ skip over the second brace when we resume scanning. */
+ literal_end = *ofs + 1;
+ *ofs += 2;
+ result = 1;
+ goto done;
+ }
+
+ /* Where a single '{' is the start of a new expression, a
+ single '}' is not allowed. */
+ if (ch == '}') {
+ ast_error(c, n, "f-string: single '}' is not allowed");
+ return -1;
+ }
+ }
+
+ /* We're either at a '{', which means we're starting another
+ expression; or a '}', which means we're at the end of this
+ f-string (for a nested format_spec). */
+ break;
+ }
+ }
+ literal_end = *ofs;
+
+ assert(*ofs == PyUnicode_GET_LENGTH(str) ||
+ PyUnicode_READ(kind, data, *ofs) == '{' ||
+ PyUnicode_READ(kind, data, *ofs) == '}');
+done:
+ if (literal_start != literal_end) {
+ *literal = PyUnicode_Substring(str, literal_start, literal_end);
+ if (!*literal)
+ return -1;
+ }
+
+ return result;
+}
+
+/* Forward declaration because parsing is recursive. */
+static expr_ty
+fstring_parse(PyObject *str, Py_ssize_t *ofs, int recurse_lvl,
+ struct compiling *c, const node *n);
+
+/* Parse the f-string str, starting at ofs. We know *ofs starts an
+ expression (so it must be a '{'). Returns the FormattedValue node,
+ which includes the expression, conversion character, and
+ format_spec expression.
+
+ Note that I don't do a perfect job here: I don't make sure that a
+ closing brace doesn't match an opening paren, for example. It
+ doesn't need to error on all invalid expressions, just correctly
+ find the end of all valid ones. Any errors inside the expression
+ will be caught when we parse it later. */
+static int
+fstring_find_expr(PyObject *str, Py_ssize_t *ofs, int recurse_lvl,
+ expr_ty *expression, struct compiling *c, const node *n)
+{
+ /* Return -1 on error, else 0. */
+
+ Py_ssize_t expr_start;
+ Py_ssize_t expr_end;
+ expr_ty simple_expression;
+ expr_ty format_spec = NULL; /* Optional format specifier. */
+ Py_UCS4 conversion = -1; /* The conversion char. -1 if not specified. */
+
+ enum PyUnicode_Kind kind = PyUnicode_KIND(str);
+ void *data = PyUnicode_DATA(str);
+
+ /* 0 if we're not in a string, else the quote char we're trying to
+ match (single or double quote). */
+ Py_UCS4 quote_char = 0;
+
+ /* If we're inside a string, 1=normal, 3=triple-quoted. */
+ int string_type = 0;
+
+ /* Keep track of nesting level for braces/parens/brackets in
+ expressions. */
+ Py_ssize_t nested_depth = 0;
+
+ /* Can only nest one level deep. */
+ if (recurse_lvl >= 2) {
+ ast_error(c, n, "f-string: expressions nested too deeply");
+ return -1;
+ }
+
+ /* The first char must be a left brace, or we wouldn't have gotten
+ here. Skip over it. */
+ assert(PyUnicode_READ(kind, data, *ofs) == '{');
+ *ofs += 1;
+
+ expr_start = *ofs;
+ for (; *ofs < PyUnicode_GET_LENGTH(str); *ofs += 1) {
+ Py_UCS4 ch;
+
+ /* Loop invariants. */
+ assert(nested_depth >= 0);
+ assert(*ofs >= expr_start);
+ if (quote_char)
+ assert(string_type == 1 || string_type == 3);
+ else
+ assert(string_type == 0);
+
+ ch = PyUnicode_READ(kind, data, *ofs);
+ if (quote_char) {
+ /* We're inside a string. See if we're at the end. */
+ /* This code needs to implement the same non-error logic
+ as tok_get from tokenizer.c, at the letter_quote
+ label. To actually share that code would be a
+ nightmare. But, it's unlikely to change and is small,
+ so duplicate it here. Note we don't need to catch all
+ of the errors, since they'll be caught when parsing the
+ expression. We just need to match the non-error
+ cases. Thus we can ignore \n in single-quoted strings,
+ for example. Or non-terminated strings. */
+ if (ch == quote_char) {
+ /* Does this match the string_type (single or triple
+ quoted)? */
+ if (string_type == 3) {
+ if (*ofs+2 < PyUnicode_GET_LENGTH(str) &&
+ PyUnicode_READ(kind, data, *ofs+1) == ch &&
+ PyUnicode_READ(kind, data, *ofs+2) == ch) {
+ /* We're at the end of a triple quoted string. */
+ *ofs += 2;
+ string_type = 0;
+ quote_char = 0;
+ continue;
+ }
+ } else {
+ /* We're at the end of a normal string. */
+ quote_char = 0;
+ string_type = 0;
+ continue;
+ }
+ }
+ /* We're inside a string, and not finished with the
+ string. If this is a backslash, skip the next char (it
+ might be an end quote that needs skipping). Otherwise,
+ just consume this character normally. */
+ if (ch == '\\' && *ofs+1 < PyUnicode_GET_LENGTH(str)) {
+ /* Just skip the next char, whatever it is. */
+ *ofs += 1;
+ }
+ } else if (ch == '\'' || ch == '"') {
+ /* Is this a triple quoted string? */
+ if (*ofs+2 < PyUnicode_GET_LENGTH(str) &&
+ PyUnicode_READ(kind, data, *ofs+1) == ch &&
+ PyUnicode_READ(kind, data, *ofs+2) == ch) {
+ string_type = 3;
+ *ofs += 2;
+ } else {
+ /* Start of a normal string. */
+ string_type = 1;
+ }
+ /* Start looking for the end of the string. */
+ quote_char = ch;
+ } else if (ch == '[' || ch == '{' || ch == '(') {
+ nested_depth++;
+ } else if (nested_depth != 0 &&
+ (ch == ']' || ch == '}' || ch == ')')) {
+ nested_depth--;
+ } else if (ch == '#') {
+ /* Error: can't include a comment character, inside parens
+ or not. */
+ ast_error(c, n, "f-string cannot include '#'");
+ return -1;
+ } else if (nested_depth == 0 &&
+ (ch == '!' || ch == ':' || ch == '}')) {
+ /* First, test for the special case of "!=". Since '=' is
+ not an allowed conversion character, nothing is lost in
+ this test. */
+ if (ch == '!' && *ofs+1 < PyUnicode_GET_LENGTH(str) &&
+ PyUnicode_READ(kind, data, *ofs+1) == '=')
+ /* This isn't a conversion character, just continue. */
+ continue;
+
+ /* Normal way out of this loop. */
+ break;
+ } else {
+ /* Just consume this char and loop around. */
+ }
+ }
+ expr_end = *ofs;
+ /* If we leave this loop in a string or with mismatched parens, we
+ don't care. We'll get a syntax error when compiling the
+ expression. But, we can produce a better error message, so
+ let's just do that.*/
+ if (quote_char) {
+ ast_error(c, n, "f-string: unterminated string");
+ return -1;
+ }
+ if (nested_depth) {
+ ast_error(c, n, "f-string: mismatched '(', '{', or '['");
+ return -1;
+ }
+
+ if (*ofs >= PyUnicode_GET_LENGTH(str))
+ goto unexpected_end_of_string;
+
+ /* Compile the expression as soon as possible, so we show errors
+ related to the expression before errors related to the
+ conversion or format_spec. */
+ simple_expression = fstring_compile_expr(str, expr_start, expr_end, c, n);
+ if (!simple_expression)
+ return -1;
+
+ /* Check for a conversion char, if present. */
+ if (PyUnicode_READ(kind, data, *ofs) == '!') {
+ *ofs += 1;
+ if (*ofs >= PyUnicode_GET_LENGTH(str))
+ goto unexpected_end_of_string;
+
+ conversion = PyUnicode_READ(kind, data, *ofs);
+ *ofs += 1;
+
+ /* Validate the conversion. */
+ if (!(conversion == 's' || conversion == 'r'
+ || conversion == 'a')) {
+ ast_error(c, n, "f-string: invalid conversion character: "
+ "expected 's', 'r', or 'a'");
+ return -1;
+ }
+ }
+
+ /* Check for the format spec, if present. */
+ if (*ofs >= PyUnicode_GET_LENGTH(str))
+ goto unexpected_end_of_string;
+ if (PyUnicode_READ(kind, data, *ofs) == ':') {
+ *ofs += 1;
+ if (*ofs >= PyUnicode_GET_LENGTH(str))
+ goto unexpected_end_of_string;
+
+ /* Parse the format spec. */
+ format_spec = fstring_parse(str, ofs, recurse_lvl+1, c, n);
+ if (!format_spec)
+ return -1;
+ }
+
+ if (*ofs >= PyUnicode_GET_LENGTH(str) ||
+ PyUnicode_READ(kind, data, *ofs) != '}')
+ goto unexpected_end_of_string;
+
+ /* We're at a right brace. Consume it. */
+ assert(*ofs < PyUnicode_GET_LENGTH(str));
+ assert(PyUnicode_READ(kind, data, *ofs) == '}');
+ *ofs += 1;
+
+ /* And now create the FormattedValue node that represents this entire
+ expression with the conversion and format spec. */
+ *expression = FormattedValue(simple_expression, (int)conversion,
+ format_spec, LINENO(n), n->n_col_offset,
+ c->c_arena);
+ if (!*expression)
+ return -1;
+
+ return 0;
+
+unexpected_end_of_string:
+ ast_error(c, n, "f-string: expecting '}'");
+ return -1;
+}
+
+/* Return -1 on error.
+
+ Return 0 if we have a literal (possible zero length) and an
+ expression (zero length if at the end of the string.
+
+ Return 1 if we have a literal, but no expression, and we want the
+ caller to call us again. This is used to deal with doubled
+ braces.
+
+ When called multiple times on the string 'a{{b{0}c', this function
+ will return:
+
+ 1. the literal 'a{' with no expression, and a return value
+ of 1. Despite the fact that there's no expression, the return
+ value of 1 means we're not finished yet.
+
+ 2. the literal 'b' and the expression '0', with a return value of
+ 0. The fact that there's an expression means we're not finished.
+
+ 3. literal 'c' with no expression and a return value of 0. The
+ combination of the return value of 0 with no expression means
+ we're finished.
+*/
+static int
+fstring_find_literal_and_expr(PyObject *str, Py_ssize_t *ofs, int recurse_lvl,
+ PyObject **literal, expr_ty *expression,
+ struct compiling *c, const node *n)
+{
+ int result;
+
+ assert(*literal == NULL && *expression == NULL);
+
+ /* Get any literal string. */
+ result = fstring_find_literal(str, ofs, literal, recurse_lvl, c, n);
+ if (result < 0)
+ goto error;
+
+ assert(result == 0 || result == 1);
+
+ if (result == 1)
+ /* We have a literal, but don't look at the expression. */
+ return 1;
+
+ assert(*ofs <= PyUnicode_GET_LENGTH(str));
+
+ if (*ofs >= PyUnicode_GET_LENGTH(str) ||
+ PyUnicode_READ_CHAR(str, *ofs) == '}')
+ /* We're at the end of the string or the end of a nested
+ f-string: no expression. The top-level error case where we
+ expect to be at the end of the string but we're at a '}' is
+ handled later. */
+ return 0;
+
+ /* We must now be the start of an expression, on a '{'. */
+ assert(*ofs < PyUnicode_GET_LENGTH(str) &&
+ PyUnicode_READ_CHAR(str, *ofs) == '{');
+
+ if (fstring_find_expr(str, ofs, recurse_lvl, expression, c, n) < 0)
+ goto error;
+
+ return 0;
+
+error:
+ Py_CLEAR(*literal);
+ return -1;
+}
+
+#define EXPRLIST_N_CACHED 64
+
+typedef struct {
+ /* Incrementally build an array of expr_ty, so be used in an
+ asdl_seq. Cache some small but reasonably sized number of
+ expr_ty's, and then after that start dynamically allocating,
+ doubling the number allocated each time. Note that the f-string
+ f'{0}a{1}' contains 3 expr_ty's: 2 FormattedValue's, and one
+ Str for the literal 'a'. So you add expr_ty's about twice as
+ fast as you add exressions in an f-string. */
+
+ Py_ssize_t allocated; /* Number we've allocated. */
+ Py_ssize_t size; /* Number we've used. */
+ expr_ty *p; /* Pointer to the memory we're actually
+ using. Will point to 'data' until we
+ start dynamically allocating. */
+ expr_ty data[EXPRLIST_N_CACHED];
+} ExprList;
+
+#ifdef NDEBUG
+#define ExprList_check_invariants(l)
+#else
+static void
+ExprList_check_invariants(ExprList *l)
+{
+ /* Check our invariants. Make sure this object is "live", and
+ hasn't been deallocated. */
+ assert(l->size >= 0);
+ assert(l->p != NULL);
+ if (l->size <= EXPRLIST_N_CACHED)
+ assert(l->data == l->p);
+}
+#endif
+
+static void
+ExprList_Init(ExprList *l)
+{
+ l->allocated = EXPRLIST_N_CACHED;
+ l->size = 0;
+
+ /* Until we start allocating dynamically, p points to data. */
+ l->p = l->data;
+
+ ExprList_check_invariants(l);
+}
+
+static int
+ExprList_Append(ExprList *l, expr_ty exp)
+{
+ ExprList_check_invariants(l);
+ if (l->size >= l->allocated) {
+ /* We need to alloc (or realloc) the memory. */
+ Py_ssize_t new_size = l->allocated * 2;
+
+ /* See if we've ever allocated anything dynamically. */
+ if (l->p == l->data) {
+ Py_ssize_t i;
+ /* We're still using the cached data. Switch to
+ alloc-ing. */
+ l->p = PyMem_RawMalloc(sizeof(expr_ty) * new_size);
+ if (!l->p)
+ return -1;
+ /* Copy the cached data into the new buffer. */
+ for (i = 0; i < l->size; i++)
+ l->p[i] = l->data[i];
+ } else {
+ /* Just realloc. */
+ expr_ty *tmp = PyMem_RawRealloc(l->p, sizeof(expr_ty) * new_size);
+ if (!tmp) {
+ PyMem_RawFree(l->p);
+ l->p = NULL;
+ return -1;
+ }
+ l->p = tmp;
+ }
+
+ l->allocated = new_size;
+ assert(l->allocated == 2 * l->size);
+ }
+
+ l->p[l->size++] = exp;
+
+ ExprList_check_invariants(l);
+ return 0;
+}
+
+static void
+ExprList_Dealloc(ExprList *l)
+{
+ ExprList_check_invariants(l);
+
+ /* If there's been an error, or we've never dynamically allocated,
+ do nothing. */
+ if (!l->p || l->p == l->data) {
+ /* Do nothing. */
+ } else {
+ /* We have dynamically allocated. Free the memory. */
+ PyMem_RawFree(l->p);
+ }
+ l->p = NULL;
+ l->size = -1;
+}
+
+static asdl_seq *
+ExprList_Finish(ExprList *l, PyArena *arena)
+{
+ asdl_seq *seq;
+
+ ExprList_check_invariants(l);
+
+ /* Allocate the asdl_seq and copy the expressions in to it. */
+ seq = _Py_asdl_seq_new(l->size, arena);
+ if (seq) {
+ Py_ssize_t i;
+ for (i = 0; i < l->size; i++)
+ asdl_seq_SET(seq, i, l->p[i]);
+ }
+ ExprList_Dealloc(l);
+ return seq;
+}
+
+/* The FstringParser is designed to add a mix of strings and
+ f-strings, and concat them together as needed. Ultimately, it
+ generates an expr_ty. */
+typedef struct {
+ PyObject *last_str;
+ ExprList expr_list;
+} FstringParser;
+
+#ifdef NDEBUG
+#define FstringParser_check_invariants(state)
+#else
+static void
+FstringParser_check_invariants(FstringParser *state)
+{
+ if (state->last_str)
+ assert(PyUnicode_CheckExact(state->last_str));
+ ExprList_check_invariants(&state->expr_list);
+}
+#endif
+
+static void
+FstringParser_Init(FstringParser *state)
+{
+ state->last_str = NULL;
+ ExprList_Init(&state->expr_list);
+ FstringParser_check_invariants(state);
+}
+
+static void
+FstringParser_Dealloc(FstringParser *state)
+{
+ FstringParser_check_invariants(state);
+
+ Py_XDECREF(state->last_str);
+ ExprList_Dealloc(&state->expr_list);
+}
+
+/* Make a Str node, but decref the PyUnicode object being added. */
+static expr_ty
+make_str_node_and_del(PyObject **str, struct compiling *c, const node* n)
+{
+ PyObject *s = *str;
+ *str = NULL;
+ assert(PyUnicode_CheckExact(s));
+ if (PyArena_AddPyObject(c->c_arena, s) < 0) {
+ Py_DECREF(s);
+ return NULL;
+ }
+ return Str(s, LINENO(n), n->n_col_offset, c->c_arena);
+}
+
+/* Add a non-f-string (that is, a regular literal string). str is
+ decref'd. */
+static int
+FstringParser_ConcatAndDel(FstringParser *state, PyObject *str)
+{
+ FstringParser_check_invariants(state);
+
+ assert(PyUnicode_CheckExact(str));
+
+ if (PyUnicode_GET_LENGTH(str) == 0) {
+ Py_DECREF(str);
+ return 0;
+ }
+
+ if (!state->last_str) {
+ /* We didn't have a string before, so just remember this one. */
+ state->last_str = str;
+ } else {
+ /* Concatenate this with the previous string. */
+ PyUnicode_AppendAndDel(&state->last_str, str);
+ if (!state->last_str)
+ return -1;
+ }
+ FstringParser_check_invariants(state);
+ return 0;
+}
+
+/* Parse an f-string. The f-string is in str, starting at ofs, with no 'f'
+ or quotes. str is not decref'd, since we don't know if it's used elsewhere.
+ And if we're only looking at a part of a string, then decref'ing is
+ definitely not the right thing to do! */
+static int
+FstringParser_ConcatFstring(FstringParser *state, PyObject *str,
+ Py_ssize_t *ofs, int recurse_lvl,
+ struct compiling *c, const node *n)
+{
+ FstringParser_check_invariants(state);
+
+ /* Parse the f-string. */
+ while (1) {
+ PyObject *literal = NULL;
+ expr_ty expression = NULL;
+
+ /* If there's a zero length literal in front of the
+ expression, literal will be NULL. If we're at the end of
+ the f-string, expression will be NULL (unless result == 1,
+ see below). */
+ int result = fstring_find_literal_and_expr(str, ofs, recurse_lvl,
+ &literal, &expression,
+ c, n);
+ if (result < 0)
+ return -1;
+
+ /* Add the literal, if any. */
+ if (!literal) {
+ /* Do nothing. Just leave last_str alone (and possibly
+ NULL). */
+ } else if (!state->last_str) {
+ state->last_str = literal;
+ literal = NULL;
+ } else {
+ /* We have a literal, concatenate it. */
+ assert(PyUnicode_GET_LENGTH(literal) != 0);
+ if (FstringParser_ConcatAndDel(state, literal) < 0)
+ return -1;
+ literal = NULL;
+ }
+ assert(!state->last_str ||
+ PyUnicode_GET_LENGTH(state->last_str) != 0);
+
+ /* We've dealt with the literal now. It can't be leaked on further
+ errors. */
+ assert(literal == NULL);
+
+ /* See if we should just loop around to get the next literal
+ and expression, while ignoring the expression this
+ time. This is used for un-doubling braces, as an
+ optimization. */
+ if (result == 1)
+ continue;
+
+ if (!expression)
+ /* We're done with this f-string. */
+ break;
+
+ /* We know we have an expression. Convert any existing string
+ to a Str node. */
+ if (!state->last_str) {
+ /* Do nothing. No previous literal. */
+ } else {
+ /* Convert the existing last_str literal to a Str node. */
+ expr_ty str = make_str_node_and_del(&state->last_str, c, n);
+ if (!str || ExprList_Append(&state->expr_list, str) < 0)
+ return -1;
+ }
+
+ if (ExprList_Append(&state->expr_list, expression) < 0)
+ return -1;
+ }
+
+ assert(*ofs <= PyUnicode_GET_LENGTH(str));
+
+ /* If recurse_lvl is zero, then we must be at the end of the
+ string. Otherwise, we must be at a right brace. */
+
+ if (recurse_lvl == 0 && *ofs < PyUnicode_GET_LENGTH(str)) {
+ ast_error(c, n, "f-string: unexpected end of string");
+ return -1;
+ }
+ if (recurse_lvl != 0 && PyUnicode_READ_CHAR(str, *ofs) != '}') {
+ ast_error(c, n, "f-string: expecting '}'");
+ return -1;
+ }
+
+ FstringParser_check_invariants(state);
+ return 0;
+}
+
+/* Convert the partial state reflected in last_str and expr_list to an
+ expr_ty. The expr_ty can be a Str, or a JoinedStr. */
+static expr_ty
+FstringParser_Finish(FstringParser *state, struct compiling *c,
+ const node *n)
+{
+ asdl_seq *seq;
+
+ FstringParser_check_invariants(state);
+
+ /* If we're just a constant string with no expressions, return
+ that. */
+ if(state->expr_list.size == 0) {
+ if (!state->last_str) {
+ /* Create a zero length string. */
+ state->last_str = PyUnicode_FromStringAndSize(NULL, 0);
+ if (!state->last_str)
+ goto error;
+ }
+ return make_str_node_and_del(&state->last_str, c, n);
+ }
+
+ /* Create a Str node out of last_str, if needed. It will be the
+ last node in our expression list. */
+ if (state->last_str) {
+ expr_ty str = make_str_node_and_del(&state->last_str, c, n);
+ if (!str || ExprList_Append(&state->expr_list, str) < 0)
+ goto error;
+ }
+ /* This has already been freed. */
+ assert(state->last_str == NULL);
+
+ seq = ExprList_Finish(&state->expr_list, c->c_arena);
+ if (!seq)
+ goto error;
+
+ /* If there's only one expression, return it. Otherwise, we need
+ to join them together. */
+ if (seq->size == 1)
+ return seq->elements[0];
+
+ return JoinedStr(seq, LINENO(n), n->n_col_offset, c->c_arena);
+
+error:
+ FstringParser_Dealloc(state);
+ return NULL;
+}
+
+/* Given an f-string (with no 'f' or quotes) that's in str starting at
+ ofs, parse it into an expr_ty. Return NULL on error. Does not
+ decref str. */
+static expr_ty
+fstring_parse(PyObject *str, Py_ssize_t *ofs, int recurse_lvl,
+ struct compiling *c, const node *n)
+{
+ FstringParser state;
+
+ FstringParser_Init(&state);
+ if (FstringParser_ConcatFstring(&state, str, ofs, recurse_lvl,
+ c, n) < 0) {
+ FstringParser_Dealloc(&state);
+ return NULL;
+ }
+
+ return FstringParser_Finish(&state, c, n);
+}
+
+/* n is a Python string literal, including the bracketing quote
+ characters, and r, b, u, &/or f prefixes (if any), and embedded
+ escape sequences (if any). parsestr parses it, and returns the
+ decoded Python string object. If the string is an f-string, set
+ *fmode and return the unparsed string object.
+*/
static PyObject *
-parsestr(struct compiling *c, const node *n, int *bytesmode)
+parsestr(struct compiling *c, const node *n, int *bytesmode, int *fmode)
{
size_t len;
const char *s = STR(n);
int quote = Py_CHARMASK(*s);
int rawmode = 0;
- int need_encoding;
if (Py_ISALPHA(quote)) {
while (!*bytesmode || !rawmode) {
if (quote == 'b' || quote == 'B') {
@@ -4024,15 +4916,24 @@
quote = *++s;
rawmode = 1;
}
+ else if (quote == 'f' || quote == 'F') {
+ quote = *++s;
+ *fmode = 1;
+ }
else {
break;
}
}
}
+ if (*fmode && *bytesmode) {
+ PyErr_BadInternalCall();
+ return NULL;
+ }
if (quote != '\'' && quote != '\"') {
PyErr_BadInternalCall();
return NULL;
}
+ /* Skip the leading quote char. */
s++;
len = strlen(s);
if (len > INT_MAX) {
@@ -4041,22 +4942,26 @@
return NULL;
}
if (s[--len] != quote) {
+ /* Last quote char must match the first. */
PyErr_BadInternalCall();
return NULL;
}
if (len >= 4 && s[0] == quote && s[1] == quote) {
+ /* A triple quoted string. We've already skipped one quote at
+ the start and one at the end of the string. Now skip the
+ two at the start. */
s += 2;
len -= 2;
+ /* And check that the last two match. */
if (s[--len] != quote || s[--len] != quote) {
PyErr_BadInternalCall();
return NULL;
}
}
- if (!*bytesmode && !rawmode) {
- return decode_unicode(c, s, len, rawmode, c->c_encoding);
- }
+ /* Avoid invoking escape decoding routines if possible. */
+ rawmode = rawmode || strchr(s, '\\') == NULL;
if (*bytesmode) {
- /* Disallow non-ascii characters (but not escapes) */
+ /* Disallow non-ASCII characters. */
const char *ch;
for (ch = s; *ch; ch++) {
if (Py_CHARMASK(*ch) >= 0x80) {
@@ -4065,71 +4970,93 @@
return NULL;
}
}
- }
- need_encoding = (!*bytesmode && c->c_encoding != NULL &&
- strcmp(c->c_encoding, "utf-8") != 0);
- if (rawmode || strchr(s, '\\') == NULL) {
- if (need_encoding) {
- PyObject *v, *u = PyUnicode_DecodeUTF8(s, len, NULL);
- if (u == NULL || !*bytesmode)
- return u;
- v = PyUnicode_AsEncodedString(u, c->c_encoding, NULL);
- Py_DECREF(u);
- return v;
- } else if (*bytesmode) {
+ if (rawmode)
return PyBytes_FromStringAndSize(s, len);
- } else if (strcmp(c->c_encoding, "utf-8") == 0) {
- return PyUnicode_FromStringAndSize(s, len);
- } else {
- return PyUnicode_DecodeLatin1(s, len, NULL);
- }
+ else
+ return PyBytes_DecodeEscape(s, len, NULL, /* ignored */ 0, NULL);
+ } else {
+ if (rawmode)
+ return PyUnicode_DecodeUTF8Stateful(s, len, NULL, NULL);
+ else
+ return decode_unicode_with_escapes(c, s, len);
}
- return PyBytes_DecodeEscape(s, len, NULL, 1,
- need_encoding ? c->c_encoding : NULL);
}
-/* Build a Python string object out of a STRING+ atom. This takes care of
- * compile-time literal catenation, calling parsestr() on each piece, and
- * pasting the intermediate results together.
- */
-static PyObject *
-parsestrplus(struct compiling *c, const node *n, int *bytesmode)
+/* Accepts a STRING+ atom, and produces an expr_ty node. Run through
+ each STRING atom, and process it as needed. For bytes, just
+ concatenate them together, and the result will be a Bytes node. For
+ normal strings and f-strings, concatenate them together. The result
+ will be a Str node if there were no f-strings; a FormattedValue
+ node if there's just an f-string (with no leading or trailing
+ literals), or a JoinedStr node if there are multiple f-strings or
+ any literals involved. */
+static expr_ty
+parsestrplus(struct compiling *c, const node *n)
{
- PyObject *v;
+ int bytesmode = 0;
+ PyObject *bytes_str = NULL;
int i;
- REQ(CHILD(n, 0), STRING);
- v = parsestr(c, CHILD(n, 0), bytesmode);
- if (v != NULL) {
- /* String literal concatenation */
- for (i = 1; i < NCH(n); i++) {
- PyObject *s;
- int subbm = 0;
- s = parsestr(c, CHILD(n, i), &subbm);
- if (s == NULL)
- goto onError;
- if (*bytesmode != subbm) {
- ast_error(c, n, "cannot mix bytes and nonbytes literals");
- Py_DECREF(s);
- goto onError;
+
+ FstringParser state;
+ FstringParser_Init(&state);
+
+ for (i = 0; i < NCH(n); i++) {
+ int this_bytesmode = 0;
+ int this_fmode = 0;
+ PyObject *s;
+
+ REQ(CHILD(n, i), STRING);
+ s = parsestr(c, CHILD(n, i), &this_bytesmode, &this_fmode);
+ if (!s)
+ goto error;
+
+ /* Check that we're not mixing bytes with unicode. */
+ if (i != 0 && bytesmode != this_bytesmode) {
+ ast_error(c, n, "cannot mix bytes and nonbytes literals");
+ Py_DECREF(s);
+ goto error;
+ }
+ bytesmode = this_bytesmode;
+
+ assert(bytesmode ? PyBytes_CheckExact(s) : PyUnicode_CheckExact(s));
+
+ if (bytesmode) {
+ /* For bytes, concat as we go. */
+ if (i == 0) {
+ /* First time, just remember this value. */
+ bytes_str = s;
+ } else {
+ PyBytes_ConcatAndDel(&bytes_str, s);
+ if (!bytes_str)
+ goto error;
}
- if (PyBytes_Check(v) && PyBytes_Check(s)) {
- PyBytes_ConcatAndDel(&v, s);
- if (v == NULL)
- goto onError;
- }
- else {
- PyObject *temp = PyUnicode_Concat(v, s);
- Py_DECREF(s);
- Py_DECREF(v);
- v = temp;
- if (v == NULL)
- goto onError;
- }
+ } else if (this_fmode) {
+ /* This is an f-string. Concatenate and decref it. */
+ Py_ssize_t ofs = 0;
+ int result = FstringParser_ConcatFstring(&state, s, &ofs, 0, c, n);
+ Py_DECREF(s);
+ if (result < 0)
+ goto error;
+ } else {
+ /* This is a regular string. Concatenate it. */
+ if (FstringParser_ConcatAndDel(&state, s) < 0)
+ goto error;
}
}
- return v;
+ if (bytesmode) {
+ /* Just return the bytes object and we're done. */
+ if (PyArena_AddPyObject(c->c_arena, bytes_str) < 0)
+ goto error;
+ return Bytes(bytes_str, LINENO(n), n->n_col_offset, c->c_arena);
+ }
- onError:
- Py_XDECREF(v);
+ /* We're not a bytes string, bytes_str should never have been set. */
+ assert(bytes_str == NULL);
+
+ return FstringParser_Finish(&state, c, n);
+
+error:
+ Py_XDECREF(bytes_str);
+ FstringParser_Dealloc(&state);
return NULL;
}
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index f3d0c9a..7d35cdb 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -331,7 +331,7 @@
Py_DECREF(it);
return NULL;
}
- if (cmp == 1) {
+ if (cmp > 0) {
Py_DECREF(it);
Py_RETURN_TRUE;
}
@@ -469,6 +469,7 @@
PyObject *it = lz->it;
long ok;
PyObject *(*iternext)(PyObject *);
+ int checktrue = lz->func == Py_None || lz->func == (PyObject *)&PyBool_Type;
iternext = *Py_TYPE(it)->tp_iternext;
for (;;) {
@@ -476,12 +477,11 @@
if (item == NULL)
return NULL;
- if (lz->func == Py_None || lz->func == (PyObject *)&PyBool_Type) {
+ if (checktrue) {
ok = PyObject_IsTrue(item);
} else {
PyObject *good;
- good = PyObject_CallFunctionObjArgs(lz->func,
- item, NULL);
+ good = PyObject_CallFunctionObjArgs(lz->func, item, NULL);
if (good == NULL) {
Py_DECREF(item);
return NULL;
@@ -1174,13 +1174,14 @@
PyObject *result;
Py_ssize_t numargs, i;
- numargs = PyTuple_Size(lz->iters);
+ numargs = PyTuple_GET_SIZE(lz->iters);
argtuple = PyTuple_New(numargs);
if (argtuple == NULL)
return NULL;
for (i=0 ; i<numargs ; i++) {
- val = PyIter_Next(PyTuple_GET_ITEM(lz->iters, i));
+ PyObject *it = PyTuple_GET_ITEM(lz->iters, i);
+ val = Py_TYPE(it)->tp_iternext(it);
if (val == NULL) {
Py_DECREF(argtuple);
return NULL;
@@ -1930,9 +1931,8 @@
Py_CLEAR(stringpo);
if (po == NULL)
goto _readline_errors;
- promptstr = PyBytes_AsString(po);
- if (promptstr == NULL)
- goto _readline_errors;
+ assert(PyBytes_Check(po));
+ promptstr = PyBytes_AS_STRING(po);
}
else {
po = NULL;
@@ -2711,10 +2711,10 @@
SETBUILTIN("zip", &PyZip_Type);
debug = PyBool_FromLong(Py_OptimizeFlag == 0);
if (PyDict_SetItemString(dict, "__debug__", debug) < 0) {
- Py_XDECREF(debug);
+ Py_DECREF(debug);
return NULL;
}
- Py_XDECREF(debug);
+ Py_DECREF(debug);
return mod;
#undef ADD_TO_ALL
diff --git a/Python/ceval.c b/Python/ceval.c
index 3d69038..2b4f7cc 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -125,7 +125,7 @@
#ifdef LLTRACE
static int lltrace;
-static int prtrace(PyObject *, char *);
+static int prtrace(PyObject *, const char *);
#endif
static int call_trace(Py_tracefunc, PyObject *,
PyThreadState *, PyFrameObject *,
@@ -144,7 +144,7 @@
static void format_exc_check_arg(PyObject *, const char *, PyObject *);
static void format_exc_unbound(PyCodeObject *co, int oparg);
static PyObject * unicode_concatenate(PyObject *, PyObject *,
- PyFrameObject *, unsigned char *);
+ PyFrameObject *, const unsigned short *);
static PyObject * special_lookup(PyObject *, _Py_Identifier *);
#define NAME_ERROR_MSG \
@@ -800,7 +800,7 @@
int lastopcode = 0;
#endif
PyObject **stack_pointer; /* Next free slot in value stack */
- unsigned char *next_instr;
+ const unsigned short *next_instr;
int opcode; /* Current opcode */
int oparg; /* Current opcode argument, if any */
enum why_code why; /* Reason for block stack unwind */
@@ -818,7 +818,7 @@
time it is tested. */
int instr_ub = -1, instr_lb = 0, instr_prev = -1;
- unsigned char *first_instr;
+ const unsigned short *first_instr;
PyObject *names;
PyObject *consts;
@@ -886,24 +886,10 @@
/* Import the static jump table */
#include "opcode_targets.h"
-/* This macro is used when several opcodes defer to the same implementation
- (e.g. SETUP_LOOP, SETUP_FINALLY) */
-#define TARGET_WITH_IMPL(op, impl) \
- TARGET_##op: \
- opcode = op; \
- if (HAS_ARG(op)) \
- oparg = NEXTARG(); \
- case op: \
- goto impl; \
-
#define TARGET(op) \
TARGET_##op: \
- opcode = op; \
- if (HAS_ARG(op)) \
- oparg = NEXTARG(); \
case op:
-
#define DISPATCH() \
{ \
if (!_Py_atomic_load_relaxed(&eval_breaker)) { \
@@ -917,7 +903,8 @@
{ \
if (!lltrace && !_Py_TracingPossible) { \
f->f_lasti = INSTR_OFFSET(); \
- goto *opcode_targets[*next_instr++]; \
+ NEXTOPARG(); \
+ goto *opcode_targets[opcode]; \
} \
goto fast_next_opcode; \
}
@@ -926,7 +913,8 @@
{ \
if (!_Py_TracingPossible) { \
f->f_lasti = INSTR_OFFSET(); \
- goto *opcode_targets[*next_instr++]; \
+ NEXTOPARG(); \
+ goto *opcode_targets[opcode]; \
} \
goto fast_next_opcode; \
}
@@ -935,10 +923,7 @@
#else
#define TARGET(op) \
case op:
-#define TARGET_WITH_IMPL(op, impl) \
- /* silence compiler warnings about `impl` unused */ \
- if (0) goto impl; \
- case op:
+
#define DISPATCH() continue
#define FAST_DISPATCH() goto fast_next_opcode
#endif
@@ -994,28 +979,38 @@
/* Code access macros */
-#define INSTR_OFFSET() ((int)(next_instr - first_instr))
-#define NEXTOP() (*next_instr++)
-#define NEXTARG() (next_instr += 2, (next_instr[-1]<<8) + next_instr[-2])
-#define PEEKARG() ((next_instr[2]<<8) + next_instr[1])
-#define JUMPTO(x) (next_instr = first_instr + (x))
-#define JUMPBY(x) (next_instr += (x))
+#ifdef WORDS_BIGENDIAN
+ #define OPCODE(word) ((word) >> 8)
+ #define OPARG(word) ((word) & 255)
+#else
+ #define OPCODE(word) ((word) & 255)
+ #define OPARG(word) ((word) >> 8)
+#endif
+/* The integer overflow is checked by an assertion below. */
+#define INSTR_OFFSET() (2*(int)(next_instr - first_instr))
+#define NEXTOPARG() do { \
+ unsigned short word = *next_instr; \
+ opcode = OPCODE(word); \
+ oparg = OPARG(word); \
+ next_instr++; \
+ } while (0)
+#define JUMPTO(x) (next_instr = first_instr + (x)/2)
+#define JUMPBY(x) (next_instr += (x)/2)
/* OpCode prediction macros
Some opcodes tend to come in pairs thus making it possible to
predict the second code when the first is run. For example,
- COMPARE_OP is often followed by JUMP_IF_FALSE or JUMP_IF_TRUE. And,
- those opcodes are often followed by a POP_TOP.
+ COMPARE_OP is often followed by POP_JUMP_IF_FALSE or POP_JUMP_IF_TRUE.
Verifying the prediction costs a single high-speed test of a register
variable against a constant. If the pairing was good, then the
processor's own internal branch predication has a high likelihood of
success, resulting in a nearly zero-overhead transition to the
next opcode. A successful prediction saves a trip through the eval-loop
- including its two unpredictable branches, the HAS_ARG test and the
- switch-case. Combined with the processor's internal branch prediction,
- a successful PREDICT has the effect of making the two opcodes run as if
- they were a single new opcode with the bodies combined.
+ including its unpredictable switch-case branch. Combined with the
+ processor's internal branch prediction, a successful PREDICT has the
+ effect of making the two opcodes run as if they were a single new opcode
+ with the bodies combined.
If collecting opcode statistics, your choices are to either keep the
predictions turned-on and interpret the results as if some opcodes
@@ -1030,13 +1025,19 @@
#if defined(DYNAMIC_EXECUTION_PROFILE) || USE_COMPUTED_GOTOS
#define PREDICT(op) if (0) goto PRED_##op
-#define PREDICTED(op) PRED_##op:
-#define PREDICTED_WITH_ARG(op) PRED_##op:
#else
-#define PREDICT(op) if (*next_instr == op) goto PRED_##op
-#define PREDICTED(op) PRED_##op: next_instr++
-#define PREDICTED_WITH_ARG(op) PRED_##op: oparg = PEEKARG(); next_instr += 3
+#define PREDICT(op) \
+ do{ \
+ unsigned short word = *next_instr; \
+ opcode = OPCODE(word); \
+ if (opcode == op){ \
+ oparg = OPARG(word); \
+ next_instr++; \
+ goto PRED_##op; \
+ } \
+ } while(0)
#endif
+#define PREDICTED(op) PRED_##op:
/* Stack manipulation macros */
@@ -1100,7 +1101,7 @@
}
#define UNWIND_EXCEPT_HANDLER(b) \
- { \
+ do { \
PyObject *type, *value, *traceback; \
assert(STACK_LEVEL() >= (b)->b_level + 3); \
while (STACK_LEVEL() > (b)->b_level + 3) { \
@@ -1116,7 +1117,7 @@
Py_XDECREF(type); \
Py_XDECREF(value); \
Py_XDECREF(traceback); \
- }
+ } while(0)
/* Start of code */
@@ -1165,16 +1166,16 @@
consts = co->co_consts;
fastlocals = f->f_localsplus;
freevars = f->f_localsplus + co->co_nlocals;
- first_instr = (unsigned char*) PyBytes_AS_STRING(co->co_code);
- /* An explanation is in order for the next line.
+ assert(PyBytes_Check(co->co_code));
+ assert(PyBytes_GET_SIZE(co->co_code) <= INT_MAX);
+ assert(PyBytes_GET_SIZE(co->co_code) % 2 == 0);
+ assert(_Py_IS_ALIGNED(PyBytes_AS_STRING(co->co_code), 2));
+ first_instr = (unsigned short*) PyBytes_AS_STRING(co->co_code);
+ /*
+ f->f_lasti refers to the index of the last instruction,
+ unless it's -1 in which case next_instr should be first_instr.
- f->f_lasti now refers to the index of the last instruction
- executed. You might think this was obvious from the name, but
- this wasn't always true before 2.3! PyFrame_New now sets
- f->f_lasti to -1 (i.e. the index *before* the first instruction)
- and YIELD_VALUE doesn't fiddle with f_lasti any more. So this
- does work. Promise.
- YIELD_FROM sets f_lasti to itself, in order to repeated yield
+ YIELD_FROM sets f_lasti to itself, in order to repeatedly yield
multiple values.
When the PREDICT() macros are enabled, some opcode pairs follow in
@@ -1183,9 +1184,13 @@
were a single new opcode; accordingly,f->f_lasti will point to
the first code in the pair (for instance, GET_ITER followed by
FOR_ITER is effectively a single opcode and f->f_lasti will point
- at to the beginning of the combined pair.)
+ to the beginning of the combined pair.)
*/
- next_instr = first_instr + f->f_lasti + 1;
+ next_instr = first_instr;
+ if (f->f_lasti >= 0) {
+ assert(f->f_lasti % 2 == 0);
+ next_instr += f->f_lasti/2 + 1;
+ }
stack_pointer = f->f_stacktop;
assert(stack_pointer != NULL);
f->f_stacktop = NULL; /* remains NULL unless yield suspends frame */
@@ -1249,7 +1254,7 @@
Py_MakePendingCalls() above. */
if (_Py_atomic_load_relaxed(&eval_breaker)) {
- if (*next_instr == SETUP_FINALLY) {
+ if (OPCODE(*next_instr) == SETUP_FINALLY) {
/* Make the last opcode before
a try: finally: block uninterruptible. */
goto fast_next_opcode;
@@ -1322,11 +1327,7 @@
/* Extract opcode and argument */
- opcode = NEXTOP();
- oparg = 0; /* allows oparg to be stored in a register because
- it doesn't have to be remembered across a full loop */
- if (HAS_ARG(opcode))
- oparg = NEXTARG();
+ NEXTOPARG();
dispatch_opcode:
#ifdef DYNAMIC_EXECUTION_PROFILE
#ifdef DXPAIRS
@@ -1377,6 +1378,7 @@
FAST_DISPATCH();
}
+ PREDICTED(LOAD_CONST);
TARGET(LOAD_CONST) {
PyObject *value = GETITEM(consts, oparg);
Py_INCREF(value);
@@ -1384,7 +1386,7 @@
FAST_DISPATCH();
}
- PREDICTED_WITH_ARG(STORE_FAST);
+ PREDICTED(STORE_FAST);
TARGET(STORE_FAST) {
PyObject *value = POP();
SETLOCAL(oparg, value);
@@ -2006,6 +2008,7 @@
}
SET_TOP(awaitable);
+ PREDICT(LOAD_CONST);
DISPATCH();
}
@@ -2048,9 +2051,11 @@
Py_DECREF(next_iter);
PUSH(awaitable);
+ PREDICT(LOAD_CONST);
DISPATCH();
}
+ PREDICTED(GET_AWAITABLE);
TARGET(GET_AWAITABLE) {
PyObject *iterable = TOP();
PyObject *iter = _PyCoro_GetAwaitableIter(iterable);
@@ -2078,6 +2083,7 @@
goto error;
}
+ PREDICT(LOAD_CONST);
DISPATCH();
}
@@ -2111,7 +2117,7 @@
f->f_stacktop = stack_pointer;
why = WHY_YIELD;
/* and repeat... */
- f->f_lasti--;
+ f->f_lasti -= 2;
goto fast_yield;
}
@@ -2133,6 +2139,7 @@
DISPATCH();
}
+ PREDICTED(POP_BLOCK);
TARGET(POP_BLOCK) {
PyTryBlock *b = PyFrame_BlockPop(f);
UNWIND_BLOCK(b);
@@ -2249,7 +2256,7 @@
DISPATCH();
}
- PREDICTED_WITH_ARG(UNPACK_SEQUENCE);
+ PREDICTED(UNPACK_SEQUENCE);
TARGET(UNPACK_SEQUENCE) {
PyObject *seq = POP(), *item, **items;
if (PyTuple_CheckExact(seq) &&
@@ -2358,7 +2365,7 @@
}
else {
v = PyObject_GetItem(locals, name);
- if (v == NULL && _PyErr_OCCURRED()) {
+ if (v == NULL) {
if (!PyErr_ExceptionMatches(PyExc_KeyError))
goto error;
PyErr_Clear();
@@ -2398,26 +2405,33 @@
PyObject *name = GETITEM(names, oparg);
PyObject *v;
if (PyDict_CheckExact(f->f_globals)
- && PyDict_CheckExact(f->f_builtins)) {
+ && PyDict_CheckExact(f->f_builtins))
+ {
v = _PyDict_LoadGlobal((PyDictObject *)f->f_globals,
(PyDictObject *)f->f_builtins,
name);
if (v == NULL) {
- if (!_PyErr_OCCURRED())
+ if (!_PyErr_OCCURRED()) {
+ /* _PyDict_LoadGlobal() returns NULL without raising
+ * an exception if the key doesn't exist */
format_exc_check_arg(PyExc_NameError,
NAME_ERROR_MSG, name);
+ }
goto error;
}
Py_INCREF(v);
}
else {
/* Slow-path if globals or builtins is not a dict */
+
+ /* namespace 1: globals */
v = PyObject_GetItem(f->f_globals, name);
if (v == NULL) {
if (!PyErr_ExceptionMatches(PyExc_KeyError))
goto error;
PyErr_Clear();
+ /* namespace 2: builtins */
v = PyObject_GetItem(f->f_builtins, name);
if (v == NULL) {
if (PyErr_ExceptionMatches(PyExc_KeyError))
@@ -2477,7 +2491,7 @@
}
else {
value = PyObject_GetItem(locals, name);
- if (value == NULL && PyErr_Occurred()) {
+ if (value == NULL) {
if (!PyErr_ExceptionMatches(PyExc_KeyError))
goto error;
PyErr_Clear();
@@ -2540,9 +2554,8 @@
DISPATCH();
}
- TARGET_WITH_IMPL(BUILD_TUPLE_UNPACK, _build_list_unpack)
- TARGET(BUILD_LIST_UNPACK)
- _build_list_unpack: {
+ TARGET(BUILD_TUPLE_UNPACK)
+ TARGET(BUILD_LIST_UNPACK) {
int convert_to_tuple = opcode == BUILD_TUPLE_UNPACK;
int i;
PyObject *sum = PyList_New(0);
@@ -2639,9 +2652,41 @@
DISPATCH();
}
- TARGET_WITH_IMPL(BUILD_MAP_UNPACK_WITH_CALL, _build_map_unpack)
- TARGET(BUILD_MAP_UNPACK)
- _build_map_unpack: {
+ TARGET(BUILD_CONST_KEY_MAP) {
+ int i;
+ PyObject *map;
+ PyObject *keys = TOP();
+ if (!PyTuple_CheckExact(keys) ||
+ PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) {
+ PyErr_SetString(PyExc_SystemError,
+ "bad BUILD_CONST_KEY_MAP keys argument");
+ goto error;
+ }
+ map = _PyDict_NewPresized((Py_ssize_t)oparg);
+ if (map == NULL) {
+ goto error;
+ }
+ for (i = oparg; i > 0; i--) {
+ int err;
+ PyObject *key = PyTuple_GET_ITEM(keys, oparg - i);
+ PyObject *value = PEEK(i + 1);
+ err = PyDict_SetItem(map, key, value);
+ if (err != 0) {
+ Py_DECREF(map);
+ goto error;
+ }
+ }
+
+ Py_DECREF(POP());
+ while (oparg--) {
+ Py_DECREF(POP());
+ }
+ PUSH(map);
+ DISPATCH();
+ }
+
+ TARGET(BUILD_MAP_UNPACK_WITH_CALL)
+ TARGET(BUILD_MAP_UNPACK) {
int with_call = opcode == BUILD_MAP_UNPACK_WITH_CALL;
int num_maps;
int function_location;
@@ -2775,21 +2820,13 @@
Py_INCREF(func);
from = POP();
level = TOP();
- if (PyLong_AsLong(level) != -1 || PyErr_Occurred())
- args = PyTuple_Pack(5,
+ args = PyTuple_Pack(5,
name,
f->f_globals,
f->f_locals == NULL ?
Py_None : f->f_locals,
from,
level);
- else
- args = PyTuple_Pack(4,
- name,
- f->f_globals,
- f->f_locals == NULL ?
- Py_None : f->f_locals,
- from);
Py_DECREF(level);
Py_DECREF(from);
if (args == NULL) {
@@ -2848,7 +2885,7 @@
FAST_DISPATCH();
}
- PREDICTED_WITH_ARG(POP_JUMP_IF_FALSE);
+ PREDICTED(POP_JUMP_IF_FALSE);
TARGET(POP_JUMP_IF_FALSE) {
PyObject *cond = POP();
int err;
@@ -2872,7 +2909,7 @@
DISPATCH();
}
- PREDICTED_WITH_ARG(POP_JUMP_IF_TRUE);
+ PREDICTED(POP_JUMP_IF_TRUE);
TARGET(POP_JUMP_IF_TRUE) {
PyObject *cond = POP();
int err;
@@ -2949,7 +2986,7 @@
DISPATCH();
}
- PREDICTED_WITH_ARG(JUMP_ABSOLUTE);
+ PREDICTED(JUMP_ABSOLUTE);
TARGET(JUMP_ABSOLUTE) {
JUMPTO(oparg);
#if FAST_LOOPS
@@ -2975,6 +3012,7 @@
if (iter == NULL)
goto error;
PREDICT(FOR_ITER);
+ PREDICT(CALL_FUNCTION);
DISPATCH();
}
@@ -3003,10 +3041,11 @@
if (iter == NULL)
goto error;
}
+ PREDICT(LOAD_CONST);
DISPATCH();
}
- PREDICTED_WITH_ARG(FOR_ITER);
+ PREDICTED(FOR_ITER);
TARGET(FOR_ITER) {
/* before: [iter]; after: [iter, iter()] *or* [] */
PyObject *iter = TOP();
@@ -3028,6 +3067,7 @@
STACKADJ(-1);
Py_DECREF(iter);
JUMPBY(oparg);
+ PREDICT(POP_BLOCK);
DISPATCH();
}
@@ -3044,10 +3084,9 @@
goto fast_block_end;
}
- TARGET_WITH_IMPL(SETUP_LOOP, _setup_finally)
- TARGET_WITH_IMPL(SETUP_EXCEPT, _setup_finally)
- TARGET(SETUP_FINALLY)
- _setup_finally: {
+ TARGET(SETUP_LOOP)
+ TARGET(SETUP_EXCEPT)
+ TARGET(SETUP_FINALLY) {
/* NOTE: If you add any new block-setup opcodes that
are not try/except/finally handlers, you may need
to update the PyGen_NeedsFinalizing() function.
@@ -3078,6 +3117,7 @@
if (res == NULL)
goto error;
PUSH(res);
+ PREDICT(GET_AWAITABLE);
DISPATCH();
}
@@ -3226,6 +3266,7 @@
DISPATCH();
}
+ PREDICTED(CALL_FUNCTION);
TARGET(CALL_FUNCTION) {
PyObject **sp, *res;
PCALL(PCALL_ALL);
@@ -3242,10 +3283,9 @@
DISPATCH();
}
- TARGET_WITH_IMPL(CALL_FUNCTION_VAR, _call_function_var_kw)
- TARGET_WITH_IMPL(CALL_FUNCTION_KW, _call_function_var_kw)
- TARGET(CALL_FUNCTION_VAR_KW)
- _call_function_var_kw: {
+ TARGET(CALL_FUNCTION_VAR)
+ TARGET(CALL_FUNCTION_KW)
+ TARGET(CALL_FUNCTION_VAR_KW) {
int na = oparg & 0xff;
int nk = (oparg>>8) & 0xff;
int flags = (opcode - CALL_FUNCTION) & 3;
@@ -3287,117 +3327,36 @@
DISPATCH();
}
- TARGET_WITH_IMPL(MAKE_CLOSURE, _make_function)
- TARGET(MAKE_FUNCTION)
- _make_function: {
- int posdefaults = oparg & 0xff;
- int kwdefaults = (oparg>>8) & 0xff;
- int num_annotations = (oparg >> 16) & 0x7fff;
+ TARGET(MAKE_FUNCTION) {
+ PyObject *qualname = POP();
+ PyObject *codeobj = POP();
+ PyFunctionObject *func = (PyFunctionObject *)
+ PyFunction_NewWithQualName(codeobj, f->f_globals, qualname);
- PyObject *qualname = POP(); /* qualname */
- PyObject *code = POP(); /* code object */
- PyObject *func = PyFunction_NewWithQualName(code, f->f_globals, qualname);
- Py_DECREF(code);
+ Py_DECREF(codeobj);
Py_DECREF(qualname);
-
- if (func == NULL)
+ if (func == NULL) {
goto error;
-
- if (opcode == MAKE_CLOSURE) {
- PyObject *closure = POP();
- if (PyFunction_SetClosure(func, closure) != 0) {
- /* Can't happen unless bytecode is corrupt. */
- Py_DECREF(func);
- Py_DECREF(closure);
- goto error;
- }
- Py_DECREF(closure);
}
- if (num_annotations > 0) {
- Py_ssize_t name_ix;
- PyObject *names = POP(); /* names of args with annotations */
- PyObject *anns = PyDict_New();
- if (anns == NULL) {
- Py_DECREF(func);
- Py_DECREF(names);
- goto error;
- }
- name_ix = PyTuple_Size(names);
- assert(num_annotations == name_ix+1);
- while (name_ix > 0) {
- PyObject *name, *value;
- int err;
- --name_ix;
- name = PyTuple_GET_ITEM(names, name_ix);
- value = POP();
- err = PyDict_SetItem(anns, name, value);
- Py_DECREF(value);
- if (err != 0) {
- Py_DECREF(anns);
- Py_DECREF(func);
- Py_DECREF(names);
- goto error;
- }
- }
- Py_DECREF(names);
-
- if (PyFunction_SetAnnotations(func, anns) != 0) {
- /* Can't happen unless
- PyFunction_SetAnnotations changes. */
- Py_DECREF(anns);
- Py_DECREF(func);
- goto error;
- }
- Py_DECREF(anns);
+ if (oparg & 0x08) {
+ assert(PyTuple_CheckExact(TOP()));
+ func ->func_closure = POP();
+ }
+ if (oparg & 0x04) {
+ assert(PyDict_CheckExact(TOP()));
+ func->func_annotations = POP();
+ }
+ if (oparg & 0x02) {
+ assert(PyDict_CheckExact(TOP()));
+ func->func_kwdefaults = POP();
+ }
+ if (oparg & 0x01) {
+ assert(PyTuple_CheckExact(TOP()));
+ func->func_defaults = POP();
}
- /* XXX Maybe this should be a separate opcode? */
- if (kwdefaults > 0) {
- PyObject *defs = PyDict_New();
- if (defs == NULL) {
- Py_DECREF(func);
- goto error;
- }
- while (--kwdefaults >= 0) {
- PyObject *v = POP(); /* default value */
- PyObject *key = POP(); /* kw only arg name */
- int err = PyDict_SetItem(defs, key, v);
- Py_DECREF(v);
- Py_DECREF(key);
- if (err != 0) {
- Py_DECREF(defs);
- Py_DECREF(func);
- goto error;
- }
- }
- if (PyFunction_SetKwDefaults(func, defs) != 0) {
- /* Can't happen unless
- PyFunction_SetKwDefaults changes. */
- Py_DECREF(func);
- Py_DECREF(defs);
- goto error;
- }
- Py_DECREF(defs);
- }
- if (posdefaults > 0) {
- PyObject *defs = PyTuple_New(posdefaults);
- if (defs == NULL) {
- Py_DECREF(func);
- goto error;
- }
- while (--posdefaults >= 0)
- PyTuple_SET_ITEM(defs, posdefaults, POP());
- if (PyFunction_SetDefaults(func, defs) != 0) {
- /* Can't happen unless
- PyFunction_SetDefaults changes. */
- Py_DECREF(defs);
- Py_DECREF(func);
- goto error;
- }
- Py_DECREF(defs);
- }
- PUSH(func);
+ PUSH((PyObject *)func);
DISPATCH();
}
@@ -3419,9 +3378,68 @@
DISPATCH();
}
+ TARGET(FORMAT_VALUE) {
+ /* Handles f-string value formatting. */
+ PyObject *result;
+ PyObject *fmt_spec;
+ PyObject *value;
+ PyObject *(*conv_fn)(PyObject *);
+ int which_conversion = oparg & FVC_MASK;
+ int have_fmt_spec = (oparg & FVS_MASK) == FVS_HAVE_SPEC;
+
+ fmt_spec = have_fmt_spec ? POP() : NULL;
+ value = POP();
+
+ /* See if any conversion is specified. */
+ switch (which_conversion) {
+ case FVC_STR: conv_fn = PyObject_Str; break;
+ case FVC_REPR: conv_fn = PyObject_Repr; break;
+ case FVC_ASCII: conv_fn = PyObject_ASCII; break;
+
+ /* Must be 0 (meaning no conversion), since only four
+ values are allowed by (oparg & FVC_MASK). */
+ default: conv_fn = NULL; break;
+ }
+
+ /* If there's a conversion function, call it and replace
+ value with that result. Otherwise, just use value,
+ without conversion. */
+ if (conv_fn != NULL) {
+ result = conv_fn(value);
+ Py_DECREF(value);
+ if (result == NULL) {
+ Py_XDECREF(fmt_spec);
+ goto error;
+ }
+ value = result;
+ }
+
+ /* If value is a unicode object, and there's no fmt_spec,
+ then we know the result of format(value) is value
+ itself. In that case, skip calling format(). I plan to
+ move this optimization in to PyObject_Format()
+ itself. */
+ if (PyUnicode_CheckExact(value) && fmt_spec == NULL) {
+ /* Do nothing, just transfer ownership to result. */
+ result = value;
+ } else {
+ /* Actually call format(). */
+ result = PyObject_Format(value, fmt_spec);
+ Py_DECREF(value);
+ Py_XDECREF(fmt_spec);
+ if (result == NULL) {
+ goto error;
+ }
+ }
+
+ PUSH(result);
+ DISPATCH();
+ }
+
TARGET(EXTENDED_ARG) {
- opcode = NEXTOP();
- oparg = oparg<<16 | NEXTARG();
+ int oldoparg = oparg;
+ NEXTOPARG();
+ oparg |= oldoparg << 8;
goto dispatch_opcode;
}
@@ -4297,7 +4315,7 @@
#ifdef LLTRACE
static int
-prtrace(PyObject *v, char *str)
+prtrace(PyObject *v, const char *str)
{
printf("%s ", str);
if (PyObject_Print(v, stdout, 0) != 0)
@@ -4863,6 +4881,21 @@
{
PyObject *callargs, *w;
+ if (!nstack) {
+ if (!stararg) {
+ /* There are no positional arguments on the stack and there is no
+ sequence to be unpacked. */
+ return PyTuple_New(0);
+ }
+ if (PyTuple_CheckExact(stararg)) {
+ /* No arguments are passed on the stack and the sequence is not a
+ tuple subclass so we can just pass the stararg tuple directly
+ to the function. */
+ Py_INCREF(stararg);
+ return stararg;
+ }
+ }
+
callargs = PyTuple_New(nstack + nstar);
if (callargs == NULL) {
return NULL;
@@ -4951,7 +4984,7 @@
if (flags & CALL_FLAG_KW) {
kwdict = EXT_POP(*pp_stack);
- if (!PyDict_Check(kwdict)) {
+ if (!PyDict_CheckExact(kwdict)) {
PyObject *d;
d = PyDict_New();
if (d == NULL)
@@ -5261,7 +5294,7 @@
static PyObject *
unicode_concatenate(PyObject *v, PyObject *w,
- PyFrameObject *f, unsigned char *next_instr)
+ PyFrameObject *f, const unsigned short *next_instr)
{
PyObject *res;
if (Py_REFCNT(v) == 2) {
@@ -5271,10 +5304,11 @@
* 'variable'. We try to delete the variable now to reduce
* the refcnt to 1.
*/
- switch (*next_instr) {
+ int opcode, oparg;
+ NEXTOPARG();
+ switch (opcode) {
case STORE_FAST:
{
- int oparg = PEEKARG();
PyObject **fastlocals = f->f_localsplus;
if (GETLOCAL(oparg) == v)
SETLOCAL(oparg, NULL);
@@ -5284,7 +5318,7 @@
{
PyObject **freevars = (f->f_localsplus +
f->f_code->co_nlocals);
- PyObject *c = freevars[PEEKARG()];
+ PyObject *c = freevars[oparg];
if (PyCell_GET(c) == v)
PyCell_Set(c, NULL);
break;
@@ -5292,7 +5326,7 @@
case STORE_NAME:
{
PyObject *names = f->f_code->co_names;
- PyObject *name = GETITEM(names, PEEKARG());
+ PyObject *name = GETITEM(names, oparg);
PyObject *locals = f->f_locals;
if (PyDict_CheckExact(locals) &&
PyDict_GetItem(locals, name) == v) {
diff --git a/Python/clinic/bltinmodule.c.h b/Python/clinic/bltinmodule.c.h
index 90995e5..6df3ef5 100644
--- a/Python/clinic/bltinmodule.c.h
+++ b/Python/clinic/bltinmodule.c.h
@@ -94,8 +94,9 @@
PyObject *format_spec = NULL;
if (!PyArg_ParseTuple(args, "O|U:format",
- &value, &format_spec))
+ &value, &format_spec)) {
goto exit;
+ }
return_value = builtin_format_impl(module, value, format_spec);
exit:
@@ -120,8 +121,9 @@
PyObject *return_value = NULL;
int i;
- if (!PyArg_Parse(arg, "i:chr", &i))
+ if (!PyArg_Parse(arg, "i:chr", &i)) {
goto exit;
+ }
return_value = builtin_chr_impl(module, i);
exit:
@@ -167,8 +169,9 @@
int optimize = -1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO&s|iii:compile", _keywords,
- &source, PyUnicode_FSDecoder, &filename, &mode, &flags, &dont_inherit, &optimize))
+ &source, PyUnicode_FSDecoder, &filename, &mode, &flags, &dont_inherit, &optimize)) {
goto exit;
+ }
return_value = builtin_compile_impl(module, source, filename, mode, flags, dont_inherit, optimize);
exit:
@@ -196,8 +199,9 @@
if (!PyArg_UnpackTuple(args, "divmod",
2, 2,
- &x, &y))
+ &x, &y)) {
goto exit;
+ }
return_value = builtin_divmod_impl(module, x, y);
exit:
@@ -233,8 +237,9 @@
if (!PyArg_UnpackTuple(args, "eval",
1, 3,
- &source, &globals, &locals))
+ &source, &globals, &locals)) {
goto exit;
+ }
return_value = builtin_eval_impl(module, source, globals, locals);
exit:
@@ -270,8 +275,9 @@
if (!PyArg_UnpackTuple(args, "exec",
1, 3,
- &source, &globals, &locals))
+ &source, &globals, &locals)) {
goto exit;
+ }
return_value = builtin_exec_impl(module, source, globals, locals);
exit:
@@ -322,8 +328,9 @@
if (!PyArg_UnpackTuple(args, "hasattr",
2, 2,
- &obj, &name))
+ &obj, &name)) {
goto exit;
+ }
return_value = builtin_hasattr_impl(module, obj, name);
exit:
@@ -367,8 +374,9 @@
if (!PyArg_UnpackTuple(args, "setattr",
3, 3,
- &obj, &name, &value))
+ &obj, &name, &value)) {
goto exit;
+ }
return_value = builtin_setattr_impl(module, obj, name, value);
exit:
@@ -398,8 +406,9 @@
if (!PyArg_UnpackTuple(args, "delattr",
2, 2,
- &obj, &name))
+ &obj, &name)) {
goto exit;
+ }
return_value = builtin_delattr_impl(module, obj, name);
exit:
@@ -507,8 +516,9 @@
if (!PyArg_UnpackTuple(args, "pow",
2, 3,
- &x, &y, &z))
+ &x, &y, &z)) {
goto exit;
+ }
return_value = builtin_pow_impl(module, x, y, z);
exit:
@@ -541,8 +551,9 @@
if (!PyArg_UnpackTuple(args, "input",
0, 1,
- &prompt))
+ &prompt)) {
goto exit;
+ }
return_value = builtin_input_impl(module, prompt);
exit:
@@ -585,8 +596,9 @@
if (!PyArg_UnpackTuple(args, "sum",
1, 2,
- &iterable, &start))
+ &iterable, &start)) {
goto exit;
+ }
return_value = builtin_sum_impl(module, iterable, start);
exit:
@@ -619,8 +631,9 @@
if (!PyArg_UnpackTuple(args, "isinstance",
2, 2,
- &obj, &class_or_tuple))
+ &obj, &class_or_tuple)) {
goto exit;
+ }
return_value = builtin_isinstance_impl(module, obj, class_or_tuple);
exit:
@@ -653,11 +666,12 @@
if (!PyArg_UnpackTuple(args, "issubclass",
2, 2,
- &cls, &class_or_tuple))
+ &cls, &class_or_tuple)) {
goto exit;
+ }
return_value = builtin_issubclass_impl(module, cls, class_or_tuple);
exit:
return return_value;
}
-/*[clinic end generated code: output=4bef16b6aa432879 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=940f25126caf8166 input=a9049054013a1b77]*/
diff --git a/Python/clinic/import.c.h b/Python/clinic/import.c.h
index 2477665..9b9f812 100644
--- a/Python/clinic/import.c.h
+++ b/Python/clinic/import.c.h
@@ -89,8 +89,9 @@
PyObject *path;
if (!PyArg_ParseTuple(args, "O!U:_fix_co_filename",
- &PyCode_Type, &code, &path))
+ &PyCode_Type, &code, &path)) {
goto exit;
+ }
return_value = _imp__fix_co_filename_impl(module, code, path);
exit:
@@ -142,8 +143,9 @@
PyObject *return_value = NULL;
PyObject *name;
- if (!PyArg_Parse(arg, "U:init_frozen", &name))
+ if (!PyArg_Parse(arg, "U:init_frozen", &name)) {
goto exit;
+ }
return_value = _imp_init_frozen_impl(module, name);
exit:
@@ -168,8 +170,9 @@
PyObject *return_value = NULL;
PyObject *name;
- if (!PyArg_Parse(arg, "U:get_frozen_object", &name))
+ if (!PyArg_Parse(arg, "U:get_frozen_object", &name)) {
goto exit;
+ }
return_value = _imp_get_frozen_object_impl(module, name);
exit:
@@ -194,8 +197,9 @@
PyObject *return_value = NULL;
PyObject *name;
- if (!PyArg_Parse(arg, "U:is_frozen_package", &name))
+ if (!PyArg_Parse(arg, "U:is_frozen_package", &name)) {
goto exit;
+ }
return_value = _imp_is_frozen_package_impl(module, name);
exit:
@@ -220,8 +224,9 @@
PyObject *return_value = NULL;
PyObject *name;
- if (!PyArg_Parse(arg, "U:is_builtin", &name))
+ if (!PyArg_Parse(arg, "U:is_builtin", &name)) {
goto exit;
+ }
return_value = _imp_is_builtin_impl(module, name);
exit:
@@ -246,8 +251,9 @@
PyObject *return_value = NULL;
PyObject *name;
- if (!PyArg_Parse(arg, "U:is_frozen", &name))
+ if (!PyArg_Parse(arg, "U:is_frozen", &name)) {
goto exit;
+ }
return_value = _imp_is_frozen_impl(module, name);
exit:
@@ -277,8 +283,9 @@
if (!PyArg_UnpackTuple(args, "create_dynamic",
1, 2,
- &spec, &file))
+ &spec, &file)) {
goto exit;
+ }
return_value = _imp_create_dynamic_impl(module, spec, file);
exit:
@@ -308,8 +315,9 @@
int _return_value;
_return_value = _imp_exec_dynamic_impl(module, mod);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong((long)_return_value);
exit:
@@ -337,8 +345,9 @@
int _return_value;
_return_value = _imp_exec_builtin_impl(module, mod);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
+ }
return_value = PyLong_FromLong((long)_return_value);
exit:
@@ -352,4 +361,4 @@
#ifndef _IMP_EXEC_DYNAMIC_METHODDEF
#define _IMP_EXEC_DYNAMIC_METHODDEF
#endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */
-/*[clinic end generated code: output=32324a5e46cdfc4b input=a9049054013a1b77]*/
+/*[clinic end generated code: output=22a7225925755674 input=a9049054013a1b77]*/
diff --git a/Python/compile.c b/Python/compile.c
index ce510aa..687b750 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -29,6 +29,7 @@
#include "code.h"
#include "symtable.h"
#include "opcode.h"
+#include "wordcode_helpers.h"
#define DEFAULT_BLOCK_SIZE 16
#define DEFAULT_BLOCKS 8
@@ -43,7 +44,6 @@
struct instr {
unsigned i_jabs : 1;
unsigned i_jrel : 1;
- unsigned i_hasarg : 1;
unsigned char i_opcode;
int i_oparg;
struct basicblock_ *i_target; /* target block (if jump instruction) */
@@ -171,7 +171,6 @@
static int compiler_addop_o(struct compiler *, int, PyObject *, PyObject *);
static int compiler_addop_i(struct compiler *, int, Py_ssize_t);
static int compiler_addop_j(struct compiler *, int, basicblock *, int);
-static basicblock *compiler_use_new_block(struct compiler *);
static int compiler_error(struct compiler *, const char *);
static int compiler_nameop(struct compiler *, identifier, expr_context_ty);
@@ -196,7 +195,7 @@
static int compiler_with(struct compiler *, stmt_ty, int);
static int compiler_async_with(struct compiler *, stmt_ty, int);
static int compiler_async_for(struct compiler *, stmt_ty);
-static int compiler_call_helper(struct compiler *c, Py_ssize_t n,
+static int compiler_call_helper(struct compiler *c, int n,
asdl_seq *args,
asdl_seq *keywords);
static int compiler_try_except(struct compiler *, stmt_ty);
@@ -477,9 +476,9 @@
{
basicblock *block;
for (block = u->u_blocks; block != NULL; block = block->b_list) {
- assert((void *)block != (void *)0xcbcbcbcb);
- assert((void *)block != (void *)0xfbfbfbfb);
- assert((void *)block != (void *)0xdbdbdbdb);
+ assert((Py_uintptr_t)block != 0xcbcbcbcbU);
+ assert((Py_uintptr_t)block != 0xfbfbfbfbU);
+ assert((Py_uintptr_t)block != 0xdbdbdbdbU);
if (block->b_instr != NULL) {
assert(block->b_ialloc > 0);
assert(block->b_iused > 0);
@@ -523,6 +522,7 @@
int scope_type, void *key, int lineno)
{
struct compiler_unit *u;
+ basicblock *block;
u = (struct compiler_unit *)PyObject_Malloc(sizeof(
struct compiler_unit));
@@ -620,8 +620,11 @@
c->u = u;
c->c_nestlevel++;
- if (compiler_use_new_block(c) == NULL)
+
+ block = compiler_new_block(c);
+ if (block == NULL)
return 0;
+ c->u->u_curblock = block;
if (u->u_scope_type != COMPILER_SCOPE_MODULE) {
if (!compiler_set_qualname(c))
@@ -731,6 +734,7 @@
return 1;
}
+
/* Allocate a new block and return a pointer to it.
Returns NULL on error.
*/
@@ -755,16 +759,6 @@
}
static basicblock *
-compiler_use_new_block(struct compiler *c)
-{
- basicblock *block = compiler_new_block(c);
- if (block == NULL)
- return NULL;
- c->u->u_curblock = block;
- return block;
-}
-
-static basicblock *
compiler_next_block(struct compiler *c)
{
basicblock *block = compiler_new_block(c);
@@ -986,6 +980,8 @@
return 1 - (oparg & 0xFF);
case BUILD_MAP:
return 1 - 2*oparg;
+ case BUILD_CONST_KEY_MAP:
+ return -oparg;
case LOAD_ATTR:
return 0;
case COMPARE_OP:
@@ -1034,11 +1030,10 @@
return -NARGS(oparg)-1;
case CALL_FUNCTION_VAR_KW:
return -NARGS(oparg)-2;
- case MAKE_FUNCTION:
- return -1 -NARGS(oparg) - ((oparg >> 16) & 0xffff);
- case MAKE_CLOSURE:
- return -2 - NARGS(oparg) - ((oparg >> 16) & 0xffff);
#undef NARGS
+ case MAKE_FUNCTION:
+ return -1 - ((oparg & 0x01) != 0) - ((oparg & 0x02) != 0) -
+ ((oparg & 0x04) != 0) - ((oparg & 0x08) != 0);
case BUILD_SLICE:
if (oparg == 3)
return -2;
@@ -1066,6 +1061,10 @@
return 1;
case GET_YIELD_FROM_ITER:
return 0;
+ case FORMAT_VALUE:
+ /* If there's a fmt_spec on the stack, we go from 2->1,
+ else 1->1. */
+ return (oparg & FVS_MASK) == FVS_HAVE_SPEC ? -1 : 0;
default:
return PY_INVALID_STACK_EFFECT;
}
@@ -1082,13 +1081,14 @@
basicblock *b;
struct instr *i;
int off;
+ assert(!HAS_ARG(opcode));
off = compiler_next_instr(c, c->u->u_curblock);
if (off < 0)
return 0;
b = c->u->u_curblock;
i = &b->b_instr[off];
i->i_opcode = opcode;
- i->i_hasarg = 0;
+ i->i_oparg = 0;
if (opcode == RETURN_VALUE)
b->b_return = 1;
compiler_set_lineno(c, off);
@@ -1165,10 +1165,15 @@
struct instr *i;
int off;
- /* Integer arguments are limit to 16-bit. There is an extension for 32-bit
- integer arguments. */
- assert((-2147483647-1) <= oparg);
- assert(oparg <= 2147483647);
+ /* oparg value is unsigned, but a signed C int is usually used to store
+ it in the C code (like Python/ceval.c).
+
+ Limit to 32-bit signed C int (rather than INT_MAX) for portability.
+
+ The argument of a concrete bytecode instruction is limited to 8-bit.
+ EXTENDED_ARG is used for 16, 24, and 32-bit arguments. */
+ assert(HAS_ARG(opcode));
+ assert(0 <= oparg && oparg <= 2147483647);
off = compiler_next_instr(c, c->u->u_curblock);
if (off < 0)
@@ -1176,7 +1181,6 @@
i = &c->u->u_curblock->b_instr[off];
i->i_opcode = opcode;
i->i_oparg = Py_SAFE_DOWNCAST(oparg, Py_ssize_t, int);
- i->i_hasarg = 1;
compiler_set_lineno(c, off);
return 1;
}
@@ -1187,6 +1191,7 @@
struct instr *i;
int off;
+ assert(HAS_ARG(opcode));
assert(b != NULL);
off = compiler_next_instr(c, c->u->u_curblock);
if (off < 0)
@@ -1194,7 +1199,6 @@
i = &c->u->u_curblock->b_instr[off];
i->i_opcode = opcode;
i->i_target = b;
- i->i_hasarg = 1;
if (absolute)
i->i_jabs = 1;
else
@@ -1203,22 +1207,12 @@
return 1;
}
-/* The distinction between NEW_BLOCK and NEXT_BLOCK is subtle. (I'd
- like to find better names.) NEW_BLOCK() creates a new block and sets
- it as the current block. NEXT_BLOCK() also creates an implicit jump
- from the current block to the new block.
+/* NEXT_BLOCK() creates an implicit jump from the current block
+ to the new block.
+
+ The returns inside this macro make it impossible to decref objects
+ created in the local function. Local objects should use the arena.
*/
-
-/* The returns inside these macros make it impossible to decref objects
- created in the local function. Local objects should use the arena.
-*/
-
-
-#define NEW_BLOCK(C) { \
- if (compiler_use_new_block((C)) == NULL) \
- return 0; \
-}
-
#define NEXT_BLOCK(C) { \
if (compiler_next_block((C)) == NULL) \
return 0; \
@@ -1241,6 +1235,15 @@
return 0; \
}
+/* Same as ADDOP_O, but steals a reference. */
+#define ADDOP_N(C, OP, O, TYPE) { \
+ if (!compiler_addop_o((C), (OP), (C)->u->u_ ## TYPE, (O))) { \
+ Py_DECREF((O)); \
+ return 0; \
+ } \
+ Py_DECREF((O)); \
+}
+
#define ADDOP_NAME(C, OP, O, TYPE) { \
if (!compiler_addop_name((C), (OP), (C)->u->u_ ## TYPE, (O))) \
return 0; \
@@ -1309,7 +1312,49 @@
{
if (s->kind != Expr_kind)
return 0;
- return s->v.Expr.value->kind == Str_kind;
+ if (s->v.Expr.value->kind == Str_kind)
+ return 1;
+ if (s->v.Expr.value->kind == Constant_kind)
+ return PyUnicode_CheckExact(s->v.Expr.value->v.Constant.value);
+ return 0;
+}
+
+static int
+is_const(expr_ty e)
+{
+ switch (e->kind) {
+ case Constant_kind:
+ case Num_kind:
+ case Str_kind:
+ case Bytes_kind:
+ case Ellipsis_kind:
+ case NameConstant_kind:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+static PyObject *
+get_const_value(expr_ty e)
+{
+ switch (e->kind) {
+ case Constant_kind:
+ return e->v.Constant.value;
+ case Num_kind:
+ return e->v.Num.n;
+ case Str_kind:
+ return e->v.Str.s;
+ case Bytes_kind:
+ return e->v.Bytes.s;
+ case Ellipsis_kind:
+ return Py_Ellipsis;
+ case NameConstant_kind:
+ return e->v.NameConstant.value;
+ default:
+ assert(!is_const(e));
+ return NULL;
+ }
}
/* Compile a sequence of statements, checking for a docstring. */
@@ -1426,53 +1471,50 @@
}
static int
-compiler_make_closure(struct compiler *c, PyCodeObject *co, Py_ssize_t args, PyObject *qualname)
+compiler_make_closure(struct compiler *c, PyCodeObject *co, Py_ssize_t flags, PyObject *qualname)
{
Py_ssize_t i, free = PyCode_GetNumFree(co);
if (qualname == NULL)
qualname = co->co_name;
- if (free == 0) {
- ADDOP_O(c, LOAD_CONST, (PyObject*)co, consts);
- ADDOP_O(c, LOAD_CONST, qualname, consts);
- ADDOP_I(c, MAKE_FUNCTION, args);
- return 1;
- }
- for (i = 0; i < free; ++i) {
- /* Bypass com_addop_varname because it will generate
- LOAD_DEREF but LOAD_CLOSURE is needed.
- */
- PyObject *name = PyTuple_GET_ITEM(co->co_freevars, i);
- int arg, reftype;
+ if (free) {
+ for (i = 0; i < free; ++i) {
+ /* Bypass com_addop_varname because it will generate
+ LOAD_DEREF but LOAD_CLOSURE is needed.
+ */
+ PyObject *name = PyTuple_GET_ITEM(co->co_freevars, i);
+ int arg, reftype;
- /* Special case: If a class contains a method with a
- free variable that has the same name as a method,
- the name will be considered free *and* local in the
- class. It should be handled by the closure, as
- well as by the normal name loookup logic.
- */
- reftype = get_ref_type(c, name);
- if (reftype == CELL)
- arg = compiler_lookup_arg(c->u->u_cellvars, name);
- else /* (reftype == FREE) */
- arg = compiler_lookup_arg(c->u->u_freevars, name);
- if (arg == -1) {
- fprintf(stderr,
- "lookup %s in %s %d %d\n"
- "freevars of %s: %s\n",
- PyUnicode_AsUTF8(PyObject_Repr(name)),
- PyUnicode_AsUTF8(c->u->u_name),
- reftype, arg,
- PyUnicode_AsUTF8(co->co_name),
- PyUnicode_AsUTF8(PyObject_Repr(co->co_freevars)));
- Py_FatalError("compiler_make_closure()");
+ /* Special case: If a class contains a method with a
+ free variable that has the same name as a method,
+ the name will be considered free *and* local in the
+ class. It should be handled by the closure, as
+ well as by the normal name loookup logic.
+ */
+ reftype = get_ref_type(c, name);
+ if (reftype == CELL)
+ arg = compiler_lookup_arg(c->u->u_cellvars, name);
+ else /* (reftype == FREE) */
+ arg = compiler_lookup_arg(c->u->u_freevars, name);
+ if (arg == -1) {
+ fprintf(stderr,
+ "lookup %s in %s %d %d\n"
+ "freevars of %s: %s\n",
+ PyUnicode_AsUTF8(PyObject_Repr(name)),
+ PyUnicode_AsUTF8(c->u->u_name),
+ reftype, arg,
+ PyUnicode_AsUTF8(co->co_name),
+ PyUnicode_AsUTF8(PyObject_Repr(co->co_freevars)));
+ Py_FatalError("compiler_make_closure()");
+ }
+ ADDOP_I(c, LOAD_CLOSURE, arg);
}
- ADDOP_I(c, LOAD_CLOSURE, arg);
+ flags |= 0x08;
+ ADDOP_I(c, BUILD_TUPLE, free);
}
- ADDOP_I(c, BUILD_TUPLE, free);
ADDOP_O(c, LOAD_CONST, (PyObject*)co, consts);
ADDOP_O(c, LOAD_CONST, qualname, consts);
- ADDOP_I(c, MAKE_CLOSURE, args);
+ ADDOP_I(c, MAKE_FUNCTION, flags);
return 1;
}
@@ -1494,26 +1536,60 @@
compiler_visit_kwonlydefaults(struct compiler *c, asdl_seq *kwonlyargs,
asdl_seq *kw_defaults)
{
- /* Return the number of defaults + 1.
- Returns 0 on error.
- */
- int i, default_count = 0;
+ /* Push a dict of keyword-only default values.
+
+ Return 0 on error, -1 if no dict pushed, 1 if a dict is pushed.
+ */
+ int i;
+ PyObject *keys = NULL;
+
for (i = 0; i < asdl_seq_LEN(kwonlyargs); i++) {
arg_ty arg = asdl_seq_GET(kwonlyargs, i);
expr_ty default_ = asdl_seq_GET(kw_defaults, i);
if (default_) {
PyObject *mangled = _Py_Mangle(c->u->u_private, arg->arg);
- if (!mangled)
- return 0;
- ADDOP_O(c, LOAD_CONST, mangled, consts);
- Py_DECREF(mangled);
- if (!compiler_visit_expr(c, default_)) {
- return 0;
+ if (!mangled) {
+ goto error;
}
- default_count++;
+ if (keys == NULL) {
+ keys = PyList_New(1);
+ if (keys == NULL) {
+ Py_DECREF(mangled);
+ return 0;
+ }
+ PyList_SET_ITEM(keys, 0, mangled);
+ }
+ else {
+ int res = PyList_Append(keys, mangled);
+ Py_DECREF(mangled);
+ if (res == -1) {
+ goto error;
+ }
+ }
+ if (!compiler_visit_expr(c, default_)) {
+ goto error;
+ }
}
}
- return default_count + 1;
+ if (keys != NULL) {
+ Py_ssize_t default_count = PyList_GET_SIZE(keys);
+ PyObject *keys_tuple = PyList_AsTuple(keys);
+ Py_DECREF(keys);
+ if (keys_tuple == NULL) {
+ return 0;
+ }
+ ADDOP_N(c, LOAD_CONST, keys_tuple, consts);
+ ADDOP_I(c, BUILD_CONST_KEY_MAP, default_count);
+ assert(default_count > 0);
+ return 1;
+ }
+ else {
+ return -1;
+ }
+
+error:
+ Py_XDECREF(keys);
+ return 0;
}
static int
@@ -1556,11 +1632,10 @@
compiler_visit_annotations(struct compiler *c, arguments_ty args,
expr_ty returns)
{
- /* Push arg annotations and a list of the argument names. Return the #
- of items pushed + 1. The expressions are evaluated out-of-order wrt the
- source code.
+ /* Push arg annotation dict.
+ The expressions are evaluated out-of-order wrt the source code.
- More than 2^16-1 annotations is a SyntaxError. Returns 0 on error.
+ Return 0 on error, -1 if no dict pushed, 1 if a dict is pushed.
*/
static identifier return_str;
PyObject *names;
@@ -1592,32 +1667,20 @@
}
len = PyList_GET_SIZE(names);
- if (len > 65534) {
- /* len must fit in 16 bits, and len is incremented below */
- PyErr_SetString(PyExc_SyntaxError,
- "too many annotations");
- goto error;
- }
if (len) {
- /* convert names to a tuple and place on stack */
- PyObject *elt;
- Py_ssize_t i;
- PyObject *s = PyTuple_New(len);
- if (!s)
- goto error;
- for (i = 0; i < len; i++) {
- elt = PyList_GET_ITEM(names, i);
- Py_INCREF(elt);
- PyTuple_SET_ITEM(s, i, elt);
+ PyObject *keytuple = PyList_AsTuple(names);
+ Py_DECREF(names);
+ if (keytuple == NULL) {
+ return 0;
}
- ADDOP_O(c, LOAD_CONST, s, consts);
- Py_DECREF(s);
- len++; /* include the just-pushed tuple */
+ ADDOP_N(c, LOAD_CONST, keytuple, consts);
+ ADDOP_I(c, BUILD_CONST_KEY_MAP, len);
+ return 1;
}
- Py_DECREF(names);
-
- /* We just checked that len <= 65535, see above */
- return Py_SAFE_DOWNCAST(len + 1, Py_ssize_t, int);
+ else {
+ Py_DECREF(names);
+ return -1;
+ }
error:
Py_DECREF(names);
@@ -1625,6 +1688,36 @@
}
static int
+compiler_visit_defaults(struct compiler *c, arguments_ty args)
+{
+ VISIT_SEQ(c, expr, args->defaults);
+ ADDOP_I(c, BUILD_TUPLE, asdl_seq_LEN(args->defaults));
+ return 1;
+}
+
+static Py_ssize_t
+compiler_default_arguments(struct compiler *c, arguments_ty args)
+{
+ Py_ssize_t funcflags = 0;
+ if (args->defaults && asdl_seq_LEN(args->defaults) > 0) {
+ if (!compiler_visit_defaults(c, args))
+ return -1;
+ funcflags |= 0x01;
+ }
+ if (args->kwonlyargs) {
+ int res = compiler_visit_kwonlydefaults(c, args->kwonlyargs,
+ args->kw_defaults);
+ if (res == 0) {
+ return -1;
+ }
+ else if (res > 0) {
+ funcflags |= 0x02;
+ }
+ }
+ return funcflags;
+}
+
+static int
compiler_function(struct compiler *c, stmt_ty s, int is_async)
{
PyCodeObject *co;
@@ -1635,12 +1728,11 @@
asdl_seq* decos;
asdl_seq *body;
stmt_ty st;
- Py_ssize_t i, n, arglength;
- int docstring, kw_default_count = 0;
- int num_annotations;
+ Py_ssize_t i, n, funcflags;
+ int docstring;
+ int annotations;
int scope_type;
-
if (is_async) {
assert(s->kind == AsyncFunctionDef_kind);
@@ -1665,30 +1757,32 @@
if (!compiler_decorators(c, decos))
return 0;
- if (args->defaults)
- VISIT_SEQ(c, expr, args->defaults);
- if (args->kwonlyargs) {
- int res = compiler_visit_kwonlydefaults(c, args->kwonlyargs,
- args->kw_defaults);
- if (res == 0)
- return 0;
- kw_default_count = res - 1;
- }
- num_annotations = compiler_visit_annotations(c, args, returns);
- if (num_annotations == 0)
- return 0;
- num_annotations--;
- assert((num_annotations & 0xFFFF) == num_annotations);
- if (!compiler_enter_scope(c, name,
- scope_type, (void *)s,
- s->lineno))
+ funcflags = compiler_default_arguments(c, args);
+ if (funcflags == -1) {
return 0;
+ }
+
+ annotations = compiler_visit_annotations(c, args, returns);
+ if (annotations == 0) {
+ return 0;
+ }
+ else if (annotations > 0) {
+ funcflags |= 0x04;
+ }
+
+ if (!compiler_enter_scope(c, name, scope_type, (void *)s, s->lineno)) {
+ return 0;
+ }
st = (stmt_ty)asdl_seq_GET(body, 0);
docstring = compiler_isdocstring(st);
- if (docstring && c->c_optimize < 2)
- first_const = st->v.Expr.value->v.Str.s;
+ if (docstring && c->c_optimize < 2) {
+ if (st->v.Expr.value->kind == Constant_kind)
+ first_const = st->v.Expr.value->v.Constant.value;
+ else
+ first_const = st->v.Expr.value->v.Str.s;
+ }
if (compiler_add_o(c, c->u->u_consts, first_const) < 0) {
compiler_exit_scope(c);
return 0;
@@ -1712,12 +1806,9 @@
return 0;
}
- arglength = asdl_seq_LEN(args->defaults);
- arglength |= kw_default_count << 8;
- arglength |= num_annotations << 16;
if (is_async)
co->co_flags |= CO_COROUTINE;
- compiler_make_closure(c, co, arglength, qualname);
+ compiler_make_closure(c, co, funcflags, qualname);
Py_DECREF(qualname);
Py_DECREF(co);
@@ -1877,8 +1968,7 @@
PyCodeObject *co;
PyObject *qualname;
static identifier name;
- int kw_default_count = 0;
- Py_ssize_t arglength;
+ Py_ssize_t funcflags;
arguments_ty args = e->v.Lambda.args;
assert(e->kind == Lambda_kind);
@@ -1888,14 +1978,11 @@
return 0;
}
- if (args->defaults)
- VISIT_SEQ(c, expr, args->defaults);
- if (args->kwonlyargs) {
- int res = compiler_visit_kwonlydefaults(c, args->kwonlyargs,
- args->kw_defaults);
- if (res == 0) return 0;
- kw_default_count = res - 1;
+ funcflags = compiler_default_arguments(c, args);
+ if (funcflags == -1) {
+ return 0;
}
+
if (!compiler_enter_scope(c, name, COMPILER_SCOPE_LAMBDA,
(void *)e, e->lineno))
return 0;
@@ -1921,9 +2008,7 @@
if (co == NULL)
return 0;
- arglength = asdl_seq_LEN(args->defaults);
- arglength |= kw_default_count << 8;
- compiler_make_closure(c, co, arglength, qualname);
+ compiler_make_closure(c, co, funcflags, qualname);
Py_DECREF(qualname);
Py_DECREF(co);
@@ -2599,6 +2684,25 @@
}
static int
+compiler_visit_stmt_expr(struct compiler *c, expr_ty value)
+{
+ if (c->c_interactive && c->c_nestlevel <= 1) {
+ VISIT(c, expr, value);
+ ADDOP(c, PRINT_EXPR);
+ return 1;
+ }
+
+ if (is_const(value)) {
+ /* ignore constant statement */
+ return 1;
+ }
+
+ VISIT(c, expr, value);
+ ADDOP(c, POP_TOP);
+ return 1;
+}
+
+static int
compiler_visit_stmt(struct compiler *c, stmt_ty s)
{
Py_ssize_t i, n;
@@ -2668,16 +2772,7 @@
case Nonlocal_kind:
break;
case Expr_kind:
- if (c->c_interactive && c->c_nestlevel <= 1) {
- VISIT(c, expr, s->v.Expr.value);
- ADDOP(c, PRINT_EXPR);
- }
- else if (s->v.Expr.value->kind != Str_kind &&
- s->v.Expr.value->kind != Num_kind) {
- VISIT(c, expr, s->v.Expr.value);
- ADDOP(c, POP_TOP);
- }
- break;
+ return compiler_visit_stmt_expr(c, s->v.Expr.value);
case Pass_kind:
break;
case Break_kind:
@@ -3079,9 +3174,53 @@
}
static int
+are_all_items_const(asdl_seq *seq, Py_ssize_t begin, Py_ssize_t end)
+{
+ Py_ssize_t i;
+ for (i = begin; i < end; i++) {
+ expr_ty key = (expr_ty)asdl_seq_GET(seq, i);
+ if (key == NULL || !is_const(key))
+ return 0;
+ }
+ return 1;
+}
+
+static int
+compiler_subdict(struct compiler *c, expr_ty e, Py_ssize_t begin, Py_ssize_t end)
+{
+ Py_ssize_t i, n = end - begin;
+ PyObject *keys, *key;
+ if (n > 1 && are_all_items_const(e->v.Dict.keys, begin, end)) {
+ for (i = begin; i < end; i++) {
+ VISIT(c, expr, (expr_ty)asdl_seq_GET(e->v.Dict.values, i));
+ }
+ keys = PyTuple_New(n);
+ if (keys == NULL) {
+ return 0;
+ }
+ for (i = begin; i < end; i++) {
+ key = get_const_value((expr_ty)asdl_seq_GET(e->v.Dict.keys, i));
+ Py_INCREF(key);
+ PyTuple_SET_ITEM(keys, i - begin, key);
+ }
+ ADDOP_N(c, LOAD_CONST, keys, consts);
+ ADDOP_I(c, BUILD_CONST_KEY_MAP, n);
+ }
+ else {
+ for (i = begin; i < end; i++) {
+ VISIT(c, expr, (expr_ty)asdl_seq_GET(e->v.Dict.keys, i));
+ VISIT(c, expr, (expr_ty)asdl_seq_GET(e->v.Dict.values, i));
+ }
+ ADDOP_I(c, BUILD_MAP, n);
+ }
+ return 1;
+}
+
+static int
compiler_dict(struct compiler *c, expr_ty e)
{
- Py_ssize_t i, n, containers, elements;
+ Py_ssize_t i, n, elements;
+ int containers;
int is_unpacking = 0;
n = asdl_seq_LEN(e->v.Dict.values);
containers = 0;
@@ -3089,7 +3228,8 @@
for (i = 0; i < n; i++) {
is_unpacking = (expr_ty)asdl_seq_GET(e->v.Dict.keys, i) == NULL;
if (elements == 0xFFFF || (elements && is_unpacking)) {
- ADDOP_I(c, BUILD_MAP, elements);
+ if (!compiler_subdict(c, e, i - elements, i))
+ return 0;
containers++;
elements = 0;
}
@@ -3098,13 +3238,12 @@
containers++;
}
else {
- VISIT(c, expr, (expr_ty)asdl_seq_GET(e->v.Dict.keys, i));
- VISIT(c, expr, (expr_ty)asdl_seq_GET(e->v.Dict.values, i));
elements++;
}
}
if (elements || containers == 0) {
- ADDOP_I(c, BUILD_MAP, elements);
+ if (!compiler_subdict(c, e, n - elements, n))
+ return 0;
containers++;
}
/* If there is more than one dict, they need to be merged into a new
@@ -3173,15 +3312,127 @@
e->v.Call.keywords);
}
+static int
+compiler_joined_str(struct compiler *c, expr_ty e)
+{
+ /* Concatenate parts of a string using ''.join(parts). There are
+ probably better ways of doing this.
+
+ This is used for constructs like "'x=' f'{42}'", which have to
+ be evaluated at compile time. */
+
+ static PyObject *empty_string;
+ static PyObject *join_string;
+
+ if (!empty_string) {
+ empty_string = PyUnicode_FromString("");
+ if (!empty_string)
+ return 0;
+ }
+ if (!join_string) {
+ join_string = PyUnicode_FromString("join");
+ if (!join_string)
+ return 0;
+ }
+
+ ADDOP_O(c, LOAD_CONST, empty_string, consts);
+ ADDOP_NAME(c, LOAD_ATTR, join_string, names);
+ VISIT_SEQ(c, expr, e->v.JoinedStr.values);
+ ADDOP_I(c, BUILD_LIST, asdl_seq_LEN(e->v.JoinedStr.values));
+ ADDOP_I(c, CALL_FUNCTION, 1);
+ return 1;
+}
+
+/* Used to implement f-strings. Format a single value. */
+static int
+compiler_formatted_value(struct compiler *c, expr_ty e)
+{
+ /* Our oparg encodes 2 pieces of information: the conversion
+ character, and whether or not a format_spec was provided.
+
+ Convert the conversion char to 2 bits:
+ None: 000 0x0 FVC_NONE
+ !s : 001 0x1 FVC_STR
+ !r : 010 0x2 FVC_REPR
+ !a : 011 0x3 FVC_ASCII
+
+ next bit is whether or not we have a format spec:
+ yes : 100 0x4
+ no : 000 0x0
+ */
+
+ int oparg;
+
+ /* Evaluate the expression to be formatted. */
+ VISIT(c, expr, e->v.FormattedValue.value);
+
+ switch (e->v.FormattedValue.conversion) {
+ case 's': oparg = FVC_STR; break;
+ case 'r': oparg = FVC_REPR; break;
+ case 'a': oparg = FVC_ASCII; break;
+ case -1: oparg = FVC_NONE; break;
+ default:
+ PyErr_SetString(PyExc_SystemError,
+ "Unrecognized conversion character");
+ return 0;
+ }
+ if (e->v.FormattedValue.format_spec) {
+ /* Evaluate the format spec, and update our opcode arg. */
+ VISIT(c, expr, e->v.FormattedValue.format_spec);
+ oparg |= FVS_HAVE_SPEC;
+ }
+
+ /* And push our opcode and oparg */
+ ADDOP_I(c, FORMAT_VALUE, oparg);
+ return 1;
+}
+
+static int
+compiler_subkwargs(struct compiler *c, asdl_seq *keywords, Py_ssize_t begin, Py_ssize_t end)
+{
+ Py_ssize_t i, n = end - begin;
+ keyword_ty kw;
+ PyObject *keys, *key;
+ assert(n > 0);
+ if (n > 1) {
+ for (i = begin; i < end; i++) {
+ kw = asdl_seq_GET(keywords, i);
+ VISIT(c, expr, kw->value);
+ }
+ keys = PyTuple_New(n);
+ if (keys == NULL) {
+ return 0;
+ }
+ for (i = begin; i < end; i++) {
+ key = ((keyword_ty) asdl_seq_GET(keywords, i))->arg;
+ Py_INCREF(key);
+ PyTuple_SET_ITEM(keys, i - begin, key);
+ }
+ ADDOP_N(c, LOAD_CONST, keys, consts);
+ ADDOP_I(c, BUILD_CONST_KEY_MAP, n);
+ }
+ else {
+ /* a for loop only executes once */
+ for (i = begin; i < end; i++) {
+ kw = asdl_seq_GET(keywords, i);
+ ADDOP_O(c, LOAD_CONST, kw->arg, consts);
+ VISIT(c, expr, kw->value);
+ }
+ ADDOP_I(c, BUILD_MAP, n);
+ }
+ return 1;
+}
+
/* shared code between compiler_call and compiler_class */
static int
compiler_call_helper(struct compiler *c,
- Py_ssize_t n, /* Args already pushed */
+ int n, /* Args already pushed */
asdl_seq *args,
asdl_seq *keywords)
{
int code = 0;
- Py_ssize_t nelts, i, nseen, nkw;
+ Py_ssize_t nelts, i, nseen;
+ int nkw;
/* the number of tuples and dictionaries on the stack */
Py_ssize_t nsubargs = 0, nsubkwargs = 0;
@@ -3238,29 +3489,38 @@
if (kw->arg == NULL) {
/* A keyword argument unpacking. */
if (nseen) {
- ADDOP_I(c, BUILD_MAP, nseen);
+ if (nsubkwargs) {
+ if (!compiler_subkwargs(c, keywords, i - nseen, i))
+ return 0;
+ nsubkwargs++;
+ }
+ else {
+ Py_ssize_t j;
+ for (j = 0; j < nseen; j++) {
+ VISIT(c, keyword, asdl_seq_GET(keywords, j));
+ }
+ nkw = nseen;
+ }
nseen = 0;
- nsubkwargs++;
}
VISIT(c, expr, kw->value);
nsubkwargs++;
}
- else if (nsubkwargs) {
- /* A keyword argument and we already have a dict. */
- ADDOP_O(c, LOAD_CONST, kw->arg, consts);
- VISIT(c, expr, kw->value);
- nseen++;
- }
else {
- /* keyword argument */
- VISIT(c, keyword, kw)
- nkw++;
+ nseen++;
}
}
if (nseen) {
- /* Pack up any trailing keyword arguments. */
- ADDOP_I(c, BUILD_MAP, nseen);
- nsubkwargs++;
+ if (nsubkwargs) {
+ /* Pack up any trailing keyword arguments. */
+ if (!compiler_subkwargs(c, keywords, nelts - nseen, nelts))
+ return 0;
+ nsubkwargs++;
+ }
+ else {
+ VISIT_SEQ(c, keyword, keywords);
+ nkw = nseen;
+ }
}
if (nsubkwargs) {
code |= 2;
@@ -3549,6 +3809,8 @@
switch (e->kind) {
case Ellipsis_kind:
return 1;
+ case Constant_kind:
+ return PyObject_IsTrue(e->v.Constant.value);
case Num_kind:
return PyObject_IsTrue(e->v.Num.n);
case Str_kind:
@@ -3592,9 +3854,9 @@
BLOCK
finally:
if an exception was raised:
- exc = copy of (exception, instance, traceback)
+ exc = copy of (exception, instance, traceback)
else:
- exc = (None, None, None)
+ exc = (None, None, None)
if not (await exit(*exc)):
raise
*/
@@ -3836,12 +4098,19 @@
return compiler_compare(c, e);
case Call_kind:
return compiler_call(c, e);
+ case Constant_kind:
+ ADDOP_O(c, LOAD_CONST, e->v.Constant.value, consts);
+ break;
case Num_kind:
ADDOP_O(c, LOAD_CONST, e->v.Num.n, consts);
break;
case Str_kind:
ADDOP_O(c, LOAD_CONST, e->v.Str.s, consts);
break;
+ case JoinedStr_kind:
+ return compiler_joined_str(c, e);
+ case FormattedValue_kind:
+ return compiler_formatted_value(c, e);
case Bytes_kind:
ADDOP_O(c, LOAD_CONST, e->v.Bytes.s, consts);
break;
@@ -4295,18 +4564,6 @@
PyObject_Free(a->a_postorder);
}
-/* Return the size of a basic block in bytes. */
-
-static int
-instrsize(struct instr *instr)
-{
- if (!instr->i_hasarg)
- return 1; /* 1 byte for the opcode*/
- if (instr->i_oparg > 0xffff)
- return 6; /* 1 (opcode) + 1 (EXTENDED_ARG opcode) + 2 (oparg) + 2(oparg extended) */
- return 3; /* 1 (opcode) + 2 (oparg) */
-}
-
static int
blocksize(basicblock *b)
{
@@ -4314,7 +4571,7 @@
int size = 0;
for (i = 0; i < b->b_iused; i++)
- size += instrsize(&b->b_instr[i]);
+ size += instrsize(b->b_instr[i].i_oparg);
return size;
}
@@ -4333,7 +4590,6 @@
d_lineno = i->i_lineno - a->a_lineno;
assert(d_bytecode >= 0);
- assert(d_lineno >= 0);
if(d_bytecode == 0 && d_lineno == 0)
return 1;
@@ -4363,9 +4619,21 @@
d_bytecode -= ncodes * 255;
a->a_lnotab_off += ncodes * 2;
}
- assert(d_bytecode <= 255);
- if (d_lineno > 255) {
- int j, nbytes, ncodes = d_lineno / 255;
+ assert(0 <= d_bytecode && d_bytecode <= 255);
+
+ if (d_lineno < -128 || 127 < d_lineno) {
+ int j, nbytes, ncodes, k;
+ if (d_lineno < 0) {
+ k = -128;
+ /* use division on positive numbers */
+ ncodes = (-d_lineno) / 128;
+ }
+ else {
+ k = 127;
+ ncodes = d_lineno / 127;
+ }
+ d_lineno -= ncodes * k;
+ assert(ncodes >= 1);
nbytes = a->a_lnotab_off + 2 * ncodes;
len = PyBytes_GET_SIZE(a->a_lnotab);
if (nbytes >= len) {
@@ -4383,15 +4651,15 @@
lnotab = (unsigned char *)
PyBytes_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
*lnotab++ = d_bytecode;
- *lnotab++ = 255;
+ *lnotab++ = k;
d_bytecode = 0;
for (j = 1; j < ncodes; j++) {
*lnotab++ = 0;
- *lnotab++ = 255;
+ *lnotab++ = k;
}
- d_lineno -= ncodes * 255;
a->a_lnotab_off += ncodes * 2;
}
+ assert(-128 <= d_lineno && d_lineno <= 127);
len = PyBytes_GET_SIZE(a->a_lnotab);
if (a->a_lnotab_off + 2 >= len) {
@@ -4423,15 +4691,12 @@
static int
assemble_emit(struct assembler *a, struct instr *i)
{
- int size, arg = 0, ext = 0;
+ int size, arg = 0;
Py_ssize_t len = PyBytes_GET_SIZE(a->a_bytecode);
char *code;
- size = instrsize(i);
- if (i->i_hasarg) {
- arg = i->i_oparg;
- ext = arg >> 16;
- }
+ arg = i->i_oparg;
+ size = instrsize(arg);
if (i->i_lineno && !assemble_lnotab(a, i))
return 0;
if (a->a_offset + size >= len) {
@@ -4442,19 +4707,7 @@
}
code = PyBytes_AS_STRING(a->a_bytecode) + a->a_offset;
a->a_offset += size;
- if (size == 6) {
- assert(i->i_hasarg);
- *code++ = (char)EXTENDED_ARG;
- *code++ = ext & 0xff;
- *code++ = ext >> 8;
- arg &= 0xffff;
- }
- *code++ = i->i_opcode;
- if (i->i_hasarg) {
- assert(size == 3 || size == 6);
- *code++ = arg & 0xff;
- *code++ = arg >> 8;
- }
+ write_op_arg((unsigned char*)code, i->i_opcode, arg, size);
return 1;
}
@@ -4462,7 +4715,7 @@
assemble_jump_offsets(struct assembler *a, struct compiler *c)
{
basicblock *b;
- int bsize, totsize, extended_arg_count = 0, last_extended_arg_count;
+ int bsize, totsize, extended_arg_recompile;
int i;
/* Compute the size of each block and fixup jump args.
@@ -4475,27 +4728,26 @@
b->b_offset = totsize;
totsize += bsize;
}
- last_extended_arg_count = extended_arg_count;
- extended_arg_count = 0;
+ extended_arg_recompile = 0;
for (b = c->u->u_blocks; b != NULL; b = b->b_list) {
bsize = b->b_offset;
for (i = 0; i < b->b_iused; i++) {
struct instr *instr = &b->b_instr[i];
+ int isize = instrsize(instr->i_oparg);
/* Relative jumps are computed relative to
the instruction pointer after fetching
the jump instruction.
*/
- bsize += instrsize(instr);
- if (instr->i_jabs)
+ bsize += isize;
+ if (instr->i_jabs || instr->i_jrel) {
instr->i_oparg = instr->i_target->b_offset;
- else if (instr->i_jrel) {
- int delta = instr->i_target->b_offset - bsize;
- instr->i_oparg = delta;
+ if (instr->i_jrel) {
+ instr->i_oparg -= bsize;
+ }
+ if (instrsize(instr->i_oparg) != isize) {
+ extended_arg_recompile = 1;
+ }
}
- else
- continue;
- if (instr->i_oparg > 0xffff)
- extended_arg_count++;
}
}
@@ -4505,7 +4757,7 @@
The issue is that in the first loop blocksize() is called
which calls instrsize() which requires i_oparg be set
- appropriately. There is a bootstrap problem because
+ appropriately. There is a bootstrap problem because
i_oparg is calculated in the second loop above.
So we loop until we stop seeing new EXTENDED_ARGs.
@@ -4513,7 +4765,7 @@
ones in jump instructions. So this should converge
fairly quickly.
*/
- } while (last_extended_arg_count != extended_arg_count);
+ } while (extended_arg_recompile);
}
static PyObject *
@@ -4659,9 +4911,9 @@
char arg[128];
*arg = '\0';
- if (i->i_hasarg)
+ if (HAS_ARG(i->i_opcode)) {
sprintf(arg, "arg: %d ", i->i_oparg);
-
+ }
fprintf(stderr, "line: %d, opcode: %d %s%s%s\n",
i->i_lineno, i->i_opcode, arg, jabs, jrel);
}
@@ -4749,4 +5001,3 @@
{
return PyAST_CompileEx(mod, filename, flags, -1, arena);
}
-
diff --git a/Python/dtoa.c b/Python/dtoa.c
index 3da546e..e0665b6 100644
--- a/Python/dtoa.c
+++ b/Python/dtoa.c
@@ -747,7 +747,7 @@
{
Bigint *b1, *p5, *p51;
int i;
- static int p05[3] = { 5, 25, 125 };
+ static const int p05[3] = { 5, 25, 125 };
if ((i = k & 3)) {
b = multadd(b, p05[i-1], 0);
@@ -803,7 +803,7 @@
{
Bigint *b1, *p5, *p51;
int i;
- static int p05[3] = { 5, 25, 125 };
+ static const int p05[3] = { 5, 25, 125 };
if ((i = k & 3)) {
b = multadd(b, p05[i-1], 0);
@@ -2315,7 +2315,7 @@
}
static char *
-nrv_alloc(char *s, char **rve, int n)
+nrv_alloc(const char *s, char **rve, int n)
{
char *rv, *t;
diff --git a/Python/dynload_win.c b/Python/dynload_win.c
index f2c796e..05050cf 100644
--- a/Python/dynload_win.c
+++ b/Python/dynload_win.c
@@ -24,12 +24,10 @@
#define PYD_DEBUG_SUFFIX ""
#endif
-#define STRINGIZE2(x) #x
-#define STRINGIZE(x) STRINGIZE2(x)
#ifdef PYD_PLATFORM_TAG
-#define PYD_TAGGED_SUFFIX PYD_DEBUG_SUFFIX ".cp" STRINGIZE(PY_MAJOR_VERSION) STRINGIZE(PY_MINOR_VERSION) "-" PYD_PLATFORM_TAG ".pyd"
+#define PYD_TAGGED_SUFFIX PYD_DEBUG_SUFFIX ".cp" Py_STRINGIFY(PY_MAJOR_VERSION) Py_STRINGIFY(PY_MINOR_VERSION) "-" PYD_PLATFORM_TAG ".pyd"
#else
-#define PYD_TAGGED_SUFFIX PYD_DEBUG_SUFFIX ".cp" STRINGIZE(PY_MAJOR_VERSION) STRINGIZE(PY_MINOR_VERSION) ".pyd"
+#define PYD_TAGGED_SUFFIX PYD_DEBUG_SUFFIX ".cp" Py_STRINGIFY(PY_MAJOR_VERSION) Py_STRINGIFY(PY_MINOR_VERSION) ".pyd"
#endif
#define PYD_UNTAGGED_SUFFIX PYD_DEBUG_SUFFIX ".pyd"
@@ -43,7 +41,7 @@
/* Case insensitive string compare, to avoid any dependencies on particular
C RTL implementations */
-static int strcasecmp (char *string1, char *string2)
+static int strcasecmp (const char *string1, const char *string2)
{
int first, second;
diff --git a/Python/fileutils.c b/Python/fileutils.c
index 23eed71..06531d9 100644
--- a/Python/fileutils.c
+++ b/Python/fileutils.c
@@ -683,6 +683,10 @@
{
int res;
+#ifdef WITH_THREAD
+ assert(PyGILState_Check());
+#endif
+
Py_BEGIN_ALLOW_THREADS
res = _Py_fstat_noraise(fd, status);
Py_END_ALLOW_THREADS
@@ -794,7 +798,7 @@
int request;
int err;
#endif
- int flags;
+ int flags, new_flags;
int res;
#endif
@@ -885,10 +889,18 @@
return -1;
}
- if (inheritable)
- flags &= ~FD_CLOEXEC;
- else
- flags |= FD_CLOEXEC;
+ if (inheritable) {
+ new_flags = flags & ~FD_CLOEXEC;
+ }
+ else {
+ new_flags = flags | FD_CLOEXEC;
+ }
+
+ if (new_flags == flags) {
+ /* FD_CLOEXEC flag already set/cleared: nothing to do */
+ return 0;
+ }
+
res = fcntl(fd, F_SETFD, flags);
if (res < 0) {
if (raise)
@@ -1169,6 +1181,10 @@
int err;
int async_err = 0;
+#ifdef WITH_THREAD
+ assert(PyGILState_Check());
+#endif
+
/* _Py_read() must not be called with an exception set, otherwise the
* caller may think that read() was interrupted by a signal and the signal
* handler raised an exception. */
@@ -1324,6 +1340,10 @@
Py_ssize_t
_Py_write(int fd, const void *buf, size_t count)
{
+#ifdef WITH_THREAD
+ assert(PyGILState_Check());
+#endif
+
/* _Py_write() must not be called with an exception set, otherwise the
* caller may think that write() was interrupted by a signal and the signal
* handler raised an exception. */
@@ -1473,6 +1493,10 @@
DWORD ftype;
#endif
+#ifdef WITH_THREAD
+ assert(PyGILState_Check());
+#endif
+
if (!_PyVerify_fd(fd)) {
PyErr_SetFromErrno(PyExc_OSError);
return -1;
diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c
index 8e9c502..d573288 100644
--- a/Python/formatter_unicode.c
+++ b/Python/formatter_unicode.c
@@ -656,7 +656,7 @@
return 0;
}
-static char no_grouping[1] = {CHAR_MAX};
+static const char no_grouping[1] = {CHAR_MAX};
/* Find the decimal point character(s?), thousands_separator(s?), and
grouping description, either for the current locale if type is
diff --git a/Python/frozen.c b/Python/frozen.c
index 676f395..7e04f3c 100644
--- a/Python/frozen.c
+++ b/Python/frozen.c
@@ -14,17 +14,15 @@
the appropriate bytes from M___main__.c. */
static unsigned char M___hello__[] = {
- 99,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,
- 0,64,0,0,0,115,20,0,0,0,100,2,0,90,1,0,
- 101,2,0,100,0,0,131,1,0,1,100,1,0,83,40,3,
- 0,0,0,117,12,0,0,0,72,101,108,108,111,32,119,111,
- 114,108,100,33,78,84,40,3,0,0,0,117,4,0,0,0,
- 84,114,117,101,117,11,0,0,0,105,110,105,116,105,97,108,
- 105,122,101,100,117,5,0,0,0,112,114,105,110,116,40,0,
- 0,0,0,40,0,0,0,0,40,0,0,0,0,117,7,0,
- 0,0,102,108,97,103,46,112,121,117,8,0,0,0,60,109,
- 111,100,117,108,101,62,1,0,0,0,115,2,0,0,0,6,
- 1,
+ 227,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,
+ 0,64,0,0,0,115,16,0,0,0,100,0,90,0,101,1,
+ 100,1,131,1,1,0,100,2,83,0,41,3,84,122,12,72,
+ 101,108,108,111,32,119,111,114,108,100,33,78,41,2,218,11,
+ 105,110,105,116,105,97,108,105,122,101,100,218,5,112,114,105,
+ 110,116,169,0,114,3,0,0,0,114,3,0,0,0,250,22,
+ 46,47,84,111,111,108,115,47,102,114,101,101,122,101,47,102,
+ 108,97,103,46,112,121,218,8,60,109,111,100,117,108,101,62,
+ 1,0,0,0,115,2,0,0,0,4,1,
};
#define SIZE (int)sizeof(M___hello__)
diff --git a/Python/frozenmain.c b/Python/frozenmain.c
index de8bd35..769b33d 100644
--- a/Python/frozenmain.c
+++ b/Python/frozenmain.c
@@ -99,7 +99,9 @@
#ifdef MS_WINDOWS
PyWinFreeze_ExeTerm();
#endif
- Py_Finalize();
+ if (Py_FinalizeEx() < 0) {
+ sts = 120;
+ }
error:
PyMem_RawFree(argv_copy);
diff --git a/Python/future.c b/Python/future.c
index 163f87f..75f2107 100644
--- a/Python/future.c
+++ b/Python/future.c
@@ -79,7 +79,10 @@
i = 0;
first = (stmt_ty)asdl_seq_GET(mod->v.Module.body, i);
- if (first->kind == Expr_kind && first->v.Expr.value->kind == Str_kind)
+ if (first->kind == Expr_kind
+ && (first->v.Expr.value->kind == Str_kind
+ || (first->v.Expr.value->kind == Constant_kind
+ && PyUnicode_CheckExact(first->v.Expr.value->v.Constant.value))))
i++;
diff --git a/Python/getargs.c b/Python/getargs.c
index 8aab067..4418ebb 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -20,12 +20,12 @@
#ifdef HAVE_DECLSPEC_DLL
/* Export functions */
-PyAPI_FUNC(int) _PyArg_Parse_SizeT(PyObject *, char *, ...);
-PyAPI_FUNC(int) _PyArg_ParseTuple_SizeT(PyObject *, char *, ...);
+PyAPI_FUNC(int) _PyArg_Parse_SizeT(PyObject *, const char *, ...);
+PyAPI_FUNC(int) _PyArg_ParseTuple_SizeT(PyObject *, const char *, ...);
PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywords_SizeT(PyObject *, PyObject *,
const char *, char **, ...);
PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...);
-PyAPI_FUNC(int) _PyArg_VaParse_SizeT(PyObject *, char *, va_list);
+PyAPI_FUNC(int) _PyArg_VaParse_SizeT(PyObject *, const char *, va_list);
PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywords_SizeT(PyObject *, PyObject *,
const char *, char **, va_list);
#endif
@@ -56,18 +56,18 @@
/* Forward */
static int vgetargs1(PyObject *, const char *, va_list *, int);
static void seterror(Py_ssize_t, const char *, int *, const char *, const char *);
-static char *convertitem(PyObject *, const char **, va_list *, int, int *,
- char *, size_t, freelist_t *);
-static char *converttuple(PyObject *, const char **, va_list *, int,
- int *, char *, size_t, int, freelist_t *);
-static char *convertsimple(PyObject *, const char **, va_list *, int, char *,
- size_t, freelist_t *);
-static Py_ssize_t convertbuffer(PyObject *, void **p, char **);
-static int getbuffer(PyObject *, Py_buffer *, char**);
+static const char *convertitem(PyObject *, const char **, va_list *, int, int *,
+ char *, size_t, freelist_t *);
+static const char *converttuple(PyObject *, const char **, va_list *, int,
+ int *, char *, size_t, int, freelist_t *);
+static const char *convertsimple(PyObject *, const char **, va_list *, int,
+ char *, size_t, freelist_t *);
+static Py_ssize_t convertbuffer(PyObject *, void **p, const char **);
+static int getbuffer(PyObject *, Py_buffer *, const char**);
static int vgetargskeywords(PyObject *, PyObject *,
const char *, char **, va_list *, int);
-static char *skipitem(const char **, va_list *, int);
+static const char *skipitem(const char **, va_list *, int);
int
PyArg_Parse(PyObject *args, const char *format, ...)
@@ -82,7 +82,7 @@
}
int
-_PyArg_Parse_SizeT(PyObject *args, char *format, ...)
+_PyArg_Parse_SizeT(PyObject *args, const char *format, ...)
{
int retval;
va_list va;
@@ -107,7 +107,7 @@
}
int
-_PyArg_ParseTuple_SizeT(PyObject *args, char *format, ...)
+_PyArg_ParseTuple_SizeT(PyObject *args, const char *format, ...)
{
int retval;
va_list va;
@@ -130,7 +130,7 @@
}
int
-_PyArg_VaParse_SizeT(PyObject *args, char *format, va_list va)
+_PyArg_VaParse_SizeT(PyObject *args, const char *format, va_list va)
{
va_list lva;
@@ -208,7 +208,7 @@
int endfmt = 0;
const char *formatsave = format;
Py_ssize_t i, len;
- char *msg;
+ const char *msg;
int compat = flags & FLAG_COMPAT;
freelistentry_t static_entries[STATIC_FREELIST_ENTRIES];
freelist_t freelist;
@@ -394,7 +394,12 @@
PyOS_snprintf(p, sizeof(buf) - (p - buf), " %.256s", msg);
message = buf;
}
- PyErr_SetString(PyExc_TypeError, message);
+ if (msg[0] == '(') {
+ PyErr_SetString(PyExc_SystemError, message);
+ }
+ else {
+ PyErr_SetString(PyExc_TypeError, message);
+ }
}
@@ -416,7 +421,7 @@
and msgbuf is returned.
*/
-static char *
+static const char *
converttuple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
int *levels, char *msgbuf, size_t bufsize, int toplevel,
freelist_t *freelist)
@@ -474,7 +479,7 @@
format = *p_format;
for (i = 0; i < n; i++) {
- char *msg;
+ const char *msg;
PyObject *item;
item = PySequence_GetItem(arg, i);
if (item == NULL) {
@@ -501,11 +506,11 @@
/* Convert a single item. */
-static char *
+static const char *
convertitem(PyObject *arg, const char **p_format, va_list *p_va, int flags,
int *levels, char *msgbuf, size_t bufsize, freelist_t *freelist)
{
- char *msg;
+ const char *msg;
const char *format = *p_format;
if (*format == '(' /* ')' */) {
@@ -530,7 +535,7 @@
/* Format an error message generated by convertsimple(). */
-static char *
+static const char *
converterr(const char *expected, PyObject *arg, char *msgbuf, size_t bufsize)
{
assert(expected != NULL);
@@ -572,7 +577,7 @@
When you add new format codes, please don't forget poor skipitem() below.
*/
-static char *
+static const char *
convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
char *msgbuf, size_t bufsize, freelist_t *freelist)
{
@@ -857,7 +862,7 @@
case 'y': {/* any bytes-like object */
void **p = (void **)va_arg(*p_va, char **);
- char *buf;
+ const char *buf;
Py_ssize_t count;
if (*format == '*') {
if (getbuffer(arg, (Py_buffer*)p, &buf) < 0)
@@ -904,7 +909,7 @@
PyBuffer_FillInfo(p, arg, sarg, len, 1, 0);
}
else { /* any bytes-like object */
- char *buf;
+ const char *buf;
if (getbuffer(arg, p, &buf) < 0)
return converterr(buf, arg, msgbuf, bufsize);
}
@@ -934,7 +939,7 @@
}
else { /* read-only bytes-like object */
/* XXX Really? */
- char *buf;
+ const char *buf;
Py_ssize_t count = convertbuffer(arg, p, &buf);
if (count < 0)
return converterr(buf, arg, msgbuf, bufsize);
@@ -1051,35 +1056,25 @@
return converterr("(AsCharBuffer failed)",
arg, msgbuf, bufsize);
}
- else {
- PyObject *u;
-
- /* Convert object to Unicode */
- u = PyUnicode_FromObject(arg);
- if (u == NULL)
- return converterr(
- "string or unicode or text buffer",
- arg, msgbuf, bufsize);
-
+ else if (PyUnicode_Check(arg)) {
/* Encode object; use default error handling */
- s = PyUnicode_AsEncodedString(u,
+ s = PyUnicode_AsEncodedString(arg,
encoding,
NULL);
- Py_DECREF(u);
if (s == NULL)
return converterr("(encoding failed)",
arg, msgbuf, bufsize);
- if (!PyBytes_Check(s)) {
- Py_DECREF(s);
- return converterr(
- "(encoder failed to return bytes)",
- arg, msgbuf, bufsize);
- }
+ assert(PyBytes_Check(s));
size = PyBytes_GET_SIZE(s);
ptr = PyBytes_AS_STRING(s);
if (ptr == NULL)
ptr = "";
}
+ else {
+ return converterr(
+ recode_strings ? "str" : "str, bytes or bytearray",
+ arg, msgbuf, bufsize);
+ }
/* Write output; output is guaranteed to be 0-terminated */
if (*format == '#') {
@@ -1129,7 +1124,7 @@
} else {
if (size + 1 > BUFFER_LEN) {
Py_DECREF(s);
- PyErr_Format(PyExc_TypeError,
+ PyErr_Format(PyExc_ValueError,
"encoded string too long "
"(%zd, maximum length %zd)",
(Py_ssize_t)size, (Py_ssize_t)(BUFFER_LEN-1));
@@ -1283,7 +1278,7 @@
}
static Py_ssize_t
-convertbuffer(PyObject *arg, void **p, char **errmsg)
+convertbuffer(PyObject *arg, void **p, const char **errmsg)
{
PyBufferProcs *pb = Py_TYPE(arg)->tp_as_buffer;
Py_ssize_t count;
@@ -1305,7 +1300,7 @@
}
static int
-getbuffer(PyObject *arg, Py_buffer *view, char **errmsg)
+getbuffer(PyObject *arg, Py_buffer *view, const char **errmsg)
{
if (PyObject_GetBuffer(arg, view, PyBUF_SIMPLE) != 0) {
*errmsg = "bytes-like object";
@@ -1448,7 +1443,8 @@
const char *fname, *msg, *custom_msg, *keyword;
int min = INT_MAX;
int max = INT_MAX;
- int i, len;
+ int i, pos, len;
+ int skip = 0;
Py_ssize_t nargs, nkeywords;
PyObject *current_arg;
freelistentry_t static_entries[STATIC_FREELIST_ENTRIES];
@@ -1476,9 +1472,17 @@
custom_msg++;
}
+ /* scan kwlist and count the number of positional-only parameters */
+ for (pos = 0; kwlist[pos] && !*kwlist[pos]; pos++) {
+ }
/* scan kwlist and get greatest possible nbr of args */
- for (len=0; kwlist[len]; len++)
- continue;
+ for (len = pos; kwlist[len]; len++) {
+ if (!*kwlist[len]) {
+ PyErr_SetString(PyExc_SystemError,
+ "Empty keyword parameter name");
+ return cleanreturn(0, &freelist);
+ }
+ }
if (len > STATIC_FREELIST_ENTRIES) {
freelist.entries = PyMem_NEW(freelistentry_t, len);
@@ -1507,7 +1511,7 @@
keyword = kwlist[i];
if (*format == '|') {
if (min != INT_MAX) {
- PyErr_SetString(PyExc_RuntimeError,
+ PyErr_SetString(PyExc_SystemError,
"Invalid format string (| specified twice)");
return cleanreturn(0, &freelist);
}
@@ -1516,14 +1520,14 @@
format++;
if (max != INT_MAX) {
- PyErr_SetString(PyExc_RuntimeError,
+ PyErr_SetString(PyExc_SystemError,
"Invalid format string ($ before |)");
return cleanreturn(0, &freelist);
}
}
if (*format == '$') {
if (max != INT_MAX) {
- PyErr_SetString(PyExc_RuntimeError,
+ PyErr_SetString(PyExc_SystemError,
"Invalid format string ($ specified twice)");
return cleanreturn(0, &freelist);
}
@@ -1531,6 +1535,14 @@
max = i;
format++;
+ if (max < pos) {
+ PyErr_SetString(PyExc_SystemError,
+ "Empty parameter name after $");
+ return cleanreturn(0, &freelist);
+ }
+ if (skip) {
+ break;
+ }
if (max < nargs) {
PyErr_Format(PyExc_TypeError,
"Function takes %s %d positional arguments"
@@ -1541,66 +1553,86 @@
}
}
if (IS_END_OF_FORMAT(*format)) {
- PyErr_Format(PyExc_RuntimeError,
+ PyErr_Format(PyExc_SystemError,
"More keyword list entries (%d) than "
"format specifiers (%d)", len, i);
return cleanreturn(0, &freelist);
}
- current_arg = NULL;
- if (nkeywords) {
- current_arg = PyDict_GetItemString(keywords, keyword);
- }
- if (current_arg) {
- --nkeywords;
- if (i < nargs) {
- /* arg present in tuple and in dict */
- PyErr_Format(PyExc_TypeError,
- "Argument given by name ('%s') "
- "and position (%d)",
- keyword, i+1);
- return cleanreturn(0, &freelist);
+ if (!skip) {
+ current_arg = NULL;
+ if (nkeywords && i >= pos) {
+ current_arg = PyDict_GetItemString(keywords, keyword);
+ if (!current_arg && PyErr_Occurred()) {
+ return cleanreturn(0, &freelist);
+ }
+ }
+ if (current_arg) {
+ --nkeywords;
+ if (i < nargs) {
+ /* arg present in tuple and in dict */
+ PyErr_Format(PyExc_TypeError,
+ "Argument given by name ('%s') "
+ "and position (%d)",
+ keyword, i+1);
+ return cleanreturn(0, &freelist);
+ }
+ }
+ else if (i < nargs)
+ current_arg = PyTuple_GET_ITEM(args, i);
+
+ if (current_arg) {
+ msg = convertitem(current_arg, &format, p_va, flags,
+ levels, msgbuf, sizeof(msgbuf), &freelist);
+ if (msg) {
+ seterror(i+1, msg, levels, fname, custom_msg);
+ return cleanreturn(0, &freelist);
+ }
+ continue;
+ }
+
+ if (i < min) {
+ if (i < pos) {
+ assert (min == INT_MAX);
+ assert (max == INT_MAX);
+ skip = 1;
+ }
+ else {
+ PyErr_Format(PyExc_TypeError, "Required argument "
+ "'%s' (pos %d) not found",
+ keyword, i+1);
+ return cleanreturn(0, &freelist);
+ }
+ }
+ /* current code reports success when all required args
+ * fulfilled and no keyword args left, with no further
+ * validation. XXX Maybe skip this in debug build ?
+ */
+ if (!nkeywords && !skip) {
+ return cleanreturn(1, &freelist);
}
}
- else if (nkeywords && PyErr_Occurred())
- return cleanreturn(0, &freelist);
- else if (i < nargs)
- current_arg = PyTuple_GET_ITEM(args, i);
-
- if (current_arg) {
- msg = convertitem(current_arg, &format, p_va, flags,
- levels, msgbuf, sizeof(msgbuf), &freelist);
- if (msg) {
- seterror(i+1, msg, levels, fname, custom_msg);
- return cleanreturn(0, &freelist);
- }
- continue;
- }
-
- if (i < min) {
- PyErr_Format(PyExc_TypeError, "Required argument "
- "'%s' (pos %d) not found",
- keyword, i+1);
- return cleanreturn(0, &freelist);
- }
- /* current code reports success when all required args
- * fulfilled and no keyword args left, with no further
- * validation. XXX Maybe skip this in debug build ?
- */
- if (!nkeywords)
- return cleanreturn(1, &freelist);
/* We are into optional args, skip thru to any remaining
* keyword args */
msg = skipitem(&format, p_va, flags);
if (msg) {
- PyErr_Format(PyExc_RuntimeError, "%s: '%s'", msg,
+ PyErr_Format(PyExc_SystemError, "%s: '%s'", msg,
format);
return cleanreturn(0, &freelist);
}
}
+ if (skip) {
+ PyErr_Format(PyExc_TypeError,
+ "Function takes %s %d positional arguments"
+ " (%d given)",
+ (Py_MIN(pos, min) < i) ? "at least" : "exactly",
+ Py_MIN(pos, min), nargs);
+ return cleanreturn(0, &freelist);
+ }
+
if (!IS_END_OF_FORMAT(*format) && (*format != '|') && (*format != '$')) {
- PyErr_Format(PyExc_RuntimeError,
+ PyErr_Format(PyExc_SystemError,
"more argument specifiers than keyword list entries "
"(remaining format:'%s')", format);
return cleanreturn(0, &freelist);
@@ -1618,7 +1650,7 @@
return cleanreturn(0, &freelist);
}
for (i = 0; i < len; i++) {
- if (!PyUnicode_CompareWithASCIIString(key, kwlist[i])) {
+ if (*kwlist[i] && !PyUnicode_CompareWithASCIIString(key, kwlist[i])) {
match = 1;
break;
}
@@ -1637,7 +1669,7 @@
}
-static char *
+static const char *
skipitem(const char **p_format, va_list *p_va, int flags)
{
const char *format = *p_format;
@@ -1730,7 +1762,7 @@
case '(': /* bypass tuple, not handled at all previously */
{
- char *msg;
+ const char *msg;
for (;;) {
if (*format==')')
break;
@@ -1766,16 +1798,9 @@
PyObject **o;
va_list vargs;
-#ifdef HAVE_STDARG_PROTOTYPES
- va_start(vargs, max);
-#else
- va_start(vargs);
-#endif
-
assert(min >= 0);
assert(min <= max);
if (!PyTuple_Check(args)) {
- va_end(vargs);
PyErr_SetString(PyExc_SystemError,
"PyArg_UnpackTuple() argument list is not a tuple");
return 0;
@@ -1793,9 +1818,10 @@
"unpacked tuple should have %s%zd elements,"
" but has %zd",
(min == max ? "" : "at least "), min, l);
- va_end(vargs);
return 0;
}
+ if (l == 0)
+ return 1;
if (l > max) {
if (name != NULL)
PyErr_Format(
@@ -1808,9 +1834,14 @@
"unpacked tuple should have %s%zd elements,"
" but has %zd",
(min == max ? "" : "at most "), max, l);
- va_end(vargs);
return 0;
}
+
+#ifdef HAVE_STDARG_PROTOTYPES
+ va_start(vargs, max);
+#else
+ va_start(vargs);
+#endif
for (i = 0; i < l; i++) {
o = va_arg(vargs, PyObject **);
*o = PyTuple_GET_ITEM(args, i);
diff --git a/Python/graminit.c b/Python/graminit.c
index 8212b2a..354dc12 100644
--- a/Python/graminit.c
+++ b/Python/graminit.c
@@ -204,11 +204,13 @@
{32, 7},
{0, 6},
};
-static arc arcs_9_7[2] = {
+static arc arcs_9_7[3] = {
{30, 12},
{34, 3},
+ {0, 7},
};
-static arc arcs_9_8[1] = {
+static arc arcs_9_8[2] = {
+ {32, 13},
{0, 8},
};
static arc arcs_9_9[2] = {
@@ -221,35 +223,39 @@
{0, 10},
};
static arc arcs_9_11[3] = {
- {30, 13},
- {32, 14},
+ {30, 14},
+ {32, 15},
{0, 11},
};
static arc arcs_9_12[3] = {
{32, 7},
- {31, 15},
+ {31, 16},
{0, 12},
};
-static arc arcs_9_13[2] = {
- {32, 14},
+static arc arcs_9_13[1] = {
{0, 13},
};
static arc arcs_9_14[2] = {
- {30, 16},
- {34, 3},
+ {32, 15},
+ {0, 14},
};
-static arc arcs_9_15[1] = {
+static arc arcs_9_15[3] = {
+ {30, 17},
+ {34, 3},
+ {0, 15},
+};
+static arc arcs_9_16[1] = {
{26, 6},
};
-static arc arcs_9_16[3] = {
- {32, 14},
- {31, 17},
- {0, 16},
+static arc arcs_9_17[3] = {
+ {32, 15},
+ {31, 18},
+ {0, 17},
};
-static arc arcs_9_17[1] = {
- {26, 13},
+static arc arcs_9_18[1] = {
+ {26, 14},
};
-static state states_9[18] = {
+static state states_9[19] = {
{3, arcs_9_0},
{3, arcs_9_1},
{3, arcs_9_2},
@@ -257,17 +263,18 @@
{1, arcs_9_4},
{4, arcs_9_5},
{2, arcs_9_6},
- {2, arcs_9_7},
- {1, arcs_9_8},
+ {3, arcs_9_7},
+ {2, arcs_9_8},
{2, arcs_9_9},
{3, arcs_9_10},
{3, arcs_9_11},
{3, arcs_9_12},
- {2, arcs_9_13},
+ {1, arcs_9_13},
{2, arcs_9_14},
- {1, arcs_9_15},
- {3, arcs_9_16},
- {1, arcs_9_17},
+ {3, arcs_9_15},
+ {1, arcs_9_16},
+ {3, arcs_9_17},
+ {1, arcs_9_18},
};
static arc arcs_10_0[1] = {
{23, 1},
@@ -319,11 +326,13 @@
{32, 7},
{0, 6},
};
-static arc arcs_11_7[2] = {
+static arc arcs_11_7[3] = {
{36, 12},
{34, 3},
+ {0, 7},
};
-static arc arcs_11_8[1] = {
+static arc arcs_11_8[2] = {
+ {32, 13},
{0, 8},
};
static arc arcs_11_9[2] = {
@@ -336,35 +345,39 @@
{0, 10},
};
static arc arcs_11_11[3] = {
- {36, 13},
- {32, 14},
+ {36, 14},
+ {32, 15},
{0, 11},
};
static arc arcs_11_12[3] = {
{32, 7},
- {31, 15},
+ {31, 16},
{0, 12},
};
-static arc arcs_11_13[2] = {
- {32, 14},
+static arc arcs_11_13[1] = {
{0, 13},
};
static arc arcs_11_14[2] = {
- {36, 16},
- {34, 3},
+ {32, 15},
+ {0, 14},
};
-static arc arcs_11_15[1] = {
+static arc arcs_11_15[3] = {
+ {36, 17},
+ {34, 3},
+ {0, 15},
+};
+static arc arcs_11_16[1] = {
{26, 6},
};
-static arc arcs_11_16[3] = {
- {32, 14},
- {31, 17},
- {0, 16},
+static arc arcs_11_17[3] = {
+ {32, 15},
+ {31, 18},
+ {0, 17},
};
-static arc arcs_11_17[1] = {
- {26, 13},
+static arc arcs_11_18[1] = {
+ {26, 14},
};
-static state states_11[18] = {
+static state states_11[19] = {
{3, arcs_11_0},
{3, arcs_11_1},
{3, arcs_11_2},
@@ -372,17 +385,18 @@
{1, arcs_11_4},
{4, arcs_11_5},
{2, arcs_11_6},
- {2, arcs_11_7},
- {1, arcs_11_8},
+ {3, arcs_11_7},
+ {2, arcs_11_8},
{2, arcs_11_9},
{3, arcs_11_10},
{3, arcs_11_11},
{3, arcs_11_12},
- {2, arcs_11_13},
+ {1, arcs_11_13},
{2, arcs_11_14},
- {1, arcs_11_15},
- {3, arcs_11_16},
- {1, arcs_11_17},
+ {3, arcs_11_15},
+ {1, arcs_11_16},
+ {3, arcs_11_17},
+ {1, arcs_11_18},
};
static arc arcs_12_0[1] = {
{23, 1},
@@ -1879,11 +1893,11 @@
"\000\000\100\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
{264, "parameters", 0, 4, states_8,
"\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
- {265, "typedargslist", 0, 18, states_9,
+ {265, "typedargslist", 0, 19, states_9,
"\000\000\200\000\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
{266, "tfpdef", 0, 4, states_10,
"\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
- {267, "varargslist", 0, 18, states_11,
+ {267, "varargslist", 0, 19, states_11,
"\000\000\200\000\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
{268, "vfpdef", 0, 2, states_12,
"\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
diff --git a/Python/import.c b/Python/import.c
index 0b843da..d4c358f 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -38,14 +38,6 @@
#include "clinic/import.c.h"
-/*[python input]
-class fs_unicode_converter(CConverter):
- type = 'PyObject *'
- converter = 'PyUnicode_FSDecoder'
-
-[python start generated code]*/
-/*[python end generated code: output=da39a3ee5e6b4b0d input=9d6786230166006e]*/
-
/* Initialize things */
void
@@ -320,7 +312,7 @@
/* List of names to clear in sys */
-static char* sys_deletes[] = {
+static const char * const sys_deletes[] = {
"path", "argv", "ps1", "ps2",
"last_type", "last_value", "last_traceback",
"path_hooks", "path_importer_cache", "meta_path",
@@ -330,7 +322,7 @@
NULL
};
-static char* sys_files[] = {
+static const char * const sys_files[] = {
"stdin", "__stdin__",
"stdout", "__stdout__",
"stderr", "__stderr__",
@@ -347,7 +339,7 @@
PyInterpreterState *interp = PyThreadState_GET()->interp;
PyObject *modules = interp->modules;
PyObject *weaklist = NULL;
- char **p;
+ const char * const *p;
if (modules == NULL)
return; /* Already done */
@@ -883,10 +875,8 @@
if (PyUnicode_Compare(co->co_filename, oldname))
return;
- tmp = co->co_filename;
- co->co_filename = newname;
- Py_INCREF(co->co_filename);
- Py_DECREF(tmp);
+ Py_INCREF(newname);
+ Py_XSETREF(co->co_filename, newname);
constants = co->co_consts;
n = PyTuple_GET_SIZE(constants);
@@ -1331,10 +1321,8 @@
(always_trim ||
PyUnicode_CompareWithASCIIString(code->co_name,
remove_frames) == 0)) {
- PyObject *tmp = *outer_link;
- *outer_link = next;
Py_XINCREF(next);
- Py_DECREF(tmp);
+ Py_XSETREF(*outer_link, next);
prev_link = outer_link;
}
else {
@@ -1361,12 +1349,12 @@
_Py_IDENTIFIER(_find_and_load);
_Py_IDENTIFIER(_handle_fromlist);
_Py_IDENTIFIER(_lock_unlock_module);
- _Py_static_string(single_dot, ".");
PyObject *abs_name = NULL;
PyObject *builtins_import = NULL;
PyObject *final_mod = NULL;
PyObject *mod = NULL;
PyObject *package = NULL;
+ PyObject *spec = NULL;
PyObject *globals = NULL;
PyObject *fromlist = NULL;
PyInterpreterState *interp = PyThreadState_GET()->interp;
@@ -1423,42 +1411,93 @@
}
else if (level > 0) {
package = _PyDict_GetItemId(globals, &PyId___package__);
+ spec = _PyDict_GetItemId(globals, &PyId___spec__);
+
if (package != NULL && package != Py_None) {
Py_INCREF(package);
if (!PyUnicode_Check(package)) {
PyErr_SetString(PyExc_TypeError, "package must be a string");
goto error;
}
+ else if (spec != NULL && spec != Py_None) {
+ int equal;
+ PyObject *parent = PyObject_GetAttrString(spec, "parent");
+ if (parent == NULL) {
+ goto error;
+ }
+
+ equal = PyObject_RichCompareBool(package, parent, Py_EQ);
+ Py_DECREF(parent);
+ if (equal < 0) {
+ goto error;
+ }
+ else if (equal == 0) {
+ if (PyErr_WarnEx(PyExc_ImportWarning,
+ "__package__ != __spec__.parent", 1) < 0) {
+ goto error;
+ }
+ }
+ }
+ }
+ else if (spec != NULL && spec != Py_None) {
+ package = PyObject_GetAttrString(spec, "parent");
+ if (package == NULL) {
+ goto error;
+ }
+ else if (!PyUnicode_Check(package)) {
+ PyErr_SetString(PyExc_TypeError,
+ "__spec__.parent must be a string");
+ goto error;
+ }
}
else {
+ if (PyErr_WarnEx(PyExc_ImportWarning,
+ "can't resolve package from __spec__ or __package__, "
+ "falling back on __name__ and __path__", 1) < 0) {
+ goto error;
+ }
+
package = _PyDict_GetItemId(globals, &PyId___name__);
if (package == NULL) {
PyErr_SetString(PyExc_KeyError, "'__name__' not in globals");
goto error;
}
- else if (!PyUnicode_Check(package)) {
- PyErr_SetString(PyExc_TypeError, "__name__ must be a string");
- }
+
Py_INCREF(package);
+ if (!PyUnicode_Check(package)) {
+ PyErr_SetString(PyExc_TypeError, "__name__ must be a string");
+ goto error;
+ }
if (_PyDict_GetItemId(globals, &PyId___path__) == NULL) {
- PyObject *partition = NULL;
- PyObject *borrowed_dot = _PyUnicode_FromId(&single_dot);
- if (borrowed_dot == NULL) {
+ Py_ssize_t dot;
+
+ if (PyUnicode_READY(package) < 0) {
goto error;
}
- partition = PyUnicode_RPartition(package, borrowed_dot);
- Py_DECREF(package);
- if (partition == NULL) {
+
+ dot = PyUnicode_FindChar(package, '.',
+ 0, PyUnicode_GET_LENGTH(package), -1);
+ if (dot == -2) {
goto error;
}
- package = PyTuple_GET_ITEM(partition, 0);
- Py_INCREF(package);
- Py_DECREF(partition);
+
+ if (dot >= 0) {
+ PyObject *substr = PyUnicode_Substring(package, 0, dot);
+ if (substr == NULL) {
+ goto error;
+ }
+ Py_SETREF(package, substr);
+ }
}
}
- if (PyDict_GetItem(interp->modules, package) == NULL) {
+ if (PyUnicode_CompareWithASCIIString(package, "") == 0) {
+ PyErr_SetString(PyExc_ImportError,
+ "attempted relative import with no known parent package");
+ goto error;
+ }
+ else if (PyDict_GetItem(interp->modules, package) == NULL) {
PyErr_Format(PyExc_SystemError,
"Parent module %R not loaded, cannot perform relative "
"import", package);
@@ -1497,17 +1536,8 @@
goto error;
if (PyUnicode_GET_LENGTH(name) > 0) {
- PyObject *borrowed_dot, *seq = NULL;
-
- borrowed_dot = _PyUnicode_FromId(&single_dot);
- seq = PyTuple_Pack(2, base, name);
+ abs_name = PyUnicode_FromFormat("%U.%U", base, name);
Py_DECREF(base);
- if (borrowed_dot == NULL || seq == NULL) {
- goto error;
- }
-
- abs_name = PyUnicode_Join(borrowed_dot, seq);
- Py_DECREF(seq);
if (abs_name == NULL) {
goto error;
}
@@ -1605,43 +1635,36 @@
if (has_from < 0)
goto error;
if (!has_from) {
- if (level == 0 || PyUnicode_GET_LENGTH(name) > 0) {
- PyObject *front = NULL;
- PyObject *partition = NULL;
- PyObject *borrowed_dot = _PyUnicode_FromId(&single_dot);
+ Py_ssize_t len = PyUnicode_GET_LENGTH(name);
+ if (level == 0 || len > 0) {
+ Py_ssize_t dot;
- if (borrowed_dot == NULL) {
+ dot = PyUnicode_FindChar(name, '.', 0, len, 1);
+ if (dot == -2) {
goto error;
}
- partition = PyUnicode_Partition(name, borrowed_dot);
- if (partition == NULL) {
- goto error;
- }
-
- if (PyUnicode_GET_LENGTH(PyTuple_GET_ITEM(partition, 1)) == 0) {
+ if (dot == -1) {
/* No dot in module name, simple exit */
- Py_DECREF(partition);
final_mod = mod;
Py_INCREF(mod);
goto error;
}
- front = PyTuple_GET_ITEM(partition, 0);
- Py_INCREF(front);
- Py_DECREF(partition);
-
if (level == 0) {
+ PyObject *front = PyUnicode_Substring(name, 0, dot);
+ if (front == NULL) {
+ goto error;
+ }
+
final_mod = PyObject_CallFunctionObjArgs(builtins_import, front, NULL);
Py_DECREF(front);
}
else {
- Py_ssize_t cut_off = PyUnicode_GET_LENGTH(name) -
- PyUnicode_GET_LENGTH(front);
+ Py_ssize_t cut_off = len - dot;
Py_ssize_t abs_name_len = PyUnicode_GET_LENGTH(abs_name);
PyObject *to_return = PyUnicode_Substring(abs_name, 0,
abs_name_len - cut_off);
- Py_DECREF(front);
if (to_return == NULL) {
goto error;
}
diff --git a/Python/importdl.c b/Python/importdl.c
index 1aa585d..ac03289 100644
--- a/Python/importdl.c
+++ b/Python/importdl.c
@@ -23,8 +23,8 @@
const char *pathname, FILE *fp);
#endif
-static const char *ascii_only_prefix = "PyInit";
-static const char *nonascii_prefix = "PyInitU";
+static const char * const ascii_only_prefix = "PyInit";
+static const char * const nonascii_prefix = "PyInitU";
/* Get the variable part of a module's export symbol name.
* Returns a bytes instance. For non-ASCII-named modules, the name is
diff --git a/Python/importlib.h b/Python/importlib.h
index 7f6b753..e3364b3 100644
--- a/Python/importlib.h
+++ b/Python/importlib.h
@@ -1,171 +1,154 @@
/* Auto-generated by Programs/_freeze_importlib.c */
const unsigned char _Py_M__importlib[] = {
- 99,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,
- 0,64,0,0,0,115,169,2,0,0,100,0,0,90,0,0,
- 100,1,0,97,1,0,100,2,0,100,3,0,132,0,0,90,
- 2,0,100,4,0,100,5,0,132,0,0,90,3,0,71,100,
- 6,0,100,7,0,132,0,0,100,7,0,131,2,0,90,4,
- 0,105,0,0,90,5,0,105,0,0,90,6,0,71,100,8,
- 0,100,9,0,132,0,0,100,9,0,101,7,0,131,3,0,
- 90,8,0,71,100,10,0,100,11,0,132,0,0,100,11,0,
- 131,2,0,90,9,0,71,100,12,0,100,13,0,132,0,0,
- 100,13,0,131,2,0,90,10,0,71,100,14,0,100,15,0,
- 132,0,0,100,15,0,131,2,0,90,11,0,100,16,0,100,
- 17,0,132,0,0,90,12,0,100,18,0,100,19,0,132,0,
- 0,90,13,0,100,20,0,100,21,0,132,0,0,90,14,0,
- 100,22,0,100,23,0,100,24,0,100,25,0,132,0,1,90,
- 15,0,100,26,0,100,27,0,132,0,0,90,16,0,100,28,
- 0,100,29,0,132,0,0,90,17,0,100,30,0,100,31,0,
- 132,0,0,90,18,0,100,32,0,100,33,0,132,0,0,90,
- 19,0,71,100,34,0,100,35,0,132,0,0,100,35,0,131,
- 2,0,90,20,0,71,100,36,0,100,37,0,132,0,0,100,
- 37,0,131,2,0,90,21,0,100,38,0,100,1,0,100,39,
- 0,100,1,0,100,40,0,100,41,0,132,0,2,90,22,0,
- 101,23,0,131,0,0,90,24,0,100,1,0,100,1,0,100,
- 42,0,100,43,0,132,2,0,90,25,0,100,44,0,100,45,
- 0,100,46,0,100,47,0,132,0,1,90,26,0,100,48,0,
- 100,49,0,132,0,0,90,27,0,100,50,0,100,51,0,132,
- 0,0,90,28,0,100,52,0,100,53,0,132,0,0,90,29,
- 0,100,54,0,100,55,0,132,0,0,90,30,0,100,56,0,
- 100,57,0,132,0,0,90,31,0,100,58,0,100,59,0,132,
- 0,0,90,32,0,71,100,60,0,100,61,0,132,0,0,100,
- 61,0,131,2,0,90,33,0,71,100,62,0,100,63,0,132,
- 0,0,100,63,0,131,2,0,90,34,0,71,100,64,0,100,
- 65,0,132,0,0,100,65,0,131,2,0,90,35,0,100,66,
- 0,100,67,0,132,0,0,90,36,0,100,68,0,100,69,0,
- 132,0,0,90,37,0,100,1,0,100,70,0,100,71,0,132,
- 1,0,90,38,0,100,72,0,100,73,0,132,0,0,90,39,
- 0,100,74,0,90,40,0,101,40,0,100,75,0,23,90,41,
- 0,100,76,0,100,77,0,132,0,0,90,42,0,100,78,0,
- 100,79,0,132,0,0,90,43,0,100,1,0,100,80,0,100,
- 81,0,100,82,0,132,2,0,90,44,0,100,83,0,100,84,
- 0,132,0,0,90,45,0,100,85,0,100,86,0,132,0,0,
- 90,46,0,100,1,0,100,1,0,102,0,0,100,80,0,100,
- 87,0,100,88,0,132,4,0,90,47,0,100,89,0,100,90,
- 0,132,0,0,90,48,0,100,91,0,100,92,0,132,0,0,
- 90,49,0,100,93,0,100,94,0,132,0,0,90,50,0,100,
- 1,0,83,41,95,97,83,1,0,0,67,111,114,101,32,105,
- 109,112,108,101,109,101,110,116,97,116,105,111,110,32,111,102,
- 32,105,109,112,111,114,116,46,10,10,84,104,105,115,32,109,
- 111,100,117,108,101,32,105,115,32,78,79,84,32,109,101,97,
- 110,116,32,116,111,32,98,101,32,100,105,114,101,99,116,108,
- 121,32,105,109,112,111,114,116,101,100,33,32,73,116,32,104,
- 97,115,32,98,101,101,110,32,100,101,115,105,103,110,101,100,
- 32,115,117,99,104,10,116,104,97,116,32,105,116,32,99,97,
- 110,32,98,101,32,98,111,111,116,115,116,114,97,112,112,101,
- 100,32,105,110,116,111,32,80,121,116,104,111,110,32,97,115,
- 32,116,104,101,32,105,109,112,108,101,109,101,110,116,97,116,
- 105,111,110,32,111,102,32,105,109,112,111,114,116,46,32,65,
- 115,10,115,117,99,104,32,105,116,32,114,101,113,117,105,114,
- 101,115,32,116,104,101,32,105,110,106,101,99,116,105,111,110,
- 32,111,102,32,115,112,101,99,105,102,105,99,32,109,111,100,
- 117,108,101,115,32,97,110,100,32,97,116,116,114,105,98,117,
- 116,101,115,32,105,110,32,111,114,100,101,114,32,116,111,10,
- 119,111,114,107,46,32,79,110,101,32,115,104,111,117,108,100,
- 32,117,115,101,32,105,109,112,111,114,116,108,105,98,32,97,
- 115,32,116,104,101,32,112,117,98,108,105,99,45,102,97,99,
- 105,110,103,32,118,101,114,115,105,111,110,32,111,102,32,116,
- 104,105,115,32,109,111,100,117,108,101,46,10,10,78,99,2,
- 0,0,0,0,0,0,0,3,0,0,0,7,0,0,0,67,
- 0,0,0,115,92,0,0,0,120,66,0,100,1,0,100,2,
- 0,100,3,0,100,4,0,103,4,0,68,93,46,0,125,2,
- 0,116,0,0,124,1,0,124,2,0,131,2,0,114,19,0,
- 116,1,0,124,0,0,124,2,0,116,2,0,124,1,0,124,
- 2,0,131,2,0,131,3,0,1,113,19,0,87,124,0,0,
- 106,3,0,106,4,0,124,1,0,106,3,0,131,1,0,1,
- 100,5,0,83,41,6,122,47,83,105,109,112,108,101,32,115,
- 117,98,115,116,105,116,117,116,101,32,102,111,114,32,102,117,
- 110,99,116,111,111,108,115,46,117,112,100,97,116,101,95,119,
- 114,97,112,112,101,114,46,218,10,95,95,109,111,100,117,108,
- 101,95,95,218,8,95,95,110,97,109,101,95,95,218,12,95,
- 95,113,117,97,108,110,97,109,101,95,95,218,7,95,95,100,
- 111,99,95,95,78,41,5,218,7,104,97,115,97,116,116,114,
- 218,7,115,101,116,97,116,116,114,218,7,103,101,116,97,116,
- 116,114,218,8,95,95,100,105,99,116,95,95,218,6,117,112,
- 100,97,116,101,41,3,90,3,110,101,119,90,3,111,108,100,
- 218,7,114,101,112,108,97,99,101,169,0,114,10,0,0,0,
- 250,29,60,102,114,111,122,101,110,32,105,109,112,111,114,116,
- 108,105,98,46,95,98,111,111,116,115,116,114,97,112,62,218,
- 5,95,119,114,97,112,27,0,0,0,115,8,0,0,0,0,
- 2,25,1,15,1,29,1,114,12,0,0,0,99,1,0,0,
- 0,0,0,0,0,1,0,0,0,2,0,0,0,67,0,0,
- 0,115,16,0,0,0,116,0,0,116,1,0,131,1,0,124,
- 0,0,131,1,0,83,41,1,78,41,2,218,4,116,121,112,
- 101,218,3,115,121,115,41,1,218,4,110,97,109,101,114,10,
- 0,0,0,114,10,0,0,0,114,11,0,0,0,218,11,95,
- 110,101,119,95,109,111,100,117,108,101,35,0,0,0,115,2,
- 0,0,0,0,1,114,16,0,0,0,99,0,0,0,0,0,
- 0,0,0,0,0,0,0,2,0,0,0,64,0,0,0,115,
- 58,0,0,0,101,0,0,90,1,0,100,0,0,90,2,0,
- 100,1,0,90,3,0,100,2,0,100,3,0,132,0,0,90,
- 4,0,100,4,0,100,5,0,132,0,0,90,5,0,100,6,
- 0,100,7,0,132,0,0,90,6,0,100,8,0,83,41,9,
- 218,13,95,77,97,110,97,103,101,82,101,108,111,97,100,122,
- 63,77,97,110,97,103,101,115,32,116,104,101,32,112,111,115,
- 115,105,98,108,101,32,99,108,101,97,110,45,117,112,32,111,
- 102,32,115,121,115,46,109,111,100,117,108,101,115,32,102,111,
- 114,32,108,111,97,100,95,109,111,100,117,108,101,40,41,46,
- 99,2,0,0,0,0,0,0,0,2,0,0,0,2,0,0,
- 0,67,0,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,218,5,95,110,
- 97,109,101,41,2,218,4,115,101,108,102,114,15,0,0,0,
- 114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,218,
- 8,95,95,105,110,105,116,95,95,43,0,0,0,115,2,0,
- 0,0,0,1,122,22,95,77,97,110,97,103,101,82,101,108,
- 111,97,100,46,95,95,105,110,105,116,95,95,99,1,0,0,
- 0,0,0,0,0,1,0,0,0,2,0,0,0,67,0,0,
- 0,115,25,0,0,0,124,0,0,106,0,0,116,1,0,106,
- 2,0,107,6,0,124,0,0,95,3,0,100,0,0,83,41,
- 1,78,41,4,114,18,0,0,0,114,14,0,0,0,218,7,
- 109,111,100,117,108,101,115,218,10,95,105,115,95,114,101,108,
- 111,97,100,41,1,114,19,0,0,0,114,10,0,0,0,114,
- 10,0,0,0,114,11,0,0,0,218,9,95,95,101,110,116,
- 101,114,95,95,46,0,0,0,115,2,0,0,0,0,1,122,
- 23,95,77,97,110,97,103,101,82,101,108,111,97,100,46,95,
- 95,101,110,116,101,114,95,95,99,1,0,0,0,0,0,0,
- 0,2,0,0,0,11,0,0,0,71,0,0,0,115,77,0,
- 0,0,116,0,0,100,1,0,100,2,0,132,0,0,124,1,
- 0,68,131,1,0,131,1,0,114,73,0,124,0,0,106,1,
- 0,12,114,73,0,121,17,0,116,2,0,106,3,0,124,0,
- 0,106,4,0,61,87,110,18,0,4,116,5,0,107,10,0,
- 114,72,0,1,1,1,89,110,1,0,88,100,0,0,83,41,
- 3,78,99,1,0,0,0,0,0,0,0,2,0,0,0,3,
- 0,0,0,115,0,0,0,115,27,0,0,0,124,0,0,93,
- 17,0,125,1,0,124,1,0,100,0,0,107,9,0,86,1,
- 113,3,0,100,0,0,83,41,1,78,114,10,0,0,0,41,
- 2,218,2,46,48,218,3,97,114,103,114,10,0,0,0,114,
- 10,0,0,0,114,11,0,0,0,250,9,60,103,101,110,101,
- 120,112,114,62,50,0,0,0,115,2,0,0,0,6,0,122,
- 41,95,77,97,110,97,103,101,82,101,108,111,97,100,46,95,
- 95,101,120,105,116,95,95,46,60,108,111,99,97,108,115,62,
- 46,60,103,101,110,101,120,112,114,62,41,6,218,3,97,110,
- 121,114,22,0,0,0,114,14,0,0,0,114,21,0,0,0,
- 114,18,0,0,0,218,8,75,101,121,69,114,114,111,114,41,
- 2,114,19,0,0,0,218,4,97,114,103,115,114,10,0,0,
- 0,114,10,0,0,0,114,11,0,0,0,218,8,95,95,101,
- 120,105,116,95,95,49,0,0,0,115,10,0,0,0,0,1,
- 35,1,3,1,17,1,13,1,122,22,95,77,97,110,97,103,
- 101,82,101,108,111,97,100,46,95,95,101,120,105,116,95,95,
- 78,41,7,114,1,0,0,0,114,0,0,0,0,114,2,0,
- 0,0,114,3,0,0,0,114,20,0,0,0,114,23,0,0,
- 0,114,30,0,0,0,114,10,0,0,0,114,10,0,0,0,
- 114,10,0,0,0,114,11,0,0,0,114,17,0,0,0,39,
- 0,0,0,115,8,0,0,0,12,2,6,2,12,3,12,3,
- 114,17,0,0,0,99,0,0,0,0,0,0,0,0,0,0,
- 0,0,1,0,0,0,64,0,0,0,115,16,0,0,0,101,
- 0,0,90,1,0,100,0,0,90,2,0,100,1,0,83,41,
- 2,218,14,95,68,101,97,100,108,111,99,107,69,114,114,111,
- 114,78,41,3,114,1,0,0,0,114,0,0,0,0,114,2,
- 0,0,0,114,10,0,0,0,114,10,0,0,0,114,10,0,
- 0,0,114,11,0,0,0,114,31,0,0,0,64,0,0,0,
- 115,2,0,0,0,12,1,114,31,0,0,0,99,0,0,0,
- 0,0,0,0,0,0,0,0,0,2,0,0,0,64,0,0,
- 0,115,82,0,0,0,101,0,0,90,1,0,100,0,0,90,
- 2,0,100,1,0,90,3,0,100,2,0,100,3,0,132,0,
- 0,90,4,0,100,4,0,100,5,0,132,0,0,90,5,0,
- 100,6,0,100,7,0,132,0,0,90,6,0,100,8,0,100,
- 9,0,132,0,0,90,7,0,100,10,0,100,11,0,132,0,
- 0,90,8,0,100,12,0,83,41,13,218,11,95,77,111,100,
+ 99,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,
+ 0,64,0,0,0,115,216,1,0,0,100,0,90,0,100,1,
+ 97,1,100,2,100,3,132,0,90,2,100,4,100,5,132,0,
+ 90,3,71,0,100,6,100,7,132,0,100,7,131,2,90,4,
+ 105,0,90,5,105,0,90,6,71,0,100,8,100,9,132,0,
+ 100,9,101,7,131,3,90,8,71,0,100,10,100,11,132,0,
+ 100,11,131,2,90,9,71,0,100,12,100,13,132,0,100,13,
+ 131,2,90,10,71,0,100,14,100,15,132,0,100,15,131,2,
+ 90,11,100,16,100,17,132,0,90,12,100,18,100,19,132,0,
+ 90,13,100,20,100,21,132,0,90,14,100,22,100,23,156,1,
+ 100,24,100,25,132,2,90,15,100,26,100,27,132,0,90,16,
+ 100,28,100,29,132,0,90,17,100,30,100,31,132,0,90,18,
+ 100,32,100,33,132,0,90,19,71,0,100,34,100,35,132,0,
+ 100,35,131,2,90,20,71,0,100,36,100,37,132,0,100,37,
+ 131,2,90,21,100,1,100,1,100,38,156,2,100,39,100,40,
+ 132,2,90,22,101,23,131,0,90,24,100,94,100,41,100,42,
+ 132,1,90,25,100,43,100,44,156,1,100,45,100,46,132,2,
+ 90,26,100,47,100,48,132,0,90,27,100,49,100,50,132,0,
+ 90,28,100,51,100,52,132,0,90,29,100,53,100,54,132,0,
+ 90,30,100,55,100,56,132,0,90,31,100,57,100,58,132,0,
+ 90,32,71,0,100,59,100,60,132,0,100,60,131,2,90,33,
+ 71,0,100,61,100,62,132,0,100,62,131,2,90,34,71,0,
+ 100,63,100,64,132,0,100,64,131,2,90,35,100,65,100,66,
+ 132,0,90,36,100,67,100,68,132,0,90,37,100,95,100,69,
+ 100,70,132,1,90,38,100,71,100,72,132,0,90,39,100,73,
+ 90,40,101,40,100,74,23,0,90,41,100,75,100,76,132,0,
+ 90,42,100,77,100,78,132,0,90,43,100,96,100,80,100,81,
+ 132,1,90,44,100,82,100,83,132,0,90,45,100,84,100,85,
+ 132,0,90,46,100,1,100,1,102,0,100,79,102,4,100,86,
+ 100,87,132,1,90,47,100,88,100,89,132,0,90,48,100,90,
+ 100,91,132,0,90,49,100,92,100,93,132,0,90,50,100,1,
+ 83,0,41,97,97,83,1,0,0,67,111,114,101,32,105,109,
+ 112,108,101,109,101,110,116,97,116,105,111,110,32,111,102,32,
+ 105,109,112,111,114,116,46,10,10,84,104,105,115,32,109,111,
+ 100,117,108,101,32,105,115,32,78,79,84,32,109,101,97,110,
+ 116,32,116,111,32,98,101,32,100,105,114,101,99,116,108,121,
+ 32,105,109,112,111,114,116,101,100,33,32,73,116,32,104,97,
+ 115,32,98,101,101,110,32,100,101,115,105,103,110,101,100,32,
+ 115,117,99,104,10,116,104,97,116,32,105,116,32,99,97,110,
+ 32,98,101,32,98,111,111,116,115,116,114,97,112,112,101,100,
+ 32,105,110,116,111,32,80,121,116,104,111,110,32,97,115,32,
+ 116,104,101,32,105,109,112,108,101,109,101,110,116,97,116,105,
+ 111,110,32,111,102,32,105,109,112,111,114,116,46,32,65,115,
+ 10,115,117,99,104,32,105,116,32,114,101,113,117,105,114,101,
+ 115,32,116,104,101,32,105,110,106,101,99,116,105,111,110,32,
+ 111,102,32,115,112,101,99,105,102,105,99,32,109,111,100,117,
+ 108,101,115,32,97,110,100,32,97,116,116,114,105,98,117,116,
+ 101,115,32,105,110,32,111,114,100,101,114,32,116,111,10,119,
+ 111,114,107,46,32,79,110,101,32,115,104,111,117,108,100,32,
+ 117,115,101,32,105,109,112,111,114,116,108,105,98,32,97,115,
+ 32,116,104,101,32,112,117,98,108,105,99,45,102,97,99,105,
+ 110,103,32,118,101,114,115,105,111,110,32,111,102,32,116,104,
+ 105,115,32,109,111,100,117,108,101,46,10,10,78,99,2,0,
+ 0,0,0,0,0,0,3,0,0,0,7,0,0,0,67,0,
+ 0,0,115,60,0,0,0,120,40,100,6,68,0,93,32,125,
+ 2,116,0,124,1,124,2,131,2,114,6,116,1,124,0,124,
+ 2,116,2,124,1,124,2,131,2,131,3,1,0,113,6,87,
+ 0,124,0,106,3,106,4,124,1,106,3,131,1,1,0,100,
+ 5,83,0,41,7,122,47,83,105,109,112,108,101,32,115,117,
+ 98,115,116,105,116,117,116,101,32,102,111,114,32,102,117,110,
+ 99,116,111,111,108,115,46,117,112,100,97,116,101,95,119,114,
+ 97,112,112,101,114,46,218,10,95,95,109,111,100,117,108,101,
+ 95,95,218,8,95,95,110,97,109,101,95,95,218,12,95,95,
+ 113,117,97,108,110,97,109,101,95,95,218,7,95,95,100,111,
+ 99,95,95,78,41,4,122,10,95,95,109,111,100,117,108,101,
+ 95,95,122,8,95,95,110,97,109,101,95,95,122,12,95,95,
+ 113,117,97,108,110,97,109,101,95,95,122,7,95,95,100,111,
+ 99,95,95,41,5,218,7,104,97,115,97,116,116,114,218,7,
+ 115,101,116,97,116,116,114,218,7,103,101,116,97,116,116,114,
+ 218,8,95,95,100,105,99,116,95,95,218,6,117,112,100,97,
+ 116,101,41,3,90,3,110,101,119,90,3,111,108,100,218,7,
+ 114,101,112,108,97,99,101,169,0,114,10,0,0,0,250,29,
+ 60,102,114,111,122,101,110,32,105,109,112,111,114,116,108,105,
+ 98,46,95,98,111,111,116,115,116,114,97,112,62,218,5,95,
+ 119,114,97,112,27,0,0,0,115,8,0,0,0,0,2,10,
+ 1,10,1,22,1,114,12,0,0,0,99,1,0,0,0,0,
+ 0,0,0,1,0,0,0,2,0,0,0,67,0,0,0,115,
+ 12,0,0,0,116,0,116,1,131,1,124,0,131,1,83,0,
+ 41,1,78,41,2,218,4,116,121,112,101,218,3,115,121,115,
+ 41,1,218,4,110,97,109,101,114,10,0,0,0,114,10,0,
+ 0,0,114,11,0,0,0,218,11,95,110,101,119,95,109,111,
+ 100,117,108,101,35,0,0,0,115,2,0,0,0,0,1,114,
+ 16,0,0,0,99,0,0,0,0,0,0,0,0,0,0,0,
+ 0,2,0,0,0,64,0,0,0,115,40,0,0,0,101,0,
+ 90,1,100,0,90,2,100,1,90,3,100,2,100,3,132,0,
+ 90,4,100,4,100,5,132,0,90,5,100,6,100,7,132,0,
+ 90,6,100,8,83,0,41,9,218,13,95,77,97,110,97,103,
+ 101,82,101,108,111,97,100,122,63,77,97,110,97,103,101,115,
+ 32,116,104,101,32,112,111,115,115,105,98,108,101,32,99,108,
+ 101,97,110,45,117,112,32,111,102,32,115,121,115,46,109,111,
+ 100,117,108,101,115,32,102,111,114,32,108,111,97,100,95,109,
+ 111,100,117,108,101,40,41,46,99,2,0,0,0,0,0,0,
+ 0,2,0,0,0,2,0,0,0,67,0,0,0,115,10,0,
+ 0,0,124,1,124,0,95,0,100,0,83,0,41,1,78,41,
+ 1,218,5,95,110,97,109,101,41,2,218,4,115,101,108,102,
+ 114,15,0,0,0,114,10,0,0,0,114,10,0,0,0,114,
+ 11,0,0,0,218,8,95,95,105,110,105,116,95,95,43,0,
+ 0,0,115,2,0,0,0,0,1,122,22,95,77,97,110,97,
+ 103,101,82,101,108,111,97,100,46,95,95,105,110,105,116,95,
+ 95,99,1,0,0,0,0,0,0,0,1,0,0,0,2,0,
+ 0,0,67,0,0,0,115,18,0,0,0,124,0,106,0,116,
+ 1,106,2,107,6,124,0,95,3,100,0,83,0,41,1,78,
+ 41,4,114,18,0,0,0,114,14,0,0,0,218,7,109,111,
+ 100,117,108,101,115,218,10,95,105,115,95,114,101,108,111,97,
+ 100,41,1,114,19,0,0,0,114,10,0,0,0,114,10,0,
+ 0,0,114,11,0,0,0,218,9,95,95,101,110,116,101,114,
+ 95,95,46,0,0,0,115,2,0,0,0,0,1,122,23,95,
+ 77,97,110,97,103,101,82,101,108,111,97,100,46,95,95,101,
+ 110,116,101,114,95,95,99,1,0,0,0,0,0,0,0,2,
+ 0,0,0,11,0,0,0,71,0,0,0,115,66,0,0,0,
+ 116,0,100,1,100,2,132,0,124,1,68,0,131,1,131,1,
+ 114,62,124,0,106,1,12,0,114,62,121,14,116,2,106,3,
+ 124,0,106,4,61,0,87,0,110,20,4,0,116,5,107,10,
+ 114,60,1,0,1,0,1,0,89,0,110,2,88,0,100,0,
+ 83,0,41,3,78,99,1,0,0,0,0,0,0,0,2,0,
+ 0,0,3,0,0,0,115,0,0,0,115,22,0,0,0,124,
+ 0,93,14,125,1,124,1,100,0,107,9,86,0,1,0,113,
+ 2,100,0,83,0,41,1,78,114,10,0,0,0,41,2,218,
+ 2,46,48,218,3,97,114,103,114,10,0,0,0,114,10,0,
+ 0,0,114,11,0,0,0,250,9,60,103,101,110,101,120,112,
+ 114,62,50,0,0,0,115,2,0,0,0,4,0,122,41,95,
+ 77,97,110,97,103,101,82,101,108,111,97,100,46,95,95,101,
+ 120,105,116,95,95,46,60,108,111,99,97,108,115,62,46,60,
+ 103,101,110,101,120,112,114,62,41,6,218,3,97,110,121,114,
+ 22,0,0,0,114,14,0,0,0,114,21,0,0,0,114,18,
+ 0,0,0,218,8,75,101,121,69,114,114,111,114,41,2,114,
+ 19,0,0,0,218,4,97,114,103,115,114,10,0,0,0,114,
+ 10,0,0,0,114,11,0,0,0,218,8,95,95,101,120,105,
+ 116,95,95,49,0,0,0,115,10,0,0,0,0,1,26,1,
+ 2,1,14,1,14,1,122,22,95,77,97,110,97,103,101,82,
+ 101,108,111,97,100,46,95,95,101,120,105,116,95,95,78,41,
+ 7,114,1,0,0,0,114,0,0,0,0,114,2,0,0,0,
+ 114,3,0,0,0,114,20,0,0,0,114,23,0,0,0,114,
+ 30,0,0,0,114,10,0,0,0,114,10,0,0,0,114,10,
+ 0,0,0,114,11,0,0,0,114,17,0,0,0,39,0,0,
+ 0,115,8,0,0,0,8,2,4,2,8,3,8,3,114,17,
+ 0,0,0,99,0,0,0,0,0,0,0,0,0,0,0,0,
+ 1,0,0,0,64,0,0,0,115,12,0,0,0,101,0,90,
+ 1,100,0,90,2,100,1,83,0,41,2,218,14,95,68,101,
+ 97,100,108,111,99,107,69,114,114,111,114,78,41,3,114,1,
+ 0,0,0,114,0,0,0,0,114,2,0,0,0,114,10,0,
+ 0,0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,
+ 0,114,31,0,0,0,64,0,0,0,115,2,0,0,0,8,
+ 1,114,31,0,0,0,99,0,0,0,0,0,0,0,0,0,
+ 0,0,0,2,0,0,0,64,0,0,0,115,56,0,0,0,
+ 101,0,90,1,100,0,90,2,100,1,90,3,100,2,100,3,
+ 132,0,90,4,100,4,100,5,132,0,90,5,100,6,100,7,
+ 132,0,90,6,100,8,100,9,132,0,90,7,100,10,100,11,
+ 132,0,90,8,100,12,83,0,41,13,218,11,95,77,111,100,
117,108,101,76,111,99,107,122,169,65,32,114,101,99,117,114,
115,105,118,101,32,108,111,99,107,32,105,109,112,108,101,109,
101,110,116,97,116,105,111,110,32,119,104,105,99,104,32,105,
@@ -178,162 +161,151 @@
32,116,111,10,32,32,32,32,116,97,107,101,32,108,111,99,
107,115,32,66,32,116,104,101,110,32,65,41,46,10,32,32,
32,32,99,2,0,0,0,0,0,0,0,2,0,0,0,2,
- 0,0,0,67,0,0,0,115,70,0,0,0,116,0,0,106,
- 1,0,131,0,0,124,0,0,95,2,0,116,0,0,106,1,
- 0,131,0,0,124,0,0,95,3,0,124,1,0,124,0,0,
- 95,4,0,100,0,0,124,0,0,95,5,0,100,1,0,124,
- 0,0,95,6,0,100,1,0,124,0,0,95,7,0,100,0,
- 0,83,41,2,78,233,0,0,0,0,41,8,218,7,95,116,
- 104,114,101,97,100,90,13,97,108,108,111,99,97,116,101,95,
- 108,111,99,107,218,4,108,111,99,107,218,6,119,97,107,101,
- 117,112,114,15,0,0,0,218,5,111,119,110,101,114,218,5,
- 99,111,117,110,116,218,7,119,97,105,116,101,114,115,41,2,
- 114,19,0,0,0,114,15,0,0,0,114,10,0,0,0,114,
- 10,0,0,0,114,11,0,0,0,114,20,0,0,0,74,0,
- 0,0,115,12,0,0,0,0,1,15,1,15,1,9,1,9,
- 1,9,1,122,20,95,77,111,100,117,108,101,76,111,99,107,
- 46,95,95,105,110,105,116,95,95,99,1,0,0,0,0,0,
- 0,0,4,0,0,0,2,0,0,0,67,0,0,0,115,88,
- 0,0,0,116,0,0,106,1,0,131,0,0,125,1,0,124,
- 0,0,106,2,0,125,2,0,120,60,0,116,3,0,106,4,
- 0,124,2,0,131,1,0,125,3,0,124,3,0,100,0,0,
- 107,8,0,114,55,0,100,1,0,83,124,3,0,106,2,0,
- 125,2,0,124,2,0,124,1,0,107,2,0,114,24,0,100,
- 2,0,83,113,24,0,87,100,0,0,83,41,3,78,70,84,
- 41,5,114,34,0,0,0,218,9,103,101,116,95,105,100,101,
- 110,116,114,37,0,0,0,218,12,95,98,108,111,99,107,105,
- 110,103,95,111,110,218,3,103,101,116,41,4,114,19,0,0,
- 0,90,2,109,101,218,3,116,105,100,114,35,0,0,0,114,
- 10,0,0,0,114,10,0,0,0,114,11,0,0,0,218,12,
- 104,97,115,95,100,101,97,100,108,111,99,107,82,0,0,0,
- 115,18,0,0,0,0,2,12,1,9,1,3,1,15,1,12,
- 1,4,1,9,1,12,1,122,24,95,77,111,100,117,108,101,
- 76,111,99,107,46,104,97,115,95,100,101,97,100,108,111,99,
- 107,99,1,0,0,0,0,0,0,0,2,0,0,0,16,0,
- 0,0,67,0,0,0,115,210,0,0,0,116,0,0,106,1,
- 0,131,0,0,125,1,0,124,0,0,116,2,0,124,1,0,
- 60,122,173,0,120,166,0,124,0,0,106,3,0,143,124,0,
- 1,124,0,0,106,4,0,100,1,0,107,2,0,115,68,0,
- 124,0,0,106,5,0,124,1,0,107,2,0,114,96,0,124,
- 1,0,124,0,0,95,5,0,124,0,0,4,106,4,0,100,
- 2,0,55,2,95,4,0,100,3,0,83,124,0,0,106,6,
- 0,131,0,0,114,124,0,116,7,0,100,4,0,124,0,0,
- 22,131,1,0,130,1,0,124,0,0,106,8,0,106,9,0,
- 100,5,0,131,1,0,114,157,0,124,0,0,4,106,10,0,
- 100,2,0,55,2,95,10,0,87,100,6,0,81,82,88,124,
- 0,0,106,8,0,106,9,0,131,0,0,1,124,0,0,106,
- 8,0,106,11,0,131,0,0,1,113,28,0,87,87,100,6,
- 0,116,2,0,124,1,0,61,88,100,6,0,83,41,7,122,
- 185,10,32,32,32,32,32,32,32,32,65,99,113,117,105,114,
- 101,32,116,104,101,32,109,111,100,117,108,101,32,108,111,99,
- 107,46,32,32,73,102,32,97,32,112,111,116,101,110,116,105,
- 97,108,32,100,101,97,100,108,111,99,107,32,105,115,32,100,
- 101,116,101,99,116,101,100,44,10,32,32,32,32,32,32,32,
- 32,97,32,95,68,101,97,100,108,111,99,107,69,114,114,111,
- 114,32,105,115,32,114,97,105,115,101,100,46,10,32,32,32,
- 32,32,32,32,32,79,116,104,101,114,119,105,115,101,44,32,
- 116,104,101,32,108,111,99,107,32,105,115,32,97,108,119,97,
- 121,115,32,97,99,113,117,105,114,101,100,32,97,110,100,32,
- 84,114,117,101,32,105,115,32,114,101,116,117,114,110,101,100,
- 46,10,32,32,32,32,32,32,32,32,114,33,0,0,0,233,
- 1,0,0,0,84,122,23,100,101,97,100,108,111,99,107,32,
- 100,101,116,101,99,116,101,100,32,98,121,32,37,114,70,78,
- 41,12,114,34,0,0,0,114,40,0,0,0,114,41,0,0,
- 0,114,35,0,0,0,114,38,0,0,0,114,37,0,0,0,
- 114,44,0,0,0,114,31,0,0,0,114,36,0,0,0,218,
- 7,97,99,113,117,105,114,101,114,39,0,0,0,218,7,114,
- 101,108,101,97,115,101,41,2,114,19,0,0,0,114,43,0,
- 0,0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,
- 0,114,46,0,0,0,94,0,0,0,115,32,0,0,0,0,
- 6,12,1,10,1,3,1,3,1,10,1,30,1,9,1,15,
- 1,4,1,12,1,16,1,18,1,22,2,13,1,21,2,122,
- 19,95,77,111,100,117,108,101,76,111,99,107,46,97,99,113,
- 117,105,114,101,99,1,0,0,0,0,0,0,0,2,0,0,
- 0,10,0,0,0,67,0,0,0,115,157,0,0,0,116,0,
- 0,106,1,0,131,0,0,125,1,0,124,0,0,106,2,0,
- 143,129,0,1,124,0,0,106,3,0,124,1,0,107,3,0,
- 114,49,0,116,4,0,100,1,0,131,1,0,130,1,0,124,
- 0,0,106,5,0,100,2,0,107,4,0,115,70,0,116,6,
- 0,130,1,0,124,0,0,4,106,5,0,100,3,0,56,2,
- 95,5,0,124,0,0,106,5,0,100,2,0,107,2,0,114,
- 146,0,100,0,0,124,0,0,95,3,0,124,0,0,106,7,
- 0,114,146,0,124,0,0,4,106,7,0,100,3,0,56,2,
- 95,7,0,124,0,0,106,8,0,106,9,0,131,0,0,1,
- 87,100,0,0,81,82,88,100,0,0,83,41,4,78,122,31,
- 99,97,110,110,111,116,32,114,101,108,101,97,115,101,32,117,
- 110,45,97,99,113,117,105,114,101,100,32,108,111,99,107,114,
- 33,0,0,0,114,45,0,0,0,41,10,114,34,0,0,0,
- 114,40,0,0,0,114,35,0,0,0,114,37,0,0,0,218,
- 12,82,117,110,116,105,109,101,69,114,114,111,114,114,38,0,
- 0,0,218,14,65,115,115,101,114,116,105,111,110,69,114,114,
- 111,114,114,39,0,0,0,114,36,0,0,0,114,47,0,0,
- 0,41,2,114,19,0,0,0,114,43,0,0,0,114,10,0,
- 0,0,114,10,0,0,0,114,11,0,0,0,114,47,0,0,
- 0,119,0,0,0,115,22,0,0,0,0,1,12,1,10,1,
- 15,1,12,1,21,1,15,1,15,1,9,1,9,1,15,1,
- 122,19,95,77,111,100,117,108,101,76,111,99,107,46,114,101,
- 108,101,97,115,101,99,1,0,0,0,0,0,0,0,1,0,
- 0,0,4,0,0,0,67,0,0,0,115,25,0,0,0,100,
- 1,0,106,0,0,124,0,0,106,1,0,116,2,0,124,0,
- 0,131,1,0,131,2,0,83,41,2,78,122,23,95,77,111,
- 100,117,108,101,76,111,99,107,40,123,33,114,125,41,32,97,
- 116,32,123,125,41,3,218,6,102,111,114,109,97,116,114,15,
- 0,0,0,218,2,105,100,41,1,114,19,0,0,0,114,10,
- 0,0,0,114,10,0,0,0,114,11,0,0,0,218,8,95,
- 95,114,101,112,114,95,95,132,0,0,0,115,2,0,0,0,
- 0,1,122,20,95,77,111,100,117,108,101,76,111,99,107,46,
- 95,95,114,101,112,114,95,95,78,41,9,114,1,0,0,0,
- 114,0,0,0,0,114,2,0,0,0,114,3,0,0,0,114,
- 20,0,0,0,114,44,0,0,0,114,46,0,0,0,114,47,
- 0,0,0,114,52,0,0,0,114,10,0,0,0,114,10,0,
- 0,0,114,10,0,0,0,114,11,0,0,0,114,32,0,0,
- 0,68,0,0,0,115,12,0,0,0,12,4,6,2,12,8,
- 12,12,12,25,12,13,114,32,0,0,0,99,0,0,0,0,
- 0,0,0,0,0,0,0,0,2,0,0,0,64,0,0,0,
- 115,70,0,0,0,101,0,0,90,1,0,100,0,0,90,2,
- 0,100,1,0,90,3,0,100,2,0,100,3,0,132,0,0,
- 90,4,0,100,4,0,100,5,0,132,0,0,90,5,0,100,
- 6,0,100,7,0,132,0,0,90,6,0,100,8,0,100,9,
- 0,132,0,0,90,7,0,100,10,0,83,41,11,218,16,95,
- 68,117,109,109,121,77,111,100,117,108,101,76,111,99,107,122,
- 86,65,32,115,105,109,112,108,101,32,95,77,111,100,117,108,
- 101,76,111,99,107,32,101,113,117,105,118,97,108,101,110,116,
- 32,102,111,114,32,80,121,116,104,111,110,32,98,117,105,108,
- 100,115,32,119,105,116,104,111,117,116,10,32,32,32,32,109,
- 117,108,116,105,45,116,104,114,101,97,100,105,110,103,32,115,
- 117,112,112,111,114,116,46,99,2,0,0,0,0,0,0,0,
- 2,0,0,0,2,0,0,0,67,0,0,0,115,22,0,0,
- 0,124,1,0,124,0,0,95,0,0,100,1,0,124,0,0,
- 95,1,0,100,0,0,83,41,2,78,114,33,0,0,0,41,
- 2,114,15,0,0,0,114,38,0,0,0,41,2,114,19,0,
- 0,0,114,15,0,0,0,114,10,0,0,0,114,10,0,0,
- 0,114,11,0,0,0,114,20,0,0,0,140,0,0,0,115,
- 4,0,0,0,0,1,9,1,122,25,95,68,117,109,109,121,
+ 0,0,0,67,0,0,0,115,48,0,0,0,116,0,106,1,
+ 131,0,124,0,95,2,116,0,106,1,131,0,124,0,95,3,
+ 124,1,124,0,95,4,100,0,124,0,95,5,100,1,124,0,
+ 95,6,100,1,124,0,95,7,100,0,83,0,41,2,78,233,
+ 0,0,0,0,41,8,218,7,95,116,104,114,101,97,100,90,
+ 13,97,108,108,111,99,97,116,101,95,108,111,99,107,218,4,
+ 108,111,99,107,218,6,119,97,107,101,117,112,114,15,0,0,
+ 0,218,5,111,119,110,101,114,218,5,99,111,117,110,116,218,
+ 7,119,97,105,116,101,114,115,41,2,114,19,0,0,0,114,
+ 15,0,0,0,114,10,0,0,0,114,10,0,0,0,114,11,
+ 0,0,0,114,20,0,0,0,74,0,0,0,115,12,0,0,
+ 0,0,1,10,1,10,1,6,1,6,1,6,1,122,20,95,
77,111,100,117,108,101,76,111,99,107,46,95,95,105,110,105,
- 116,95,95,99,1,0,0,0,0,0,0,0,1,0,0,0,
- 3,0,0,0,67,0,0,0,115,19,0,0,0,124,0,0,
- 4,106,0,0,100,1,0,55,2,95,0,0,100,2,0,83,
- 41,3,78,114,45,0,0,0,84,41,1,114,38,0,0,0,
- 41,1,114,19,0,0,0,114,10,0,0,0,114,10,0,0,
- 0,114,11,0,0,0,114,46,0,0,0,144,0,0,0,115,
- 4,0,0,0,0,1,15,1,122,24,95,68,117,109,109,121,
- 77,111,100,117,108,101,76,111,99,107,46,97,99,113,117,105,
- 114,101,99,1,0,0,0,0,0,0,0,1,0,0,0,3,
- 0,0,0,67,0,0,0,115,46,0,0,0,124,0,0,106,
- 0,0,100,1,0,107,2,0,114,27,0,116,1,0,100,2,
- 0,131,1,0,130,1,0,124,0,0,4,106,0,0,100,3,
- 0,56,2,95,0,0,100,0,0,83,41,4,78,114,33,0,
- 0,0,122,31,99,97,110,110,111,116,32,114,101,108,101,97,
- 115,101,32,117,110,45,97,99,113,117,105,114,101,100,32,108,
- 111,99,107,114,45,0,0,0,41,2,114,38,0,0,0,114,
- 48,0,0,0,41,1,114,19,0,0,0,114,10,0,0,0,
- 114,10,0,0,0,114,11,0,0,0,114,47,0,0,0,148,
- 0,0,0,115,6,0,0,0,0,1,15,1,12,1,122,24,
- 95,68,117,109,109,121,77,111,100,117,108,101,76,111,99,107,
- 46,114,101,108,101,97,115,101,99,1,0,0,0,0,0,0,
- 0,1,0,0,0,4,0,0,0,67,0,0,0,115,25,0,
- 0,0,100,1,0,106,0,0,124,0,0,106,1,0,116,2,
- 0,124,0,0,131,1,0,131,2,0,83,41,2,78,122,28,
+ 116,95,95,99,1,0,0,0,0,0,0,0,4,0,0,0,
+ 2,0,0,0,67,0,0,0,115,64,0,0,0,116,0,106,
+ 1,131,0,125,1,124,0,106,2,125,2,120,44,116,3,106,
+ 4,124,2,131,1,125,3,124,3,100,0,107,8,114,38,100,
+ 1,83,0,124,3,106,2,125,2,124,2,124,1,107,2,114,
+ 16,100,2,83,0,113,16,87,0,100,0,83,0,41,3,78,
+ 70,84,41,5,114,34,0,0,0,218,9,103,101,116,95,105,
+ 100,101,110,116,114,37,0,0,0,218,12,95,98,108,111,99,
+ 107,105,110,103,95,111,110,218,3,103,101,116,41,4,114,19,
+ 0,0,0,90,2,109,101,218,3,116,105,100,114,35,0,0,
+ 0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,
+ 218,12,104,97,115,95,100,101,97,100,108,111,99,107,82,0,
+ 0,0,115,18,0,0,0,0,2,8,1,6,1,2,1,10,
+ 1,8,1,4,1,6,1,8,1,122,24,95,77,111,100,117,
+ 108,101,76,111,99,107,46,104,97,115,95,100,101,97,100,108,
+ 111,99,107,99,1,0,0,0,0,0,0,0,2,0,0,0,
+ 16,0,0,0,67,0,0,0,115,168,0,0,0,116,0,106,
+ 1,131,0,125,1,124,0,116,2,124,1,60,0,122,138,120,
+ 132,124,0,106,3,143,96,1,0,124,0,106,4,100,1,107,
+ 2,115,48,124,0,106,5,124,1,107,2,114,72,124,1,124,
+ 0,95,5,124,0,4,0,106,4,100,2,55,0,2,0,95,
+ 4,100,3,83,0,124,0,106,6,131,0,114,92,116,7,100,
+ 4,124,0,22,0,131,1,130,1,124,0,106,8,106,9,100,
+ 5,131,1,114,118,124,0,4,0,106,10,100,2,55,0,2,
+ 0,95,10,87,0,100,6,81,0,82,0,88,0,124,0,106,
+ 8,106,9,131,0,1,0,124,0,106,8,106,11,131,0,1,
+ 0,113,20,87,0,87,0,100,6,116,2,124,1,61,0,88,
+ 0,100,6,83,0,41,7,122,185,10,32,32,32,32,32,32,
+ 32,32,65,99,113,117,105,114,101,32,116,104,101,32,109,111,
+ 100,117,108,101,32,108,111,99,107,46,32,32,73,102,32,97,
+ 32,112,111,116,101,110,116,105,97,108,32,100,101,97,100,108,
+ 111,99,107,32,105,115,32,100,101,116,101,99,116,101,100,44,
+ 10,32,32,32,32,32,32,32,32,97,32,95,68,101,97,100,
+ 108,111,99,107,69,114,114,111,114,32,105,115,32,114,97,105,
+ 115,101,100,46,10,32,32,32,32,32,32,32,32,79,116,104,
+ 101,114,119,105,115,101,44,32,116,104,101,32,108,111,99,107,
+ 32,105,115,32,97,108,119,97,121,115,32,97,99,113,117,105,
+ 114,101,100,32,97,110,100,32,84,114,117,101,32,105,115,32,
+ 114,101,116,117,114,110,101,100,46,10,32,32,32,32,32,32,
+ 32,32,114,33,0,0,0,233,1,0,0,0,84,122,23,100,
+ 101,97,100,108,111,99,107,32,100,101,116,101,99,116,101,100,
+ 32,98,121,32,37,114,70,78,41,12,114,34,0,0,0,114,
+ 40,0,0,0,114,41,0,0,0,114,35,0,0,0,114,38,
+ 0,0,0,114,37,0,0,0,114,44,0,0,0,114,31,0,
+ 0,0,114,36,0,0,0,218,7,97,99,113,117,105,114,101,
+ 114,39,0,0,0,218,7,114,101,108,101,97,115,101,41,2,
+ 114,19,0,0,0,114,43,0,0,0,114,10,0,0,0,114,
+ 10,0,0,0,114,11,0,0,0,114,46,0,0,0,94,0,
+ 0,0,115,32,0,0,0,0,6,8,1,8,1,2,1,2,
+ 1,8,1,20,1,6,1,14,1,4,1,8,1,12,1,12,
+ 1,24,2,10,1,18,2,122,19,95,77,111,100,117,108,101,
+ 76,111,99,107,46,97,99,113,117,105,114,101,99,1,0,0,
+ 0,0,0,0,0,2,0,0,0,10,0,0,0,67,0,0,
+ 0,115,122,0,0,0,116,0,106,1,131,0,125,1,124,0,
+ 106,2,143,98,1,0,124,0,106,3,124,1,107,3,114,34,
+ 116,4,100,1,131,1,130,1,124,0,106,5,100,2,107,4,
+ 115,48,116,6,130,1,124,0,4,0,106,5,100,3,56,0,
+ 2,0,95,5,124,0,106,5,100,2,107,2,114,108,100,0,
+ 124,0,95,3,124,0,106,7,114,108,124,0,4,0,106,7,
+ 100,3,56,0,2,0,95,7,124,0,106,8,106,9,131,0,
+ 1,0,87,0,100,0,81,0,82,0,88,0,100,0,83,0,
+ 41,4,78,122,31,99,97,110,110,111,116,32,114,101,108,101,
+ 97,115,101,32,117,110,45,97,99,113,117,105,114,101,100,32,
+ 108,111,99,107,114,33,0,0,0,114,45,0,0,0,41,10,
+ 114,34,0,0,0,114,40,0,0,0,114,35,0,0,0,114,
+ 37,0,0,0,218,12,82,117,110,116,105,109,101,69,114,114,
+ 111,114,114,38,0,0,0,218,14,65,115,115,101,114,116,105,
+ 111,110,69,114,114,111,114,114,39,0,0,0,114,36,0,0,
+ 0,114,47,0,0,0,41,2,114,19,0,0,0,114,43,0,
+ 0,0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,
+ 0,114,47,0,0,0,119,0,0,0,115,22,0,0,0,0,
+ 1,8,1,8,1,10,1,8,1,14,1,14,1,10,1,6,
+ 1,6,1,14,1,122,19,95,77,111,100,117,108,101,76,111,
+ 99,107,46,114,101,108,101,97,115,101,99,1,0,0,0,0,
+ 0,0,0,1,0,0,0,4,0,0,0,67,0,0,0,115,
+ 18,0,0,0,100,1,106,0,124,0,106,1,116,2,124,0,
+ 131,1,131,2,83,0,41,2,78,122,23,95,77,111,100,117,
+ 108,101,76,111,99,107,40,123,33,114,125,41,32,97,116,32,
+ 123,125,41,3,218,6,102,111,114,109,97,116,114,15,0,0,
+ 0,218,2,105,100,41,1,114,19,0,0,0,114,10,0,0,
+ 0,114,10,0,0,0,114,11,0,0,0,218,8,95,95,114,
+ 101,112,114,95,95,132,0,0,0,115,2,0,0,0,0,1,
+ 122,20,95,77,111,100,117,108,101,76,111,99,107,46,95,95,
+ 114,101,112,114,95,95,78,41,9,114,1,0,0,0,114,0,
+ 0,0,0,114,2,0,0,0,114,3,0,0,0,114,20,0,
+ 0,0,114,44,0,0,0,114,46,0,0,0,114,47,0,0,
+ 0,114,52,0,0,0,114,10,0,0,0,114,10,0,0,0,
+ 114,10,0,0,0,114,11,0,0,0,114,32,0,0,0,68,
+ 0,0,0,115,12,0,0,0,8,4,4,2,8,8,8,12,
+ 8,25,8,13,114,32,0,0,0,99,0,0,0,0,0,0,
+ 0,0,0,0,0,0,2,0,0,0,64,0,0,0,115,48,
+ 0,0,0,101,0,90,1,100,0,90,2,100,1,90,3,100,
+ 2,100,3,132,0,90,4,100,4,100,5,132,0,90,5,100,
+ 6,100,7,132,0,90,6,100,8,100,9,132,0,90,7,100,
+ 10,83,0,41,11,218,16,95,68,117,109,109,121,77,111,100,
+ 117,108,101,76,111,99,107,122,86,65,32,115,105,109,112,108,
+ 101,32,95,77,111,100,117,108,101,76,111,99,107,32,101,113,
+ 117,105,118,97,108,101,110,116,32,102,111,114,32,80,121,116,
+ 104,111,110,32,98,117,105,108,100,115,32,119,105,116,104,111,
+ 117,116,10,32,32,32,32,109,117,108,116,105,45,116,104,114,
+ 101,97,100,105,110,103,32,115,117,112,112,111,114,116,46,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,0,124,1,124,0,95,0,100,
+ 1,124,0,95,1,100,0,83,0,41,2,78,114,33,0,0,
+ 0,41,2,114,15,0,0,0,114,38,0,0,0,41,2,114,
+ 19,0,0,0,114,15,0,0,0,114,10,0,0,0,114,10,
+ 0,0,0,114,11,0,0,0,114,20,0,0,0,140,0,0,
+ 0,115,4,0,0,0,0,1,6,1,122,25,95,68,117,109,
+ 109,121,77,111,100,117,108,101,76,111,99,107,46,95,95,105,
+ 110,105,116,95,95,99,1,0,0,0,0,0,0,0,1,0,
+ 0,0,3,0,0,0,67,0,0,0,115,18,0,0,0,124,
+ 0,4,0,106,0,100,1,55,0,2,0,95,0,100,2,83,
+ 0,41,3,78,114,45,0,0,0,84,41,1,114,38,0,0,
+ 0,41,1,114,19,0,0,0,114,10,0,0,0,114,10,0,
+ 0,0,114,11,0,0,0,114,46,0,0,0,144,0,0,0,
+ 115,4,0,0,0,0,1,14,1,122,24,95,68,117,109,109,
+ 121,77,111,100,117,108,101,76,111,99,107,46,97,99,113,117,
+ 105,114,101,99,1,0,0,0,0,0,0,0,1,0,0,0,
+ 3,0,0,0,67,0,0,0,115,36,0,0,0,124,0,106,
+ 0,100,1,107,2,114,18,116,1,100,2,131,1,130,1,124,
+ 0,4,0,106,0,100,3,56,0,2,0,95,0,100,0,83,
+ 0,41,4,78,114,33,0,0,0,122,31,99,97,110,110,111,
+ 116,32,114,101,108,101,97,115,101,32,117,110,45,97,99,113,
+ 117,105,114,101,100,32,108,111,99,107,114,45,0,0,0,41,
+ 2,114,38,0,0,0,114,48,0,0,0,41,1,114,19,0,
+ 0,0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,
+ 0,114,47,0,0,0,148,0,0,0,115,6,0,0,0,0,
+ 1,10,1,8,1,122,24,95,68,117,109,109,121,77,111,100,
+ 117,108,101,76,111,99,107,46,114,101,108,101,97,115,101,99,
+ 1,0,0,0,0,0,0,0,1,0,0,0,4,0,0,0,
+ 67,0,0,0,115,18,0,0,0,100,1,106,0,124,0,106,
+ 1,116,2,124,0,131,1,131,2,83,0,41,2,78,122,28,
95,68,117,109,109,121,77,111,100,117,108,101,76,111,99,107,
40,123,33,114,125,41,32,97,116,32,123,125,41,3,114,50,
0,0,0,114,15,0,0,0,114,51,0,0,0,41,1,114,
@@ -345,262 +317,249 @@
114,3,0,0,0,114,20,0,0,0,114,46,0,0,0,114,
47,0,0,0,114,52,0,0,0,114,10,0,0,0,114,10,
0,0,0,114,10,0,0,0,114,11,0,0,0,114,53,0,
- 0,0,136,0,0,0,115,10,0,0,0,12,2,6,2,12,
- 4,12,4,12,5,114,53,0,0,0,99,0,0,0,0,0,
+ 0,0,136,0,0,0,115,10,0,0,0,8,2,4,2,8,
+ 4,8,4,8,5,114,53,0,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,0,0,90,1,0,100,0,0,90,2,0,
- 100,1,0,100,2,0,132,0,0,90,3,0,100,3,0,100,
- 4,0,132,0,0,90,4,0,100,5,0,100,6,0,132,0,
- 0,90,5,0,100,7,0,83,41,8,218,18,95,77,111,100,
+ 36,0,0,0,101,0,90,1,100,0,90,2,100,1,100,2,
+ 132,0,90,3,100,3,100,4,132,0,90,4,100,5,100,6,
+ 132,0,90,5,100,7,83,0,41,8,218,18,95,77,111,100,
117,108,101,76,111,99,107,77,97,110,97,103,101,114,99,2,
0,0,0,0,0,0,0,2,0,0,0,2,0,0,0,67,
- 0,0,0,115,22,0,0,0,124,1,0,124,0,0,95,0,
- 0,100,0,0,124,0,0,95,1,0,100,0,0,83,41,1,
- 78,41,2,114,18,0,0,0,218,5,95,108,111,99,107,41,
- 2,114,19,0,0,0,114,15,0,0,0,114,10,0,0,0,
- 114,10,0,0,0,114,11,0,0,0,114,20,0,0,0,159,
- 0,0,0,115,4,0,0,0,0,1,9,1,122,27,95,77,
- 111,100,117,108,101,76,111,99,107,77,97,110,97,103,101,114,
- 46,95,95,105,110,105,116,95,95,99,1,0,0,0,0,0,
- 0,0,1,0,0,0,10,0,0,0,67,0,0,0,115,53,
- 0,0,0,122,22,0,116,0,0,124,0,0,106,1,0,131,
- 1,0,124,0,0,95,2,0,87,100,0,0,116,3,0,106,
- 4,0,131,0,0,1,88,124,0,0,106,2,0,106,5,0,
- 131,0,0,1,100,0,0,83,41,1,78,41,6,218,16,95,
- 103,101,116,95,109,111,100,117,108,101,95,108,111,99,107,114,
- 18,0,0,0,114,55,0,0,0,218,4,95,105,109,112,218,
- 12,114,101,108,101,97,115,101,95,108,111,99,107,114,46,0,
- 0,0,41,1,114,19,0,0,0,114,10,0,0,0,114,10,
- 0,0,0,114,11,0,0,0,114,23,0,0,0,163,0,0,
- 0,115,8,0,0,0,0,1,3,1,22,2,11,1,122,28,
- 95,77,111,100,117,108,101,76,111,99,107,77,97,110,97,103,
- 101,114,46,95,95,101,110,116,101,114,95,95,99,1,0,0,
- 0,0,0,0,0,3,0,0,0,1,0,0,0,79,0,0,
- 0,115,17,0,0,0,124,0,0,106,0,0,106,1,0,131,
- 0,0,1,100,0,0,83,41,1,78,41,2,114,55,0,0,
- 0,114,47,0,0,0,41,3,114,19,0,0,0,114,29,0,
- 0,0,90,6,107,119,97,114,103,115,114,10,0,0,0,114,
- 10,0,0,0,114,11,0,0,0,114,30,0,0,0,170,0,
- 0,0,115,2,0,0,0,0,1,122,27,95,77,111,100,117,
- 108,101,76,111,99,107,77,97,110,97,103,101,114,46,95,95,
- 101,120,105,116,95,95,78,41,6,114,1,0,0,0,114,0,
- 0,0,0,114,2,0,0,0,114,20,0,0,0,114,23,0,
- 0,0,114,30,0,0,0,114,10,0,0,0,114,10,0,0,
- 0,114,10,0,0,0,114,11,0,0,0,114,54,0,0,0,
- 157,0,0,0,115,6,0,0,0,12,2,12,4,12,7,114,
- 54,0,0,0,99,1,0,0,0,0,0,0,0,3,0,0,
- 0,11,0,0,0,3,0,0,0,115,139,0,0,0,100,1,
- 0,125,1,0,121,17,0,116,0,0,136,0,0,25,131,0,
- 0,125,1,0,87,110,18,0,4,116,1,0,107,10,0,114,
- 43,0,1,1,1,89,110,1,0,88,124,1,0,100,1,0,
- 107,8,0,114,135,0,116,2,0,100,1,0,107,8,0,114,
- 83,0,116,3,0,136,0,0,131,1,0,125,1,0,110,12,
- 0,116,4,0,136,0,0,131,1,0,125,1,0,135,0,0,
- 102,1,0,100,2,0,100,3,0,134,0,0,125,2,0,116,
- 5,0,106,6,0,124,1,0,124,2,0,131,2,0,116,0,
- 0,136,0,0,60,124,1,0,83,41,4,122,109,71,101,116,
- 32,111,114,32,99,114,101,97,116,101,32,116,104,101,32,109,
- 111,100,117,108,101,32,108,111,99,107,32,102,111,114,32,97,
- 32,103,105,118,101,110,32,109,111,100,117,108,101,32,110,97,
- 109,101,46,10,10,32,32,32,32,83,104,111,117,108,100,32,
- 111,110,108,121,32,98,101,32,99,97,108,108,101,100,32,119,
- 105,116,104,32,116,104,101,32,105,109,112,111,114,116,32,108,
- 111,99,107,32,116,97,107,101,110,46,78,99,1,0,0,0,
- 0,0,0,0,1,0,0,0,2,0,0,0,19,0,0,0,
- 115,11,0,0,0,116,0,0,136,0,0,61,100,0,0,83,
- 41,1,78,41,1,218,13,95,109,111,100,117,108,101,95,108,
- 111,99,107,115,41,1,218,1,95,41,1,114,15,0,0,0,
- 114,10,0,0,0,114,11,0,0,0,218,2,99,98,190,0,
- 0,0,115,2,0,0,0,0,1,122,28,95,103,101,116,95,
- 109,111,100,117,108,101,95,108,111,99,107,46,60,108,111,99,
- 97,108,115,62,46,99,98,41,7,114,59,0,0,0,114,28,
- 0,0,0,114,34,0,0,0,114,53,0,0,0,114,32,0,
- 0,0,218,8,95,119,101,97,107,114,101,102,90,3,114,101,
- 102,41,3,114,15,0,0,0,114,35,0,0,0,114,61,0,
- 0,0,114,10,0,0,0,41,1,114,15,0,0,0,114,11,
- 0,0,0,114,56,0,0,0,176,0,0,0,115,24,0,0,
- 0,0,4,6,1,3,1,17,1,13,1,5,1,12,1,12,
- 1,15,2,12,1,18,2,22,1,114,56,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,71,0,0,0,116,0,0,124,0,0,131,1,
- 0,125,1,0,116,1,0,106,2,0,131,0,0,1,121,14,
- 0,124,1,0,106,3,0,131,0,0,1,87,110,18,0,4,
- 116,4,0,107,10,0,114,56,0,1,1,1,89,110,11,0,
- 88,124,1,0,106,5,0,131,0,0,1,100,1,0,83,41,
- 2,97,21,1,0,0,82,101,108,101,97,115,101,32,116,104,
- 101,32,103,108,111,98,97,108,32,105,109,112,111,114,116,32,
- 108,111,99,107,44,32,97,110,100,32,97,99,113,117,105,114,
- 101,115,32,116,104,101,110,32,114,101,108,101,97,115,101,32,
- 116,104,101,10,32,32,32,32,109,111,100,117,108,101,32,108,
- 111,99,107,32,102,111,114,32,97,32,103,105,118,101,110,32,
- 109,111,100,117,108,101,32,110,97,109,101,46,10,32,32,32,
- 32,84,104,105,115,32,105,115,32,117,115,101,100,32,116,111,
- 32,101,110,115,117,114,101,32,97,32,109,111,100,117,108,101,
- 32,105,115,32,99,111,109,112,108,101,116,101,108,121,32,105,
- 110,105,116,105,97,108,105,122,101,100,44,32,105,110,32,116,
- 104,101,10,32,32,32,32,101,118,101,110,116,32,105,116,32,
- 105,115,32,98,101,105,110,103,32,105,109,112,111,114,116,101,
- 100,32,98,121,32,97,110,111,116,104,101,114,32,116,104,114,
- 101,97,100,46,10,10,32,32,32,32,83,104,111,117,108,100,
- 32,111,110,108,121,32,98,101,32,99,97,108,108,101,100,32,
- 119,105,116,104,32,116,104,101,32,105,109,112,111,114,116,32,
- 108,111,99,107,32,116,97,107,101,110,46,78,41,6,114,56,
- 0,0,0,114,57,0,0,0,114,58,0,0,0,114,46,0,
- 0,0,114,31,0,0,0,114,47,0,0,0,41,2,114,15,
- 0,0,0,114,35,0,0,0,114,10,0,0,0,114,10,0,
- 0,0,114,11,0,0,0,218,19,95,108,111,99,107,95,117,
- 110,108,111,99,107,95,109,111,100,117,108,101,195,0,0,0,
- 115,14,0,0,0,0,7,12,1,10,1,3,1,14,1,13,
- 3,5,2,114,63,0,0,0,99,1,0,0,0,0,0,0,
- 0,3,0,0,0,3,0,0,0,79,0,0,0,115,13,0,
- 0,0,124,0,0,124,1,0,124,2,0,142,0,0,83,41,
- 1,97,46,1,0,0,114,101,109,111,118,101,95,105,109,112,
- 111,114,116,108,105,98,95,102,114,97,109,101,115,32,105,110,
- 32,105,109,112,111,114,116,46,99,32,119,105,108,108,32,97,
- 108,119,97,121,115,32,114,101,109,111,118,101,32,115,101,113,
- 117,101,110,99,101,115,10,32,32,32,32,111,102,32,105,109,
- 112,111,114,116,108,105,98,32,102,114,97,109,101,115,32,116,
- 104,97,116,32,101,110,100,32,119,105,116,104,32,97,32,99,
- 97,108,108,32,116,111,32,116,104,105,115,32,102,117,110,99,
- 116,105,111,110,10,10,32,32,32,32,85,115,101,32,105,116,
- 32,105,110,115,116,101,97,100,32,111,102,32,97,32,110,111,
- 114,109,97,108,32,99,97,108,108,32,105,110,32,112,108,97,
- 99,101,115,32,119,104,101,114,101,32,105,110,99,108,117,100,
- 105,110,103,32,116,104,101,32,105,109,112,111,114,116,108,105,
- 98,10,32,32,32,32,102,114,97,109,101,115,32,105,110,116,
- 114,111,100,117,99,101,115,32,117,110,119,97,110,116,101,100,
- 32,110,111,105,115,101,32,105,110,116,111,32,116,104,101,32,
- 116,114,97,99,101,98,97,99,107,32,40,101,46,103,46,32,
- 119,104,101,110,32,101,120,101,99,117,116,105,110,103,10,32,
- 32,32,32,109,111,100,117,108,101,32,99,111,100,101,41,10,
- 32,32,32,32,114,10,0,0,0,41,3,218,1,102,114,29,
- 0,0,0,90,4,107,119,100,115,114,10,0,0,0,114,10,
- 0,0,0,114,11,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,214,0,0,0,115,2,0,0,0,0,8,114,65,
- 0,0,0,218,9,118,101,114,98,111,115,105,116,121,114,45,
- 0,0,0,99,1,0,0,0,1,0,0,0,3,0,0,0,
- 4,0,0,0,71,0,0,0,115,75,0,0,0,116,0,0,
- 106,1,0,106,2,0,124,1,0,107,5,0,114,71,0,124,
- 0,0,106,3,0,100,6,0,131,1,0,115,43,0,100,3,
- 0,124,0,0,23,125,0,0,116,4,0,124,0,0,106,5,
- 0,124,2,0,140,0,0,100,4,0,116,0,0,106,6,0,
- 131,1,1,1,100,5,0,83,41,7,122,61,80,114,105,110,
- 116,32,116,104,101,32,109,101,115,115,97,103,101,32,116,111,
- 32,115,116,100,101,114,114,32,105,102,32,45,118,47,80,89,
- 84,72,79,78,86,69,82,66,79,83,69,32,105,115,32,116,
- 117,114,110,101,100,32,111,110,46,250,1,35,250,7,105,109,
- 112,111,114,116,32,122,2,35,32,90,4,102,105,108,101,78,
- 41,2,114,67,0,0,0,114,68,0,0,0,41,7,114,14,
- 0,0,0,218,5,102,108,97,103,115,218,7,118,101,114,98,
- 111,115,101,218,10,115,116,97,114,116,115,119,105,116,104,218,
- 5,112,114,105,110,116,114,50,0,0,0,218,6,115,116,100,
- 101,114,114,41,3,218,7,109,101,115,115,97,103,101,114,66,
- 0,0,0,114,29,0,0,0,114,10,0,0,0,114,10,0,
- 0,0,114,11,0,0,0,218,16,95,118,101,114,98,111,115,
- 101,95,109,101,115,115,97,103,101,225,0,0,0,115,8,0,
- 0,0,0,2,18,1,15,1,10,1,114,75,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,125,1,0,116,0,0,124,1,
- 0,136,0,0,131,2,0,1,124,1,0,83,41,3,122,49,
- 68,101,99,111,114,97,116,111,114,32,116,111,32,118,101,114,
- 105,102,121,32,116,104,101,32,110,97,109,101,100,32,109,111,
- 100,117,108,101,32,105,115,32,98,117,105,108,116,45,105,110,
- 46,99,2,0,0,0,0,0,0,0,2,0,0,0,4,0,
- 0,0,19,0,0,0,115,55,0,0,0,124,1,0,116,0,
- 0,106,1,0,107,7,0,114,42,0,116,2,0,100,1,0,
- 106,3,0,124,1,0,131,1,0,100,2,0,124,1,0,131,
- 1,1,130,1,0,136,0,0,124,0,0,124,1,0,131,2,
- 0,83,41,3,78,122,29,123,33,114,125,32,105,115,32,110,
- 111,116,32,97,32,98,117,105,108,116,45,105,110,32,109,111,
- 100,117,108,101,114,15,0,0,0,41,4,114,14,0,0,0,
- 218,20,98,117,105,108,116,105,110,95,109,111,100,117,108,101,
- 95,110,97,109,101,115,218,11,73,109,112,111,114,116,69,114,
- 114,111,114,114,50,0,0,0,41,2,114,19,0,0,0,218,
- 8,102,117,108,108,110,97,109,101,41,1,218,3,102,120,110,
- 114,10,0,0,0,114,11,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,235,0,0,0,115,8,0,0,0,0,1,
- 15,1,18,1,9,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,98,117,105,
- 108,116,105,110,95,119,114,97,112,112,101,114,41,1,114,12,
- 0,0,0,41,2,114,79,0,0,0,114,80,0,0,0,114,
- 10,0,0,0,41,1,114,79,0,0,0,114,11,0,0,0,
- 218,17,95,114,101,113,117,105,114,101,115,95,98,117,105,108,
- 116,105,110,233,0,0,0,115,6,0,0,0,0,2,18,5,
- 13,1,114,81,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,
- 125,1,0,116,0,0,124,1,0,136,0,0,131,2,0,1,
- 124,1,0,83,41,3,122,47,68,101,99,111,114,97,116,111,
- 114,32,116,111,32,118,101,114,105,102,121,32,116,104,101,32,
- 110,97,109,101,100,32,109,111,100,117,108,101,32,105,115,32,
- 102,114,111,122,101,110,46,99,2,0,0,0,0,0,0,0,
- 2,0,0,0,4,0,0,0,19,0,0,0,115,55,0,0,
- 0,116,0,0,106,1,0,124,1,0,131,1,0,115,42,0,
- 116,2,0,100,1,0,106,3,0,124,1,0,131,1,0,100,
- 2,0,124,1,0,131,1,1,130,1,0,136,0,0,124,0,
- 0,124,1,0,131,2,0,83,41,3,78,122,27,123,33,114,
- 125,32,105,115,32,110,111,116,32,97,32,102,114,111,122,101,
- 110,32,109,111,100,117,108,101,114,15,0,0,0,41,4,114,
- 57,0,0,0,218,9,105,115,95,102,114,111,122,101,110,114,
- 77,0,0,0,114,50,0,0,0,41,2,114,19,0,0,0,
- 114,78,0,0,0,41,1,114,79,0,0,0,114,10,0,0,
- 0,114,11,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,
- 246,0,0,0,115,8,0,0,0,0,1,15,1,18,1,9,
- 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,122,101,110,95,119,114,
- 97,112,112,101,114,41,1,114,12,0,0,0,41,2,114,79,
- 0,0,0,114,83,0,0,0,114,10,0,0,0,41,1,114,
- 79,0,0,0,114,11,0,0,0,218,16,95,114,101,113,117,
- 105,114,101,115,95,102,114,111,122,101,110,244,0,0,0,115,
- 6,0,0,0,0,2,18,5,13,1,114,84,0,0,0,99,
- 2,0,0,0,0,0,0,0,4,0,0,0,3,0,0,0,
- 67,0,0,0,115,81,0,0,0,116,0,0,124,1,0,124,
- 0,0,131,2,0,125,2,0,124,1,0,116,1,0,106,2,
- 0,107,6,0,114,67,0,116,1,0,106,2,0,124,1,0,
- 25,125,3,0,116,3,0,124,2,0,124,3,0,131,2,0,
- 1,116,1,0,106,2,0,124,1,0,25,83,116,4,0,124,
- 2,0,131,1,0,83,100,1,0,83,41,2,122,128,76,111,
- 97,100,32,116,104,101,32,115,112,101,99,105,102,105,101,100,
- 32,109,111,100,117,108,101,32,105,110,116,111,32,115,121,115,
- 46,109,111,100,117,108,101,115,32,97,110,100,32,114,101,116,
- 117,114,110,32,105,116,46,10,10,32,32,32,32,84,104,105,
- 115,32,109,101,116,104,111,100,32,105,115,32,100,101,112,114,
- 101,99,97,116,101,100,46,32,32,85,115,101,32,108,111,97,
- 100,101,114,46,101,120,101,99,95,109,111,100,117,108,101,32,
- 105,110,115,116,101,97,100,46,10,10,32,32,32,32,78,41,
- 5,218,16,115,112,101,99,95,102,114,111,109,95,108,111,97,
- 100,101,114,114,14,0,0,0,114,21,0,0,0,218,5,95,
- 101,120,101,99,218,5,95,108,111,97,100,41,4,114,19,0,
- 0,0,114,78,0,0,0,218,4,115,112,101,99,218,6,109,
- 111,100,117,108,101,114,10,0,0,0,114,10,0,0,0,114,
- 11,0,0,0,218,17,95,108,111,97,100,95,109,111,100,117,
- 108,101,95,115,104,105,109,0,1,0,0,115,12,0,0,0,
- 0,6,15,1,15,1,13,1,13,1,11,2,114,90,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,6,1,0,0,116,0,0,124,0,
- 0,100,1,0,100,0,0,131,3,0,125,1,0,116,1,0,
- 124,1,0,100,2,0,131,2,0,114,71,0,121,17,0,124,
- 1,0,106,2,0,124,0,0,131,1,0,83,87,110,18,0,
- 4,116,3,0,107,10,0,114,70,0,1,1,1,89,110,1,
- 0,88,121,13,0,124,0,0,106,4,0,125,2,0,87,110,
- 18,0,4,116,5,0,107,10,0,114,104,0,1,1,1,89,
- 110,23,0,88,124,2,0,100,0,0,107,9,0,114,127,0,
- 116,6,0,124,2,0,131,1,0,83,121,13,0,124,0,0,
- 106,7,0,125,3,0,87,110,24,0,4,116,5,0,107,10,
- 0,114,166,0,1,1,1,100,3,0,125,3,0,89,110,1,
- 0,88,121,13,0,124,0,0,106,8,0,125,4,0,87,110,
- 59,0,4,116,5,0,107,10,0,114,241,0,1,1,1,124,
- 1,0,100,0,0,107,8,0,114,221,0,100,4,0,106,9,
- 0,124,3,0,131,1,0,83,100,5,0,106,9,0,124,3,
- 0,124,1,0,131,2,0,83,89,110,17,0,88,100,6,0,
- 106,9,0,124,3,0,124,4,0,131,2,0,83,100,0,0,
- 83,41,7,78,218,10,95,95,108,111,97,100,101,114,95,95,
+ 0,0,0,115,16,0,0,0,124,1,124,0,95,0,100,0,
+ 124,0,95,1,100,0,83,0,41,1,78,41,2,114,18,0,
+ 0,0,218,5,95,108,111,99,107,41,2,114,19,0,0,0,
+ 114,15,0,0,0,114,10,0,0,0,114,10,0,0,0,114,
+ 11,0,0,0,114,20,0,0,0,159,0,0,0,115,4,0,
+ 0,0,0,1,6,1,122,27,95,77,111,100,117,108,101,76,
+ 111,99,107,77,97,110,97,103,101,114,46,95,95,105,110,105,
+ 116,95,95,99,1,0,0,0,0,0,0,0,1,0,0,0,
+ 10,0,0,0,67,0,0,0,115,42,0,0,0,122,16,116,
+ 0,124,0,106,1,131,1,124,0,95,2,87,0,100,0,116,
+ 3,106,4,131,0,1,0,88,0,124,0,106,2,106,5,131,
+ 0,1,0,100,0,83,0,41,1,78,41,6,218,16,95,103,
+ 101,116,95,109,111,100,117,108,101,95,108,111,99,107,114,18,
+ 0,0,0,114,55,0,0,0,218,4,95,105,109,112,218,12,
+ 114,101,108,101,97,115,101,95,108,111,99,107,114,46,0,0,
+ 0,41,1,114,19,0,0,0,114,10,0,0,0,114,10,0,
+ 0,0,114,11,0,0,0,114,23,0,0,0,163,0,0,0,
+ 115,8,0,0,0,0,1,2,1,16,2,10,1,122,28,95,
+ 77,111,100,117,108,101,76,111,99,107,77,97,110,97,103,101,
+ 114,46,95,95,101,110,116,101,114,95,95,99,1,0,0,0,
+ 0,0,0,0,3,0,0,0,1,0,0,0,79,0,0,0,
+ 115,14,0,0,0,124,0,106,0,106,1,131,0,1,0,100,
+ 0,83,0,41,1,78,41,2,114,55,0,0,0,114,47,0,
+ 0,0,41,3,114,19,0,0,0,114,29,0,0,0,90,6,
+ 107,119,97,114,103,115,114,10,0,0,0,114,10,0,0,0,
+ 114,11,0,0,0,114,30,0,0,0,170,0,0,0,115,2,
+ 0,0,0,0,1,122,27,95,77,111,100,117,108,101,76,111,
+ 99,107,77,97,110,97,103,101,114,46,95,95,101,120,105,116,
+ 95,95,78,41,6,114,1,0,0,0,114,0,0,0,0,114,
+ 2,0,0,0,114,20,0,0,0,114,23,0,0,0,114,30,
+ 0,0,0,114,10,0,0,0,114,10,0,0,0,114,10,0,
+ 0,0,114,11,0,0,0,114,54,0,0,0,157,0,0,0,
+ 115,6,0,0,0,8,2,8,4,8,7,114,54,0,0,0,
+ 99,1,0,0,0,0,0,0,0,3,0,0,0,11,0,0,
+ 0,3,0,0,0,115,106,0,0,0,100,1,125,1,121,14,
+ 116,0,136,0,25,0,131,0,125,1,87,0,110,20,4,0,
+ 116,1,107,10,114,38,1,0,1,0,1,0,89,0,110,2,
+ 88,0,124,1,100,1,107,8,114,102,116,2,100,1,107,8,
+ 114,66,116,3,136,0,131,1,125,1,110,8,116,4,136,0,
+ 131,1,125,1,135,0,102,1,100,2,100,3,132,8,125,2,
+ 116,5,106,6,124,1,124,2,131,2,116,0,136,0,60,0,
+ 124,1,83,0,41,4,122,109,71,101,116,32,111,114,32,99,
+ 114,101,97,116,101,32,116,104,101,32,109,111,100,117,108,101,
+ 32,108,111,99,107,32,102,111,114,32,97,32,103,105,118,101,
+ 110,32,109,111,100,117,108,101,32,110,97,109,101,46,10,10,
+ 32,32,32,32,83,104,111,117,108,100,32,111,110,108,121,32,
+ 98,101,32,99,97,108,108,101,100,32,119,105,116,104,32,116,
+ 104,101,32,105,109,112,111,114,116,32,108,111,99,107,32,116,
+ 97,107,101,110,46,78,99,1,0,0,0,0,0,0,0,1,
+ 0,0,0,2,0,0,0,19,0,0,0,115,10,0,0,0,
+ 116,0,136,0,61,0,100,0,83,0,41,1,78,41,1,218,
+ 13,95,109,111,100,117,108,101,95,108,111,99,107,115,41,1,
+ 218,1,95,41,1,114,15,0,0,0,114,10,0,0,0,114,
+ 11,0,0,0,218,2,99,98,190,0,0,0,115,2,0,0,
+ 0,0,1,122,28,95,103,101,116,95,109,111,100,117,108,101,
+ 95,108,111,99,107,46,60,108,111,99,97,108,115,62,46,99,
+ 98,41,7,114,59,0,0,0,114,28,0,0,0,114,34,0,
+ 0,0,114,53,0,0,0,114,32,0,0,0,218,8,95,119,
+ 101,97,107,114,101,102,90,3,114,101,102,41,3,114,15,0,
+ 0,0,114,35,0,0,0,114,61,0,0,0,114,10,0,0,
+ 0,41,1,114,15,0,0,0,114,11,0,0,0,114,56,0,
+ 0,0,176,0,0,0,115,24,0,0,0,0,4,4,1,2,
+ 1,14,1,14,1,6,1,8,1,8,1,10,2,8,1,12,
+ 2,16,1,114,56,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,62,0,
+ 0,0,116,0,124,0,131,1,125,1,116,1,106,2,131,0,
+ 1,0,121,12,124,1,106,3,131,0,1,0,87,0,110,20,
+ 4,0,116,4,107,10,114,48,1,0,1,0,1,0,89,0,
+ 110,10,88,0,124,1,106,5,131,0,1,0,100,1,83,0,
+ 41,2,97,21,1,0,0,82,101,108,101,97,115,101,32,116,
+ 104,101,32,103,108,111,98,97,108,32,105,109,112,111,114,116,
+ 32,108,111,99,107,44,32,97,110,100,32,97,99,113,117,105,
+ 114,101,115,32,116,104,101,110,32,114,101,108,101,97,115,101,
+ 32,116,104,101,10,32,32,32,32,109,111,100,117,108,101,32,
+ 108,111,99,107,32,102,111,114,32,97,32,103,105,118,101,110,
+ 32,109,111,100,117,108,101,32,110,97,109,101,46,10,32,32,
+ 32,32,84,104,105,115,32,105,115,32,117,115,101,100,32,116,
+ 111,32,101,110,115,117,114,101,32,97,32,109,111,100,117,108,
+ 101,32,105,115,32,99,111,109,112,108,101,116,101,108,121,32,
+ 105,110,105,116,105,97,108,105,122,101,100,44,32,105,110,32,
+ 116,104,101,10,32,32,32,32,101,118,101,110,116,32,105,116,
+ 32,105,115,32,98,101,105,110,103,32,105,109,112,111,114,116,
+ 101,100,32,98,121,32,97,110,111,116,104,101,114,32,116,104,
+ 114,101,97,100,46,10,10,32,32,32,32,83,104,111,117,108,
+ 100,32,111,110,108,121,32,98,101,32,99,97,108,108,101,100,
+ 32,119,105,116,104,32,116,104,101,32,105,109,112,111,114,116,
+ 32,108,111,99,107,32,116,97,107,101,110,46,78,41,6,114,
+ 56,0,0,0,114,57,0,0,0,114,58,0,0,0,114,46,
+ 0,0,0,114,31,0,0,0,114,47,0,0,0,41,2,114,
+ 15,0,0,0,114,35,0,0,0,114,10,0,0,0,114,10,
+ 0,0,0,114,11,0,0,0,218,19,95,108,111,99,107,95,
+ 117,110,108,111,99,107,95,109,111,100,117,108,101,195,0,0,
+ 0,115,14,0,0,0,0,7,8,1,8,1,2,1,12,1,
+ 14,3,6,2,114,63,0,0,0,99,1,0,0,0,0,0,
+ 0,0,3,0,0,0,3,0,0,0,79,0,0,0,115,10,
+ 0,0,0,124,0,124,1,124,2,142,0,83,0,41,1,97,
+ 46,1,0,0,114,101,109,111,118,101,95,105,109,112,111,114,
+ 116,108,105,98,95,102,114,97,109,101,115,32,105,110,32,105,
+ 109,112,111,114,116,46,99,32,119,105,108,108,32,97,108,119,
+ 97,121,115,32,114,101,109,111,118,101,32,115,101,113,117,101,
+ 110,99,101,115,10,32,32,32,32,111,102,32,105,109,112,111,
+ 114,116,108,105,98,32,102,114,97,109,101,115,32,116,104,97,
+ 116,32,101,110,100,32,119,105,116,104,32,97,32,99,97,108,
+ 108,32,116,111,32,116,104,105,115,32,102,117,110,99,116,105,
+ 111,110,10,10,32,32,32,32,85,115,101,32,105,116,32,105,
+ 110,115,116,101,97,100,32,111,102,32,97,32,110,111,114,109,
+ 97,108,32,99,97,108,108,32,105,110,32,112,108,97,99,101,
+ 115,32,119,104,101,114,101,32,105,110,99,108,117,100,105,110,
+ 103,32,116,104,101,32,105,109,112,111,114,116,108,105,98,10,
+ 32,32,32,32,102,114,97,109,101,115,32,105,110,116,114,111,
+ 100,117,99,101,115,32,117,110,119,97,110,116,101,100,32,110,
+ 111,105,115,101,32,105,110,116,111,32,116,104,101,32,116,114,
+ 97,99,101,98,97,99,107,32,40,101,46,103,46,32,119,104,
+ 101,110,32,101,120,101,99,117,116,105,110,103,10,32,32,32,
+ 32,109,111,100,117,108,101,32,99,111,100,101,41,10,32,32,
+ 32,32,114,10,0,0,0,41,3,218,1,102,114,29,0,0,
+ 0,90,4,107,119,100,115,114,10,0,0,0,114,10,0,0,
+ 0,114,11,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,214,0,0,0,115,2,0,0,0,0,8,114,65,0,0,
+ 0,114,45,0,0,0,41,1,218,9,118,101,114,98,111,115,
+ 105,116,121,99,1,0,0,0,1,0,0,0,3,0,0,0,
+ 4,0,0,0,71,0,0,0,115,56,0,0,0,116,0,106,
+ 1,106,2,124,1,107,5,114,52,124,0,106,3,100,6,131,
+ 1,115,30,100,3,124,0,23,0,125,0,116,4,124,0,106,
+ 5,124,2,140,0,100,4,116,0,106,6,144,1,131,1,1,
+ 0,100,5,83,0,41,7,122,61,80,114,105,110,116,32,116,
+ 104,101,32,109,101,115,115,97,103,101,32,116,111,32,115,116,
+ 100,101,114,114,32,105,102,32,45,118,47,80,89,84,72,79,
+ 78,86,69,82,66,79,83,69,32,105,115,32,116,117,114,110,
+ 101,100,32,111,110,46,250,1,35,250,7,105,109,112,111,114,
+ 116,32,122,2,35,32,90,4,102,105,108,101,78,41,2,114,
+ 67,0,0,0,114,68,0,0,0,41,7,114,14,0,0,0,
+ 218,5,102,108,97,103,115,218,7,118,101,114,98,111,115,101,
+ 218,10,115,116,97,114,116,115,119,105,116,104,218,5,112,114,
+ 105,110,116,114,50,0,0,0,218,6,115,116,100,101,114,114,
+ 41,3,218,7,109,101,115,115,97,103,101,114,66,0,0,0,
+ 114,29,0,0,0,114,10,0,0,0,114,10,0,0,0,114,
+ 11,0,0,0,218,16,95,118,101,114,98,111,115,101,95,109,
+ 101,115,115,97,103,101,225,0,0,0,115,8,0,0,0,0,
+ 2,12,1,10,1,8,1,114,75,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,26,0,0,0,135,0,102,1,100,1,100,2,132,8,
+ 125,1,116,0,124,1,136,0,131,2,1,0,124,1,83,0,
+ 41,3,122,49,68,101,99,111,114,97,116,111,114,32,116,111,
+ 32,118,101,114,105,102,121,32,116,104,101,32,110,97,109,101,
+ 100,32,109,111,100,117,108,101,32,105,115,32,98,117,105,108,
+ 116,45,105,110,46,99,2,0,0,0,0,0,0,0,2,0,
+ 0,0,4,0,0,0,19,0,0,0,115,40,0,0,0,124,
+ 1,116,0,106,1,107,7,114,30,116,2,100,1,106,3,124,
+ 1,131,1,100,2,124,1,144,1,131,1,130,1,136,0,124,
+ 0,124,1,131,2,83,0,41,3,78,122,29,123,33,114,125,
+ 32,105,115,32,110,111,116,32,97,32,98,117,105,108,116,45,
+ 105,110,32,109,111,100,117,108,101,114,15,0,0,0,41,4,
+ 114,14,0,0,0,218,20,98,117,105,108,116,105,110,95,109,
+ 111,100,117,108,101,95,110,97,109,101,115,218,11,73,109,112,
+ 111,114,116,69,114,114,111,114,114,50,0,0,0,41,2,114,
+ 19,0,0,0,218,8,102,117,108,108,110,97,109,101,41,1,
+ 218,3,102,120,110,114,10,0,0,0,114,11,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,235,0,0,0,115,8,
+ 0,0,0,0,1,10,1,12,1,8,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,98,117,105,108,116,105,110,95,119,114,97,112,112,101,
+ 114,41,1,114,12,0,0,0,41,2,114,79,0,0,0,114,
+ 80,0,0,0,114,10,0,0,0,41,1,114,79,0,0,0,
+ 114,11,0,0,0,218,17,95,114,101,113,117,105,114,101,115,
+ 95,98,117,105,108,116,105,110,233,0,0,0,115,6,0,0,
+ 0,0,2,12,5,10,1,114,81,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,26,0,0,0,135,0,102,1,100,1,100,2,132,8,
+ 125,1,116,0,124,1,136,0,131,2,1,0,124,1,83,0,
+ 41,3,122,47,68,101,99,111,114,97,116,111,114,32,116,111,
+ 32,118,101,114,105,102,121,32,116,104,101,32,110,97,109,101,
+ 100,32,109,111,100,117,108,101,32,105,115,32,102,114,111,122,
+ 101,110,46,99,2,0,0,0,0,0,0,0,2,0,0,0,
+ 4,0,0,0,19,0,0,0,115,40,0,0,0,116,0,106,
+ 1,124,1,131,1,115,30,116,2,100,1,106,3,124,1,131,
+ 1,100,2,124,1,144,1,131,1,130,1,136,0,124,0,124,
+ 1,131,2,83,0,41,3,78,122,27,123,33,114,125,32,105,
+ 115,32,110,111,116,32,97,32,102,114,111,122,101,110,32,109,
+ 111,100,117,108,101,114,15,0,0,0,41,4,114,57,0,0,
+ 0,218,9,105,115,95,102,114,111,122,101,110,114,77,0,0,
+ 0,114,50,0,0,0,41,2,114,19,0,0,0,114,78,0,
+ 0,0,41,1,114,79,0,0,0,114,10,0,0,0,114,11,
+ 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,246,0,0,
+ 0,115,8,0,0,0,0,1,10,1,12,1,8,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,122,101,110,95,119,114,97,112,112,
+ 101,114,41,1,114,12,0,0,0,41,2,114,79,0,0,0,
+ 114,83,0,0,0,114,10,0,0,0,41,1,114,79,0,0,
+ 0,114,11,0,0,0,218,16,95,114,101,113,117,105,114,101,
+ 115,95,102,114,111,122,101,110,244,0,0,0,115,6,0,0,
+ 0,0,2,12,5,10,1,114,84,0,0,0,99,2,0,0,
+ 0,0,0,0,0,4,0,0,0,3,0,0,0,67,0,0,
+ 0,115,64,0,0,0,116,0,124,1,124,0,131,2,125,2,
+ 124,1,116,1,106,2,107,6,114,52,116,1,106,2,124,1,
+ 25,0,125,3,116,3,124,2,124,3,131,2,1,0,116,1,
+ 106,2,124,1,25,0,83,0,110,8,116,4,124,2,131,1,
+ 83,0,100,1,83,0,41,2,122,128,76,111,97,100,32,116,
+ 104,101,32,115,112,101,99,105,102,105,101,100,32,109,111,100,
+ 117,108,101,32,105,110,116,111,32,115,121,115,46,109,111,100,
+ 117,108,101,115,32,97,110,100,32,114,101,116,117,114,110,32,
+ 105,116,46,10,10,32,32,32,32,84,104,105,115,32,109,101,
+ 116,104,111,100,32,105,115,32,100,101,112,114,101,99,97,116,
+ 101,100,46,32,32,85,115,101,32,108,111,97,100,101,114,46,
+ 101,120,101,99,95,109,111,100,117,108,101,32,105,110,115,116,
+ 101,97,100,46,10,10,32,32,32,32,78,41,5,218,16,115,
+ 112,101,99,95,102,114,111,109,95,108,111,97,100,101,114,114,
+ 14,0,0,0,114,21,0,0,0,218,5,95,101,120,101,99,
+ 218,5,95,108,111,97,100,41,4,114,19,0,0,0,114,78,
+ 0,0,0,218,4,115,112,101,99,218,6,109,111,100,117,108,
+ 101,114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,
+ 218,17,95,108,111,97,100,95,109,111,100,117,108,101,95,115,
+ 104,105,109,0,1,0,0,115,12,0,0,0,0,6,10,1,
+ 10,1,10,1,10,1,12,2,114,90,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,218,0,0,0,116,0,124,0,100,1,100,0,131,
+ 3,125,1,116,1,124,1,100,2,131,2,114,54,121,10,124,
+ 1,106,2,124,0,131,1,83,0,4,0,116,3,107,10,114,
+ 52,1,0,1,0,1,0,89,0,110,2,88,0,121,10,124,
+ 0,106,4,125,2,87,0,110,20,4,0,116,5,107,10,114,
+ 84,1,0,1,0,1,0,89,0,110,18,88,0,124,2,100,
+ 0,107,9,114,102,116,6,124,2,131,1,83,0,121,10,124,
+ 0,106,7,125,3,87,0,110,24,4,0,116,5,107,10,114,
+ 136,1,0,1,0,1,0,100,3,125,3,89,0,110,2,88,
+ 0,121,10,124,0,106,8,125,4,87,0,110,52,4,0,116,
+ 5,107,10,114,200,1,0,1,0,1,0,124,1,100,0,107,
+ 8,114,184,100,4,106,9,124,3,131,1,83,0,110,12,100,
+ 5,106,9,124,3,124,1,131,2,83,0,89,0,110,14,88,
+ 0,100,6,106,9,124,3,124,4,131,2,83,0,100,0,83,
+ 0,41,7,78,218,10,95,95,108,111,97,100,101,114,95,95,
218,11,109,111,100,117,108,101,95,114,101,112,114,250,1,63,
122,13,60,109,111,100,117,108,101,32,123,33,114,125,62,122,
20,60,109,111,100,117,108,101,32,123,33,114,125,32,40,123,
@@ -616,1374 +575,1310 @@
88,0,0,0,114,15,0,0,0,218,8,102,105,108,101,110,
97,109,101,114,10,0,0,0,114,10,0,0,0,114,11,0,
0,0,218,12,95,109,111,100,117,108,101,95,114,101,112,114,
- 16,1,0,0,115,46,0,0,0,0,2,18,1,15,4,3,
- 1,17,1,13,1,5,1,3,1,13,1,13,1,5,2,12,
- 1,10,4,3,1,13,1,13,1,11,1,3,1,13,1,13,
- 1,12,1,13,2,21,2,114,101,0,0,0,99,0,0,0,
+ 16,1,0,0,115,46,0,0,0,0,2,12,1,10,4,2,
+ 1,10,1,14,1,6,1,2,1,10,1,14,1,6,2,8,
+ 1,8,4,2,1,10,1,14,1,10,1,2,1,10,1,14,
+ 1,8,1,12,2,18,2,114,101,0,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,0,0,90,1,0,100,0,0,90,
- 2,0,100,1,0,100,2,0,132,0,0,90,3,0,100,3,
- 0,100,4,0,132,0,0,90,4,0,100,5,0,100,6,0,
- 132,0,0,90,5,0,100,7,0,83,41,8,218,17,95,105,
+ 0,115,36,0,0,0,101,0,90,1,100,0,90,2,100,1,
+ 100,2,132,0,90,3,100,3,100,4,132,0,90,4,100,5,
+ 100,6,132,0,90,5,100,7,83,0,41,8,218,17,95,105,
110,115,116,97,108,108,101,100,95,115,97,102,101,108,121,99,
2,0,0,0,0,0,0,0,2,0,0,0,2,0,0,0,
- 67,0,0,0,115,25,0,0,0,124,1,0,124,0,0,95,
- 0,0,124,1,0,106,1,0,124,0,0,95,2,0,100,0,
- 0,83,41,1,78,41,3,218,7,95,109,111,100,117,108,101,
- 114,95,0,0,0,218,5,95,115,112,101,99,41,2,114,19,
- 0,0,0,114,89,0,0,0,114,10,0,0,0,114,10,0,
- 0,0,114,11,0,0,0,114,20,0,0,0,54,1,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,0,3,0,0,0,67,0,0,0,115,38,0,0,0,100,
- 1,0,124,0,0,106,0,0,95,1,0,124,0,0,106,2,
- 0,116,3,0,106,4,0,124,0,0,106,0,0,106,5,0,
- 60,100,0,0,83,41,2,78,84,41,6,114,104,0,0,0,
- 218,13,95,105,110,105,116,105,97,108,105,122,105,110,103,114,
- 103,0,0,0,114,14,0,0,0,114,21,0,0,0,114,15,
- 0,0,0,41,1,114,19,0,0,0,114,10,0,0,0,114,
- 10,0,0,0,114,11,0,0,0,114,23,0,0,0,58,1,
- 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,3,0,0,0,17,0,0,0,71,0,0,0,115,121,0,
- 0,0,122,101,0,124,0,0,106,0,0,125,2,0,116,1,
- 0,100,1,0,100,2,0,132,0,0,124,1,0,68,131,1,
- 0,131,1,0,114,78,0,121,17,0,116,2,0,106,3,0,
- 124,2,0,106,4,0,61,87,113,100,0,4,116,5,0,107,
- 10,0,114,74,0,1,1,1,89,113,100,0,88,110,22,0,
- 116,6,0,100,3,0,124,2,0,106,4,0,124,2,0,106,
- 7,0,131,3,0,1,87,100,0,0,100,4,0,124,0,0,
- 106,0,0,95,8,0,88,100,0,0,83,41,5,78,99,1,
- 0,0,0,0,0,0,0,2,0,0,0,3,0,0,0,115,
- 0,0,0,115,27,0,0,0,124,0,0,93,17,0,125,1,
- 0,124,1,0,100,0,0,107,9,0,86,1,113,3,0,100,
- 0,0,83,41,1,78,114,10,0,0,0,41,2,114,24,0,
- 0,0,114,25,0,0,0,114,10,0,0,0,114,10,0,0,
- 0,114,11,0,0,0,114,26,0,0,0,68,1,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,120,112,114,62,122,18,105,109,112,111,114,116,32,123,33,
- 114,125,32,35,32,123,33,114,125,70,41,9,114,104,0,0,
- 0,114,27,0,0,0,114,14,0,0,0,114,21,0,0,0,
- 114,15,0,0,0,114,28,0,0,0,114,75,0,0,0,114,
- 99,0,0,0,114,105,0,0,0,41,3,114,19,0,0,0,
- 114,29,0,0,0,114,88,0,0,0,114,10,0,0,0,114,
- 10,0,0,0,114,11,0,0,0,114,30,0,0,0,65,1,
- 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,
+ 67,0,0,0,115,18,0,0,0,124,1,124,0,95,0,124,
+ 1,106,1,124,0,95,2,100,0,83,0,41,1,78,41,3,
+ 218,7,95,109,111,100,117,108,101,114,95,0,0,0,218,5,
+ 95,115,112,101,99,41,2,114,19,0,0,0,114,89,0,0,
+ 0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,
+ 114,20,0,0,0,54,1,0,0,115,4,0,0,0,0,1,
+ 6,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,0,3,0,0,0,67,
+ 0,0,0,115,28,0,0,0,100,1,124,0,106,0,95,1,
+ 124,0,106,2,116,3,106,4,124,0,106,0,106,5,60,0,
+ 100,0,83,0,41,2,78,84,41,6,114,104,0,0,0,218,
+ 13,95,105,110,105,116,105,97,108,105,122,105,110,103,114,103,
+ 0,0,0,114,14,0,0,0,114,21,0,0,0,114,15,0,
+ 0,0,41,1,114,19,0,0,0,114,10,0,0,0,114,10,
+ 0,0,0,114,11,0,0,0,114,23,0,0,0,58,1,0,
+ 0,115,4,0,0,0,0,4,8,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,
+ 3,0,0,0,17,0,0,0,71,0,0,0,115,98,0,0,
+ 0,122,82,124,0,106,0,125,2,116,1,100,1,100,2,132,
+ 0,124,1,68,0,131,1,131,1,114,64,121,14,116,2,106,
+ 3,124,2,106,4,61,0,87,0,113,80,4,0,116,5,107,
+ 10,114,60,1,0,1,0,1,0,89,0,113,80,88,0,110,
+ 16,116,6,100,3,124,2,106,4,124,2,106,7,131,3,1,
+ 0,87,0,100,0,100,4,124,0,106,0,95,8,88,0,100,
+ 0,83,0,41,5,78,99,1,0,0,0,0,0,0,0,2,
+ 0,0,0,3,0,0,0,115,0,0,0,115,22,0,0,0,
+ 124,0,93,14,125,1,124,1,100,0,107,9,86,0,1,0,
+ 113,2,100,0,83,0,41,1,78,114,10,0,0,0,41,2,
+ 114,24,0,0,0,114,25,0,0,0,114,10,0,0,0,114,
+ 10,0,0,0,114,11,0,0,0,114,26,0,0,0,68,1,
+ 0,0,115,2,0,0,0,4,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,78,41,6,114,1,0,0,0,114,0,0,
- 0,0,114,2,0,0,0,114,20,0,0,0,114,23,0,0,
- 0,114,30,0,0,0,114,10,0,0,0,114,10,0,0,0,
- 114,10,0,0,0,114,11,0,0,0,114,102,0,0,0,52,
- 1,0,0,115,6,0,0,0,12,2,12,4,12,7,114,102,
- 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,1,0,100,0,0,90,2,0,100,1,0,90,3,0,100,
- 2,0,100,3,0,100,4,0,100,3,0,100,5,0,100,3,
- 0,100,6,0,100,7,0,132,0,3,90,4,0,100,8,0,
- 100,9,0,132,0,0,90,5,0,100,10,0,100,11,0,132,
- 0,0,90,6,0,101,7,0,100,12,0,100,13,0,132,0,
- 0,131,1,0,90,8,0,101,8,0,106,9,0,100,14,0,
- 100,13,0,132,0,0,131,1,0,90,8,0,101,7,0,100,
- 15,0,100,16,0,132,0,0,131,1,0,90,10,0,101,7,
- 0,100,17,0,100,18,0,132,0,0,131,1,0,90,11,0,
- 101,11,0,106,9,0,100,19,0,100,18,0,132,0,0,131,
- 1,0,90,11,0,100,3,0,83,41,20,218,10,77,111,100,
- 117,108,101,83,112,101,99,97,208,5,0,0,84,104,101,32,
- 115,112,101,99,105,102,105,99,97,116,105,111,110,32,102,111,
- 114,32,97,32,109,111,100,117,108,101,44,32,117,115,101,100,
- 32,102,111,114,32,108,111,97,100,105,110,103,46,10,10,32,
- 32,32,32,65,32,109,111,100,117,108,101,39,115,32,115,112,
- 101,99,32,105,115,32,116,104,101,32,115,111,117,114,99,101,
- 32,102,111,114,32,105,110,102,111,114,109,97,116,105,111,110,
- 32,97,98,111,117,116,32,116,104,101,32,109,111,100,117,108,
- 101,46,32,32,70,111,114,10,32,32,32,32,100,97,116,97,
- 32,97,115,115,111,99,105,97,116,101,100,32,119,105,116,104,
- 32,116,104,101,32,109,111,100,117,108,101,44,32,105,110,99,
- 108,117,100,105,110,103,32,115,111,117,114,99,101,44,32,117,
- 115,101,32,116,104,101,32,115,112,101,99,39,115,10,32,32,
- 32,32,108,111,97,100,101,114,46,10,10,32,32,32,32,96,
- 110,97,109,101,96,32,105,115,32,116,104,101,32,97,98,115,
- 111,108,117,116,101,32,110,97,109,101,32,111,102,32,116,104,
- 101,32,109,111,100,117,108,101,46,32,32,96,108,111,97,100,
- 101,114,96,32,105,115,32,116,104,101,32,108,111,97,100,101,
- 114,10,32,32,32,32,116,111,32,117,115,101,32,119,104,101,
- 110,32,108,111,97,100,105,110,103,32,116,104,101,32,109,111,
- 100,117,108,101,46,32,32,96,112,97,114,101,110,116,96,32,
- 105,115,32,116,104,101,32,110,97,109,101,32,111,102,32,116,
- 104,101,10,32,32,32,32,112,97,99,107,97,103,101,32,116,
- 104,101,32,109,111,100,117,108,101,32,105,115,32,105,110,46,
- 32,32,84,104,101,32,112,97,114,101,110,116,32,105,115,32,
- 100,101,114,105,118,101,100,32,102,114,111,109,32,116,104,101,
- 32,110,97,109,101,46,10,10,32,32,32,32,96,105,115,95,
- 112,97,99,107,97,103,101,96,32,100,101,116,101,114,109,105,
- 110,101,115,32,105,102,32,116,104,101,32,109,111,100,117,108,
- 101,32,105,115,32,99,111,110,115,105,100,101,114,101,100,32,
- 97,32,112,97,99,107,97,103,101,32,111,114,10,32,32,32,
- 32,110,111,116,46,32,32,79,110,32,109,111,100,117,108,101,
- 115,32,116,104,105,115,32,105,115,32,114,101,102,108,101,99,
- 116,101,100,32,98,121,32,116,104,101,32,96,95,95,112,97,
- 116,104,95,95,96,32,97,116,116,114,105,98,117,116,101,46,
- 10,10,32,32,32,32,96,111,114,105,103,105,110,96,32,105,
- 115,32,116,104,101,32,115,112,101,99,105,102,105,99,32,108,
- 111,99,97,116,105,111,110,32,117,115,101,100,32,98,121,32,
- 116,104,101,32,108,111,97,100,101,114,32,102,114,111,109,32,
- 119,104,105,99,104,32,116,111,10,32,32,32,32,108,111,97,
- 100,32,116,104,101,32,109,111,100,117,108,101,44,32,105,102,
- 32,116,104,97,116,32,105,110,102,111,114,109,97,116,105,111,
- 110,32,105,115,32,97,118,97,105,108,97,98,108,101,46,32,
- 32,87,104,101,110,32,102,105,108,101,110,97,109,101,32,105,
- 115,10,32,32,32,32,115,101,116,44,32,111,114,105,103,105,
- 110,32,119,105,108,108,32,109,97,116,99,104,46,10,10,32,
- 32,32,32,96,104,97,115,95,108,111,99,97,116,105,111,110,
- 96,32,105,110,100,105,99,97,116,101,115,32,116,104,97,116,
- 32,97,32,115,112,101,99,39,115,32,34,111,114,105,103,105,
- 110,34,32,114,101,102,108,101,99,116,115,32,97,32,108,111,
- 99,97,116,105,111,110,46,10,32,32,32,32,87,104,101,110,
- 32,116,104,105,115,32,105,115,32,84,114,117,101,44,32,96,
- 95,95,102,105,108,101,95,95,96,32,97,116,116,114,105,98,
- 117,116,101,32,111,102,32,116,104,101,32,109,111,100,117,108,
- 101,32,105,115,32,115,101,116,46,10,10,32,32,32,32,96,
- 99,97,99,104,101,100,96,32,105,115,32,116,104,101,32,108,
- 111,99,97,116,105,111,110,32,111,102,32,116,104,101,32,99,
- 97,99,104,101,100,32,98,121,116,101,99,111,100,101,32,102,
- 105,108,101,44,32,105,102,32,97,110,121,46,32,32,73,116,
- 10,32,32,32,32,99,111,114,114,101,115,112,111,110,100,115,
- 32,116,111,32,116,104,101,32,96,95,95,99,97,99,104,101,
- 100,95,95,96,32,97,116,116,114,105,98,117,116,101,46,10,
- 10,32,32,32,32,96,115,117,98,109,111,100,117,108,101,95,
+ 120,105,116,95,95,46,60,108,111,99,97,108,115,62,46,60,
+ 103,101,110,101,120,112,114,62,122,18,105,109,112,111,114,116,
+ 32,123,33,114,125,32,35,32,123,33,114,125,70,41,9,114,
+ 104,0,0,0,114,27,0,0,0,114,14,0,0,0,114,21,
+ 0,0,0,114,15,0,0,0,114,28,0,0,0,114,75,0,
+ 0,0,114,99,0,0,0,114,105,0,0,0,41,3,114,19,
+ 0,0,0,114,29,0,0,0,114,88,0,0,0,114,10,0,
+ 0,0,114,10,0,0,0,114,11,0,0,0,114,30,0,0,
+ 0,65,1,0,0,115,18,0,0,0,0,1,2,1,6,1,
+ 18,1,2,1,14,1,14,1,8,2,20,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,1,0,0,0,
+ 114,0,0,0,0,114,2,0,0,0,114,20,0,0,0,114,
+ 23,0,0,0,114,30,0,0,0,114,10,0,0,0,114,10,
+ 0,0,0,114,10,0,0,0,114,11,0,0,0,114,102,0,
+ 0,0,52,1,0,0,115,6,0,0,0,8,2,8,4,8,
+ 7,114,102,0,0,0,99,0,0,0,0,0,0,0,0,0,
+ 0,0,0,4,0,0,0,64,0,0,0,115,114,0,0,0,
+ 101,0,90,1,100,0,90,2,100,1,90,3,100,2,100,2,
+ 100,2,100,3,156,3,100,4,100,5,132,2,90,4,100,6,
+ 100,7,132,0,90,5,100,8,100,9,132,0,90,6,101,7,
+ 100,10,100,11,132,0,131,1,90,8,101,8,106,9,100,12,
+ 100,11,132,0,131,1,90,8,101,7,100,13,100,14,132,0,
+ 131,1,90,10,101,7,100,15,100,16,132,0,131,1,90,11,
+ 101,11,106,9,100,17,100,16,132,0,131,1,90,11,100,2,
+ 83,0,41,18,218,10,77,111,100,117,108,101,83,112,101,99,
+ 97,208,5,0,0,84,104,101,32,115,112,101,99,105,102,105,
+ 99,97,116,105,111,110,32,102,111,114,32,97,32,109,111,100,
+ 117,108,101,44,32,117,115,101,100,32,102,111,114,32,108,111,
+ 97,100,105,110,103,46,10,10,32,32,32,32,65,32,109,111,
+ 100,117,108,101,39,115,32,115,112,101,99,32,105,115,32,116,
+ 104,101,32,115,111,117,114,99,101,32,102,111,114,32,105,110,
+ 102,111,114,109,97,116,105,111,110,32,97,98,111,117,116,32,
+ 116,104,101,32,109,111,100,117,108,101,46,32,32,70,111,114,
+ 10,32,32,32,32,100,97,116,97,32,97,115,115,111,99,105,
+ 97,116,101,100,32,119,105,116,104,32,116,104,101,32,109,111,
+ 100,117,108,101,44,32,105,110,99,108,117,100,105,110,103,32,
+ 115,111,117,114,99,101,44,32,117,115,101,32,116,104,101,32,
+ 115,112,101,99,39,115,10,32,32,32,32,108,111,97,100,101,
+ 114,46,10,10,32,32,32,32,96,110,97,109,101,96,32,105,
+ 115,32,116,104,101,32,97,98,115,111,108,117,116,101,32,110,
+ 97,109,101,32,111,102,32,116,104,101,32,109,111,100,117,108,
+ 101,46,32,32,96,108,111,97,100,101,114,96,32,105,115,32,
+ 116,104,101,32,108,111,97,100,101,114,10,32,32,32,32,116,
+ 111,32,117,115,101,32,119,104,101,110,32,108,111,97,100,105,
+ 110,103,32,116,104,101,32,109,111,100,117,108,101,46,32,32,
+ 96,112,97,114,101,110,116,96,32,105,115,32,116,104,101,32,
+ 110,97,109,101,32,111,102,32,116,104,101,10,32,32,32,32,
+ 112,97,99,107,97,103,101,32,116,104,101,32,109,111,100,117,
+ 108,101,32,105,115,32,105,110,46,32,32,84,104,101,32,112,
+ 97,114,101,110,116,32,105,115,32,100,101,114,105,118,101,100,
+ 32,102,114,111,109,32,116,104,101,32,110,97,109,101,46,10,
+ 10,32,32,32,32,96,105,115,95,112,97,99,107,97,103,101,
+ 96,32,100,101,116,101,114,109,105,110,101,115,32,105,102,32,
+ 116,104,101,32,109,111,100,117,108,101,32,105,115,32,99,111,
+ 110,115,105,100,101,114,101,100,32,97,32,112,97,99,107,97,
+ 103,101,32,111,114,10,32,32,32,32,110,111,116,46,32,32,
+ 79,110,32,109,111,100,117,108,101,115,32,116,104,105,115,32,
+ 105,115,32,114,101,102,108,101,99,116,101,100,32,98,121,32,
+ 116,104,101,32,96,95,95,112,97,116,104,95,95,96,32,97,
+ 116,116,114,105,98,117,116,101,46,10,10,32,32,32,32,96,
+ 111,114,105,103,105,110,96,32,105,115,32,116,104,101,32,115,
+ 112,101,99,105,102,105,99,32,108,111,99,97,116,105,111,110,
+ 32,117,115,101,100,32,98,121,32,116,104,101,32,108,111,97,
+ 100,101,114,32,102,114,111,109,32,119,104,105,99,104,32,116,
+ 111,10,32,32,32,32,108,111,97,100,32,116,104,101,32,109,
+ 111,100,117,108,101,44,32,105,102,32,116,104,97,116,32,105,
+ 110,102,111,114,109,97,116,105,111,110,32,105,115,32,97,118,
+ 97,105,108,97,98,108,101,46,32,32,87,104,101,110,32,102,
+ 105,108,101,110,97,109,101,32,105,115,10,32,32,32,32,115,
+ 101,116,44,32,111,114,105,103,105,110,32,119,105,108,108,32,
+ 109,97,116,99,104,46,10,10,32,32,32,32,96,104,97,115,
+ 95,108,111,99,97,116,105,111,110,96,32,105,110,100,105,99,
+ 97,116,101,115,32,116,104,97,116,32,97,32,115,112,101,99,
+ 39,115,32,34,111,114,105,103,105,110,34,32,114,101,102,108,
+ 101,99,116,115,32,97,32,108,111,99,97,116,105,111,110,46,
+ 10,32,32,32,32,87,104,101,110,32,116,104,105,115,32,105,
+ 115,32,84,114,117,101,44,32,96,95,95,102,105,108,101,95,
+ 95,96,32,97,116,116,114,105,98,117,116,101,32,111,102,32,
+ 116,104,101,32,109,111,100,117,108,101,32,105,115,32,115,101,
+ 116,46,10,10,32,32,32,32,96,99,97,99,104,101,100,96,
+ 32,105,115,32,116,104,101,32,108,111,99,97,116,105,111,110,
+ 32,111,102,32,116,104,101,32,99,97,99,104,101,100,32,98,
+ 121,116,101,99,111,100,101,32,102,105,108,101,44,32,105,102,
+ 32,97,110,121,46,32,32,73,116,10,32,32,32,32,99,111,
+ 114,114,101,115,112,111,110,100,115,32,116,111,32,116,104,101,
+ 32,96,95,95,99,97,99,104,101,100,95,95,96,32,97,116,
+ 116,114,105,98,117,116,101,46,10,10,32,32,32,32,96,115,
+ 117,98,109,111,100,117,108,101,95,115,101,97,114,99,104,95,
+ 108,111,99,97,116,105,111,110,115,96,32,105,115,32,116,104,
+ 101,32,115,101,113,117,101,110,99,101,32,111,102,32,112,97,
+ 116,104,32,101,110,116,114,105,101,115,32,116,111,10,32,32,
+ 32,32,115,101,97,114,99,104,32,119,104,101,110,32,105,109,
+ 112,111,114,116,105,110,103,32,115,117,98,109,111,100,117,108,
+ 101,115,46,32,32,73,102,32,115,101,116,44,32,105,115,95,
+ 112,97,99,107,97,103,101,32,115,104,111,117,108,100,32,98,
+ 101,10,32,32,32,32,84,114,117,101,45,45,97,110,100,32,
+ 70,97,108,115,101,32,111,116,104,101,114,119,105,115,101,46,
+ 10,10,32,32,32,32,80,97,99,107,97,103,101,115,32,97,
+ 114,101,32,115,105,109,112,108,121,32,109,111,100,117,108,101,
+ 115,32,116,104,97,116,32,40,109,97,121,41,32,104,97,118,
+ 101,32,115,117,98,109,111,100,117,108,101,115,46,32,32,73,
+ 102,32,97,32,115,112,101,99,10,32,32,32,32,104,97,115,
+ 32,97,32,110,111,110,45,78,111,110,101,32,118,97,108,117,
+ 101,32,105,110,32,96,115,117,98,109,111,100,117,108,101,95,
115,101,97,114,99,104,95,108,111,99,97,116,105,111,110,115,
- 96,32,105,115,32,116,104,101,32,115,101,113,117,101,110,99,
- 101,32,111,102,32,112,97,116,104,32,101,110,116,114,105,101,
- 115,32,116,111,10,32,32,32,32,115,101,97,114,99,104,32,
- 119,104,101,110,32,105,109,112,111,114,116,105,110,103,32,115,
- 117,98,109,111,100,117,108,101,115,46,32,32,73,102,32,115,
- 101,116,44,32,105,115,95,112,97,99,107,97,103,101,32,115,
- 104,111,117,108,100,32,98,101,10,32,32,32,32,84,114,117,
- 101,45,45,97,110,100,32,70,97,108,115,101,32,111,116,104,
- 101,114,119,105,115,101,46,10,10,32,32,32,32,80,97,99,
- 107,97,103,101,115,32,97,114,101,32,115,105,109,112,108,121,
- 32,109,111,100,117,108,101,115,32,116,104,97,116,32,40,109,
- 97,121,41,32,104,97,118,101,32,115,117,98,109,111,100,117,
- 108,101,115,46,32,32,73,102,32,97,32,115,112,101,99,10,
- 32,32,32,32,104,97,115,32,97,32,110,111,110,45,78,111,
- 110,101,32,118,97,108,117,101,32,105,110,32,96,115,117,98,
- 109,111,100,117,108,101,95,115,101,97,114,99,104,95,108,111,
- 99,97,116,105,111,110,115,96,44,32,116,104,101,32,105,109,
- 112,111,114,116,10,32,32,32,32,115,121,115,116,101,109,32,
- 119,105,108,108,32,99,111,110,115,105,100,101,114,32,109,111,
- 100,117,108,101,115,32,108,111,97,100,101,100,32,102,114,111,
- 109,32,116,104,101,32,115,112,101,99,32,97,115,32,112,97,
- 99,107,97,103,101,115,46,10,10,32,32,32,32,79,110,108,
- 121,32,102,105,110,100,101,114,115,32,40,115,101,101,32,105,
- 109,112,111,114,116,108,105,98,46,97,98,99,46,77,101,116,
- 97,80,97,116,104,70,105,110,100,101,114,32,97,110,100,10,
- 32,32,32,32,105,109,112,111,114,116,108,105,98,46,97,98,
- 99,46,80,97,116,104,69,110,116,114,121,70,105,110,100,101,
- 114,41,32,115,104,111,117,108,100,32,109,111,100,105,102,121,
- 32,77,111,100,117,108,101,83,112,101,99,32,105,110,115,116,
- 97,110,99,101,115,46,10,10,32,32,32,32,218,6,111,114,
- 105,103,105,110,78,218,12,108,111,97,100,101,114,95,115,116,
- 97,116,101,218,10,105,115,95,112,97,99,107,97,103,101,99,
- 3,0,0,0,3,0,0,0,6,0,0,0,2,0,0,0,
- 67,0,0,0,115,79,0,0,0,124,1,0,124,0,0,95,
- 0,0,124,2,0,124,0,0,95,1,0,124,3,0,124,0,
- 0,95,2,0,124,4,0,124,0,0,95,3,0,124,5,0,
- 114,48,0,103,0,0,110,3,0,100,0,0,124,0,0,95,
- 4,0,100,1,0,124,0,0,95,5,0,100,0,0,124,0,
- 0,95,6,0,100,0,0,83,41,2,78,70,41,7,114,15,
- 0,0,0,114,99,0,0,0,114,107,0,0,0,114,108,0,
- 0,0,218,26,115,117,98,109,111,100,117,108,101,95,115,101,
- 97,114,99,104,95,108,111,99,97,116,105,111,110,115,218,13,
- 95,115,101,116,95,102,105,108,101,97,116,116,114,218,7,95,
- 99,97,99,104,101,100,41,6,114,19,0,0,0,114,15,0,
- 0,0,114,99,0,0,0,114,107,0,0,0,114,108,0,0,
- 0,114,109,0,0,0,114,10,0,0,0,114,10,0,0,0,
- 114,11,0,0,0,114,20,0,0,0,116,1,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,0,0,4,0,0,0,67,0,0,0,115,147,0,0,0,
- 100,1,0,106,0,0,124,0,0,106,1,0,131,1,0,100,
- 2,0,106,0,0,124,0,0,106,2,0,131,1,0,103,2,
- 0,125,1,0,124,0,0,106,3,0,100,0,0,107,9,0,
- 114,76,0,124,1,0,106,4,0,100,3,0,106,0,0,124,
- 0,0,106,3,0,131,1,0,131,1,0,1,124,0,0,106,
- 5,0,100,0,0,107,9,0,114,116,0,124,1,0,106,4,
- 0,100,4,0,106,0,0,124,0,0,106,5,0,131,1,0,
- 131,1,0,1,100,5,0,106,0,0,124,0,0,106,6,0,
- 106,7,0,100,6,0,106,8,0,124,1,0,131,1,0,131,
- 2,0,83,41,7,78,122,9,110,97,109,101,61,123,33,114,
- 125,122,11,108,111,97,100,101,114,61,123,33,114,125,122,11,
- 111,114,105,103,105,110,61,123,33,114,125,122,29,115,117,98,
- 109,111,100,117,108,101,95,115,101,97,114,99,104,95,108,111,
- 99,97,116,105,111,110,115,61,123,125,122,6,123,125,40,123,
- 125,41,122,2,44,32,41,9,114,50,0,0,0,114,15,0,
- 0,0,114,99,0,0,0,114,107,0,0,0,218,6,97,112,
- 112,101,110,100,114,110,0,0,0,218,9,95,95,99,108,97,
- 115,115,95,95,114,1,0,0,0,218,4,106,111,105,110,41,
- 2,114,19,0,0,0,114,29,0,0,0,114,10,0,0,0,
- 114,10,0,0,0,114,11,0,0,0,114,52,0,0,0,128,
- 1,0,0,115,16,0,0,0,0,1,15,1,21,1,15,1,
- 25,1,15,1,12,1,13,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,11,0,0,0,67,0,
- 0,0,115,145,0,0,0,124,0,0,106,0,0,125,2,0,
- 121,107,0,124,0,0,106,1,0,124,1,0,106,1,0,107,
- 2,0,111,114,0,124,0,0,106,2,0,124,1,0,106,2,
- 0,107,2,0,111,114,0,124,0,0,106,3,0,124,1,0,
- 106,3,0,107,2,0,111,114,0,124,2,0,124,1,0,106,
- 0,0,107,2,0,111,114,0,124,0,0,106,4,0,124,1,
- 0,106,4,0,107,2,0,111,114,0,124,0,0,106,5,0,
- 124,1,0,106,5,0,107,2,0,83,87,110,22,0,4,116,
- 6,0,107,10,0,114,140,0,1,1,1,100,1,0,83,89,
- 110,1,0,88,100,0,0,83,41,2,78,70,41,7,114,110,
- 0,0,0,114,15,0,0,0,114,99,0,0,0,114,107,0,
- 0,0,218,6,99,97,99,104,101,100,218,12,104,97,115,95,
- 108,111,99,97,116,105,111,110,114,96,0,0,0,41,3,114,
- 19,0,0,0,90,5,111,116,104,101,114,90,4,115,109,115,
- 108,114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,
- 218,6,95,95,101,113,95,95,138,1,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,0,0,0,0,
- 0,1,0,0,0,2,0,0,0,67,0,0,0,115,85,0,
- 0,0,124,0,0,106,0,0,100,0,0,107,8,0,114,78,
- 0,124,0,0,106,1,0,100,0,0,107,9,0,114,78,0,
- 124,0,0,106,2,0,114,78,0,116,3,0,100,0,0,107,
- 8,0,114,57,0,116,4,0,130,1,0,116,3,0,106,5,
- 0,124,0,0,106,1,0,131,1,0,124,0,0,95,0,0,
- 124,0,0,106,0,0,83,41,1,78,41,6,114,112,0,0,
- 0,114,107,0,0,0,114,111,0,0,0,218,19,95,98,111,
- 111,116,115,116,114,97,112,95,101,120,116,101,114,110,97,108,
- 218,19,78,111,116,73,109,112,108,101,109,101,110,116,101,100,
- 69,114,114,111,114,90,11,95,103,101,116,95,99,97,99,104,
- 101,100,41,1,114,19,0,0,0,114,10,0,0,0,114,10,
- 0,0,0,114,11,0,0,0,114,116,0,0,0,150,1,0,
- 0,115,12,0,0,0,0,2,15,1,24,1,12,1,6,1,
- 21,1,122,17,77,111,100,117,108,101,83,112,101,99,46,99,
- 97,99,104,101,100,99,2,0,0,0,0,0,0,0,2,0,
- 0,0,2,0,0,0,67,0,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,112,0,0,0,41,2,114,19,0,0,0,114,116,0,
- 0,0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,
- 0,114,116,0,0,0,159,1,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,35,0,124,0,0,106,1,0,
- 106,2,0,100,2,0,131,1,0,100,3,0,25,83,124,0,
- 0,106,1,0,83,100,1,0,83,41,4,122,32,84,104,101,
- 32,110,97,109,101,32,111,102,32,116,104,101,32,109,111,100,
- 117,108,101,39,115,32,112,97,114,101,110,116,46,78,218,1,
- 46,114,33,0,0,0,41,3,114,110,0,0,0,114,15,0,
- 0,0,218,10,114,112,97,114,116,105,116,105,111,110,41,1,
- 114,19,0,0,0,114,10,0,0,0,114,10,0,0,0,114,
- 11,0,0,0,218,6,112,97,114,101,110,116,163,1,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,111,0,0,0,41,1,114,19,0,0,0,
+ 96,44,32,116,104,101,32,105,109,112,111,114,116,10,32,32,
+ 32,32,115,121,115,116,101,109,32,119,105,108,108,32,99,111,
+ 110,115,105,100,101,114,32,109,111,100,117,108,101,115,32,108,
+ 111,97,100,101,100,32,102,114,111,109,32,116,104,101,32,115,
+ 112,101,99,32,97,115,32,112,97,99,107,97,103,101,115,46,
+ 10,10,32,32,32,32,79,110,108,121,32,102,105,110,100,101,
+ 114,115,32,40,115,101,101,32,105,109,112,111,114,116,108,105,
+ 98,46,97,98,99,46,77,101,116,97,80,97,116,104,70,105,
+ 110,100,101,114,32,97,110,100,10,32,32,32,32,105,109,112,
+ 111,114,116,108,105,98,46,97,98,99,46,80,97,116,104,69,
+ 110,116,114,121,70,105,110,100,101,114,41,32,115,104,111,117,
+ 108,100,32,109,111,100,105,102,121,32,77,111,100,117,108,101,
+ 83,112,101,99,32,105,110,115,116,97,110,99,101,115,46,10,
+ 10,32,32,32,32,78,41,3,218,6,111,114,105,103,105,110,
+ 218,12,108,111,97,100,101,114,95,115,116,97,116,101,218,10,
+ 105,115,95,112,97,99,107,97,103,101,99,3,0,0,0,3,
+ 0,0,0,6,0,0,0,2,0,0,0,67,0,0,0,115,
+ 54,0,0,0,124,1,124,0,95,0,124,2,124,0,95,1,
+ 124,3,124,0,95,2,124,4,124,0,95,3,124,5,114,32,
+ 103,0,110,2,100,0,124,0,95,4,100,1,124,0,95,5,
+ 100,0,124,0,95,6,100,0,83,0,41,2,78,70,41,7,
+ 114,15,0,0,0,114,99,0,0,0,114,107,0,0,0,114,
+ 108,0,0,0,218,26,115,117,98,109,111,100,117,108,101,95,
+ 115,101,97,114,99,104,95,108,111,99,97,116,105,111,110,115,
+ 218,13,95,115,101,116,95,102,105,108,101,97,116,116,114,218,
+ 7,95,99,97,99,104,101,100,41,6,114,19,0,0,0,114,
+ 15,0,0,0,114,99,0,0,0,114,107,0,0,0,114,108,
+ 0,0,0,114,109,0,0,0,114,10,0,0,0,114,10,0,
+ 0,0,114,11,0,0,0,114,20,0,0,0,116,1,0,0,
+ 115,14,0,0,0,0,2,6,1,6,1,6,1,6,1,14,
+ 3,6,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,0,0,4,0,0,0,67,0,0,0,115,102,0,
+ 0,0,100,1,106,0,124,0,106,1,131,1,100,2,106,0,
+ 124,0,106,2,131,1,103,2,125,1,124,0,106,3,100,0,
+ 107,9,114,52,124,1,106,4,100,3,106,0,124,0,106,3,
+ 131,1,131,1,1,0,124,0,106,5,100,0,107,9,114,80,
+ 124,1,106,4,100,4,106,0,124,0,106,5,131,1,131,1,
+ 1,0,100,5,106,0,124,0,106,6,106,7,100,6,106,8,
+ 124,1,131,1,131,2,83,0,41,7,78,122,9,110,97,109,
+ 101,61,123,33,114,125,122,11,108,111,97,100,101,114,61,123,
+ 33,114,125,122,11,111,114,105,103,105,110,61,123,33,114,125,
+ 122,29,115,117,98,109,111,100,117,108,101,95,115,101,97,114,
+ 99,104,95,108,111,99,97,116,105,111,110,115,61,123,125,122,
+ 6,123,125,40,123,125,41,122,2,44,32,41,9,114,50,0,
+ 0,0,114,15,0,0,0,114,99,0,0,0,114,107,0,0,
+ 0,218,6,97,112,112,101,110,100,114,110,0,0,0,218,9,
+ 95,95,99,108,97,115,115,95,95,114,1,0,0,0,218,4,
+ 106,111,105,110,41,2,114,19,0,0,0,114,29,0,0,0,
114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,114,
- 117,0,0,0,171,1,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,115,19,0,
- 0,0,116,0,0,124,1,0,131,1,0,124,0,0,95,1,
- 0,100,0,0,83,41,1,78,41,2,218,4,98,111,111,108,
- 114,111,0,0,0,41,2,114,19,0,0,0,218,5,118,97,
- 108,117,101,114,10,0,0,0,114,10,0,0,0,114,11,0,
- 0,0,114,117,0,0,0,175,1,0,0,115,2,0,0,0,
- 0,2,41,12,114,1,0,0,0,114,0,0,0,0,114,2,
- 0,0,0,114,3,0,0,0,114,20,0,0,0,114,52,0,
- 0,0,114,118,0,0,0,218,8,112,114,111,112,101,114,116,
- 121,114,116,0,0,0,218,6,115,101,116,116,101,114,114,123,
- 0,0,0,114,117,0,0,0,114,10,0,0,0,114,10,0,
- 0,0,114,10,0,0,0,114,11,0,0,0,114,106,0,0,
- 0,79,1,0,0,115,20,0,0,0,12,35,6,2,15,1,
- 15,11,12,10,12,12,18,9,21,4,18,8,18,4,114,106,
- 0,0,0,114,107,0,0,0,114,109,0,0,0,99,2,0,
+ 52,0,0,0,128,1,0,0,115,16,0,0,0,0,1,10,
+ 1,14,1,10,1,18,1,10,1,8,1,10,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,11,
+ 0,0,0,67,0,0,0,115,102,0,0,0,124,0,106,0,
+ 125,2,121,70,124,0,106,1,124,1,106,1,107,2,111,76,
+ 124,0,106,2,124,1,106,2,107,2,111,76,124,0,106,3,
+ 124,1,106,3,107,2,111,76,124,2,124,1,106,0,107,2,
+ 111,76,124,0,106,4,124,1,106,4,107,2,111,76,124,0,
+ 106,5,124,1,106,5,107,2,83,0,4,0,116,6,107,10,
+ 114,96,1,0,1,0,1,0,100,1,83,0,88,0,100,0,
+ 83,0,41,2,78,70,41,7,114,110,0,0,0,114,15,0,
+ 0,0,114,99,0,0,0,114,107,0,0,0,218,6,99,97,
+ 99,104,101,100,218,12,104,97,115,95,108,111,99,97,116,105,
+ 111,110,114,96,0,0,0,41,3,114,19,0,0,0,90,5,
+ 111,116,104,101,114,90,4,115,109,115,108,114,10,0,0,0,
+ 114,10,0,0,0,114,11,0,0,0,218,6,95,95,101,113,
+ 95,95,138,1,0,0,115,20,0,0,0,0,1,6,1,2,
+ 1,12,1,12,1,12,1,10,1,12,1,12,1,14,1,122,
+ 17,77,111,100,117,108,101,83,112,101,99,46,95,95,101,113,
+ 95,95,99,1,0,0,0,0,0,0,0,1,0,0,0,2,
+ 0,0,0,67,0,0,0,115,58,0,0,0,124,0,106,0,
+ 100,0,107,8,114,52,124,0,106,1,100,0,107,9,114,52,
+ 124,0,106,2,114,52,116,3,100,0,107,8,114,38,116,4,
+ 130,1,116,3,106,5,124,0,106,1,131,1,124,0,95,0,
+ 124,0,106,0,83,0,41,1,78,41,6,114,112,0,0,0,
+ 114,107,0,0,0,114,111,0,0,0,218,19,95,98,111,111,
+ 116,115,116,114,97,112,95,101,120,116,101,114,110,97,108,218,
+ 19,78,111,116,73,109,112,108,101,109,101,110,116,101,100,69,
+ 114,114,111,114,90,11,95,103,101,116,95,99,97,99,104,101,
+ 100,41,1,114,19,0,0,0,114,10,0,0,0,114,10,0,
+ 0,0,114,11,0,0,0,114,116,0,0,0,150,1,0,0,
+ 115,12,0,0,0,0,2,10,1,16,1,8,1,4,1,14,
+ 1,122,17,77,111,100,117,108,101,83,112,101,99,46,99,97,
+ 99,104,101,100,99,2,0,0,0,0,0,0,0,2,0,0,
+ 0,2,0,0,0,67,0,0,0,115,10,0,0,0,124,1,
+ 124,0,95,0,100,0,83,0,41,1,78,41,1,114,112,0,
+ 0,0,41,2,114,19,0,0,0,114,116,0,0,0,114,10,
+ 0,0,0,114,10,0,0,0,114,11,0,0,0,114,116,0,
+ 0,0,159,1,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,38,0,0,0,124,0,106,0,100,1,107,8,114,
+ 28,124,0,106,1,106,2,100,2,131,1,100,3,25,0,83,
+ 0,110,6,124,0,106,1,83,0,100,1,83,0,41,4,122,
+ 32,84,104,101,32,110,97,109,101,32,111,102,32,116,104,101,
+ 32,109,111,100,117,108,101,39,115,32,112,97,114,101,110,116,
+ 46,78,218,1,46,114,33,0,0,0,41,3,114,110,0,0,
+ 0,114,15,0,0,0,218,10,114,112,97,114,116,105,116,105,
+ 111,110,41,1,114,19,0,0,0,114,10,0,0,0,114,10,
+ 0,0,0,114,11,0,0,0,218,6,112,97,114,101,110,116,
+ 163,1,0,0,115,6,0,0,0,0,3,10,1,18,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,6,0,0,0,124,0,106,0,
+ 83,0,41,1,78,41,1,114,111,0,0,0,41,1,114,19,
+ 0,0,0,114,10,0,0,0,114,10,0,0,0,114,11,0,
+ 0,0,114,117,0,0,0,171,1,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,
+ 115,14,0,0,0,116,0,124,1,131,1,124,0,95,1,100,
+ 0,83,0,41,1,78,41,2,218,4,98,111,111,108,114,111,
+ 0,0,0,41,2,114,19,0,0,0,218,5,118,97,108,117,
+ 101,114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,
+ 114,117,0,0,0,175,1,0,0,115,2,0,0,0,0,2,
+ 41,12,114,1,0,0,0,114,0,0,0,0,114,2,0,0,
+ 0,114,3,0,0,0,114,20,0,0,0,114,52,0,0,0,
+ 114,118,0,0,0,218,8,112,114,111,112,101,114,116,121,114,
+ 116,0,0,0,218,6,115,101,116,116,101,114,114,123,0,0,
+ 0,114,117,0,0,0,114,10,0,0,0,114,10,0,0,0,
+ 114,10,0,0,0,114,11,0,0,0,114,106,0,0,0,79,
+ 1,0,0,115,20,0,0,0,8,35,4,2,4,1,14,11,
+ 8,10,8,12,12,9,14,4,12,8,12,4,114,106,0,0,
+ 0,41,2,114,107,0,0,0,114,109,0,0,0,99,2,0,
0,0,2,0,0,0,6,0,0,0,15,0,0,0,67,0,
- 0,0,115,217,0,0,0,116,0,0,124,1,0,100,1,0,
- 131,2,0,114,110,0,116,1,0,100,2,0,107,8,0,114,
- 33,0,116,2,0,130,1,0,116,1,0,106,3,0,125,4,
- 0,124,3,0,100,2,0,107,8,0,114,70,0,124,4,0,
- 124,0,0,100,3,0,124,1,0,131,1,1,83,124,3,0,
- 114,82,0,103,0,0,110,3,0,100,2,0,125,5,0,124,
- 4,0,124,0,0,100,3,0,124,1,0,100,4,0,124,5,
- 0,131,1,2,83,124,3,0,100,2,0,107,8,0,114,192,
- 0,116,0,0,124,1,0,100,5,0,131,2,0,114,186,0,
- 121,19,0,124,1,0,106,4,0,124,0,0,131,1,0,125,
- 3,0,87,113,192,0,4,116,5,0,107,10,0,114,182,0,
- 1,1,1,100,2,0,125,3,0,89,113,192,0,88,110,6,
- 0,100,6,0,125,3,0,116,6,0,124,0,0,124,1,0,
- 100,7,0,124,2,0,100,5,0,124,3,0,131,2,2,83,
- 41,8,122,53,82,101,116,117,114,110,32,97,32,109,111,100,
- 117,108,101,32,115,112,101,99,32,98,97,115,101,100,32,111,
- 110,32,118,97,114,105,111,117,115,32,108,111,97,100,101,114,
- 32,109,101,116,104,111,100,115,46,90,12,103,101,116,95,102,
- 105,108,101,110,97,109,101,78,114,99,0,0,0,114,110,0,
- 0,0,114,109,0,0,0,70,114,107,0,0,0,41,7,114,
- 4,0,0,0,114,119,0,0,0,114,120,0,0,0,218,23,
- 115,112,101,99,95,102,114,111,109,95,102,105,108,101,95,108,
- 111,99,97,116,105,111,110,114,109,0,0,0,114,77,0,0,
- 0,114,106,0,0,0,41,6,114,15,0,0,0,114,99,0,
- 0,0,114,107,0,0,0,114,109,0,0,0,114,128,0,0,
- 0,90,6,115,101,97,114,99,104,114,10,0,0,0,114,10,
- 0,0,0,114,11,0,0,0,114,85,0,0,0,180,1,0,
- 0,115,34,0,0,0,0,2,15,1,12,1,6,1,9,2,
- 12,1,16,1,18,1,15,1,7,2,12,1,15,1,3,1,
- 19,1,13,1,14,3,6,2,114,85,0,0,0,99,3,0,
- 0,0,0,0,0,0,8,0,0,0,53,0,0,0,67,0,
- 0,0,115,118,1,0,0,121,13,0,124,0,0,106,0,0,
- 125,3,0,87,110,18,0,4,116,1,0,107,10,0,114,33,
- 0,1,1,1,89,110,17,0,88,124,3,0,100,0,0,107,
- 9,0,114,50,0,124,3,0,83,124,0,0,106,2,0,125,
- 4,0,124,1,0,100,0,0,107,8,0,114,105,0,121,13,
- 0,124,0,0,106,3,0,125,1,0,87,110,18,0,4,116,
- 1,0,107,10,0,114,104,0,1,1,1,89,110,1,0,88,
- 121,13,0,124,0,0,106,4,0,125,5,0,87,110,24,0,
- 4,116,1,0,107,10,0,114,144,0,1,1,1,100,0,0,
- 125,5,0,89,110,1,0,88,124,2,0,100,0,0,107,8,
- 0,114,218,0,124,5,0,100,0,0,107,8,0,114,212,0,
- 121,13,0,124,1,0,106,5,0,125,2,0,87,113,218,0,
- 4,116,1,0,107,10,0,114,208,0,1,1,1,100,0,0,
- 125,2,0,89,113,218,0,88,110,6,0,124,5,0,125,2,
- 0,121,13,0,124,0,0,106,6,0,125,6,0,87,110,24,
- 0,4,116,1,0,107,10,0,114,1,1,1,1,1,100,0,
- 0,125,6,0,89,110,1,0,88,121,19,0,116,7,0,124,
- 0,0,106,8,0,131,1,0,125,7,0,87,110,24,0,4,
- 116,1,0,107,10,0,114,47,1,1,1,1,100,0,0,125,
- 7,0,89,110,1,0,88,116,9,0,124,4,0,124,1,0,
- 100,1,0,124,2,0,131,2,1,125,3,0,124,5,0,100,
- 0,0,107,8,0,114,87,1,100,2,0,110,3,0,100,3,
- 0,124,3,0,95,10,0,124,6,0,124,3,0,95,11,0,
- 124,7,0,124,3,0,95,12,0,124,3,0,83,41,4,78,
- 114,107,0,0,0,70,84,41,13,114,95,0,0,0,114,96,
- 0,0,0,114,1,0,0,0,114,91,0,0,0,114,98,0,
- 0,0,90,7,95,79,82,73,71,73,78,218,10,95,95,99,
- 97,99,104,101,100,95,95,218,4,108,105,115,116,218,8,95,
- 95,112,97,116,104,95,95,114,106,0,0,0,114,111,0,0,
- 0,114,116,0,0,0,114,110,0,0,0,41,8,114,89,0,
- 0,0,114,99,0,0,0,114,107,0,0,0,114,88,0,0,
- 0,114,15,0,0,0,90,8,108,111,99,97,116,105,111,110,
- 114,116,0,0,0,114,110,0,0,0,114,10,0,0,0,114,
- 10,0,0,0,114,11,0,0,0,218,17,95,115,112,101,99,
- 95,102,114,111,109,95,109,111,100,117,108,101,209,1,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,5,1,3,
- 1,13,1,13,1,11,1,12,1,12,1,3,1,13,1,13,
- 1,14,2,6,1,3,1,13,1,13,1,11,1,3,1,19,
- 1,13,1,11,2,21,1,27,1,9,1,9,1,114,132,0,
- 0,0,218,8,111,118,101,114,114,105,100,101,70,99,2,0,
- 0,0,1,0,0,0,5,0,0,0,59,0,0,0,67,0,
- 0,0,115,54,2,0,0,124,2,0,115,30,0,116,0,0,
- 124,1,0,100,1,0,100,0,0,131,3,0,100,0,0,107,
- 8,0,114,67,0,121,16,0,124,0,0,106,1,0,124,1,
- 0,95,2,0,87,110,18,0,4,116,3,0,107,10,0,114,
- 66,0,1,1,1,89,110,1,0,88,124,2,0,115,97,0,
- 116,0,0,124,1,0,100,2,0,100,0,0,131,3,0,100,
- 0,0,107,8,0,114,221,0,124,0,0,106,4,0,125,3,
- 0,124,3,0,100,0,0,107,8,0,114,187,0,124,0,0,
- 106,5,0,100,0,0,107,9,0,114,187,0,116,6,0,100,
- 0,0,107,8,0,114,151,0,116,7,0,130,1,0,116,6,
- 0,106,8,0,125,4,0,124,4,0,106,9,0,124,4,0,
- 131,1,0,125,3,0,124,0,0,106,5,0,124,3,0,95,
- 10,0,121,13,0,124,3,0,124,1,0,95,11,0,87,110,
- 18,0,4,116,3,0,107,10,0,114,220,0,1,1,1,89,
- 110,1,0,88,124,2,0,115,251,0,116,0,0,124,1,0,
- 100,3,0,100,0,0,131,3,0,100,0,0,107,8,0,114,
- 32,1,121,16,0,124,0,0,106,12,0,124,1,0,95,13,
- 0,87,110,18,0,4,116,3,0,107,10,0,114,31,1,1,
- 1,1,89,110,1,0,88,121,13,0,124,0,0,124,1,0,
- 95,14,0,87,110,18,0,4,116,3,0,107,10,0,114,65,
- 1,1,1,1,89,110,1,0,88,124,2,0,115,96,1,116,
- 0,0,124,1,0,100,4,0,100,0,0,131,3,0,100,0,
- 0,107,8,0,114,148,1,124,0,0,106,5,0,100,0,0,
- 107,9,0,114,148,1,121,16,0,124,0,0,106,5,0,124,
- 1,0,95,15,0,87,110,18,0,4,116,3,0,107,10,0,
- 114,147,1,1,1,1,89,110,1,0,88,124,0,0,106,16,
- 0,114,50,2,124,2,0,115,187,1,116,0,0,124,1,0,
- 100,5,0,100,0,0,131,3,0,100,0,0,107,8,0,114,
- 224,1,121,16,0,124,0,0,106,17,0,124,1,0,95,18,
- 0,87,110,18,0,4,116,3,0,107,10,0,114,223,1,1,
- 1,1,89,110,1,0,88,124,2,0,115,254,1,116,0,0,
- 124,1,0,100,6,0,100,0,0,131,3,0,100,0,0,107,
- 8,0,114,50,2,124,0,0,106,19,0,100,0,0,107,9,
- 0,114,50,2,121,16,0,124,0,0,106,19,0,124,1,0,
- 95,20,0,87,110,18,0,4,116,3,0,107,10,0,114,49,
- 2,1,1,1,89,110,1,0,88,124,1,0,83,41,7,78,
- 114,1,0,0,0,114,91,0,0,0,218,11,95,95,112,97,
- 99,107,97,103,101,95,95,114,131,0,0,0,114,98,0,0,
- 0,114,129,0,0,0,41,21,114,6,0,0,0,114,15,0,
- 0,0,114,1,0,0,0,114,96,0,0,0,114,99,0,0,
- 0,114,110,0,0,0,114,119,0,0,0,114,120,0,0,0,
- 218,16,95,78,97,109,101,115,112,97,99,101,76,111,97,100,
- 101,114,218,7,95,95,110,101,119,95,95,90,5,95,112,97,
- 116,104,114,91,0,0,0,114,123,0,0,0,114,134,0,0,
- 0,114,95,0,0,0,114,131,0,0,0,114,117,0,0,0,
- 114,107,0,0,0,114,98,0,0,0,114,116,0,0,0,114,
- 129,0,0,0,41,5,114,88,0,0,0,114,89,0,0,0,
- 114,133,0,0,0,114,99,0,0,0,114,135,0,0,0,114,
- 10,0,0,0,114,10,0,0,0,114,11,0,0,0,218,18,
- 95,105,110,105,116,95,109,111,100,117,108,101,95,97,116,116,
- 114,115,254,1,0,0,115,92,0,0,0,0,4,30,1,3,
- 1,16,1,13,1,5,2,30,1,9,1,12,2,15,1,12,
- 1,6,1,9,2,15,1,12,1,3,1,13,1,13,1,5,
- 2,30,1,3,1,16,1,13,1,5,2,3,1,13,1,13,
- 1,5,2,30,1,15,1,3,1,16,1,13,1,5,2,9,
- 1,30,1,3,1,16,1,13,1,5,2,30,1,15,1,3,
- 1,16,1,13,1,5,1,114,137,0,0,0,99,1,0,0,
- 0,0,0,0,0,2,0,0,0,5,0,0,0,67,0,0,
- 0,115,129,0,0,0,100,1,0,125,1,0,116,0,0,124,
- 0,0,106,1,0,100,2,0,131,2,0,114,45,0,124,0,
- 0,106,1,0,106,2,0,124,0,0,131,1,0,125,1,0,
- 110,40,0,116,0,0,124,0,0,106,1,0,100,3,0,131,
- 2,0,114,85,0,116,3,0,106,4,0,100,4,0,116,5,
- 0,100,5,0,100,6,0,131,2,1,1,124,1,0,100,1,
- 0,107,8,0,114,112,0,116,6,0,124,0,0,106,7,0,
- 131,1,0,125,1,0,116,8,0,124,0,0,124,1,0,131,
- 2,0,1,124,1,0,83,41,7,122,43,67,114,101,97,116,
- 101,32,97,32,109,111,100,117,108,101,32,98,97,115,101,100,
- 32,111,110,32,116,104,101,32,112,114,111,118,105,100,101,100,
- 32,115,112,101,99,46,78,218,13,99,114,101,97,116,101,95,
- 109,111,100,117,108,101,218,11,101,120,101,99,95,109,111,100,
- 117,108,101,122,87,115,116,97,114,116,105,110,103,32,105,110,
- 32,80,121,116,104,111,110,32,51,46,54,44,32,108,111,97,
- 100,101,114,115,32,100,101,102,105,110,105,110,103,32,101,120,
- 101,99,95,109,111,100,117,108,101,40,41,32,109,117,115,116,
- 32,97,108,115,111,32,100,101,102,105,110,101,32,99,114,101,
- 97,116,101,95,109,111,100,117,108,101,40,41,90,10,115,116,
- 97,99,107,108,101,118,101,108,233,2,0,0,0,41,9,114,
- 4,0,0,0,114,99,0,0,0,114,138,0,0,0,218,9,
- 95,119,97,114,110,105,110,103,115,218,4,119,97,114,110,218,
- 18,68,101,112,114,101,99,97,116,105,111,110,87,97,114,110,
- 105,110,103,114,16,0,0,0,114,15,0,0,0,114,137,0,
- 0,0,41,2,114,88,0,0,0,114,89,0,0,0,114,10,
- 0,0,0,114,10,0,0,0,114,11,0,0,0,218,16,109,
- 111,100,117,108,101,95,102,114,111,109,95,115,112,101,99,58,
- 2,0,0,115,20,0,0,0,0,3,6,1,18,3,21,1,
- 18,1,9,2,13,1,12,1,15,1,13,1,114,144,0,0,
- 0,99,1,0,0,0,0,0,0,0,2,0,0,0,3,0,
- 0,0,67,0,0,0,115,149,0,0,0,124,0,0,106,0,
- 0,100,1,0,107,8,0,114,21,0,100,2,0,110,6,0,
- 124,0,0,106,0,0,125,1,0,124,0,0,106,1,0,100,
- 1,0,107,8,0,114,95,0,124,0,0,106,2,0,100,1,
- 0,107,8,0,114,73,0,100,3,0,106,3,0,124,1,0,
- 131,1,0,83,100,4,0,106,3,0,124,1,0,124,0,0,
- 106,2,0,131,2,0,83,110,50,0,124,0,0,106,4,0,
- 114,123,0,100,5,0,106,3,0,124,1,0,124,0,0,106,
- 1,0,131,2,0,83,100,6,0,106,3,0,124,0,0,106,
- 0,0,124,0,0,106,1,0,131,2,0,83,100,1,0,83,
- 41,7,122,38,82,101,116,117,114,110,32,116,104,101,32,114,
- 101,112,114,32,116,111,32,117,115,101,32,102,111,114,32,116,
- 104,101,32,109,111,100,117,108,101,46,78,114,93,0,0,0,
- 122,13,60,109,111,100,117,108,101,32,123,33,114,125,62,122,
- 20,60,109,111,100,117,108,101,32,123,33,114,125,32,40,123,
- 33,114,125,41,62,122,23,60,109,111,100,117,108,101,32,123,
- 33,114,125,32,102,114,111,109,32,123,33,114,125,62,122,18,
- 60,109,111,100,117,108,101,32,123,33,114,125,32,40,123,125,
- 41,62,41,5,114,15,0,0,0,114,107,0,0,0,114,99,
- 0,0,0,114,50,0,0,0,114,117,0,0,0,41,2,114,
- 88,0,0,0,114,15,0,0,0,114,10,0,0,0,114,10,
- 0,0,0,114,11,0,0,0,114,97,0,0,0,76,2,0,
- 0,115,16,0,0,0,0,3,30,1,15,1,15,1,13,2,
- 22,2,9,1,19,2,114,97,0,0,0,99,2,0,0,0,
- 0,0,0,0,4,0,0,0,12,0,0,0,67,0,0,0,
- 115,253,0,0,0,124,0,0,106,0,0,125,2,0,116,1,
- 0,106,2,0,131,0,0,1,116,3,0,124,2,0,131,1,
- 0,143,208,0,1,116,4,0,106,5,0,106,6,0,124,2,
- 0,131,1,0,124,1,0,107,9,0,114,89,0,100,1,0,
- 106,7,0,124,2,0,131,1,0,125,3,0,116,8,0,124,
- 3,0,100,2,0,124,2,0,131,1,1,130,1,0,124,0,
- 0,106,9,0,100,3,0,107,8,0,114,163,0,124,0,0,
- 106,10,0,100,3,0,107,8,0,114,140,0,116,8,0,100,
- 4,0,100,2,0,124,0,0,106,0,0,131,1,1,130,1,
- 0,116,11,0,124,0,0,124,1,0,100,5,0,100,6,0,
- 131,2,1,1,124,1,0,83,116,11,0,124,0,0,124,1,
- 0,100,5,0,100,6,0,131,2,1,1,116,12,0,124,0,
- 0,106,9,0,100,7,0,131,2,0,115,219,0,124,0,0,
- 106,9,0,106,13,0,124,2,0,131,1,0,1,110,16,0,
- 124,0,0,106,9,0,106,14,0,124,1,0,131,1,0,1,
- 87,100,3,0,81,82,88,116,4,0,106,5,0,124,2,0,
- 25,83,41,8,122,51,69,120,101,99,117,116,101,32,116,104,
- 101,32,115,112,101,99,32,105,110,32,97,110,32,101,120,105,
- 115,116,105,110,103,32,109,111,100,117,108,101,39,115,32,110,
- 97,109,101,115,112,97,99,101,46,122,30,109,111,100,117,108,
- 101,32,123,33,114,125,32,110,111,116,32,105,110,32,115,121,
- 115,46,109,111,100,117,108,101,115,114,15,0,0,0,78,122,
- 14,109,105,115,115,105,110,103,32,108,111,97,100,101,114,114,
- 133,0,0,0,84,114,139,0,0,0,41,15,114,15,0,0,
- 0,114,57,0,0,0,218,12,97,99,113,117,105,114,101,95,
- 108,111,99,107,114,54,0,0,0,114,14,0,0,0,114,21,
- 0,0,0,114,42,0,0,0,114,50,0,0,0,114,77,0,
- 0,0,114,99,0,0,0,114,110,0,0,0,114,137,0,0,
- 0,114,4,0,0,0,218,11,108,111,97,100,95,109,111,100,
- 117,108,101,114,139,0,0,0,41,4,114,88,0,0,0,114,
- 89,0,0,0,114,15,0,0,0,218,3,109,115,103,114,10,
- 0,0,0,114,10,0,0,0,114,11,0,0,0,114,86,0,
- 0,0,93,2,0,0,115,32,0,0,0,0,2,9,1,10,
- 1,13,1,24,1,15,1,18,1,15,1,15,1,21,2,19,
- 1,4,1,19,1,18,4,19,2,23,1,114,86,0,0,0,
- 99,1,0,0,0,0,0,0,0,2,0,0,0,27,0,0,
- 0,67,0,0,0,115,3,1,0,0,124,0,0,106,0,0,
- 106,1,0,124,0,0,106,2,0,131,1,0,1,116,3,0,
- 106,4,0,124,0,0,106,2,0,25,125,1,0,116,5,0,
- 124,1,0,100,1,0,100,0,0,131,3,0,100,0,0,107,
- 8,0,114,96,0,121,16,0,124,0,0,106,0,0,124,1,
- 0,95,6,0,87,110,18,0,4,116,7,0,107,10,0,114,
- 95,0,1,1,1,89,110,1,0,88,116,5,0,124,1,0,
- 100,2,0,100,0,0,131,3,0,100,0,0,107,8,0,114,
- 197,0,121,56,0,124,1,0,106,8,0,124,1,0,95,9,
- 0,116,10,0,124,1,0,100,3,0,131,2,0,115,175,0,
- 124,0,0,106,2,0,106,11,0,100,4,0,131,1,0,100,
- 5,0,25,124,1,0,95,9,0,87,110,18,0,4,116,7,
- 0,107,10,0,114,196,0,1,1,1,89,110,1,0,88,116,
- 5,0,124,1,0,100,6,0,100,0,0,131,3,0,100,0,
- 0,107,8,0,114,255,0,121,13,0,124,0,0,124,1,0,
- 95,12,0,87,110,18,0,4,116,7,0,107,10,0,114,254,
- 0,1,1,1,89,110,1,0,88,124,1,0,83,41,7,78,
- 114,91,0,0,0,114,134,0,0,0,114,131,0,0,0,114,
- 121,0,0,0,114,33,0,0,0,114,95,0,0,0,41,13,
- 114,99,0,0,0,114,146,0,0,0,114,15,0,0,0,114,
- 14,0,0,0,114,21,0,0,0,114,6,0,0,0,114,91,
- 0,0,0,114,96,0,0,0,114,1,0,0,0,114,134,0,
- 0,0,114,4,0,0,0,114,122,0,0,0,114,95,0,0,
- 0,41,2,114,88,0,0,0,114,89,0,0,0,114,10,0,
- 0,0,114,10,0,0,0,114,11,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,118,2,0,0,115,40,0,0,0,
- 0,4,19,2,16,1,24,1,3,1,16,1,13,1,5,1,
- 24,1,3,4,12,1,15,1,29,1,13,1,5,1,24,1,
- 3,1,13,1,13,1,5,1,114,148,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,159,0,0,0,124,0,0,106,0,0,100,0,0,
- 107,9,0,114,43,0,116,1,0,124,0,0,106,0,0,100,
- 1,0,131,2,0,115,43,0,116,2,0,124,0,0,131,1,
- 0,83,116,3,0,124,0,0,131,1,0,125,1,0,116,4,
- 0,124,1,0,131,1,0,143,75,0,1,124,0,0,106,0,
- 0,100,0,0,107,8,0,114,122,0,124,0,0,106,5,0,
- 100,0,0,107,8,0,114,138,0,116,6,0,100,2,0,100,
- 3,0,124,0,0,106,7,0,131,1,1,130,1,0,110,16,
- 0,124,0,0,106,0,0,106,8,0,124,1,0,131,1,0,
- 1,87,100,0,0,81,82,88,116,9,0,106,10,0,124,0,
- 0,106,7,0,25,83,41,4,78,114,139,0,0,0,122,14,
- 109,105,115,115,105,110,103,32,108,111,97,100,101,114,114,15,
- 0,0,0,41,11,114,99,0,0,0,114,4,0,0,0,114,
- 148,0,0,0,114,144,0,0,0,114,102,0,0,0,114,110,
- 0,0,0,114,77,0,0,0,114,15,0,0,0,114,139,0,
- 0,0,114,14,0,0,0,114,21,0,0,0,41,2,114,88,
+ 0,0,115,164,0,0,0,116,0,124,1,100,1,131,2,114,
+ 80,116,1,100,2,107,8,114,22,116,2,130,1,116,1,106,
+ 3,125,4,124,3,100,2,107,8,114,50,124,4,124,0,100,
+ 3,124,1,144,1,131,1,83,0,124,3,114,58,103,0,110,
+ 2,100,2,125,5,124,4,124,0,100,3,124,1,100,4,124,
+ 5,144,2,131,1,83,0,124,3,100,2,107,8,114,144,116,
+ 0,124,1,100,5,131,2,114,140,121,14,124,1,106,4,124,
+ 0,131,1,125,3,87,0,113,144,4,0,116,5,107,10,114,
+ 136,1,0,1,0,1,0,100,2,125,3,89,0,113,144,88,
+ 0,110,4,100,6,125,3,116,6,124,0,124,1,100,7,124,
+ 2,100,5,124,3,144,2,131,2,83,0,41,8,122,53,82,
+ 101,116,117,114,110,32,97,32,109,111,100,117,108,101,32,115,
+ 112,101,99,32,98,97,115,101,100,32,111,110,32,118,97,114,
+ 105,111,117,115,32,108,111,97,100,101,114,32,109,101,116,104,
+ 111,100,115,46,90,12,103,101,116,95,102,105,108,101,110,97,
+ 109,101,78,114,99,0,0,0,114,110,0,0,0,114,109,0,
+ 0,0,70,114,107,0,0,0,41,7,114,4,0,0,0,114,
+ 119,0,0,0,114,120,0,0,0,218,23,115,112,101,99,95,
+ 102,114,111,109,95,102,105,108,101,95,108,111,99,97,116,105,
+ 111,110,114,109,0,0,0,114,77,0,0,0,114,106,0,0,
+ 0,41,6,114,15,0,0,0,114,99,0,0,0,114,107,0,
+ 0,0,114,109,0,0,0,114,128,0,0,0,90,6,115,101,
+ 97,114,99,104,114,10,0,0,0,114,10,0,0,0,114,11,
+ 0,0,0,114,85,0,0,0,180,1,0,0,115,34,0,0,
+ 0,0,2,10,1,8,1,4,1,6,2,8,1,14,1,12,
+ 1,10,1,8,2,8,1,10,1,2,1,14,1,14,1,12,
+ 3,4,2,114,85,0,0,0,99,3,0,0,0,0,0,0,
+ 0,8,0,0,0,53,0,0,0,67,0,0,0,115,58,1,
+ 0,0,121,10,124,0,106,0,125,3,87,0,110,20,4,0,
+ 116,1,107,10,114,30,1,0,1,0,1,0,89,0,110,14,
+ 88,0,124,3,100,0,107,9,114,44,124,3,83,0,124,0,
+ 106,2,125,4,124,1,100,0,107,8,114,90,121,10,124,0,
+ 106,3,125,1,87,0,110,20,4,0,116,1,107,10,114,88,
+ 1,0,1,0,1,0,89,0,110,2,88,0,121,10,124,0,
+ 106,4,125,5,87,0,110,24,4,0,116,1,107,10,114,124,
+ 1,0,1,0,1,0,100,0,125,5,89,0,110,2,88,0,
+ 124,2,100,0,107,8,114,184,124,5,100,0,107,8,114,180,
+ 121,10,124,1,106,5,125,2,87,0,113,184,4,0,116,1,
+ 107,10,114,176,1,0,1,0,1,0,100,0,125,2,89,0,
+ 113,184,88,0,110,4,124,5,125,2,121,10,124,0,106,6,
+ 125,6,87,0,110,24,4,0,116,1,107,10,114,218,1,0,
+ 1,0,1,0,100,0,125,6,89,0,110,2,88,0,121,14,
+ 116,7,124,0,106,8,131,1,125,7,87,0,110,26,4,0,
+ 116,1,107,10,144,1,114,4,1,0,1,0,1,0,100,0,
+ 125,7,89,0,110,2,88,0,116,9,124,4,124,1,100,1,
+ 124,2,144,1,131,2,125,3,124,5,100,0,107,8,144,1,
+ 114,36,100,2,110,2,100,3,124,3,95,10,124,6,124,3,
+ 95,11,124,7,124,3,95,12,124,3,83,0,41,4,78,114,
+ 107,0,0,0,70,84,41,13,114,95,0,0,0,114,96,0,
+ 0,0,114,1,0,0,0,114,91,0,0,0,114,98,0,0,
+ 0,90,7,95,79,82,73,71,73,78,218,10,95,95,99,97,
+ 99,104,101,100,95,95,218,4,108,105,115,116,218,8,95,95,
+ 112,97,116,104,95,95,114,106,0,0,0,114,111,0,0,0,
+ 114,116,0,0,0,114,110,0,0,0,41,8,114,89,0,0,
+ 0,114,99,0,0,0,114,107,0,0,0,114,88,0,0,0,
+ 114,15,0,0,0,90,8,108,111,99,97,116,105,111,110,114,
+ 116,0,0,0,114,110,0,0,0,114,10,0,0,0,114,10,
+ 0,0,0,114,11,0,0,0,218,17,95,115,112,101,99,95,
+ 102,114,111,109,95,109,111,100,117,108,101,209,1,0,0,115,
+ 72,0,0,0,0,2,2,1,10,1,14,1,6,2,8,1,
+ 4,2,6,1,8,1,2,1,10,1,14,2,6,1,2,1,
+ 10,1,14,1,10,1,8,1,8,1,2,1,10,1,14,1,
+ 12,2,4,1,2,1,10,1,14,1,10,1,2,1,14,1,
+ 16,1,10,2,16,1,20,1,6,1,6,1,114,132,0,0,
+ 0,70,41,1,218,8,111,118,101,114,114,105,100,101,99,2,
+ 0,0,0,1,0,0,0,5,0,0,0,59,0,0,0,67,
+ 0,0,0,115,212,1,0,0,124,2,115,20,116,0,124,1,
+ 100,1,100,0,131,3,100,0,107,8,114,54,121,12,124,0,
+ 106,1,124,1,95,2,87,0,110,20,4,0,116,3,107,10,
+ 114,52,1,0,1,0,1,0,89,0,110,2,88,0,124,2,
+ 115,74,116,0,124,1,100,2,100,0,131,3,100,0,107,8,
+ 114,166,124,0,106,4,125,3,124,3,100,0,107,8,114,134,
+ 124,0,106,5,100,0,107,9,114,134,116,6,100,0,107,8,
+ 114,110,116,7,130,1,116,6,106,8,125,4,124,4,106,9,
+ 124,4,131,1,125,3,124,0,106,5,124,3,95,10,121,10,
+ 124,3,124,1,95,11,87,0,110,20,4,0,116,3,107,10,
+ 114,164,1,0,1,0,1,0,89,0,110,2,88,0,124,2,
+ 115,186,116,0,124,1,100,3,100,0,131,3,100,0,107,8,
+ 114,220,121,12,124,0,106,12,124,1,95,13,87,0,110,20,
+ 4,0,116,3,107,10,114,218,1,0,1,0,1,0,89,0,
+ 110,2,88,0,121,10,124,0,124,1,95,14,87,0,110,20,
+ 4,0,116,3,107,10,114,250,1,0,1,0,1,0,89,0,
+ 110,2,88,0,124,2,144,1,115,20,116,0,124,1,100,4,
+ 100,0,131,3,100,0,107,8,144,1,114,68,124,0,106,5,
+ 100,0,107,9,144,1,114,68,121,12,124,0,106,5,124,1,
+ 95,15,87,0,110,22,4,0,116,3,107,10,144,1,114,66,
+ 1,0,1,0,1,0,89,0,110,2,88,0,124,0,106,16,
+ 144,1,114,208,124,2,144,1,115,100,116,0,124,1,100,5,
+ 100,0,131,3,100,0,107,8,144,1,114,136,121,12,124,0,
+ 106,17,124,1,95,18,87,0,110,22,4,0,116,3,107,10,
+ 144,1,114,134,1,0,1,0,1,0,89,0,110,2,88,0,
+ 124,2,144,1,115,160,116,0,124,1,100,6,100,0,131,3,
+ 100,0,107,8,144,1,114,208,124,0,106,19,100,0,107,9,
+ 144,1,114,208,121,12,124,0,106,19,124,1,95,20,87,0,
+ 110,22,4,0,116,3,107,10,144,1,114,206,1,0,1,0,
+ 1,0,89,0,110,2,88,0,124,1,83,0,41,7,78,114,
+ 1,0,0,0,114,91,0,0,0,218,11,95,95,112,97,99,
+ 107,97,103,101,95,95,114,131,0,0,0,114,98,0,0,0,
+ 114,129,0,0,0,41,21,114,6,0,0,0,114,15,0,0,
+ 0,114,1,0,0,0,114,96,0,0,0,114,99,0,0,0,
+ 114,110,0,0,0,114,119,0,0,0,114,120,0,0,0,218,
+ 16,95,78,97,109,101,115,112,97,99,101,76,111,97,100,101,
+ 114,218,7,95,95,110,101,119,95,95,90,5,95,112,97,116,
+ 104,114,91,0,0,0,114,123,0,0,0,114,134,0,0,0,
+ 114,95,0,0,0,114,131,0,0,0,114,117,0,0,0,114,
+ 107,0,0,0,114,98,0,0,0,114,116,0,0,0,114,129,
+ 0,0,0,41,5,114,88,0,0,0,114,89,0,0,0,114,
+ 133,0,0,0,114,99,0,0,0,114,135,0,0,0,114,10,
+ 0,0,0,114,10,0,0,0,114,11,0,0,0,218,18,95,
+ 105,110,105,116,95,109,111,100,117,108,101,95,97,116,116,114,
+ 115,254,1,0,0,115,92,0,0,0,0,4,20,1,2,1,
+ 12,1,14,1,6,2,20,1,6,1,8,2,10,1,8,1,
+ 4,1,6,2,10,1,8,1,2,1,10,1,14,1,6,2,
+ 20,1,2,1,12,1,14,1,6,2,2,1,10,1,14,1,
+ 6,2,24,1,12,1,2,1,12,1,16,1,6,2,8,1,
+ 24,1,2,1,12,1,16,1,6,2,24,1,12,1,2,1,
+ 12,1,16,1,6,1,114,137,0,0,0,99,1,0,0,0,
+ 0,0,0,0,2,0,0,0,5,0,0,0,67,0,0,0,
+ 115,92,0,0,0,100,1,125,1,116,0,124,0,106,1,100,
+ 2,131,2,114,30,124,0,106,1,106,2,124,0,131,1,125,
+ 1,110,30,116,0,124,0,106,1,100,3,131,2,114,60,116,
+ 3,106,4,100,4,116,5,100,5,100,6,144,1,131,2,1,
+ 0,124,1,100,1,107,8,114,78,116,6,124,0,106,7,131,
+ 1,125,1,116,8,124,0,124,1,131,2,1,0,124,1,83,
+ 0,41,7,122,43,67,114,101,97,116,101,32,97,32,109,111,
+ 100,117,108,101,32,98,97,115,101,100,32,111,110,32,116,104,
+ 101,32,112,114,111,118,105,100,101,100,32,115,112,101,99,46,
+ 78,218,13,99,114,101,97,116,101,95,109,111,100,117,108,101,
+ 218,11,101,120,101,99,95,109,111,100,117,108,101,122,87,115,
+ 116,97,114,116,105,110,103,32,105,110,32,80,121,116,104,111,
+ 110,32,51,46,54,44,32,108,111,97,100,101,114,115,32,100,
+ 101,102,105,110,105,110,103,32,101,120,101,99,95,109,111,100,
+ 117,108,101,40,41,32,109,117,115,116,32,97,108,115,111,32,
+ 100,101,102,105,110,101,32,99,114,101,97,116,101,95,109,111,
+ 100,117,108,101,40,41,218,10,115,116,97,99,107,108,101,118,
+ 101,108,233,2,0,0,0,41,9,114,4,0,0,0,114,99,
+ 0,0,0,114,138,0,0,0,218,9,95,119,97,114,110,105,
+ 110,103,115,218,4,119,97,114,110,218,18,68,101,112,114,101,
+ 99,97,116,105,111,110,87,97,114,110,105,110,103,114,16,0,
+ 0,0,114,15,0,0,0,114,137,0,0,0,41,2,114,88,
0,0,0,114,89,0,0,0,114,10,0,0,0,114,10,0,
- 0,0,114,11,0,0,0,218,14,95,108,111,97,100,95,117,
- 110,108,111,99,107,101,100,147,2,0,0,115,20,0,0,0,
- 0,2,15,2,18,1,10,2,12,1,13,1,15,1,15,1,
- 24,3,23,5,114,149,0,0,0,99,1,0,0,0,0,0,
- 0,0,1,0,0,0,9,0,0,0,67,0,0,0,115,47,
- 0,0,0,116,0,0,106,1,0,131,0,0,1,116,2,0,
- 124,0,0,106,3,0,131,1,0,143,15,0,1,116,4,0,
- 124,0,0,131,1,0,83,87,100,1,0,81,82,88,100,1,
- 0,83,41,2,122,191,82,101,116,117,114,110,32,97,32,110,
- 101,119,32,109,111,100,117,108,101,32,111,98,106,101,99,116,
- 44,32,108,111,97,100,101,100,32,98,121,32,116,104,101,32,
- 115,112,101,99,39,115,32,108,111,97,100,101,114,46,10,10,
- 32,32,32,32,84,104,101,32,109,111,100,117,108,101,32,105,
- 115,32,110,111,116,32,97,100,100,101,100,32,116,111,32,105,
- 116,115,32,112,97,114,101,110,116,46,10,10,32,32,32,32,
- 73,102,32,97,32,109,111,100,117,108,101,32,105,115,32,97,
- 108,114,101,97,100,121,32,105,110,32,115,121,115,46,109,111,
- 100,117,108,101,115,44,32,116,104,97,116,32,101,120,105,115,
- 116,105,110,103,32,109,111,100,117,108,101,32,103,101,116,115,
- 10,32,32,32,32,99,108,111,98,98,101,114,101,100,46,10,
- 10,32,32,32,32,78,41,5,114,57,0,0,0,114,145,0,
- 0,0,114,54,0,0,0,114,15,0,0,0,114,149,0,0,
- 0,41,1,114,88,0,0,0,114,10,0,0,0,114,10,0,
- 0,0,114,11,0,0,0,114,87,0,0,0,170,2,0,0,
- 115,6,0,0,0,0,9,10,1,16,1,114,87,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,205,0,0,0,101,0,0,90,1,0,
- 100,0,0,90,2,0,100,1,0,90,3,0,101,4,0,100,
- 2,0,100,3,0,132,0,0,131,1,0,90,5,0,101,6,
- 0,100,4,0,100,4,0,100,5,0,100,6,0,132,2,0,
- 131,1,0,90,7,0,101,6,0,100,4,0,100,7,0,100,
- 8,0,132,1,0,131,1,0,90,8,0,101,6,0,100,9,
- 0,100,10,0,132,0,0,131,1,0,90,9,0,101,6,0,
- 100,11,0,100,12,0,132,0,0,131,1,0,90,10,0,101,
- 6,0,101,11,0,100,13,0,100,14,0,132,0,0,131,1,
- 0,131,1,0,90,12,0,101,6,0,101,11,0,100,15,0,
- 100,16,0,132,0,0,131,1,0,131,1,0,90,13,0,101,
- 6,0,101,11,0,100,17,0,100,18,0,132,0,0,131,1,
- 0,131,1,0,90,14,0,101,6,0,101,15,0,131,1,0,
- 90,16,0,100,4,0,83,41,19,218,15,66,117,105,108,116,
- 105,110,73,109,112,111,114,116,101,114,122,144,77,101,116,97,
- 32,112,97,116,104,32,105,109,112,111,114,116,32,102,111,114,
- 32,98,117,105,108,116,45,105,110,32,109,111,100,117,108,101,
- 115,46,10,10,32,32,32,32,65,108,108,32,109,101,116,104,
- 111,100,115,32,97,114,101,32,101,105,116,104,101,114,32,99,
- 108,97,115,115,32,111,114,32,115,116,97,116,105,99,32,109,
- 101,116,104,111,100,115,32,116,111,32,97,118,111,105,100,32,
- 116,104,101,32,110,101,101,100,32,116,111,10,32,32,32,32,
- 105,110,115,116,97,110,116,105,97,116,101,32,116,104,101,32,
- 99,108,97,115,115,46,10,10,32,32,32,32,99,1,0,0,
- 0,0,0,0,0,1,0,0,0,2,0,0,0,67,0,0,
- 0,115,16,0,0,0,100,1,0,106,0,0,124,0,0,106,
- 1,0,131,1,0,83,41,2,122,115,82,101,116,117,114,110,
- 32,114,101,112,114,32,102,111,114,32,116,104,101,32,109,111,
- 100,117,108,101,46,10,10,32,32,32,32,32,32,32,32,84,
- 104,101,32,109,101,116,104,111,100,32,105,115,32,100,101,112,
- 114,101,99,97,116,101,100,46,32,32,84,104,101,32,105,109,
- 112,111,114,116,32,109,97,99,104,105,110,101,114,121,32,100,
- 111,101,115,32,116,104,101,32,106,111,98,32,105,116,115,101,
- 108,102,46,10,10,32,32,32,32,32,32,32,32,122,24,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,50,0,0,0,114,1,
- 0,0,0,41,1,114,89,0,0,0,114,10,0,0,0,114,
- 10,0,0,0,114,11,0,0,0,114,92,0,0,0,195,2,
- 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,0,
- 4,0,0,0,5,0,0,0,67,0,0,0,115,58,0,0,
- 0,124,2,0,100,0,0,107,9,0,114,16,0,100,0,0,
- 83,116,0,0,106,1,0,124,1,0,131,1,0,114,50,0,
- 116,2,0,124,1,0,124,0,0,100,1,0,100,2,0,131,
- 2,1,83,100,0,0,83,100,0,0,83,41,3,78,114,107,
+ 0,0,114,11,0,0,0,218,16,109,111,100,117,108,101,95,
+ 102,114,111,109,95,115,112,101,99,58,2,0,0,115,20,0,
+ 0,0,0,3,4,1,12,3,14,1,12,1,6,2,12,1,
+ 8,1,10,1,10,1,114,145,0,0,0,99,1,0,0,0,
+ 0,0,0,0,2,0,0,0,3,0,0,0,67,0,0,0,
+ 115,110,0,0,0,124,0,106,0,100,1,107,8,114,14,100,
+ 2,110,4,124,0,106,0,125,1,124,0,106,1,100,1,107,
+ 8,114,68,124,0,106,2,100,1,107,8,114,52,100,3,106,
+ 3,124,1,131,1,83,0,113,106,100,4,106,3,124,1,124,
+ 0,106,2,131,2,83,0,110,38,124,0,106,4,114,90,100,
+ 5,106,3,124,1,124,0,106,1,131,2,83,0,110,16,100,
+ 6,106,3,124,0,106,0,124,0,106,1,131,2,83,0,100,
+ 1,83,0,41,7,122,38,82,101,116,117,114,110,32,116,104,
+ 101,32,114,101,112,114,32,116,111,32,117,115,101,32,102,111,
+ 114,32,116,104,101,32,109,111,100,117,108,101,46,78,114,93,
+ 0,0,0,122,13,60,109,111,100,117,108,101,32,123,33,114,
+ 125,62,122,20,60,109,111,100,117,108,101,32,123,33,114,125,
+ 32,40,123,33,114,125,41,62,122,23,60,109,111,100,117,108,
+ 101,32,123,33,114,125,32,102,114,111,109,32,123,33,114,125,
+ 62,122,18,60,109,111,100,117,108,101,32,123,33,114,125,32,
+ 40,123,125,41,62,41,5,114,15,0,0,0,114,107,0,0,
+ 0,114,99,0,0,0,114,50,0,0,0,114,117,0,0,0,
+ 41,2,114,88,0,0,0,114,15,0,0,0,114,10,0,0,
+ 0,114,10,0,0,0,114,11,0,0,0,114,97,0,0,0,
+ 76,2,0,0,115,16,0,0,0,0,3,20,1,10,1,10,
+ 1,12,2,16,2,6,1,16,2,114,97,0,0,0,99,2,
+ 0,0,0,0,0,0,0,4,0,0,0,12,0,0,0,67,
+ 0,0,0,115,194,0,0,0,124,0,106,0,125,2,116,1,
+ 106,2,131,0,1,0,116,3,124,2,131,1,143,156,1,0,
+ 116,4,106,5,106,6,124,2,131,1,124,1,107,9,114,64,
+ 100,1,106,7,124,2,131,1,125,3,116,8,124,3,100,2,
+ 124,2,144,1,131,1,130,1,124,0,106,9,100,3,107,8,
+ 114,120,124,0,106,10,100,3,107,8,114,100,116,8,100,4,
+ 100,2,124,0,106,0,144,1,131,1,130,1,116,11,124,0,
+ 124,1,100,5,100,6,144,1,131,2,1,0,124,1,83,0,
+ 116,11,124,0,124,1,100,5,100,6,144,1,131,2,1,0,
+ 116,12,124,0,106,9,100,7,131,2,115,162,124,0,106,9,
+ 106,13,124,2,131,1,1,0,110,12,124,0,106,9,106,14,
+ 124,1,131,1,1,0,87,0,100,3,81,0,82,0,88,0,
+ 116,4,106,5,124,2,25,0,83,0,41,8,122,51,69,120,
+ 101,99,117,116,101,32,116,104,101,32,115,112,101,99,32,105,
+ 110,32,97,110,32,101,120,105,115,116,105,110,103,32,109,111,
+ 100,117,108,101,39,115,32,110,97,109,101,115,112,97,99,101,
+ 46,122,30,109,111,100,117,108,101,32,123,33,114,125,32,110,
+ 111,116,32,105,110,32,115,121,115,46,109,111,100,117,108,101,
+ 115,114,15,0,0,0,78,122,14,109,105,115,115,105,110,103,
+ 32,108,111,97,100,101,114,114,133,0,0,0,84,114,139,0,
+ 0,0,41,15,114,15,0,0,0,114,57,0,0,0,218,12,
+ 97,99,113,117,105,114,101,95,108,111,99,107,114,54,0,0,
+ 0,114,14,0,0,0,114,21,0,0,0,114,42,0,0,0,
+ 114,50,0,0,0,114,77,0,0,0,114,99,0,0,0,114,
+ 110,0,0,0,114,137,0,0,0,114,4,0,0,0,218,11,
+ 108,111,97,100,95,109,111,100,117,108,101,114,139,0,0,0,
+ 41,4,114,88,0,0,0,114,89,0,0,0,114,15,0,0,
+ 0,218,3,109,115,103,114,10,0,0,0,114,10,0,0,0,
+ 114,11,0,0,0,114,86,0,0,0,93,2,0,0,115,32,
+ 0,0,0,0,2,6,1,8,1,10,1,16,1,10,1,14,
+ 1,10,1,10,1,16,2,16,1,4,1,16,1,12,4,14,
+ 2,22,1,114,86,0,0,0,99,1,0,0,0,0,0,0,
+ 0,2,0,0,0,27,0,0,0,67,0,0,0,115,206,0,
+ 0,0,124,0,106,0,106,1,124,0,106,2,131,1,1,0,
+ 116,3,106,4,124,0,106,2,25,0,125,1,116,5,124,1,
+ 100,1,100,0,131,3,100,0,107,8,114,76,121,12,124,0,
+ 106,0,124,1,95,6,87,0,110,20,4,0,116,7,107,10,
+ 114,74,1,0,1,0,1,0,89,0,110,2,88,0,116,5,
+ 124,1,100,2,100,0,131,3,100,0,107,8,114,154,121,40,
+ 124,1,106,8,124,1,95,9,116,10,124,1,100,3,131,2,
+ 115,130,124,0,106,2,106,11,100,4,131,1,100,5,25,0,
+ 124,1,95,9,87,0,110,20,4,0,116,7,107,10,114,152,
+ 1,0,1,0,1,0,89,0,110,2,88,0,116,5,124,1,
+ 100,6,100,0,131,3,100,0,107,8,114,202,121,10,124,0,
+ 124,1,95,12,87,0,110,20,4,0,116,7,107,10,114,200,
+ 1,0,1,0,1,0,89,0,110,2,88,0,124,1,83,0,
+ 41,7,78,114,91,0,0,0,114,134,0,0,0,114,131,0,
+ 0,0,114,121,0,0,0,114,33,0,0,0,114,95,0,0,
+ 0,41,13,114,99,0,0,0,114,147,0,0,0,114,15,0,
+ 0,0,114,14,0,0,0,114,21,0,0,0,114,6,0,0,
+ 0,114,91,0,0,0,114,96,0,0,0,114,1,0,0,0,
+ 114,134,0,0,0,114,4,0,0,0,114,122,0,0,0,114,
+ 95,0,0,0,41,2,114,88,0,0,0,114,89,0,0,0,
+ 114,10,0,0,0,114,10,0,0,0,114,11,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,118,2,0,0,115,40,
+ 0,0,0,0,4,14,2,12,1,16,1,2,1,12,1,14,
+ 1,6,1,16,1,2,4,8,1,10,1,22,1,14,1,6,
+ 1,16,1,2,1,10,1,14,1,6,1,114,149,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,120,0,0,0,124,0,106,0,100,0,
+ 107,9,114,30,116,1,124,0,106,0,100,1,131,2,115,30,
+ 116,2,124,0,131,1,83,0,116,3,124,0,131,1,125,1,
+ 116,4,124,1,131,1,143,56,1,0,124,0,106,0,100,0,
+ 107,8,114,86,124,0,106,5,100,0,107,8,114,98,116,6,
+ 100,2,100,3,124,0,106,7,144,1,131,1,130,1,110,12,
+ 124,0,106,0,106,8,124,1,131,1,1,0,87,0,100,0,
+ 81,0,82,0,88,0,116,9,106,10,124,0,106,7,25,0,
+ 83,0,41,4,78,114,139,0,0,0,122,14,109,105,115,115,
+ 105,110,103,32,108,111,97,100,101,114,114,15,0,0,0,41,
+ 11,114,99,0,0,0,114,4,0,0,0,114,149,0,0,0,
+ 114,145,0,0,0,114,102,0,0,0,114,110,0,0,0,114,
+ 77,0,0,0,114,15,0,0,0,114,139,0,0,0,114,14,
+ 0,0,0,114,21,0,0,0,41,2,114,88,0,0,0,114,
+ 89,0,0,0,114,10,0,0,0,114,10,0,0,0,114,11,
+ 0,0,0,218,14,95,108,111,97,100,95,117,110,108,111,99,
+ 107,101,100,147,2,0,0,115,20,0,0,0,0,2,10,2,
+ 12,1,8,2,8,1,10,1,10,1,10,1,18,3,22,5,
+ 114,150,0,0,0,99,1,0,0,0,0,0,0,0,1,0,
+ 0,0,9,0,0,0,67,0,0,0,115,38,0,0,0,116,
+ 0,106,1,131,0,1,0,116,2,124,0,106,3,131,1,143,
+ 10,1,0,116,4,124,0,131,1,83,0,81,0,82,0,88,
+ 0,100,1,83,0,41,2,122,191,82,101,116,117,114,110,32,
+ 97,32,110,101,119,32,109,111,100,117,108,101,32,111,98,106,
+ 101,99,116,44,32,108,111,97,100,101,100,32,98,121,32,116,
+ 104,101,32,115,112,101,99,39,115,32,108,111,97,100,101,114,
+ 46,10,10,32,32,32,32,84,104,101,32,109,111,100,117,108,
+ 101,32,105,115,32,110,111,116,32,97,100,100,101,100,32,116,
+ 111,32,105,116,115,32,112,97,114,101,110,116,46,10,10,32,
+ 32,32,32,73,102,32,97,32,109,111,100,117,108,101,32,105,
+ 115,32,97,108,114,101,97,100,121,32,105,110,32,115,121,115,
+ 46,109,111,100,117,108,101,115,44,32,116,104,97,116,32,101,
+ 120,105,115,116,105,110,103,32,109,111,100,117,108,101,32,103,
+ 101,116,115,10,32,32,32,32,99,108,111,98,98,101,114,101,
+ 100,46,10,10,32,32,32,32,78,41,5,114,57,0,0,0,
+ 114,146,0,0,0,114,54,0,0,0,114,15,0,0,0,114,
+ 150,0,0,0,41,1,114,88,0,0,0,114,10,0,0,0,
+ 114,10,0,0,0,114,11,0,0,0,114,87,0,0,0,170,
+ 2,0,0,115,6,0,0,0,0,9,8,1,12,1,114,87,
+ 0,0,0,99,0,0,0,0,0,0,0,0,0,0,0,0,
+ 4,0,0,0,64,0,0,0,115,136,0,0,0,101,0,90,
+ 1,100,0,90,2,100,1,90,3,101,4,100,2,100,3,132,
+ 0,131,1,90,5,101,6,100,19,100,5,100,6,132,1,131,
+ 1,90,7,101,6,100,20,100,7,100,8,132,1,131,1,90,
+ 8,101,6,100,9,100,10,132,0,131,1,90,9,101,6,100,
+ 11,100,12,132,0,131,1,90,10,101,6,101,11,100,13,100,
+ 14,132,0,131,1,131,1,90,12,101,6,101,11,100,15,100,
+ 16,132,0,131,1,131,1,90,13,101,6,101,11,100,17,100,
+ 18,132,0,131,1,131,1,90,14,101,6,101,15,131,1,90,
+ 16,100,4,83,0,41,21,218,15,66,117,105,108,116,105,110,
+ 73,109,112,111,114,116,101,114,122,144,77,101,116,97,32,112,
+ 97,116,104,32,105,109,112,111,114,116,32,102,111,114,32,98,
+ 117,105,108,116,45,105,110,32,109,111,100,117,108,101,115,46,
+ 10,10,32,32,32,32,65,108,108,32,109,101,116,104,111,100,
+ 115,32,97,114,101,32,101,105,116,104,101,114,32,99,108,97,
+ 115,115,32,111,114,32,115,116,97,116,105,99,32,109,101,116,
+ 104,111,100,115,32,116,111,32,97,118,111,105,100,32,116,104,
+ 101,32,110,101,101,100,32,116,111,10,32,32,32,32,105,110,
+ 115,116,97,110,116,105,97,116,101,32,116,104,101,32,99,108,
+ 97,115,115,46,10,10,32,32,32,32,99,1,0,0,0,0,
+ 0,0,0,1,0,0,0,2,0,0,0,67,0,0,0,115,
+ 12,0,0,0,100,1,106,0,124,0,106,1,131,1,83,0,
+ 41,2,122,115,82,101,116,117,114,110,32,114,101,112,114,32,
+ 102,111,114,32,116,104,101,32,109,111,100,117,108,101,46,10,
+ 10,32,32,32,32,32,32,32,32,84,104,101,32,109,101,116,
+ 104,111,100,32,105,115,32,100,101,112,114,101,99,97,116,101,
+ 100,46,32,32,84,104,101,32,105,109,112,111,114,116,32,109,
+ 97,99,104,105,110,101,114,121,32,100,111,101,115,32,116,104,
+ 101,32,106,111,98,32,105,116,115,101,108,102,46,10,10,32,
+ 32,32,32,32,32,32,32,122,24,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,50,0,0,0,114,1,0,0,0,41,1,114,
+ 89,0,0,0,114,10,0,0,0,114,10,0,0,0,114,11,
+ 0,0,0,114,92,0,0,0,195,2,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,0,4,0,0,0,5,0,
+ 0,0,67,0,0,0,115,48,0,0,0,124,2,100,0,107,
+ 9,114,12,100,0,83,0,116,0,106,1,124,1,131,1,114,
+ 40,116,2,124,1,124,0,100,1,100,2,144,1,131,2,83,
+ 0,110,4,100,0,83,0,100,0,83,0,41,3,78,114,107,
0,0,0,122,8,98,117,105,108,116,45,105,110,41,3,114,
57,0,0,0,90,10,105,115,95,98,117,105,108,116,105,110,
114,85,0,0,0,41,4,218,3,99,108,115,114,78,0,0,
0,218,4,112,97,116,104,218,6,116,97,114,103,101,116,114,
10,0,0,0,114,10,0,0,0,114,11,0,0,0,218,9,
102,105,110,100,95,115,112,101,99,204,2,0,0,115,10,0,
- 0,0,0,2,12,1,4,1,15,1,19,2,122,25,66,117,
+ 0,0,0,2,8,1,4,1,10,1,18,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,
- 4,0,0,0,3,0,0,0,67,0,0,0,115,41,0,0,
- 0,124,0,0,106,0,0,124,1,0,124,2,0,131,2,0,
- 125,3,0,124,3,0,100,1,0,107,9,0,114,37,0,124,
- 3,0,106,1,0,83,100,1,0,83,41,2,122,175,70,105,
- 110,100,32,116,104,101,32,98,117,105,108,116,45,105,110,32,
- 109,111,100,117,108,101,46,10,10,32,32,32,32,32,32,32,
- 32,73,102,32,39,112,97,116,104,39,32,105,115,32,101,118,
- 101,114,32,115,112,101,99,105,102,105,101,100,32,116,104,101,
- 110,32,116,104,101,32,115,101,97,114,99,104,32,105,115,32,
- 99,111,110,115,105,100,101,114,101,100,32,97,32,102,97,105,
- 108,117,114,101,46,10,10,32,32,32,32,32,32,32,32,84,
- 104,105,115,32,109,101,116,104,111,100,32,105,115,32,100,101,
- 112,114,101,99,97,116,101,100,46,32,32,85,115,101,32,102,
- 105,110,100,95,115,112,101,99,40,41,32,105,110,115,116,101,
- 97,100,46,10,10,32,32,32,32,32,32,32,32,78,41,2,
- 114,154,0,0,0,114,99,0,0,0,41,4,114,151,0,0,
- 0,114,78,0,0,0,114,152,0,0,0,114,88,0,0,0,
- 114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,218,
- 11,102,105,110,100,95,109,111,100,117,108,101,213,2,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,2,
- 0,0,0,4,0,0,0,67,0,0,0,115,67,0,0,0,
- 124,1,0,106,0,0,116,1,0,106,2,0,107,7,0,114,
- 51,0,116,3,0,100,1,0,106,4,0,124,1,0,106,0,
- 0,131,1,0,100,2,0,124,1,0,106,0,0,131,1,1,
- 130,1,0,116,5,0,116,6,0,106,7,0,124,1,0,131,
- 2,0,83,41,3,122,24,67,114,101,97,116,101,32,97,32,
- 98,117,105,108,116,45,105,110,32,109,111,100,117,108,101,122,
- 29,123,33,114,125,32,105,115,32,110,111,116,32,97,32,98,
- 117,105,108,116,45,105,110,32,109,111,100,117,108,101,114,15,
- 0,0,0,41,8,114,15,0,0,0,114,14,0,0,0,114,
- 76,0,0,0,114,77,0,0,0,114,50,0,0,0,114,65,
- 0,0,0,114,57,0,0,0,90,14,99,114,101,97,116,101,
- 95,98,117,105,108,116,105,110,41,2,114,19,0,0,0,114,
- 88,0,0,0,114,10,0,0,0,114,10,0,0,0,114,11,
- 0,0,0,114,138,0,0,0,225,2,0,0,115,8,0,0,
- 0,0,3,18,1,21,1,12,1,122,29,66,117,105,108,116,
- 105,110,73,109,112,111,114,116,101,114,46,99,114,101,97,116,
- 101,95,109,111,100,117,108,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,116,0,0,116,1,0,106,2,0,124,1,0,131,2,
- 0,1,100,1,0,83,41,2,122,22,69,120,101,99,32,97,
+ 4,0,0,0,3,0,0,0,67,0,0,0,115,30,0,0,
+ 0,124,0,106,0,124,1,124,2,131,2,125,3,124,3,100,
+ 1,107,9,114,26,124,3,106,1,83,0,100,1,83,0,41,
+ 2,122,175,70,105,110,100,32,116,104,101,32,98,117,105,108,
+ 116,45,105,110,32,109,111,100,117,108,101,46,10,10,32,32,
+ 32,32,32,32,32,32,73,102,32,39,112,97,116,104,39,32,
+ 105,115,32,101,118,101,114,32,115,112,101,99,105,102,105,101,
+ 100,32,116,104,101,110,32,116,104,101,32,115,101,97,114,99,
+ 104,32,105,115,32,99,111,110,115,105,100,101,114,101,100,32,
+ 97,32,102,97,105,108,117,114,101,46,10,10,32,32,32,32,
+ 32,32,32,32,84,104,105,115,32,109,101,116,104,111,100,32,
+ 105,115,32,100,101,112,114,101,99,97,116,101,100,46,32,32,
+ 85,115,101,32,102,105,110,100,95,115,112,101,99,40,41,32,
+ 105,110,115,116,101,97,100,46,10,10,32,32,32,32,32,32,
+ 32,32,78,41,2,114,155,0,0,0,114,99,0,0,0,41,
+ 4,114,152,0,0,0,114,78,0,0,0,114,153,0,0,0,
+ 114,88,0,0,0,114,10,0,0,0,114,10,0,0,0,114,
+ 11,0,0,0,218,11,102,105,110,100,95,109,111,100,117,108,
+ 101,213,2,0,0,115,4,0,0,0,0,9,12,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,2,0,0,0,4,0,0,0,67,0,0,0,
+ 115,48,0,0,0,124,1,106,0,116,1,106,2,107,7,114,
+ 36,116,3,100,1,106,4,124,1,106,0,131,1,100,2,124,
+ 1,106,0,144,1,131,1,130,1,116,5,116,6,106,7,124,
+ 1,131,2,83,0,41,3,122,24,67,114,101,97,116,101,32,
+ 97,32,98,117,105,108,116,45,105,110,32,109,111,100,117,108,
+ 101,122,29,123,33,114,125,32,105,115,32,110,111,116,32,97,
32,98,117,105,108,116,45,105,110,32,109,111,100,117,108,101,
- 78,41,3,114,65,0,0,0,114,57,0,0,0,90,12,101,
- 120,101,99,95,98,117,105,108,116,105,110,41,2,114,19,0,
- 0,0,114,89,0,0,0,114,10,0,0,0,114,10,0,0,
- 0,114,11,0,0,0,114,139,0,0,0,233,2,0,0,115,
- 2,0,0,0,0,3,122,27,66,117,105,108,116,105,110,73,
- 109,112,111,114,116,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,0,
- 1,0,0,0,67,0,0,0,115,4,0,0,0,100,1,0,
- 83,41,2,122,57,82,101,116,117,114,110,32,78,111,110,101,
- 32,97,115,32,98,117,105,108,116,45,105,110,32,109,111,100,
- 117,108,101,115,32,100,111,32,110,111,116,32,104,97,118,101,
- 32,99,111,100,101,32,111,98,106,101,99,116,115,46,78,114,
- 10,0,0,0,41,2,114,151,0,0,0,114,78,0,0,0,
- 114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,218,
- 8,103,101,116,95,99,111,100,101,238,2,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,1,0,83,41,2,122,56,
- 82,101,116,117,114,110,32,78,111,110,101,32,97,115,32,98,
- 117,105,108,116,45,105,110,32,109,111,100,117,108,101,115,32,
- 100,111,32,110,111,116,32,104,97,118,101,32,115,111,117,114,
- 99,101,32,99,111,100,101,46,78,114,10,0,0,0,41,2,
- 114,151,0,0,0,114,78,0,0,0,114,10,0,0,0,114,
- 10,0,0,0,114,11,0,0,0,218,10,103,101,116,95,115,
- 111,117,114,99,101,244,2,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,
+ 114,15,0,0,0,41,8,114,15,0,0,0,114,14,0,0,
+ 0,114,76,0,0,0,114,77,0,0,0,114,50,0,0,0,
+ 114,65,0,0,0,114,57,0,0,0,90,14,99,114,101,97,
+ 116,101,95,98,117,105,108,116,105,110,41,2,114,19,0,0,
+ 0,114,88,0,0,0,114,10,0,0,0,114,10,0,0,0,
+ 114,11,0,0,0,114,138,0,0,0,225,2,0,0,115,8,
+ 0,0,0,0,3,12,1,14,1,10,1,122,29,66,117,105,
+ 108,116,105,110,73,109,112,111,114,116,101,114,46,99,114,101,
+ 97,116,101,95,109,111,100,117,108,101,99,2,0,0,0,0,
+ 0,0,0,2,0,0,0,3,0,0,0,67,0,0,0,115,
+ 16,0,0,0,116,0,116,1,106,2,124,1,131,2,1,0,
+ 100,1,83,0,41,2,122,22,69,120,101,99,32,97,32,98,
+ 117,105,108,116,45,105,110,32,109,111,100,117,108,101,78,41,
+ 3,114,65,0,0,0,114,57,0,0,0,90,12,101,120,101,
+ 99,95,98,117,105,108,116,105,110,41,2,114,19,0,0,0,
+ 114,89,0,0,0,114,10,0,0,0,114,10,0,0,0,114,
+ 11,0,0,0,114,139,0,0,0,233,2,0,0,115,2,0,
+ 0,0,0,3,122,27,66,117,105,108,116,105,110,73,109,112,
+ 111,114,116,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,0,1,0,
+ 0,0,67,0,0,0,115,4,0,0,0,100,1,83,0,41,
+ 2,122,57,82,101,116,117,114,110,32,78,111,110,101,32,97,
+ 115,32,98,117,105,108,116,45,105,110,32,109,111,100,117,108,
+ 101,115,32,100,111,32,110,111,116,32,104,97,118,101,32,99,
+ 111,100,101,32,111,98,106,101,99,116,115,46,78,114,10,0,
+ 0,0,41,2,114,152,0,0,0,114,78,0,0,0,114,10,
+ 0,0,0,114,10,0,0,0,114,11,0,0,0,218,8,103,
+ 101,116,95,99,111,100,101,238,2,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,1,0,83,41,2,122,52,82,101,
- 116,117,114,110,32,70,97,108,115,101,32,97,115,32,98,117,
- 105,108,116,45,105,110,32,109,111,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,10,0,0,0,41,2,114,151,0,0,0,114,
- 78,0,0,0,114,10,0,0,0,114,10,0,0,0,114,11,
- 0,0,0,114,109,0,0,0,250,2,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,
- 17,114,1,0,0,0,114,0,0,0,0,114,2,0,0,0,
- 114,3,0,0,0,218,12,115,116,97,116,105,99,109,101,116,
- 104,111,100,114,92,0,0,0,218,11,99,108,97,115,115,109,
- 101,116,104,111,100,114,154,0,0,0,114,155,0,0,0,114,
- 138,0,0,0,114,139,0,0,0,114,81,0,0,0,114,156,
- 0,0,0,114,157,0,0,0,114,109,0,0,0,114,90,0,
- 0,0,114,146,0,0,0,114,10,0,0,0,114,10,0,0,
- 0,114,10,0,0,0,114,11,0,0,0,114,150,0,0,0,
- 186,2,0,0,115,30,0,0,0,12,7,6,2,18,9,3,
- 1,21,8,3,1,18,11,18,8,18,5,3,1,21,5,3,
- 1,21,5,3,1,21,5,114,150,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,211,0,0,0,101,0,0,90,1,0,100,0,0,90,
- 2,0,100,1,0,90,3,0,101,4,0,100,2,0,100,3,
- 0,132,0,0,131,1,0,90,5,0,101,6,0,100,4,0,
- 100,4,0,100,5,0,100,6,0,132,2,0,131,1,0,90,
- 7,0,101,6,0,100,4,0,100,7,0,100,8,0,132,1,
- 0,131,1,0,90,8,0,101,6,0,100,9,0,100,10,0,
- 132,0,0,131,1,0,90,9,0,101,4,0,100,11,0,100,
- 12,0,132,0,0,131,1,0,90,10,0,101,6,0,100,13,
- 0,100,14,0,132,0,0,131,1,0,90,11,0,101,6,0,
- 101,12,0,100,15,0,100,16,0,132,0,0,131,1,0,131,
- 1,0,90,13,0,101,6,0,101,12,0,100,17,0,100,18,
- 0,132,0,0,131,1,0,131,1,0,90,14,0,101,6,0,
- 101,12,0,100,19,0,100,20,0,132,0,0,131,1,0,131,
- 1,0,90,15,0,100,4,0,83,41,21,218,14,70,114,111,
- 122,101,110,73,109,112,111,114,116,101,114,122,142,77,101,116,
- 97,32,112,97,116,104,32,105,109,112,111,114,116,32,102,111,
- 114,32,102,114,111,122,101,110,32,109,111,100,117,108,101,115,
- 46,10,10,32,32,32,32,65,108,108,32,109,101,116,104,111,
- 100,115,32,97,114,101,32,101,105,116,104,101,114,32,99,108,
- 97,115,115,32,111,114,32,115,116,97,116,105,99,32,109,101,
- 116,104,111,100,115,32,116,111,32,97,118,111,105,100,32,116,
- 104,101,32,110,101,101,100,32,116,111,10,32,32,32,32,105,
- 110,115,116,97,110,116,105,97,116,101,32,116,104,101,32,99,
- 108,97,115,115,46,10,10,32,32,32,32,99,1,0,0,0,
- 0,0,0,0,1,0,0,0,2,0,0,0,67,0,0,0,
- 115,16,0,0,0,100,1,0,106,0,0,124,0,0,106,1,
- 0,131,1,0,83,41,2,122,115,82,101,116,117,114,110,32,
- 114,101,112,114,32,102,111,114,32,116,104,101,32,109,111,100,
- 117,108,101,46,10,10,32,32,32,32,32,32,32,32,84,104,
- 101,32,109,101,116,104,111,100,32,105,115,32,100,101,112,114,
- 101,99,97,116,101,100,46,32,32,84,104,101,32,105,109,112,
- 111,114,116,32,109,97,99,104,105,110,101,114,121,32,100,111,
- 101,115,32,116,104,101,32,106,111,98,32,105,116,115,101,108,
- 102,46,10,10,32,32,32,32,32,32,32,32,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,50,0,0,0,114,1,0,0,0,
- 41,1,218,1,109,114,10,0,0,0,114,10,0,0,0,114,
- 11,0,0,0,114,92,0,0,0,12,3,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,0,0,5,0,
- 0,0,67,0,0,0,115,42,0,0,0,116,0,0,106,1,
- 0,124,1,0,131,1,0,114,34,0,116,2,0,124,1,0,
- 124,0,0,100,1,0,100,2,0,131,2,1,83,100,0,0,
- 83,100,0,0,83,41,3,78,114,107,0,0,0,90,6,102,
- 114,111,122,101,110,41,3,114,57,0,0,0,114,82,0,0,
- 0,114,85,0,0,0,41,4,114,151,0,0,0,114,78,0,
- 0,0,114,152,0,0,0,114,153,0,0,0,114,10,0,0,
- 0,114,10,0,0,0,114,11,0,0,0,114,154,0,0,0,
- 21,3,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,0,0,115,23,
- 0,0,0,116,0,0,106,1,0,124,1,0,131,1,0,114,
- 19,0,124,0,0,83,100,1,0,83,41,2,122,93,70,105,
- 110,100,32,97,32,102,114,111,122,101,110,32,109,111,100,117,
- 108,101,46,10,10,32,32,32,32,32,32,32,32,84,104,105,
- 115,32,109,101,116,104,111,100,32,105,115,32,100,101,112,114,
- 101,99,97,116,101,100,46,32,32,85,115,101,32,102,105,110,
- 100,95,115,112,101,99,40,41,32,105,110,115,116,101,97,100,
- 46,10,10,32,32,32,32,32,32,32,32,78,41,2,114,57,
- 0,0,0,114,82,0,0,0,41,3,114,151,0,0,0,114,
- 78,0,0,0,114,152,0,0,0,114,10,0,0,0,114,10,
- 0,0,0,114,11,0,0,0,114,155,0,0,0,28,3,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,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,122,42,85,115,101,32,100,101,102,97,117,108,
- 116,32,115,101,109,97,110,116,105,99,115,32,102,111,114,32,
- 109,111,100,117,108,101,32,99,114,101,97,116,105,111,110,46,
- 78,114,10,0,0,0,41,2,114,151,0,0,0,114,88,0,
+ 0,115,4,0,0,0,100,1,83,0,41,2,122,56,82,101,
+ 116,117,114,110,32,78,111,110,101,32,97,115,32,98,117,105,
+ 108,116,45,105,110,32,109,111,100,117,108,101,115,32,100,111,
+ 32,110,111,116,32,104,97,118,101,32,115,111,117,114,99,101,
+ 32,99,111,100,101,46,78,114,10,0,0,0,41,2,114,152,
+ 0,0,0,114,78,0,0,0,114,10,0,0,0,114,10,0,
+ 0,0,114,11,0,0,0,218,10,103,101,116,95,115,111,117,
+ 114,99,101,244,2,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,1,0,0,0,67,0,0,0,115,
+ 4,0,0,0,100,1,83,0,41,2,122,52,82,101,116,117,
+ 114,110,32,70,97,108,115,101,32,97,115,32,98,117,105,108,
+ 116,45,105,110,32,109,111,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,10,0,0,0,41,2,114,152,0,0,0,114,78,0,
0,0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,
- 0,114,138,0,0,0,37,3,0,0,115,0,0,0,0,122,
- 28,70,114,111,122,101,110,73,109,112,111,114,116,101,114,46,
- 99,114,101,97,116,101,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,92,0,0,0,124,0,0,106,0,0,106,1,0,
- 125,1,0,116,2,0,106,3,0,124,1,0,131,1,0,115,
- 54,0,116,4,0,100,1,0,106,5,0,124,1,0,131,1,
- 0,100,2,0,124,1,0,131,1,1,130,1,0,116,6,0,
- 116,2,0,106,7,0,124,1,0,131,2,0,125,2,0,116,
- 8,0,124,2,0,124,0,0,106,9,0,131,2,0,1,100,
- 0,0,83,41,3,78,122,27,123,33,114,125,32,105,115,32,
- 110,111,116,32,97,32,102,114,111,122,101,110,32,109,111,100,
- 117,108,101,114,15,0,0,0,41,10,114,95,0,0,0,114,
- 15,0,0,0,114,57,0,0,0,114,82,0,0,0,114,77,
- 0,0,0,114,50,0,0,0,114,65,0,0,0,218,17,103,
- 101,116,95,102,114,111,122,101,110,95,111,98,106,101,99,116,
- 218,4,101,120,101,99,114,7,0,0,0,41,3,114,89,0,
- 0,0,114,15,0,0,0,218,4,99,111,100,101,114,10,0,
- 0,0,114,10,0,0,0,114,11,0,0,0,114,139,0,0,
- 0,41,3,0,0,115,12,0,0,0,0,2,12,1,15,1,
- 18,1,9,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,0,0,0,0,0,0,0,2,0,0,0,3,
- 0,0,0,67,0,0,0,115,13,0,0,0,116,0,0,124,
- 0,0,124,1,0,131,2,0,83,41,1,122,95,76,111,97,
+ 0,114,109,0,0,0,250,2,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,2,78,
+ 78,41,1,78,41,17,114,1,0,0,0,114,0,0,0,0,
+ 114,2,0,0,0,114,3,0,0,0,218,12,115,116,97,116,
+ 105,99,109,101,116,104,111,100,114,92,0,0,0,218,11,99,
+ 108,97,115,115,109,101,116,104,111,100,114,155,0,0,0,114,
+ 156,0,0,0,114,138,0,0,0,114,139,0,0,0,114,81,
+ 0,0,0,114,157,0,0,0,114,158,0,0,0,114,109,0,
+ 0,0,114,90,0,0,0,114,147,0,0,0,114,10,0,0,
+ 0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,
+ 114,151,0,0,0,186,2,0,0,115,30,0,0,0,8,7,
+ 4,2,12,9,2,1,12,8,2,1,12,11,12,8,12,5,
+ 2,1,14,5,2,1,14,5,2,1,14,5,114,151,0,0,
+ 0,99,0,0,0,0,0,0,0,0,0,0,0,0,4,0,
+ 0,0,64,0,0,0,115,140,0,0,0,101,0,90,1,100,
+ 0,90,2,100,1,90,3,101,4,100,2,100,3,132,0,131,
+ 1,90,5,101,6,100,21,100,5,100,6,132,1,131,1,90,
+ 7,101,6,100,22,100,7,100,8,132,1,131,1,90,8,101,
+ 6,100,9,100,10,132,0,131,1,90,9,101,4,100,11,100,
+ 12,132,0,131,1,90,10,101,6,100,13,100,14,132,0,131,
+ 1,90,11,101,6,101,12,100,15,100,16,132,0,131,1,131,
+ 1,90,13,101,6,101,12,100,17,100,18,132,0,131,1,131,
+ 1,90,14,101,6,101,12,100,19,100,20,132,0,131,1,131,
+ 1,90,15,100,4,83,0,41,23,218,14,70,114,111,122,101,
+ 110,73,109,112,111,114,116,101,114,122,142,77,101,116,97,32,
+ 112,97,116,104,32,105,109,112,111,114,116,32,102,111,114,32,
+ 102,114,111,122,101,110,32,109,111,100,117,108,101,115,46,10,
+ 10,32,32,32,32,65,108,108,32,109,101,116,104,111,100,115,
+ 32,97,114,101,32,101,105,116,104,101,114,32,99,108,97,115,
+ 115,32,111,114,32,115,116,97,116,105,99,32,109,101,116,104,
+ 111,100,115,32,116,111,32,97,118,111,105,100,32,116,104,101,
+ 32,110,101,101,100,32,116,111,10,32,32,32,32,105,110,115,
+ 116,97,110,116,105,97,116,101,32,116,104,101,32,99,108,97,
+ 115,115,46,10,10,32,32,32,32,99,1,0,0,0,0,0,
+ 0,0,1,0,0,0,2,0,0,0,67,0,0,0,115,12,
+ 0,0,0,100,1,106,0,124,0,106,1,131,1,83,0,41,
+ 2,122,115,82,101,116,117,114,110,32,114,101,112,114,32,102,
+ 111,114,32,116,104,101,32,109,111,100,117,108,101,46,10,10,
+ 32,32,32,32,32,32,32,32,84,104,101,32,109,101,116,104,
+ 111,100,32,105,115,32,100,101,112,114,101,99,97,116,101,100,
+ 46,32,32,84,104,101,32,105,109,112,111,114,116,32,109,97,
+ 99,104,105,110,101,114,121,32,100,111,101,115,32,116,104,101,
+ 32,106,111,98,32,105,116,115,101,108,102,46,10,10,32,32,
+ 32,32,32,32,32,32,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,50,0,0,0,114,1,0,0,0,41,1,218,1,109,114,
+ 10,0,0,0,114,10,0,0,0,114,11,0,0,0,114,92,
+ 0,0,0,12,3,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,0,0,5,0,0,0,67,0,0,0,
+ 115,36,0,0,0,116,0,106,1,124,1,131,1,114,28,116,
+ 2,124,1,124,0,100,1,100,2,144,1,131,2,83,0,110,
+ 4,100,0,83,0,100,0,83,0,41,3,78,114,107,0,0,
+ 0,90,6,102,114,111,122,101,110,41,3,114,57,0,0,0,
+ 114,82,0,0,0,114,85,0,0,0,41,4,114,152,0,0,
+ 0,114,78,0,0,0,114,153,0,0,0,114,154,0,0,0,
+ 114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,114,
+ 155,0,0,0,21,3,0,0,115,6,0,0,0,0,2,10,
+ 1,18,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,
+ 0,0,115,18,0,0,0,116,0,106,1,124,1,131,1,114,
+ 14,124,0,83,0,100,1,83,0,41,2,122,93,70,105,110,
100,32,97,32,102,114,111,122,101,110,32,109,111,100,117,108,
101,46,10,10,32,32,32,32,32,32,32,32,84,104,105,115,
32,109,101,116,104,111,100,32,105,115,32,100,101,112,114,101,
- 99,97,116,101,100,46,32,32,85,115,101,32,101,120,101,99,
- 95,109,111,100,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,90,
- 0,0,0,41,2,114,151,0,0,0,114,78,0,0,0,114,
- 10,0,0,0,114,10,0,0,0,114,11,0,0,0,114,146,
- 0,0,0,50,3,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,0,0,0,2,0,0,0,67,0,0,0,115,
- 13,0,0,0,116,0,0,106,1,0,124,1,0,131,1,0,
- 83,41,1,122,45,82,101,116,117,114,110,32,116,104,101,32,
- 99,111,100,101,32,111,98,106,101,99,116,32,102,111,114,32,
- 116,104,101,32,102,114,111,122,101,110,32,109,111,100,117,108,
- 101,46,41,2,114,57,0,0,0,114,162,0,0,0,41,2,
- 114,151,0,0,0,114,78,0,0,0,114,10,0,0,0,114,
- 10,0,0,0,114,11,0,0,0,114,156,0,0,0,59,3,
- 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,0,0,0,115,4,0,0,0,100,1,0,83,
- 41,2,122,54,82,101,116,117,114,110,32,78,111,110,101,32,
- 97,115,32,102,114,111,122,101,110,32,109,111,100,117,108,101,
- 115,32,100,111,32,110,111,116,32,104,97,118,101,32,115,111,
- 117,114,99,101,32,99,111,100,101,46,78,114,10,0,0,0,
- 41,2,114,151,0,0,0,114,78,0,0,0,114,10,0,0,
- 0,114,10,0,0,0,114,11,0,0,0,114,157,0,0,0,
- 65,3,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,0,0,0,67,0,0,0,115,13,0,0,0,
- 116,0,0,106,1,0,124,1,0,131,1,0,83,41,1,122,
- 46,82,101,116,117,114,110,32,84,114,117,101,32,105,102,32,
- 116,104,101,32,102,114,111,122,101,110,32,109,111,100,117,108,
- 101,32,105,115,32,97,32,112,97,99,107,97,103,101,46,41,
- 2,114,57,0,0,0,90,17,105,115,95,102,114,111,122,101,
- 110,95,112,97,99,107,97,103,101,41,2,114,151,0,0,0,
- 114,78,0,0,0,114,10,0,0,0,114,10,0,0,0,114,
- 11,0,0,0,114,109,0,0,0,71,3,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,
- 16,114,1,0,0,0,114,0,0,0,0,114,2,0,0,0,
- 114,3,0,0,0,114,158,0,0,0,114,92,0,0,0,114,
- 159,0,0,0,114,154,0,0,0,114,155,0,0,0,114,138,
- 0,0,0,114,139,0,0,0,114,146,0,0,0,114,84,0,
- 0,0,114,156,0,0,0,114,157,0,0,0,114,109,0,0,
- 0,114,10,0,0,0,114,10,0,0,0,114,10,0,0,0,
- 114,11,0,0,0,114,160,0,0,0,3,3,0,0,115,30,
- 0,0,0,12,7,6,2,18,9,3,1,21,6,3,1,18,
- 8,18,4,18,9,18,9,3,1,21,5,3,1,21,5,3,
- 1,114,160,0,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,0,0,90,2,0,100,1,0,90,
- 3,0,100,2,0,100,3,0,132,0,0,90,4,0,100,4,
- 0,100,5,0,132,0,0,90,5,0,100,6,0,83,41,7,
- 218,18,95,73,109,112,111,114,116,76,111,99,107,67,111,110,
- 116,101,120,116,122,36,67,111,110,116,101,120,116,32,109,97,
- 110,97,103,101,114,32,102,111,114,32,116,104,101,32,105,109,
- 112,111,114,116,32,108,111,99,107,46,99,1,0,0,0,0,
- 0,0,0,1,0,0,0,1,0,0,0,67,0,0,0,115,
- 14,0,0,0,116,0,0,106,1,0,131,0,0,1,100,1,
- 0,83,41,2,122,24,65,99,113,117,105,114,101,32,116,104,
- 101,32,105,109,112,111,114,116,32,108,111,99,107,46,78,41,
- 2,114,57,0,0,0,114,145,0,0,0,41,1,114,19,0,
- 0,0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,
- 0,114,23,0,0,0,84,3,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,0,0,0,
- 67,0,0,0,115,14,0,0,0,116,0,0,106,1,0,131,
- 0,0,1,100,1,0,83,41,2,122,60,82,101,108,101,97,
- 115,101,32,116,104,101,32,105,109,112,111,114,116,32,108,111,
- 99,107,32,114,101,103,97,114,100,108,101,115,115,32,111,102,
- 32,97,110,121,32,114,97,105,115,101,100,32,101,120,99,101,
- 112,116,105,111,110,115,46,78,41,2,114,57,0,0,0,114,
- 58,0,0,0,41,4,114,19,0,0,0,90,8,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,
- 10,0,0,0,114,10,0,0,0,114,11,0,0,0,114,30,
- 0,0,0,88,3,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,1,
- 0,0,0,114,0,0,0,0,114,2,0,0,0,114,3,0,
- 0,0,114,23,0,0,0,114,30,0,0,0,114,10,0,0,
+ 99,97,116,101,100,46,32,32,85,115,101,32,102,105,110,100,
+ 95,115,112,101,99,40,41,32,105,110,115,116,101,97,100,46,
+ 10,10,32,32,32,32,32,32,32,32,78,41,2,114,57,0,
+ 0,0,114,82,0,0,0,41,3,114,152,0,0,0,114,78,
+ 0,0,0,114,153,0,0,0,114,10,0,0,0,114,10,0,
+ 0,0,114,11,0,0,0,114,156,0,0,0,28,3,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,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,83,
+ 0,41,2,122,42,85,115,101,32,100,101,102,97,117,108,116,
+ 32,115,101,109,97,110,116,105,99,115,32,102,111,114,32,109,
+ 111,100,117,108,101,32,99,114,101,97,116,105,111,110,46,78,
+ 114,10,0,0,0,41,2,114,152,0,0,0,114,88,0,0,
0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,
- 114,165,0,0,0,80,3,0,0,115,6,0,0,0,12,2,
- 6,2,12,4,114,165,0,0,0,99,3,0,0,0,0,0,
- 0,0,5,0,0,0,4,0,0,0,67,0,0,0,115,88,
- 0,0,0,124,1,0,106,0,0,100,1,0,124,2,0,100,
- 2,0,24,131,2,0,125,3,0,116,1,0,124,3,0,131,
- 1,0,124,2,0,107,0,0,114,52,0,116,2,0,100,3,
- 0,131,1,0,130,1,0,124,3,0,100,4,0,25,125,4,
- 0,124,0,0,114,84,0,100,5,0,106,3,0,124,4,0,
- 124,0,0,131,2,0,83,124,4,0,83,41,6,122,50,82,
- 101,115,111,108,118,101,32,97,32,114,101,108,97,116,105,118,
- 101,32,109,111,100,117,108,101,32,110,97,109,101,32,116,111,
- 32,97,110,32,97,98,115,111,108,117,116,101,32,111,110,101,
- 46,114,121,0,0,0,114,45,0,0,0,122,50,97,116,116,
- 101,109,112,116,101,100,32,114,101,108,97,116,105,118,101,32,
- 105,109,112,111,114,116,32,98,101,121,111,110,100,32,116,111,
- 112,45,108,101,118,101,108,32,112,97,99,107,97,103,101,114,
- 33,0,0,0,122,5,123,125,46,123,125,41,4,218,6,114,
- 115,112,108,105,116,218,3,108,101,110,218,10,86,97,108,117,
- 101,69,114,114,111,114,114,50,0,0,0,41,5,114,15,0,
- 0,0,218,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,10,
- 0,0,0,114,10,0,0,0,114,11,0,0,0,218,13,95,
- 114,101,115,111,108,118,101,95,110,97,109,101,93,3,0,0,
- 115,10,0,0,0,0,2,22,1,18,1,12,1,10,1,114,
- 171,0,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,124,1,0,124,2,0,131,2,0,125,3,0,
- 124,3,0,100,0,0,107,8,0,114,34,0,100,0,0,83,
- 116,1,0,124,1,0,124,3,0,131,2,0,83,41,1,78,
- 41,2,114,155,0,0,0,114,85,0,0,0,41,4,218,6,
- 102,105,110,100,101,114,114,15,0,0,0,114,152,0,0,0,
- 114,99,0,0,0,114,10,0,0,0,114,10,0,0,0,114,
- 11,0,0,0,218,17,95,102,105,110,100,95,115,112,101,99,
- 95,108,101,103,97,99,121,102,3,0,0,115,8,0,0,0,
- 0,3,18,1,12,1,4,1,114,173,0,0,0,99,3,0,
- 0,0,0,0,0,0,9,0,0,0,27,0,0,0,67,0,
- 0,0,115,42,1,0,0,116,0,0,106,1,0,100,1,0,
- 107,9,0,114,41,0,116,0,0,106,1,0,12,114,41,0,
- 116,2,0,106,3,0,100,2,0,116,4,0,131,2,0,1,
- 124,0,0,116,0,0,106,5,0,107,6,0,125,3,0,120,
- 235,0,116,0,0,106,1,0,68,93,220,0,125,4,0,116,
- 6,0,131,0,0,143,90,0,1,121,13,0,124,4,0,106,
- 7,0,125,5,0,87,110,51,0,4,116,8,0,107,10,0,
- 114,148,0,1,1,1,116,9,0,124,4,0,124,0,0,124,
- 1,0,131,3,0,125,6,0,124,6,0,100,1,0,107,8,
- 0,114,144,0,119,66,0,89,110,19,0,88,124,5,0,124,
- 0,0,124,1,0,124,2,0,131,3,0,125,6,0,87,100,
- 1,0,81,82,88,124,6,0,100,1,0,107,9,0,114,66,
- 0,124,3,0,12,114,26,1,124,0,0,116,0,0,106,5,
- 0,107,6,0,114,26,1,116,0,0,106,5,0,124,0,0,
- 25,125,7,0,121,13,0,124,7,0,106,10,0,125,8,0,
- 87,110,22,0,4,116,8,0,107,10,0,114,2,1,1,1,
- 1,124,6,0,83,89,113,30,1,88,124,8,0,100,1,0,
- 107,8,0,114,19,1,124,6,0,83,124,8,0,83,113,66,
- 0,124,6,0,83,113,66,0,87,100,1,0,83,100,1,0,
- 83,41,3,122,23,70,105,110,100,32,97,32,109,111,100,117,
- 108,101,39,115,32,108,111,97,100,101,114,46,78,122,22,115,
- 121,115,46,109,101,116,97,95,112,97,116,104,32,105,115,32,
- 101,109,112,116,121,41,11,114,14,0,0,0,218,9,109,101,
- 116,97,95,112,97,116,104,114,141,0,0,0,114,142,0,0,
- 0,218,13,73,109,112,111,114,116,87,97,114,110,105,110,103,
- 114,21,0,0,0,114,165,0,0,0,114,154,0,0,0,114,
- 96,0,0,0,114,173,0,0,0,114,95,0,0,0,41,9,
- 114,15,0,0,0,114,152,0,0,0,114,153,0,0,0,90,
- 9,105,115,95,114,101,108,111,97,100,114,172,0,0,0,114,
- 154,0,0,0,114,88,0,0,0,114,89,0,0,0,114,95,
- 0,0,0,114,10,0,0,0,114,10,0,0,0,114,11,0,
- 0,0,218,10,95,102,105,110,100,95,115,112,101,99,111,3,
- 0,0,115,48,0,0,0,0,2,25,1,16,4,15,1,16,
- 1,10,1,3,1,13,1,13,1,18,1,12,1,8,2,25,
- 1,12,2,22,1,13,1,3,1,13,1,13,4,9,2,12,
- 1,4,2,7,2,8,2,114,176,0,0,0,99,3,0,0,
- 0,0,0,0,0,4,0,0,0,4,0,0,0,67,0,0,
- 0,115,185,0,0,0,116,0,0,124,0,0,116,1,0,131,
- 2,0,115,42,0,116,2,0,100,1,0,106,3,0,116,4,
- 0,124,0,0,131,1,0,131,1,0,131,1,0,130,1,0,
- 124,2,0,100,2,0,107,0,0,114,66,0,116,5,0,100,
- 3,0,131,1,0,130,1,0,124,2,0,100,2,0,107,4,
- 0,114,150,0,116,0,0,124,1,0,116,1,0,131,2,0,
- 115,108,0,116,2,0,100,4,0,131,1,0,130,1,0,110,
- 42,0,124,1,0,116,6,0,106,7,0,107,7,0,114,150,
- 0,100,5,0,125,3,0,116,8,0,124,3,0,106,3,0,
- 124,1,0,131,1,0,131,1,0,130,1,0,124,0,0,12,
- 114,181,0,124,2,0,100,2,0,107,2,0,114,181,0,116,
- 5,0,100,6,0,131,1,0,130,1,0,100,7,0,83,41,
- 8,122,28,86,101,114,105,102,121,32,97,114,103,117,109,101,
+ 114,138,0,0,0,37,3,0,0,115,0,0,0,0,122,28,
+ 70,114,111,122,101,110,73,109,112,111,114,116,101,114,46,99,
+ 114,101,97,116,101,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,66,0,0,0,124,0,106,0,106,1,125,1,116,2,
+ 106,3,124,1,131,1,115,38,116,4,100,1,106,5,124,1,
+ 131,1,100,2,124,1,144,1,131,1,130,1,116,6,116,2,
+ 106,7,124,1,131,2,125,2,116,8,124,2,124,0,106,9,
+ 131,2,1,0,100,0,83,0,41,3,78,122,27,123,33,114,
+ 125,32,105,115,32,110,111,116,32,97,32,102,114,111,122,101,
+ 110,32,109,111,100,117,108,101,114,15,0,0,0,41,10,114,
+ 95,0,0,0,114,15,0,0,0,114,57,0,0,0,114,82,
+ 0,0,0,114,77,0,0,0,114,50,0,0,0,114,65,0,
+ 0,0,218,17,103,101,116,95,102,114,111,122,101,110,95,111,
+ 98,106,101,99,116,218,4,101,120,101,99,114,7,0,0,0,
+ 41,3,114,89,0,0,0,114,15,0,0,0,218,4,99,111,
+ 100,101,114,10,0,0,0,114,10,0,0,0,114,11,0,0,
+ 0,114,139,0,0,0,41,3,0,0,115,12,0,0,0,0,
+ 2,8,1,10,1,12,1,8,1,12,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,0,0,0,0,0,0,0,
+ 2,0,0,0,3,0,0,0,67,0,0,0,115,10,0,0,
+ 0,116,0,124,0,124,1,131,2,83,0,41,1,122,95,76,
+ 111,97,100,32,97,32,102,114,111,122,101,110,32,109,111,100,
+ 117,108,101,46,10,10,32,32,32,32,32,32,32,32,84,104,
+ 105,115,32,109,101,116,104,111,100,32,105,115,32,100,101,112,
+ 114,101,99,97,116,101,100,46,32,32,85,115,101,32,101,120,
+ 101,99,95,109,111,100,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,90,0,0,0,41,2,114,152,0,0,0,114,78,0,0,
+ 0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,
+ 114,147,0,0,0,50,3,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,0,0,0,2,0,0,0,67,0,0,
+ 0,115,10,0,0,0,116,0,106,1,124,1,131,1,83,0,
+ 41,1,122,45,82,101,116,117,114,110,32,116,104,101,32,99,
+ 111,100,101,32,111,98,106,101,99,116,32,102,111,114,32,116,
+ 104,101,32,102,114,111,122,101,110,32,109,111,100,117,108,101,
+ 46,41,2,114,57,0,0,0,114,163,0,0,0,41,2,114,
+ 152,0,0,0,114,78,0,0,0,114,10,0,0,0,114,10,
+ 0,0,0,114,11,0,0,0,114,157,0,0,0,59,3,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,0,0,0,115,4,0,0,0,100,1,83,0,41,
+ 2,122,54,82,101,116,117,114,110,32,78,111,110,101,32,97,
+ 115,32,102,114,111,122,101,110,32,109,111,100,117,108,101,115,
+ 32,100,111,32,110,111,116,32,104,97,118,101,32,115,111,117,
+ 114,99,101,32,99,111,100,101,46,78,114,10,0,0,0,41,
+ 2,114,152,0,0,0,114,78,0,0,0,114,10,0,0,0,
+ 114,10,0,0,0,114,11,0,0,0,114,158,0,0,0,65,
+ 3,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,0,0,0,67,0,0,0,115,10,0,0,0,116,
+ 0,106,1,124,1,131,1,83,0,41,1,122,46,82,101,116,
+ 117,114,110,32,84,114,117,101,32,105,102,32,116,104,101,32,
+ 102,114,111,122,101,110,32,109,111,100,117,108,101,32,105,115,
+ 32,97,32,112,97,99,107,97,103,101,46,41,2,114,57,0,
+ 0,0,90,17,105,115,95,102,114,111,122,101,110,95,112,97,
+ 99,107,97,103,101,41,2,114,152,0,0,0,114,78,0,0,
+ 0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,
+ 114,109,0,0,0,71,3,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,2,78,78,41,
+ 1,78,41,16,114,1,0,0,0,114,0,0,0,0,114,2,
+ 0,0,0,114,3,0,0,0,114,159,0,0,0,114,92,0,
+ 0,0,114,160,0,0,0,114,155,0,0,0,114,156,0,0,
+ 0,114,138,0,0,0,114,139,0,0,0,114,147,0,0,0,
+ 114,84,0,0,0,114,157,0,0,0,114,158,0,0,0,114,
+ 109,0,0,0,114,10,0,0,0,114,10,0,0,0,114,10,
+ 0,0,0,114,11,0,0,0,114,161,0,0,0,3,3,0,
+ 0,115,30,0,0,0,8,7,4,2,12,9,2,1,12,6,
+ 2,1,12,8,12,4,12,9,12,9,2,1,14,5,2,1,
+ 14,5,2,1,114,161,0,0,0,99,0,0,0,0,0,0,
+ 0,0,0,0,0,0,2,0,0,0,64,0,0,0,115,32,
+ 0,0,0,101,0,90,1,100,0,90,2,100,1,90,3,100,
+ 2,100,3,132,0,90,4,100,4,100,5,132,0,90,5,100,
+ 6,83,0,41,7,218,18,95,73,109,112,111,114,116,76,111,
+ 99,107,67,111,110,116,101,120,116,122,36,67,111,110,116,101,
+ 120,116,32,109,97,110,97,103,101,114,32,102,111,114,32,116,
+ 104,101,32,105,109,112,111,114,116,32,108,111,99,107,46,99,
+ 1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,
+ 67,0,0,0,115,12,0,0,0,116,0,106,1,131,0,1,
+ 0,100,1,83,0,41,2,122,24,65,99,113,117,105,114,101,
+ 32,116,104,101,32,105,109,112,111,114,116,32,108,111,99,107,
+ 46,78,41,2,114,57,0,0,0,114,146,0,0,0,41,1,
+ 114,19,0,0,0,114,10,0,0,0,114,10,0,0,0,114,
+ 11,0,0,0,114,23,0,0,0,84,3,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,
+ 0,0,0,67,0,0,0,115,12,0,0,0,116,0,106,1,
+ 131,0,1,0,100,1,83,0,41,2,122,60,82,101,108,101,
+ 97,115,101,32,116,104,101,32,105,109,112,111,114,116,32,108,
+ 111,99,107,32,114,101,103,97,114,100,108,101,115,115,32,111,
+ 102,32,97,110,121,32,114,97,105,115,101,100,32,101,120,99,
+ 101,112,116,105,111,110,115,46,78,41,2,114,57,0,0,0,
+ 114,58,0,0,0,41,4,114,19,0,0,0,90,8,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,10,0,0,0,114,10,0,0,0,114,11,0,0,0,114,
+ 30,0,0,0,88,3,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,
+ 1,0,0,0,114,0,0,0,0,114,2,0,0,0,114,3,
+ 0,0,0,114,23,0,0,0,114,30,0,0,0,114,10,0,
+ 0,0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,
+ 0,114,166,0,0,0,80,3,0,0,115,6,0,0,0,8,
+ 2,4,2,8,4,114,166,0,0,0,99,3,0,0,0,0,
+ 0,0,0,5,0,0,0,4,0,0,0,67,0,0,0,115,
+ 64,0,0,0,124,1,106,0,100,1,124,2,100,2,24,0,
+ 131,2,125,3,116,1,124,3,131,1,124,2,107,0,114,36,
+ 116,2,100,3,131,1,130,1,124,3,100,4,25,0,125,4,
+ 124,0,114,60,100,5,106,3,124,4,124,0,131,2,83,0,
+ 124,4,83,0,41,6,122,50,82,101,115,111,108,118,101,32,
+ 97,32,114,101,108,97,116,105,118,101,32,109,111,100,117,108,
+ 101,32,110,97,109,101,32,116,111,32,97,110,32,97,98,115,
+ 111,108,117,116,101,32,111,110,101,46,114,121,0,0,0,114,
+ 45,0,0,0,122,50,97,116,116,101,109,112,116,101,100,32,
+ 114,101,108,97,116,105,118,101,32,105,109,112,111,114,116,32,
+ 98,101,121,111,110,100,32,116,111,112,45,108,101,118,101,108,
+ 32,112,97,99,107,97,103,101,114,33,0,0,0,122,5,123,
+ 125,46,123,125,41,4,218,6,114,115,112,108,105,116,218,3,
+ 108,101,110,218,10,86,97,108,117,101,69,114,114,111,114,114,
+ 50,0,0,0,41,5,114,15,0,0,0,218,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,10,0,0,0,114,10,0,0,
+ 0,114,11,0,0,0,218,13,95,114,101,115,111,108,118,101,
+ 95,110,97,109,101,93,3,0,0,115,10,0,0,0,0,2,
+ 16,1,12,1,8,1,8,1,114,172,0,0,0,99,3,0,
+ 0,0,0,0,0,0,4,0,0,0,3,0,0,0,67,0,
+ 0,0,115,34,0,0,0,124,0,106,0,124,1,124,2,131,
+ 2,125,3,124,3,100,0,107,8,114,24,100,0,83,0,116,
+ 1,124,1,124,3,131,2,83,0,41,1,78,41,2,114,156,
+ 0,0,0,114,85,0,0,0,41,4,218,6,102,105,110,100,
+ 101,114,114,15,0,0,0,114,153,0,0,0,114,99,0,0,
+ 0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,
+ 218,17,95,102,105,110,100,95,115,112,101,99,95,108,101,103,
+ 97,99,121,102,3,0,0,115,8,0,0,0,0,3,12,1,
+ 8,1,4,1,114,174,0,0,0,99,3,0,0,0,0,0,
+ 0,0,10,0,0,0,27,0,0,0,67,0,0,0,115,244,
+ 0,0,0,116,0,106,1,125,3,124,3,100,1,107,8,114,
+ 22,116,2,100,2,131,1,130,1,124,3,115,38,116,3,106,
+ 4,100,3,116,5,131,2,1,0,124,0,116,0,106,6,107,
+ 6,125,4,120,190,124,3,68,0,93,178,125,5,116,7,131,
+ 0,143,72,1,0,121,10,124,5,106,8,125,6,87,0,110,
+ 42,4,0,116,9,107,10,114,118,1,0,1,0,1,0,116,
+ 10,124,5,124,0,124,1,131,3,125,7,124,7,100,1,107,
+ 8,114,114,119,54,89,0,110,14,88,0,124,6,124,0,124,
+ 1,124,2,131,3,125,7,87,0,100,1,81,0,82,0,88,
+ 0,124,7,100,1,107,9,114,54,124,4,12,0,114,228,124,
+ 0,116,0,106,6,107,6,114,228,116,0,106,6,124,0,25,
+ 0,125,8,121,10,124,8,106,11,125,9,87,0,110,20,4,
+ 0,116,9,107,10,114,206,1,0,1,0,1,0,124,7,83,
+ 0,88,0,124,9,100,1,107,8,114,222,124,7,83,0,113,
+ 232,124,9,83,0,113,54,124,7,83,0,113,54,87,0,100,
+ 1,83,0,100,1,83,0,41,4,122,23,70,105,110,100,32,
+ 97,32,109,111,100,117,108,101,39,115,32,108,111,97,100,101,
+ 114,46,78,122,53,115,121,115,46,109,101,116,97,95,112,97,
+ 116,104,32,105,115,32,78,111,110,101,44,32,80,121,116,104,
+ 111,110,32,105,115,32,108,105,107,101,108,121,32,115,104,117,
+ 116,116,105,110,103,32,100,111,119,110,122,22,115,121,115,46,
+ 109,101,116,97,95,112,97,116,104,32,105,115,32,101,109,112,
+ 116,121,41,12,114,14,0,0,0,218,9,109,101,116,97,95,
+ 112,97,116,104,114,77,0,0,0,114,142,0,0,0,114,143,
+ 0,0,0,218,13,73,109,112,111,114,116,87,97,114,110,105,
+ 110,103,114,21,0,0,0,114,166,0,0,0,114,155,0,0,
+ 0,114,96,0,0,0,114,174,0,0,0,114,95,0,0,0,
+ 41,10,114,15,0,0,0,114,153,0,0,0,114,154,0,0,
+ 0,114,175,0,0,0,90,9,105,115,95,114,101,108,111,97,
+ 100,114,173,0,0,0,114,155,0,0,0,114,88,0,0,0,
+ 114,89,0,0,0,114,95,0,0,0,114,10,0,0,0,114,
+ 10,0,0,0,114,11,0,0,0,218,10,95,102,105,110,100,
+ 95,115,112,101,99,111,3,0,0,115,54,0,0,0,0,2,
+ 6,1,8,2,8,3,4,1,12,5,10,1,10,1,8,1,
+ 2,1,10,1,14,1,12,1,8,1,8,2,22,1,8,2,
+ 16,1,10,1,2,1,10,1,14,4,6,2,8,1,6,2,
+ 6,2,8,2,114,177,0,0,0,99,3,0,0,0,0,0,
+ 0,0,4,0,0,0,4,0,0,0,67,0,0,0,115,140,
+ 0,0,0,116,0,124,0,116,1,131,2,115,28,116,2,100,
+ 1,106,3,116,4,124,0,131,1,131,1,131,1,130,1,124,
+ 2,100,2,107,0,114,44,116,5,100,3,131,1,130,1,124,
+ 2,100,2,107,4,114,114,116,0,124,1,116,1,131,2,115,
+ 72,116,2,100,4,131,1,130,1,110,42,124,1,115,86,116,
+ 6,100,5,131,1,130,1,110,28,124,1,116,7,106,8,107,
+ 7,114,114,100,6,125,3,116,9,124,3,106,3,124,1,131,
+ 1,131,1,130,1,124,0,12,0,114,136,124,2,100,2,107,
+ 2,114,136,116,5,100,7,131,1,130,1,100,8,83,0,41,
+ 9,122,28,86,101,114,105,102,121,32,97,114,103,117,109,101,
110,116,115,32,97,114,101,32,34,115,97,110,101,34,46,122,
31,109,111,100,117,108,101,32,110,97,109,101,32,109,117,115,
116,32,98,101,32,115,116,114,44,32,110,111,116,32,123,125,
114,33,0,0,0,122,18,108,101,118,101,108,32,109,117,115,
116,32,98,101,32,62,61,32,48,122,31,95,95,112,97,99,
107,97,103,101,95,95,32,110,111,116,32,115,101,116,32,116,
- 111,32,97,32,115,116,114,105,110,103,122,61,80,97,114,101,
- 110,116,32,109,111,100,117,108,101,32,123,33,114,125,32,110,
- 111,116,32,108,111,97,100,101,100,44,32,99,97,110,110,111,
- 116,32,112,101,114,102,111,114,109,32,114,101,108,97,116,105,
- 118,101,32,105,109,112,111,114,116,122,17,69,109,112,116,121,
- 32,109,111,100,117,108,101,32,110,97,109,101,78,41,9,218,
- 10,105,115,105,110,115,116,97,110,99,101,218,3,115,116,114,
- 218,9,84,121,112,101,69,114,114,111,114,114,50,0,0,0,
- 114,13,0,0,0,114,168,0,0,0,114,14,0,0,0,114,
- 21,0,0,0,218,11,83,121,115,116,101,109,69,114,114,111,
- 114,41,4,114,15,0,0,0,114,169,0,0,0,114,170,0,
- 0,0,114,147,0,0,0,114,10,0,0,0,114,10,0,0,
- 0,114,11,0,0,0,218,13,95,115,97,110,105,116,121,95,
- 99,104,101,99,107,151,3,0,0,115,24,0,0,0,0,2,
- 15,1,27,1,12,1,12,1,12,1,15,1,15,1,15,1,
- 6,2,21,1,19,1,114,181,0,0,0,122,16,78,111,32,
- 109,111,100,117,108,101,32,110,97,109,101,100,32,122,4,123,
- 33,114,125,99,2,0,0,0,0,0,0,0,8,0,0,0,
- 12,0,0,0,67,0,0,0,115,40,1,0,0,100,0,0,
- 125,2,0,124,0,0,106,0,0,100,1,0,131,1,0,100,
- 2,0,25,125,3,0,124,3,0,114,175,0,124,3,0,116,
- 1,0,106,2,0,107,7,0,114,59,0,116,3,0,124,1,
- 0,124,3,0,131,2,0,1,124,0,0,116,1,0,106,2,
- 0,107,6,0,114,85,0,116,1,0,106,2,0,124,0,0,
- 25,83,116,1,0,106,2,0,124,3,0,25,125,4,0,121,
- 13,0,124,4,0,106,4,0,125,2,0,87,110,61,0,4,
- 116,5,0,107,10,0,114,174,0,1,1,1,116,6,0,100,
- 3,0,23,106,7,0,124,0,0,124,3,0,131,2,0,125,
- 5,0,116,8,0,124,5,0,100,4,0,124,0,0,131,1,
- 1,100,0,0,130,2,0,89,110,1,0,88,116,9,0,124,
- 0,0,124,2,0,131,2,0,125,6,0,124,6,0,100,0,
- 0,107,8,0,114,232,0,116,8,0,116,6,0,106,7,0,
- 124,0,0,131,1,0,100,4,0,124,0,0,131,1,1,130,
- 1,0,110,12,0,116,10,0,124,6,0,131,1,0,125,7,
- 0,124,3,0,114,36,1,116,1,0,106,2,0,124,3,0,
- 25,125,4,0,116,11,0,124,4,0,124,0,0,106,0,0,
- 100,1,0,131,1,0,100,5,0,25,124,7,0,131,3,0,
- 1,124,7,0,83,41,6,78,114,121,0,0,0,114,33,0,
- 0,0,122,23,59,32,123,33,114,125,32,105,115,32,110,111,
- 116,32,97,32,112,97,99,107,97,103,101,114,15,0,0,0,
- 114,140,0,0,0,41,12,114,122,0,0,0,114,14,0,0,
- 0,114,21,0,0,0,114,65,0,0,0,114,131,0,0,0,
- 114,96,0,0,0,218,8,95,69,82,82,95,77,83,71,114,
- 50,0,0,0,114,77,0,0,0,114,176,0,0,0,114,149,
- 0,0,0,114,5,0,0,0,41,8,114,15,0,0,0,218,
- 7,105,109,112,111,114,116,95,114,152,0,0,0,114,123,0,
- 0,0,90,13,112,97,114,101,110,116,95,109,111,100,117,108,
- 101,114,147,0,0,0,114,88,0,0,0,114,89,0,0,0,
+ 111,32,97,32,115,116,114,105,110,103,122,54,97,116,116,101,
+ 109,112,116,101,100,32,114,101,108,97,116,105,118,101,32,105,
+ 109,112,111,114,116,32,119,105,116,104,32,110,111,32,107,110,
+ 111,119,110,32,112,97,114,101,110,116,32,112,97,99,107,97,
+ 103,101,122,61,80,97,114,101,110,116,32,109,111,100,117,108,
+ 101,32,123,33,114,125,32,110,111,116,32,108,111,97,100,101,
+ 100,44,32,99,97,110,110,111,116,32,112,101,114,102,111,114,
+ 109,32,114,101,108,97,116,105,118,101,32,105,109,112,111,114,
+ 116,122,17,69,109,112,116,121,32,109,111,100,117,108,101,32,
+ 110,97,109,101,78,41,10,218,10,105,115,105,110,115,116,97,
+ 110,99,101,218,3,115,116,114,218,9,84,121,112,101,69,114,
+ 114,111,114,114,50,0,0,0,114,13,0,0,0,114,169,0,
+ 0,0,114,77,0,0,0,114,14,0,0,0,114,21,0,0,
+ 0,218,11,83,121,115,116,101,109,69,114,114,111,114,41,4,
+ 114,15,0,0,0,114,170,0,0,0,114,171,0,0,0,114,
+ 148,0,0,0,114,10,0,0,0,114,10,0,0,0,114,11,
+ 0,0,0,218,13,95,115,97,110,105,116,121,95,99,104,101,
+ 99,107,158,3,0,0,115,28,0,0,0,0,2,10,1,18,
+ 1,8,1,8,1,8,1,10,1,10,1,4,1,10,2,10,
+ 1,4,2,14,1,14,1,114,182,0,0,0,122,16,78,111,
+ 32,109,111,100,117,108,101,32,110,97,109,101,100,32,122,4,
+ 123,33,114,125,99,2,0,0,0,0,0,0,0,8,0,0,
+ 0,12,0,0,0,67,0,0,0,115,224,0,0,0,100,0,
+ 125,2,124,0,106,0,100,1,131,1,100,2,25,0,125,3,
+ 124,3,114,136,124,3,116,1,106,2,107,7,114,42,116,3,
+ 124,1,124,3,131,2,1,0,124,0,116,1,106,2,107,6,
+ 114,62,116,1,106,2,124,0,25,0,83,0,116,1,106,2,
+ 124,3,25,0,125,4,121,10,124,4,106,4,125,2,87,0,
+ 110,52,4,0,116,5,107,10,114,134,1,0,1,0,1,0,
+ 116,6,100,3,23,0,106,7,124,0,124,3,131,2,125,5,
+ 116,8,124,5,100,4,124,0,144,1,131,1,100,0,130,2,
+ 89,0,110,2,88,0,116,9,124,0,124,2,131,2,125,6,
+ 124,6,100,0,107,8,114,176,116,8,116,6,106,7,124,0,
+ 131,1,100,4,124,0,144,1,131,1,130,1,110,8,116,10,
+ 124,6,131,1,125,7,124,3,114,220,116,1,106,2,124,3,
+ 25,0,125,4,116,11,124,4,124,0,106,0,100,1,131,1,
+ 100,5,25,0,124,7,131,3,1,0,124,7,83,0,41,6,
+ 78,114,121,0,0,0,114,33,0,0,0,122,23,59,32,123,
+ 33,114,125,32,105,115,32,110,111,116,32,97,32,112,97,99,
+ 107,97,103,101,114,15,0,0,0,114,141,0,0,0,41,12,
+ 114,122,0,0,0,114,14,0,0,0,114,21,0,0,0,114,
+ 65,0,0,0,114,131,0,0,0,114,96,0,0,0,218,8,
+ 95,69,82,82,95,77,83,71,114,50,0,0,0,114,77,0,
+ 0,0,114,177,0,0,0,114,150,0,0,0,114,5,0,0,
+ 0,41,8,114,15,0,0,0,218,7,105,109,112,111,114,116,
+ 95,114,153,0,0,0,114,123,0,0,0,90,13,112,97,114,
+ 101,110,116,95,109,111,100,117,108,101,114,148,0,0,0,114,
+ 88,0,0,0,114,89,0,0,0,114,10,0,0,0,114,10,
+ 0,0,0,114,11,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,181,3,0,0,115,42,0,0,0,0,1,4,1,14,1,
+ 4,1,10,1,10,2,10,1,10,1,10,1,2,1,10,1,
+ 14,1,16,1,22,1,10,1,8,1,22,2,8,1,4,2,
+ 10,1,22,1,114,185,0,0,0,99,2,0,0,0,0,0,
+ 0,0,2,0,0,0,10,0,0,0,67,0,0,0,115,30,
+ 0,0,0,116,0,124,0,131,1,143,12,1,0,116,1,124,
+ 0,124,1,131,2,83,0,81,0,82,0,88,0,100,1,83,
+ 0,41,2,122,54,70,105,110,100,32,97,110,100,32,108,111,
+ 97,100,32,116,104,101,32,109,111,100,117,108,101,44,32,97,
+ 110,100,32,114,101,108,101,97,115,101,32,116,104,101,32,105,
+ 109,112,111,114,116,32,108,111,99,107,46,78,41,2,114,54,
+ 0,0,0,114,185,0,0,0,41,2,114,15,0,0,0,114,
+ 184,0,0,0,114,10,0,0,0,114,10,0,0,0,114,11,
+ 0,0,0,218,14,95,102,105,110,100,95,97,110,100,95,108,
+ 111,97,100,208,3,0,0,115,4,0,0,0,0,2,10,1,
+ 114,186,0,0,0,114,33,0,0,0,99,3,0,0,0,0,
+ 0,0,0,5,0,0,0,4,0,0,0,67,0,0,0,115,
+ 122,0,0,0,116,0,124,0,124,1,124,2,131,3,1,0,
+ 124,2,100,1,107,4,114,32,116,1,124,0,124,1,124,2,
+ 131,3,125,0,116,2,106,3,131,0,1,0,124,0,116,4,
+ 106,5,107,7,114,60,116,6,124,0,116,7,131,2,83,0,
+ 116,4,106,5,124,0,25,0,125,3,124,3,100,2,107,8,
+ 114,110,116,2,106,8,131,0,1,0,100,3,106,9,124,0,
+ 131,1,125,4,116,10,124,4,100,4,124,0,144,1,131,1,
+ 130,1,116,11,124,0,131,1,1,0,124,3,83,0,41,5,
+ 97,50,1,0,0,73,109,112,111,114,116,32,97,110,100,32,
+ 114,101,116,117,114,110,32,116,104,101,32,109,111,100,117,108,
+ 101,32,98,97,115,101,100,32,111,110,32,105,116,115,32,110,
+ 97,109,101,44,32,116,104,101,32,112,97,99,107,97,103,101,
+ 32,116,104,101,32,99,97,108,108,32,105,115,10,32,32,32,
+ 32,98,101,105,110,103,32,109,97,100,101,32,102,114,111,109,
+ 44,32,97,110,100,32,116,104,101,32,108,101,118,101,108,32,
+ 97,100,106,117,115,116,109,101,110,116,46,10,10,32,32,32,
+ 32,84,104,105,115,32,102,117,110,99,116,105,111,110,32,114,
+ 101,112,114,101,115,101,110,116,115,32,116,104,101,32,103,114,
+ 101,97,116,101,115,116,32,99,111,109,109,111,110,32,100,101,
+ 110,111,109,105,110,97,116,111,114,32,111,102,32,102,117,110,
+ 99,116,105,111,110,97,108,105,116,121,10,32,32,32,32,98,
+ 101,116,119,101,101,110,32,105,109,112,111,114,116,95,109,111,
+ 100,117,108,101,32,97,110,100,32,95,95,105,109,112,111,114,
+ 116,95,95,46,32,84,104,105,115,32,105,110,99,108,117,100,
+ 101,115,32,115,101,116,116,105,110,103,32,95,95,112,97,99,
+ 107,97,103,101,95,95,32,105,102,10,32,32,32,32,116,104,
+ 101,32,108,111,97,100,101,114,32,100,105,100,32,110,111,116,
+ 46,10,10,32,32,32,32,114,33,0,0,0,78,122,40,105,
+ 109,112,111,114,116,32,111,102,32,123,125,32,104,97,108,116,
+ 101,100,59,32,78,111,110,101,32,105,110,32,115,121,115,46,
+ 109,111,100,117,108,101,115,114,15,0,0,0,41,12,114,182,
+ 0,0,0,114,172,0,0,0,114,57,0,0,0,114,146,0,
+ 0,0,114,14,0,0,0,114,21,0,0,0,114,186,0,0,
+ 0,218,11,95,103,99,100,95,105,109,112,111,114,116,114,58,
+ 0,0,0,114,50,0,0,0,114,77,0,0,0,114,63,0,
+ 0,0,41,5,114,15,0,0,0,114,170,0,0,0,114,171,
+ 0,0,0,114,89,0,0,0,114,74,0,0,0,114,10,0,
+ 0,0,114,10,0,0,0,114,11,0,0,0,114,187,0,0,
+ 0,214,3,0,0,115,28,0,0,0,0,9,12,1,8,1,
+ 12,1,8,1,10,1,10,1,10,1,8,1,8,1,4,1,
+ 6,1,14,1,8,1,114,187,0,0,0,99,3,0,0,0,
+ 0,0,0,0,6,0,0,0,17,0,0,0,67,0,0,0,
+ 115,178,0,0,0,116,0,124,0,100,1,131,2,114,174,100,
+ 2,124,1,107,6,114,58,116,1,124,1,131,1,125,1,124,
+ 1,106,2,100,2,131,1,1,0,116,0,124,0,100,3,131,
+ 2,114,58,124,1,106,3,124,0,106,4,131,1,1,0,120,
+ 114,124,1,68,0,93,106,125,3,116,0,124,0,124,3,131,
+ 2,115,64,100,4,106,5,124,0,106,6,124,3,131,2,125,
+ 4,121,14,116,7,124,2,124,4,131,2,1,0,87,0,113,
+ 64,4,0,116,8,107,10,114,168,1,0,125,5,1,0,122,
+ 34,116,9,124,5,131,1,106,10,116,11,131,1,114,150,124,
+ 5,106,12,124,4,107,2,114,150,119,64,130,0,87,0,89,
+ 0,100,5,100,5,125,5,126,5,88,0,113,64,88,0,113,
+ 64,87,0,124,0,83,0,41,6,122,238,70,105,103,117,114,
+ 101,32,111,117,116,32,119,104,97,116,32,95,95,105,109,112,
+ 111,114,116,95,95,32,115,104,111,117,108,100,32,114,101,116,
+ 117,114,110,46,10,10,32,32,32,32,84,104,101,32,105,109,
+ 112,111,114,116,95,32,112,97,114,97,109,101,116,101,114,32,
+ 105,115,32,97,32,99,97,108,108,97,98,108,101,32,119,104,
+ 105,99,104,32,116,97,107,101,115,32,116,104,101,32,110,97,
+ 109,101,32,111,102,32,109,111,100,117,108,101,32,116,111,10,
+ 32,32,32,32,105,109,112,111,114,116,46,32,73,116,32,105,
+ 115,32,114,101,113,117,105,114,101,100,32,116,111,32,100,101,
+ 99,111,117,112,108,101,32,116,104,101,32,102,117,110,99,116,
+ 105,111,110,32,102,114,111,109,32,97,115,115,117,109,105,110,
+ 103,32,105,109,112,111,114,116,108,105,98,39,115,10,32,32,
+ 32,32,105,109,112,111,114,116,32,105,109,112,108,101,109,101,
+ 110,116,97,116,105,111,110,32,105,115,32,100,101,115,105,114,
+ 101,100,46,10,10,32,32,32,32,114,131,0,0,0,250,1,
+ 42,218,7,95,95,97,108,108,95,95,122,5,123,125,46,123,
+ 125,78,41,13,114,4,0,0,0,114,130,0,0,0,218,6,
+ 114,101,109,111,118,101,218,6,101,120,116,101,110,100,114,189,
+ 0,0,0,114,50,0,0,0,114,1,0,0,0,114,65,0,
+ 0,0,114,77,0,0,0,114,179,0,0,0,114,71,0,0,
+ 0,218,15,95,69,82,82,95,77,83,71,95,80,82,69,70,
+ 73,88,114,15,0,0,0,41,6,114,89,0,0,0,218,8,
+ 102,114,111,109,108,105,115,116,114,184,0,0,0,218,1,120,
+ 90,9,102,114,111,109,95,110,97,109,101,90,3,101,120,99,
114,10,0,0,0,114,10,0,0,0,114,11,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,171,3,0,0,115,42,0,0,
- 0,0,1,6,1,19,1,6,1,15,1,13,2,15,1,11,
- 1,13,1,3,1,13,1,13,1,22,1,26,1,15,1,12,
- 1,30,2,12,1,6,2,13,1,29,1,114,184,0,0,0,
- 99,2,0,0,0,0,0,0,0,2,0,0,0,10,0,0,
- 0,67,0,0,0,115,37,0,0,0,116,0,0,124,0,0,
- 131,1,0,143,18,0,1,116,1,0,124,0,0,124,1,0,
- 131,2,0,83,87,100,1,0,81,82,88,100,1,0,83,41,
- 2,122,54,70,105,110,100,32,97,110,100,32,108,111,97,100,
- 32,116,104,101,32,109,111,100,117,108,101,44,32,97,110,100,
- 32,114,101,108,101,97,115,101,32,116,104,101,32,105,109,112,
- 111,114,116,32,108,111,99,107,46,78,41,2,114,54,0,0,
- 0,114,184,0,0,0,41,2,114,15,0,0,0,114,183,0,
- 0,0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,
- 0,218,14,95,102,105,110,100,95,97,110,100,95,108,111,97,
- 100,198,3,0,0,115,4,0,0,0,0,2,13,1,114,185,
- 0,0,0,114,33,0,0,0,99,3,0,0,0,0,0,0,
- 0,5,0,0,0,4,0,0,0,67,0,0,0,115,166,0,
- 0,0,116,0,0,124,0,0,124,1,0,124,2,0,131,3,
- 0,1,124,2,0,100,1,0,107,4,0,114,46,0,116,1,
- 0,124,0,0,124,1,0,124,2,0,131,3,0,125,0,0,
- 116,2,0,106,3,0,131,0,0,1,124,0,0,116,4,0,
- 106,5,0,107,7,0,114,84,0,116,6,0,124,0,0,116,
- 7,0,131,2,0,83,116,4,0,106,5,0,124,0,0,25,
- 125,3,0,124,3,0,100,2,0,107,8,0,114,152,0,116,
- 2,0,106,8,0,131,0,0,1,100,3,0,106,9,0,124,
- 0,0,131,1,0,125,4,0,116,10,0,124,4,0,100,4,
- 0,124,0,0,131,1,1,130,1,0,116,11,0,124,0,0,
- 131,1,0,1,124,3,0,83,41,5,97,50,1,0,0,73,
- 109,112,111,114,116,32,97,110,100,32,114,101,116,117,114,110,
- 32,116,104,101,32,109,111,100,117,108,101,32,98,97,115,101,
- 100,32,111,110,32,105,116,115,32,110,97,109,101,44,32,116,
- 104,101,32,112,97,99,107,97,103,101,32,116,104,101,32,99,
- 97,108,108,32,105,115,10,32,32,32,32,98,101,105,110,103,
- 32,109,97,100,101,32,102,114,111,109,44,32,97,110,100,32,
- 116,104,101,32,108,101,118,101,108,32,97,100,106,117,115,116,
- 109,101,110,116,46,10,10,32,32,32,32,84,104,105,115,32,
- 102,117,110,99,116,105,111,110,32,114,101,112,114,101,115,101,
- 110,116,115,32,116,104,101,32,103,114,101,97,116,101,115,116,
- 32,99,111,109,109,111,110,32,100,101,110,111,109,105,110,97,
- 116,111,114,32,111,102,32,102,117,110,99,116,105,111,110,97,
- 108,105,116,121,10,32,32,32,32,98,101,116,119,101,101,110,
- 32,105,109,112,111,114,116,95,109,111,100,117,108,101,32,97,
- 110,100,32,95,95,105,109,112,111,114,116,95,95,46,32,84,
- 104,105,115,32,105,110,99,108,117,100,101,115,32,115,101,116,
- 116,105,110,103,32,95,95,112,97,99,107,97,103,101,95,95,
- 32,105,102,10,32,32,32,32,116,104,101,32,108,111,97,100,
- 101,114,32,100,105,100,32,110,111,116,46,10,10,32,32,32,
- 32,114,33,0,0,0,78,122,40,105,109,112,111,114,116,32,
- 111,102,32,123,125,32,104,97,108,116,101,100,59,32,78,111,
- 110,101,32,105,110,32,115,121,115,46,109,111,100,117,108,101,
- 115,114,15,0,0,0,41,12,114,181,0,0,0,114,171,0,
- 0,0,114,57,0,0,0,114,145,0,0,0,114,14,0,0,
- 0,114,21,0,0,0,114,185,0,0,0,218,11,95,103,99,
- 100,95,105,109,112,111,114,116,114,58,0,0,0,114,50,0,
- 0,0,114,77,0,0,0,114,63,0,0,0,41,5,114,15,
- 0,0,0,114,169,0,0,0,114,170,0,0,0,114,89,0,
- 0,0,114,74,0,0,0,114,10,0,0,0,114,10,0,0,
- 0,114,11,0,0,0,114,186,0,0,0,204,3,0,0,115,
- 28,0,0,0,0,9,16,1,12,1,18,1,10,1,15,1,
- 13,1,13,1,12,1,10,1,6,1,9,1,18,1,10,1,
- 114,186,0,0,0,99,3,0,0,0,0,0,0,0,6,0,
- 0,0,17,0,0,0,67,0,0,0,115,239,0,0,0,116,
- 0,0,124,0,0,100,1,0,131,2,0,114,235,0,100,2,
- 0,124,1,0,107,6,0,114,83,0,116,1,0,124,1,0,
- 131,1,0,125,1,0,124,1,0,106,2,0,100,2,0,131,
- 1,0,1,116,0,0,124,0,0,100,3,0,131,2,0,114,
- 83,0,124,1,0,106,3,0,124,0,0,106,4,0,131,1,
- 0,1,120,149,0,124,1,0,68,93,141,0,125,3,0,116,
- 0,0,124,0,0,124,3,0,131,2,0,115,90,0,100,4,
- 0,106,5,0,124,0,0,106,6,0,124,3,0,131,2,0,
- 125,4,0,121,17,0,116,7,0,124,2,0,124,4,0,131,
- 2,0,1,87,113,90,0,4,116,8,0,107,10,0,114,230,
- 0,1,125,5,0,1,122,47,0,116,9,0,124,5,0,131,
- 1,0,106,10,0,116,11,0,131,1,0,114,209,0,124,5,
- 0,106,12,0,124,4,0,107,2,0,114,209,0,119,90,0,
- 130,0,0,87,89,100,5,0,100,5,0,125,5,0,126,5,
- 0,88,113,90,0,88,113,90,0,87,124,0,0,83,41,6,
- 122,238,70,105,103,117,114,101,32,111,117,116,32,119,104,97,
- 116,32,95,95,105,109,112,111,114,116,95,95,32,115,104,111,
- 117,108,100,32,114,101,116,117,114,110,46,10,10,32,32,32,
- 32,84,104,101,32,105,109,112,111,114,116,95,32,112,97,114,
- 97,109,101,116,101,114,32,105,115,32,97,32,99,97,108,108,
- 97,98,108,101,32,119,104,105,99,104,32,116,97,107,101,115,
- 32,116,104,101,32,110,97,109,101,32,111,102,32,109,111,100,
- 117,108,101,32,116,111,10,32,32,32,32,105,109,112,111,114,
- 116,46,32,73,116,32,105,115,32,114,101,113,117,105,114,101,
- 100,32,116,111,32,100,101,99,111,117,112,108,101,32,116,104,
- 101,32,102,117,110,99,116,105,111,110,32,102,114,111,109,32,
- 97,115,115,117,109,105,110,103,32,105,109,112,111,114,116,108,
- 105,98,39,115,10,32,32,32,32,105,109,112,111,114,116,32,
- 105,109,112,108,101,109,101,110,116,97,116,105,111,110,32,105,
- 115,32,100,101,115,105,114,101,100,46,10,10,32,32,32,32,
- 114,131,0,0,0,250,1,42,218,7,95,95,97,108,108,95,
- 95,122,5,123,125,46,123,125,78,41,13,114,4,0,0,0,
- 114,130,0,0,0,218,6,114,101,109,111,118,101,218,6,101,
- 120,116,101,110,100,114,188,0,0,0,114,50,0,0,0,114,
- 1,0,0,0,114,65,0,0,0,114,77,0,0,0,114,178,
- 0,0,0,114,71,0,0,0,218,15,95,69,82,82,95,77,
- 83,71,95,80,82,69,70,73,88,114,15,0,0,0,41,6,
- 114,89,0,0,0,218,8,102,114,111,109,108,105,115,116,114,
- 183,0,0,0,218,1,120,90,9,102,114,111,109,95,110,97,
- 109,101,90,3,101,120,99,114,10,0,0,0,114,10,0,0,
- 0,114,11,0,0,0,218,16,95,104,97,110,100,108,101,95,
- 102,114,111,109,108,105,115,116,228,3,0,0,115,34,0,0,
- 0,0,10,15,1,12,1,12,1,13,1,15,1,16,1,13,
- 1,15,1,21,1,3,1,17,1,18,4,21,1,15,1,3,
- 1,26,1,114,194,0,0,0,99,1,0,0,0,0,0,0,
- 0,2,0,0,0,2,0,0,0,67,0,0,0,115,72,0,
- 0,0,124,0,0,106,0,0,100,1,0,131,1,0,125,1,
- 0,124,1,0,100,2,0,107,8,0,114,68,0,124,0,0,
- 100,3,0,25,125,1,0,100,4,0,124,0,0,107,7,0,
- 114,68,0,124,1,0,106,1,0,100,5,0,131,1,0,100,
- 6,0,25,125,1,0,124,1,0,83,41,7,122,167,67,97,
- 108,99,117,108,97,116,101,32,119,104,97,116,32,95,95,112,
- 97,99,107,97,103,101,95,95,32,115,104,111,117,108,100,32,
- 98,101,46,10,10,32,32,32,32,95,95,112,97,99,107,97,
- 103,101,95,95,32,105,115,32,110,111,116,32,103,117,97,114,
- 97,110,116,101,101,100,32,116,111,32,98,101,32,100,101,102,
- 105,110,101,100,32,111,114,32,99,111,117,108,100,32,98,101,
- 32,115,101,116,32,116,111,32,78,111,110,101,10,32,32,32,
- 32,116,111,32,114,101,112,114,101,115,101,110,116,32,116,104,
- 97,116,32,105,116,115,32,112,114,111,112,101,114,32,118,97,
- 108,117,101,32,105,115,32,117,110,107,110,111,119,110,46,10,
- 10,32,32,32,32,114,134,0,0,0,78,114,1,0,0,0,
- 114,131,0,0,0,114,121,0,0,0,114,33,0,0,0,41,
- 2,114,42,0,0,0,114,122,0,0,0,41,2,218,7,103,
- 108,111,98,97,108,115,114,169,0,0,0,114,10,0,0,0,
- 114,10,0,0,0,114,11,0,0,0,218,17,95,99,97,108,
- 99,95,95,95,112,97,99,107,97,103,101,95,95,4,4,0,
- 0,115,12,0,0,0,0,7,15,1,12,1,10,1,12,1,
- 19,1,114,196,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,0,
- 124,0,0,131,1,0,125,5,0,110,54,0,124,1,0,100,
- 2,0,107,9,0,114,45,0,124,1,0,110,3,0,105,0,
- 0,125,6,0,116,1,0,124,6,0,131,1,0,125,7,0,
- 116,0,0,124,0,0,124,7,0,124,4,0,131,3,0,125,
- 5,0,124,3,0,115,207,0,124,4,0,100,1,0,107,2,
- 0,114,122,0,116,0,0,124,0,0,106,2,0,100,3,0,
- 131,1,0,100,1,0,25,131,1,0,83,124,0,0,115,132,
- 0,124,5,0,83,116,3,0,124,0,0,131,1,0,116,3,
- 0,124,0,0,106,2,0,100,3,0,131,1,0,100,1,0,
- 25,131,1,0,24,125,8,0,116,4,0,106,5,0,124,5,
- 0,106,6,0,100,2,0,116,3,0,124,5,0,106,6,0,
- 131,1,0,124,8,0,24,133,2,0,25,25,83,110,16,0,
- 116,7,0,124,5,0,124,3,0,116,0,0,131,3,0,83,
- 100,2,0,83,41,4,97,215,1,0,0,73,109,112,111,114,
- 116,32,97,32,109,111,100,117,108,101,46,10,10,32,32,32,
- 32,84,104,101,32,39,103,108,111,98,97,108,115,39,32,97,
- 114,103,117,109,101,110,116,32,105,115,32,117,115,101,100,32,
- 116,111,32,105,110,102,101,114,32,119,104,101,114,101,32,116,
- 104,101,32,105,109,112,111,114,116,32,105,115,32,111,99,99,
- 117,114,114,105,110,103,32,102,114,111,109,10,32,32,32,32,
- 116,111,32,104,97,110,100,108,101,32,114,101,108,97,116,105,
- 118,101,32,105,109,112,111,114,116,115,46,32,84,104,101,32,
- 39,108,111,99,97,108,115,39,32,97,114,103,117,109,101,110,
- 116,32,105,115,32,105,103,110,111,114,101,100,46,32,84,104,
- 101,10,32,32,32,32,39,102,114,111,109,108,105,115,116,39,
- 32,97,114,103,117,109,101,110,116,32,115,112,101,99,105,102,
- 105,101,115,32,119,104,97,116,32,115,104,111,117,108,100,32,
- 101,120,105,115,116,32,97,115,32,97,116,116,114,105,98,117,
- 116,101,115,32,111,110,32,116,104,101,32,109,111,100,117,108,
- 101,10,32,32,32,32,98,101,105,110,103,32,105,109,112,111,
- 114,116,101,100,32,40,101,46,103,46,32,96,96,102,114,111,
- 109,32,109,111,100,117,108,101,32,105,109,112,111,114,116,32,
- 60,102,114,111,109,108,105,115,116,62,96,96,41,46,32,32,
- 84,104,101,32,39,108,101,118,101,108,39,10,32,32,32,32,
- 97,114,103,117,109,101,110,116,32,114,101,112,114,101,115,101,
- 110,116,115,32,116,104,101,32,112,97,99,107,97,103,101,32,
- 108,111,99,97,116,105,111,110,32,116,111,32,105,109,112,111,
- 114,116,32,102,114,111,109,32,105,110,32,97,32,114,101,108,
- 97,116,105,118,101,10,32,32,32,32,105,109,112,111,114,116,
- 32,40,101,46,103,46,32,96,96,102,114,111,109,32,46,46,
- 112,107,103,32,105,109,112,111,114,116,32,109,111,100,96,96,
- 32,119,111,117,108,100,32,104,97,118,101,32,97,32,39,108,
- 101,118,101,108,39,32,111,102,32,50,41,46,10,10,32,32,
- 32,32,114,33,0,0,0,78,114,121,0,0,0,41,8,114,
- 186,0,0,0,114,196,0,0,0,218,9,112,97,114,116,105,
- 116,105,111,110,114,167,0,0,0,114,14,0,0,0,114,21,
- 0,0,0,114,1,0,0,0,114,194,0,0,0,41,9,114,
- 15,0,0,0,114,195,0,0,0,218,6,108,111,99,97,108,
- 115,114,192,0,0,0,114,170,0,0,0,114,89,0,0,0,
- 90,8,103,108,111,98,97,108,115,95,114,169,0,0,0,90,
- 7,99,117,116,95,111,102,102,114,10,0,0,0,114,10,0,
- 0,0,114,11,0,0,0,218,10,95,95,105,109,112,111,114,
- 116,95,95,19,4,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,199,0,0,0,99,1,0,0,0,
- 0,0,0,0,2,0,0,0,3,0,0,0,67,0,0,0,
- 115,53,0,0,0,116,0,0,106,1,0,124,0,0,131,1,
- 0,125,1,0,124,1,0,100,0,0,107,8,0,114,43,0,
- 116,2,0,100,1,0,124,0,0,23,131,1,0,130,1,0,
- 116,3,0,124,1,0,131,1,0,83,41,2,78,122,25,110,
+ 16,95,104,97,110,100,108,101,95,102,114,111,109,108,105,115,
+ 116,238,3,0,0,115,34,0,0,0,0,10,10,1,8,1,
+ 8,1,10,1,10,1,12,1,10,1,10,1,14,1,2,1,
+ 14,1,16,4,14,1,10,1,2,1,24,1,114,195,0,0,
+ 0,99,1,0,0,0,0,0,0,0,3,0,0,0,7,0,
+ 0,0,67,0,0,0,115,160,0,0,0,124,0,106,0,100,
+ 1,131,1,125,1,124,0,106,0,100,2,131,1,125,2,124,
+ 1,100,3,107,9,114,92,124,2,100,3,107,9,114,86,124,
+ 1,124,2,106,1,107,3,114,86,116,2,106,3,100,4,106,
+ 4,100,5,124,1,155,2,100,6,124,2,106,1,155,2,100,
+ 7,103,5,131,1,116,5,100,8,100,9,144,1,131,2,1,
+ 0,124,1,83,0,110,64,124,2,100,3,107,9,114,108,124,
+ 2,106,1,83,0,110,48,116,2,106,3,100,10,116,5,100,
+ 8,100,9,144,1,131,2,1,0,124,0,100,11,25,0,125,
+ 1,100,12,124,0,107,7,114,156,124,1,106,6,100,13,131,
+ 1,100,14,25,0,125,1,124,1,83,0,41,15,122,167,67,
+ 97,108,99,117,108,97,116,101,32,119,104,97,116,32,95,95,
+ 112,97,99,107,97,103,101,95,95,32,115,104,111,117,108,100,
+ 32,98,101,46,10,10,32,32,32,32,95,95,112,97,99,107,
+ 97,103,101,95,95,32,105,115,32,110,111,116,32,103,117,97,
+ 114,97,110,116,101,101,100,32,116,111,32,98,101,32,100,101,
+ 102,105,110,101,100,32,111,114,32,99,111,117,108,100,32,98,
+ 101,32,115,101,116,32,116,111,32,78,111,110,101,10,32,32,
+ 32,32,116,111,32,114,101,112,114,101,115,101,110,116,32,116,
+ 104,97,116,32,105,116,115,32,112,114,111,112,101,114,32,118,
+ 97,108,117,101,32,105,115,32,117,110,107,110,111,119,110,46,
+ 10,10,32,32,32,32,114,134,0,0,0,114,95,0,0,0,
+ 78,218,0,122,32,95,95,112,97,99,107,97,103,101,95,95,
+ 32,33,61,32,95,95,115,112,101,99,95,95,46,112,97,114,
+ 101,110,116,32,40,122,4,32,33,61,32,250,1,41,114,140,
+ 0,0,0,233,3,0,0,0,122,89,99,97,110,39,116,32,
+ 114,101,115,111,108,118,101,32,112,97,99,107,97,103,101,32,
+ 102,114,111,109,32,95,95,115,112,101,99,95,95,32,111,114,
+ 32,95,95,112,97,99,107,97,103,101,95,95,44,32,102,97,
+ 108,108,105,110,103,32,98,97,99,107,32,111,110,32,95,95,
+ 110,97,109,101,95,95,32,97,110,100,32,95,95,112,97,116,
+ 104,95,95,114,1,0,0,0,114,131,0,0,0,114,121,0,
+ 0,0,114,33,0,0,0,41,7,114,42,0,0,0,114,123,
+ 0,0,0,114,142,0,0,0,114,143,0,0,0,114,115,0,
+ 0,0,114,176,0,0,0,114,122,0,0,0,41,3,218,7,
+ 103,108,111,98,97,108,115,114,170,0,0,0,114,88,0,0,
+ 0,114,10,0,0,0,114,10,0,0,0,114,11,0,0,0,
+ 218,17,95,99,97,108,99,95,95,95,112,97,99,107,97,103,
+ 101,95,95,14,4,0,0,115,30,0,0,0,0,7,10,1,
+ 10,1,8,1,18,1,28,2,12,1,6,1,8,1,8,2,
+ 6,2,12,1,8,1,8,1,14,1,114,200,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,170,0,0,0,124,4,100,1,107,2,114,
+ 18,116,0,124,0,131,1,125,5,110,36,124,1,100,2,107,
+ 9,114,30,124,1,110,2,105,0,125,6,116,1,124,6,131,
+ 1,125,7,116,0,124,0,124,7,124,4,131,3,125,5,124,
+ 3,115,154,124,4,100,1,107,2,114,86,116,0,124,0,106,
+ 2,100,3,131,1,100,1,25,0,131,1,83,0,113,166,124,
+ 0,115,96,124,5,83,0,113,166,116,3,124,0,131,1,116,
+ 3,124,0,106,2,100,3,131,1,100,1,25,0,131,1,24,
+ 0,125,8,116,4,106,5,124,5,106,6,100,2,116,3,124,
+ 5,106,6,131,1,124,8,24,0,133,2,25,0,25,0,83,
+ 0,110,12,116,7,124,5,124,3,116,0,131,3,83,0,100,
+ 2,83,0,41,4,97,215,1,0,0,73,109,112,111,114,116,
+ 32,97,32,109,111,100,117,108,101,46,10,10,32,32,32,32,
+ 84,104,101,32,39,103,108,111,98,97,108,115,39,32,97,114,
+ 103,117,109,101,110,116,32,105,115,32,117,115,101,100,32,116,
+ 111,32,105,110,102,101,114,32,119,104,101,114,101,32,116,104,
+ 101,32,105,109,112,111,114,116,32,105,115,32,111,99,99,117,
+ 114,114,105,110,103,32,102,114,111,109,10,32,32,32,32,116,
+ 111,32,104,97,110,100,108,101,32,114,101,108,97,116,105,118,
+ 101,32,105,109,112,111,114,116,115,46,32,84,104,101,32,39,
+ 108,111,99,97,108,115,39,32,97,114,103,117,109,101,110,116,
+ 32,105,115,32,105,103,110,111,114,101,100,46,32,84,104,101,
+ 10,32,32,32,32,39,102,114,111,109,108,105,115,116,39,32,
+ 97,114,103,117,109,101,110,116,32,115,112,101,99,105,102,105,
+ 101,115,32,119,104,97,116,32,115,104,111,117,108,100,32,101,
+ 120,105,115,116,32,97,115,32,97,116,116,114,105,98,117,116,
+ 101,115,32,111,110,32,116,104,101,32,109,111,100,117,108,101,
+ 10,32,32,32,32,98,101,105,110,103,32,105,109,112,111,114,
+ 116,101,100,32,40,101,46,103,46,32,96,96,102,114,111,109,
+ 32,109,111,100,117,108,101,32,105,109,112,111,114,116,32,60,
+ 102,114,111,109,108,105,115,116,62,96,96,41,46,32,32,84,
+ 104,101,32,39,108,101,118,101,108,39,10,32,32,32,32,97,
+ 114,103,117,109,101,110,116,32,114,101,112,114,101,115,101,110,
+ 116,115,32,116,104,101,32,112,97,99,107,97,103,101,32,108,
+ 111,99,97,116,105,111,110,32,116,111,32,105,109,112,111,114,
+ 116,32,102,114,111,109,32,105,110,32,97,32,114,101,108,97,
+ 116,105,118,101,10,32,32,32,32,105,109,112,111,114,116,32,
+ 40,101,46,103,46,32,96,96,102,114,111,109,32,46,46,112,
+ 107,103,32,105,109,112,111,114,116,32,109,111,100,96,96,32,
+ 119,111,117,108,100,32,104,97,118,101,32,97,32,39,108,101,
+ 118,101,108,39,32,111,102,32,50,41,46,10,10,32,32,32,
+ 32,114,33,0,0,0,78,114,121,0,0,0,41,8,114,187,
+ 0,0,0,114,200,0,0,0,218,9,112,97,114,116,105,116,
+ 105,111,110,114,168,0,0,0,114,14,0,0,0,114,21,0,
+ 0,0,114,1,0,0,0,114,195,0,0,0,41,9,114,15,
+ 0,0,0,114,199,0,0,0,218,6,108,111,99,97,108,115,
+ 114,193,0,0,0,114,171,0,0,0,114,89,0,0,0,90,
+ 8,103,108,111,98,97,108,115,95,114,170,0,0,0,90,7,
+ 99,117,116,95,111,102,102,114,10,0,0,0,114,10,0,0,
+ 0,114,11,0,0,0,218,10,95,95,105,109,112,111,114,116,
+ 95,95,41,4,0,0,115,26,0,0,0,0,11,8,1,10,
+ 2,16,1,8,1,12,1,4,3,8,1,20,1,4,1,6,
+ 4,26,3,32,2,114,203,0,0,0,99,1,0,0,0,0,
+ 0,0,0,2,0,0,0,3,0,0,0,67,0,0,0,115,
+ 38,0,0,0,116,0,106,1,124,0,131,1,125,1,124,1,
+ 100,0,107,8,114,30,116,2,100,1,124,0,23,0,131,1,
+ 130,1,116,3,124,1,131,1,83,0,41,2,78,122,25,110,
111,32,98,117,105,108,116,45,105,110,32,109,111,100,117,108,
- 101,32,110,97,109,101,100,32,41,4,114,150,0,0,0,114,
- 154,0,0,0,114,77,0,0,0,114,149,0,0,0,41,2,
+ 101,32,110,97,109,101,100,32,41,4,114,151,0,0,0,114,
+ 155,0,0,0,114,77,0,0,0,114,150,0,0,0,41,2,
114,15,0,0,0,114,88,0,0,0,114,10,0,0,0,114,
10,0,0,0,114,11,0,0,0,218,18,95,98,117,105,108,
- 116,105,110,95,102,114,111,109,95,110,97,109,101,54,4,0,
- 0,115,8,0,0,0,0,1,15,1,12,1,16,1,114,200,
+ 116,105,110,95,102,114,111,109,95,110,97,109,101,76,4,0,
+ 0,115,8,0,0,0,0,1,10,1,8,1,12,1,114,204,
0,0,0,99,2,0,0,0,0,0,0,0,12,0,0,0,
- 12,0,0,0,67,0,0,0,115,74,1,0,0,124,1,0,
- 97,0,0,124,0,0,97,1,0,116,2,0,116,1,0,131,
- 1,0,125,2,0,120,123,0,116,1,0,106,3,0,106,4,
- 0,131,0,0,68,93,106,0,92,2,0,125,3,0,125,4,
- 0,116,5,0,124,4,0,124,2,0,131,2,0,114,40,0,
- 124,3,0,116,1,0,106,6,0,107,6,0,114,91,0,116,
- 7,0,125,5,0,110,27,0,116,0,0,106,8,0,124,3,
- 0,131,1,0,114,40,0,116,9,0,125,5,0,110,3,0,
- 113,40,0,116,10,0,124,4,0,124,5,0,131,2,0,125,
- 6,0,116,11,0,124,6,0,124,4,0,131,2,0,1,113,
- 40,0,87,116,1,0,106,3,0,116,12,0,25,125,7,0,
- 120,73,0,100,5,0,68,93,65,0,125,8,0,124,8,0,
- 116,1,0,106,3,0,107,7,0,114,206,0,116,13,0,124,
- 8,0,131,1,0,125,9,0,110,13,0,116,1,0,106,3,
- 0,124,8,0,25,125,9,0,116,14,0,124,7,0,124,8,
- 0,124,9,0,131,3,0,1,113,170,0,87,121,16,0,116,
- 13,0,100,2,0,131,1,0,125,10,0,87,110,24,0,4,
- 116,15,0,107,10,0,114,25,1,1,1,1,100,3,0,125,
- 10,0,89,110,1,0,88,116,14,0,124,7,0,100,2,0,
- 124,10,0,131,3,0,1,116,13,0,100,4,0,131,1,0,
- 125,11,0,116,14,0,124,7,0,100,4,0,124,11,0,131,
- 3,0,1,100,3,0,83,41,6,122,250,83,101,116,117,112,
- 32,105,109,112,111,114,116,108,105,98,32,98,121,32,105,109,
- 112,111,114,116,105,110,103,32,110,101,101,100,101,100,32,98,
- 117,105,108,116,45,105,110,32,109,111,100,117,108,101,115,32,
- 97,110,100,32,105,110,106,101,99,116,105,110,103,32,116,104,
- 101,109,10,32,32,32,32,105,110,116,111,32,116,104,101,32,
- 103,108,111,98,97,108,32,110,97,109,101,115,112,97,99,101,
- 46,10,10,32,32,32,32,65,115,32,115,121,115,32,105,115,
- 32,110,101,101,100,101,100,32,102,111,114,32,115,121,115,46,
- 109,111,100,117,108,101,115,32,97,99,99,101,115,115,32,97,
- 110,100,32,95,105,109,112,32,105,115,32,110,101,101,100,101,
- 100,32,116,111,32,108,111,97,100,32,98,117,105,108,116,45,
- 105,110,10,32,32,32,32,109,111,100,117,108,101,115,44,32,
- 116,104,111,115,101,32,116,119,111,32,109,111,100,117,108,101,
- 115,32,109,117,115,116,32,98,101,32,101,120,112,108,105,99,
- 105,116,108,121,32,112,97,115,115,101,100,32,105,110,46,10,
- 10,32,32,32,32,114,141,0,0,0,114,34,0,0,0,78,
- 114,62,0,0,0,41,1,122,9,95,119,97,114,110,105,110,
- 103,115,41,16,114,57,0,0,0,114,14,0,0,0,114,13,
- 0,0,0,114,21,0,0,0,218,5,105,116,101,109,115,114,
- 177,0,0,0,114,76,0,0,0,114,150,0,0,0,114,82,
- 0,0,0,114,160,0,0,0,114,132,0,0,0,114,137,0,
- 0,0,114,1,0,0,0,114,200,0,0,0,114,5,0,0,
- 0,114,77,0,0,0,41,12,218,10,115,121,115,95,109,111,
- 100,117,108,101,218,11,95,105,109,112,95,109,111,100,117,108,
- 101,90,11,109,111,100,117,108,101,95,116,121,112,101,114,15,
- 0,0,0,114,89,0,0,0,114,99,0,0,0,114,88,0,
- 0,0,90,11,115,101,108,102,95,109,111,100,117,108,101,90,
- 12,98,117,105,108,116,105,110,95,110,97,109,101,90,14,98,
- 117,105,108,116,105,110,95,109,111,100,117,108,101,90,13,116,
- 104,114,101,97,100,95,109,111,100,117,108,101,90,14,119,101,
- 97,107,114,101,102,95,109,111,100,117,108,101,114,10,0,0,
- 0,114,10,0,0,0,114,11,0,0,0,218,6,95,115,101,
- 116,117,112,61,4,0,0,115,50,0,0,0,0,9,6,1,
- 6,3,12,1,28,1,15,1,15,1,9,1,15,1,9,2,
- 3,1,15,1,17,3,13,1,13,1,15,1,15,2,13,1,
- 20,3,3,1,16,1,13,2,11,1,16,3,12,1,114,204,
- 0,0,0,99,2,0,0,0,0,0,0,0,3,0,0,0,
- 3,0,0,0,67,0,0,0,115,87,0,0,0,116,0,0,
- 124,0,0,124,1,0,131,2,0,1,116,1,0,106,2,0,
- 106,3,0,116,4,0,131,1,0,1,116,1,0,106,2,0,
- 106,3,0,116,5,0,131,1,0,1,100,1,0,100,2,0,
- 108,6,0,125,2,0,124,2,0,97,7,0,124,2,0,106,
- 8,0,116,1,0,106,9,0,116,10,0,25,131,1,0,1,
- 100,2,0,83,41,3,122,50,73,110,115,116,97,108,108,32,
- 105,109,112,111,114,116,108,105,98,32,97,115,32,116,104,101,
- 32,105,109,112,108,101,109,101,110,116,97,116,105,111,110,32,
- 111,102,32,105,109,112,111,114,116,46,114,33,0,0,0,78,
- 41,11,114,204,0,0,0,114,14,0,0,0,114,174,0,0,
- 0,114,113,0,0,0,114,150,0,0,0,114,160,0,0,0,
- 218,26,95,102,114,111,122,101,110,95,105,109,112,111,114,116,
- 108,105,98,95,101,120,116,101,114,110,97,108,114,119,0,0,
- 0,218,8,95,105,110,115,116,97,108,108,114,21,0,0,0,
- 114,1,0,0,0,41,3,114,202,0,0,0,114,203,0,0,
- 0,114,205,0,0,0,114,10,0,0,0,114,10,0,0,0,
- 114,11,0,0,0,114,206,0,0,0,108,4,0,0,115,12,
- 0,0,0,0,2,13,2,16,1,16,3,12,1,6,1,114,
- 206,0,0,0,41,51,114,3,0,0,0,114,119,0,0,0,
- 114,12,0,0,0,114,16,0,0,0,114,17,0,0,0,114,
- 59,0,0,0,114,41,0,0,0,114,48,0,0,0,114,31,
- 0,0,0,114,32,0,0,0,114,53,0,0,0,114,54,0,
- 0,0,114,56,0,0,0,114,63,0,0,0,114,65,0,0,
- 0,114,75,0,0,0,114,81,0,0,0,114,84,0,0,0,
- 114,90,0,0,0,114,101,0,0,0,114,102,0,0,0,114,
- 106,0,0,0,114,85,0,0,0,218,6,111,98,106,101,99,
- 116,90,9,95,80,79,80,85,76,65,84,69,114,132,0,0,
- 0,114,137,0,0,0,114,144,0,0,0,114,97,0,0,0,
- 114,86,0,0,0,114,148,0,0,0,114,149,0,0,0,114,
- 87,0,0,0,114,150,0,0,0,114,160,0,0,0,114,165,
- 0,0,0,114,171,0,0,0,114,173,0,0,0,114,176,0,
- 0,0,114,181,0,0,0,114,191,0,0,0,114,182,0,0,
- 0,114,184,0,0,0,114,185,0,0,0,114,186,0,0,0,
- 114,194,0,0,0,114,196,0,0,0,114,199,0,0,0,114,
- 200,0,0,0,114,204,0,0,0,114,206,0,0,0,114,10,
- 0,0,0,114,10,0,0,0,114,10,0,0,0,114,11,0,
- 0,0,218,8,60,109,111,100,117,108,101,62,8,0,0,0,
- 115,96,0,0,0,6,17,6,2,12,8,12,4,19,20,6,
- 2,6,3,22,4,19,68,19,21,19,19,12,19,12,19,12,
- 11,18,8,12,11,12,12,12,16,12,36,19,27,19,101,24,
- 26,9,3,18,45,18,60,12,18,12,17,12,25,12,29,12,
- 23,12,16,19,73,19,77,19,13,12,9,12,9,15,40,12,
- 17,6,1,10,2,12,27,12,6,18,24,12,32,12,15,24,
- 35,12,7,12,47,
+ 12,0,0,0,67,0,0,0,115,244,0,0,0,124,1,97,
+ 0,124,0,97,1,116,2,116,1,131,1,125,2,120,86,116,
+ 1,106,3,106,4,131,0,68,0,93,72,92,2,125,3,125,
+ 4,116,5,124,4,124,2,131,2,114,28,124,3,116,1,106,
+ 6,107,6,114,62,116,7,125,5,110,18,116,0,106,8,124,
+ 3,131,1,114,28,116,9,125,5,110,2,113,28,116,10,124,
+ 4,124,5,131,2,125,6,116,11,124,6,124,4,131,2,1,
+ 0,113,28,87,0,116,1,106,3,116,12,25,0,125,7,120,
+ 54,100,5,68,0,93,46,125,8,124,8,116,1,106,3,107,
+ 7,114,144,116,13,124,8,131,1,125,9,110,10,116,1,106,
+ 3,124,8,25,0,125,9,116,14,124,7,124,8,124,9,131,
+ 3,1,0,113,120,87,0,121,12,116,13,100,2,131,1,125,
+ 10,87,0,110,24,4,0,116,15,107,10,114,206,1,0,1,
+ 0,1,0,100,3,125,10,89,0,110,2,88,0,116,14,124,
+ 7,100,2,124,10,131,3,1,0,116,13,100,4,131,1,125,
+ 11,116,14,124,7,100,4,124,11,131,3,1,0,100,3,83,
+ 0,41,6,122,250,83,101,116,117,112,32,105,109,112,111,114,
+ 116,108,105,98,32,98,121,32,105,109,112,111,114,116,105,110,
+ 103,32,110,101,101,100,101,100,32,98,117,105,108,116,45,105,
+ 110,32,109,111,100,117,108,101,115,32,97,110,100,32,105,110,
+ 106,101,99,116,105,110,103,32,116,104,101,109,10,32,32,32,
+ 32,105,110,116,111,32,116,104,101,32,103,108,111,98,97,108,
+ 32,110,97,109,101,115,112,97,99,101,46,10,10,32,32,32,
+ 32,65,115,32,115,121,115,32,105,115,32,110,101,101,100,101,
+ 100,32,102,111,114,32,115,121,115,46,109,111,100,117,108,101,
+ 115,32,97,99,99,101,115,115,32,97,110,100,32,95,105,109,
+ 112,32,105,115,32,110,101,101,100,101,100,32,116,111,32,108,
+ 111,97,100,32,98,117,105,108,116,45,105,110,10,32,32,32,
+ 32,109,111,100,117,108,101,115,44,32,116,104,111,115,101,32,
+ 116,119,111,32,109,111,100,117,108,101,115,32,109,117,115,116,
+ 32,98,101,32,101,120,112,108,105,99,105,116,108,121,32,112,
+ 97,115,115,101,100,32,105,110,46,10,10,32,32,32,32,114,
+ 142,0,0,0,114,34,0,0,0,78,114,62,0,0,0,41,
+ 1,122,9,95,119,97,114,110,105,110,103,115,41,16,114,57,
+ 0,0,0,114,14,0,0,0,114,13,0,0,0,114,21,0,
+ 0,0,218,5,105,116,101,109,115,114,178,0,0,0,114,76,
+ 0,0,0,114,151,0,0,0,114,82,0,0,0,114,161,0,
+ 0,0,114,132,0,0,0,114,137,0,0,0,114,1,0,0,
+ 0,114,204,0,0,0,114,5,0,0,0,114,77,0,0,0,
+ 41,12,218,10,115,121,115,95,109,111,100,117,108,101,218,11,
+ 95,105,109,112,95,109,111,100,117,108,101,90,11,109,111,100,
+ 117,108,101,95,116,121,112,101,114,15,0,0,0,114,89,0,
+ 0,0,114,99,0,0,0,114,88,0,0,0,90,11,115,101,
+ 108,102,95,109,111,100,117,108,101,90,12,98,117,105,108,116,
+ 105,110,95,110,97,109,101,90,14,98,117,105,108,116,105,110,
+ 95,109,111,100,117,108,101,90,13,116,104,114,101,97,100,95,
+ 109,111,100,117,108,101,90,14,119,101,97,107,114,101,102,95,
+ 109,111,100,117,108,101,114,10,0,0,0,114,10,0,0,0,
+ 114,11,0,0,0,218,6,95,115,101,116,117,112,83,4,0,
+ 0,115,50,0,0,0,0,9,4,1,4,3,8,1,20,1,
+ 10,1,10,1,6,1,10,1,6,2,2,1,10,1,14,3,
+ 10,1,10,1,10,1,10,2,10,1,16,3,2,1,12,1,
+ 14,2,10,1,12,3,8,1,114,208,0,0,0,99,2,0,
+ 0,0,0,0,0,0,3,0,0,0,3,0,0,0,67,0,
+ 0,0,115,66,0,0,0,116,0,124,0,124,1,131,2,1,
+ 0,116,1,106,2,106,3,116,4,131,1,1,0,116,1,106,
+ 2,106,3,116,5,131,1,1,0,100,1,100,2,108,6,125,
+ 2,124,2,97,7,124,2,106,8,116,1,106,9,116,10,25,
+ 0,131,1,1,0,100,2,83,0,41,3,122,50,73,110,115,
+ 116,97,108,108,32,105,109,112,111,114,116,108,105,98,32,97,
+ 115,32,116,104,101,32,105,109,112,108,101,109,101,110,116,97,
+ 116,105,111,110,32,111,102,32,105,109,112,111,114,116,46,114,
+ 33,0,0,0,78,41,11,114,208,0,0,0,114,14,0,0,
+ 0,114,175,0,0,0,114,113,0,0,0,114,151,0,0,0,
+ 114,161,0,0,0,218,26,95,102,114,111,122,101,110,95,105,
+ 109,112,111,114,116,108,105,98,95,101,120,116,101,114,110,97,
+ 108,114,119,0,0,0,218,8,95,105,110,115,116,97,108,108,
+ 114,21,0,0,0,114,1,0,0,0,41,3,114,206,0,0,
+ 0,114,207,0,0,0,114,209,0,0,0,114,10,0,0,0,
+ 114,10,0,0,0,114,11,0,0,0,114,210,0,0,0,130,
+ 4,0,0,115,12,0,0,0,0,2,10,2,12,1,12,3,
+ 8,1,4,1,114,210,0,0,0,41,2,78,78,41,1,78,
+ 41,2,78,114,33,0,0,0,41,51,114,3,0,0,0,114,
+ 119,0,0,0,114,12,0,0,0,114,16,0,0,0,114,17,
+ 0,0,0,114,59,0,0,0,114,41,0,0,0,114,48,0,
+ 0,0,114,31,0,0,0,114,32,0,0,0,114,53,0,0,
+ 0,114,54,0,0,0,114,56,0,0,0,114,63,0,0,0,
+ 114,65,0,0,0,114,75,0,0,0,114,81,0,0,0,114,
+ 84,0,0,0,114,90,0,0,0,114,101,0,0,0,114,102,
+ 0,0,0,114,106,0,0,0,114,85,0,0,0,218,6,111,
+ 98,106,101,99,116,90,9,95,80,79,80,85,76,65,84,69,
+ 114,132,0,0,0,114,137,0,0,0,114,145,0,0,0,114,
+ 97,0,0,0,114,86,0,0,0,114,149,0,0,0,114,150,
+ 0,0,0,114,87,0,0,0,114,151,0,0,0,114,161,0,
+ 0,0,114,166,0,0,0,114,172,0,0,0,114,174,0,0,
+ 0,114,177,0,0,0,114,182,0,0,0,114,192,0,0,0,
+ 114,183,0,0,0,114,185,0,0,0,114,186,0,0,0,114,
+ 187,0,0,0,114,195,0,0,0,114,200,0,0,0,114,203,
+ 0,0,0,114,204,0,0,0,114,208,0,0,0,114,210,0,
+ 0,0,114,10,0,0,0,114,10,0,0,0,114,10,0,0,
+ 0,114,11,0,0,0,218,8,60,109,111,100,117,108,101,62,
+ 8,0,0,0,115,96,0,0,0,4,17,4,2,8,8,8,
+ 4,14,20,4,2,4,3,16,4,14,68,14,21,14,19,8,
+ 19,8,19,8,11,14,8,8,11,8,12,8,16,8,36,14,
+ 27,14,101,16,26,6,3,10,45,14,60,8,18,8,17,8,
+ 25,8,29,8,23,8,16,14,73,14,77,14,13,8,9,8,
+ 9,10,47,8,20,4,1,8,2,8,27,8,6,10,24,8,
+ 32,8,27,18,35,8,7,8,47,
};
diff --git a/Python/importlib_external.h b/Python/importlib_external.h
index a871f54..ba2f6bb 100644
--- a/Python/importlib_external.h
+++ b/Python/importlib_external.h
@@ -1,116 +1,99 @@
/* Auto-generated by Programs/_freeze_importlib.c */
const unsigned char _Py_M__importlib_external[] = {
- 99,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,
- 0,64,0,0,0,115,228,2,0,0,100,0,0,90,0,0,
- 100,96,0,90,1,0,100,4,0,100,5,0,132,0,0,90,
- 2,0,100,6,0,100,7,0,132,0,0,90,3,0,100,8,
- 0,100,9,0,132,0,0,90,4,0,100,10,0,100,11,0,
- 132,0,0,90,5,0,100,12,0,100,13,0,132,0,0,90,
- 6,0,100,14,0,100,15,0,132,0,0,90,7,0,100,16,
- 0,100,17,0,132,0,0,90,8,0,100,18,0,100,19,0,
- 132,0,0,90,9,0,100,20,0,100,21,0,132,0,0,90,
- 10,0,100,22,0,100,23,0,100,24,0,132,1,0,90,11,
- 0,101,12,0,101,11,0,106,13,0,131,1,0,90,14,0,
- 100,25,0,106,15,0,100,26,0,100,27,0,131,2,0,100,
- 28,0,23,90,16,0,101,17,0,106,18,0,101,16,0,100,
- 27,0,131,2,0,90,19,0,100,29,0,90,20,0,100,30,
- 0,90,21,0,100,31,0,103,1,0,90,22,0,100,32,0,
- 103,1,0,90,23,0,101,23,0,4,90,24,0,90,25,0,
- 100,33,0,100,34,0,100,33,0,100,35,0,100,36,0,132,
- 1,1,90,26,0,100,37,0,100,38,0,132,0,0,90,27,
- 0,100,39,0,100,40,0,132,0,0,90,28,0,100,41,0,
- 100,42,0,132,0,0,90,29,0,100,43,0,100,44,0,132,
- 0,0,90,30,0,100,45,0,100,46,0,100,47,0,100,48,
- 0,132,0,1,90,31,0,100,49,0,100,50,0,132,0,0,
- 90,32,0,100,51,0,100,52,0,132,0,0,90,33,0,100,
- 33,0,100,33,0,100,33,0,100,53,0,100,54,0,132,3,
- 0,90,34,0,100,33,0,100,33,0,100,33,0,100,55,0,
- 100,56,0,132,3,0,90,35,0,100,57,0,100,57,0,100,
- 58,0,100,59,0,132,2,0,90,36,0,100,60,0,100,61,
- 0,132,0,0,90,37,0,101,38,0,131,0,0,90,39,0,
- 100,33,0,100,62,0,100,33,0,100,63,0,101,39,0,100,
- 64,0,100,65,0,132,1,2,90,40,0,71,100,66,0,100,
- 67,0,132,0,0,100,67,0,131,2,0,90,41,0,71,100,
- 68,0,100,69,0,132,0,0,100,69,0,131,2,0,90,42,
- 0,71,100,70,0,100,71,0,132,0,0,100,71,0,101,42,
- 0,131,3,0,90,43,0,71,100,72,0,100,73,0,132,0,
- 0,100,73,0,131,2,0,90,44,0,71,100,74,0,100,75,
- 0,132,0,0,100,75,0,101,44,0,101,43,0,131,4,0,
- 90,45,0,71,100,76,0,100,77,0,132,0,0,100,77,0,
- 101,44,0,101,42,0,131,4,0,90,46,0,103,0,0,90,
- 47,0,71,100,78,0,100,79,0,132,0,0,100,79,0,101,
- 44,0,101,42,0,131,4,0,90,48,0,71,100,80,0,100,
- 81,0,132,0,0,100,81,0,131,2,0,90,49,0,71,100,
- 82,0,100,83,0,132,0,0,100,83,0,131,2,0,90,50,
- 0,71,100,84,0,100,85,0,132,0,0,100,85,0,131,2,
- 0,90,51,0,71,100,86,0,100,87,0,132,0,0,100,87,
- 0,131,2,0,90,52,0,100,33,0,100,88,0,100,89,0,
- 132,1,0,90,53,0,100,90,0,100,91,0,132,0,0,90,
- 54,0,100,92,0,100,93,0,132,0,0,90,55,0,100,94,
- 0,100,95,0,132,0,0,90,56,0,100,33,0,83,41,97,
- 97,94,1,0,0,67,111,114,101,32,105,109,112,108,101,109,
- 101,110,116,97,116,105,111,110,32,111,102,32,112,97,116,104,
- 45,98,97,115,101,100,32,105,109,112,111,114,116,46,10,10,
- 84,104,105,115,32,109,111,100,117,108,101,32,105,115,32,78,
- 79,84,32,109,101,97,110,116,32,116,111,32,98,101,32,100,
- 105,114,101,99,116,108,121,32,105,109,112,111,114,116,101,100,
- 33,32,73,116,32,104,97,115,32,98,101,101,110,32,100,101,
- 115,105,103,110,101,100,32,115,117,99,104,10,116,104,97,116,
- 32,105,116,32,99,97,110,32,98,101,32,98,111,111,116,115,
- 116,114,97,112,112,101,100,32,105,110,116,111,32,80,121,116,
- 104,111,110,32,97,115,32,116,104,101,32,105,109,112,108,101,
- 109,101,110,116,97,116,105,111,110,32,111,102,32,105,109,112,
- 111,114,116,46,32,65,115,10,115,117,99,104,32,105,116,32,
- 114,101,113,117,105,114,101,115,32,116,104,101,32,105,110,106,
- 101,99,116,105,111,110,32,111,102,32,115,112,101,99,105,102,
- 105,99,32,109,111,100,117,108,101,115,32,97,110,100,32,97,
- 116,116,114,105,98,117,116,101,115,32,105,110,32,111,114,100,
- 101,114,32,116,111,10,119,111,114,107,46,32,79,110,101,32,
- 115,104,111,117,108,100,32,117,115,101,32,105,109,112,111,114,
- 116,108,105,98,32,97,115,32,116,104,101,32,112,117,98,108,
- 105,99,45,102,97,99,105,110,103,32,118,101,114,115,105,111,
- 110,32,111,102,32,116,104,105,115,32,109,111,100,117,108,101,
- 46,10,10,218,3,119,105,110,218,6,99,121,103,119,105,110,
- 218,6,100,97,114,119,105,110,99,0,0,0,0,0,0,0,
- 0,1,0,0,0,2,0,0,0,67,0,0,0,115,49,0,
- 0,0,116,0,0,106,1,0,106,2,0,116,3,0,131,1,
- 0,114,33,0,100,1,0,100,2,0,132,0,0,125,0,0,
- 110,12,0,100,3,0,100,2,0,132,0,0,125,0,0,124,
- 0,0,83,41,4,78,99,0,0,0,0,0,0,0,0,0,
- 0,0,0,2,0,0,0,83,0,0,0,115,13,0,0,0,
- 100,1,0,116,0,0,106,1,0,107,6,0,83,41,2,122,
- 53,84,114,117,101,32,105,102,32,102,105,108,101,110,97,109,
- 101,115,32,109,117,115,116,32,98,101,32,99,104,101,99,107,
- 101,100,32,99,97,115,101,45,105,110,115,101,110,115,105,116,
- 105,118,101,108,121,46,115,12,0,0,0,80,89,84,72,79,
- 78,67,65,83,69,79,75,41,2,218,3,95,111,115,90,7,
- 101,110,118,105,114,111,110,169,0,114,4,0,0,0,114,4,
- 0,0,0,250,38,60,102,114,111,122,101,110,32,105,109,112,
- 111,114,116,108,105,98,46,95,98,111,111,116,115,116,114,97,
- 112,95,101,120,116,101,114,110,97,108,62,218,11,95,114,101,
- 108,97,120,95,99,97,115,101,30,0,0,0,115,2,0,0,
- 0,0,2,122,37,95,109,97,107,101,95,114,101,108,97,120,
- 95,99,97,115,101,46,60,108,111,99,97,108,115,62,46,95,
- 114,101,108,97,120,95,99,97,115,101,99,0,0,0,0,0,
- 0,0,0,0,0,0,0,1,0,0,0,83,0,0,0,115,
- 4,0,0,0,100,1,0,83,41,2,122,53,84,114,117,101,
- 32,105,102,32,102,105,108,101,110,97,109,101,115,32,109,117,
- 115,116,32,98,101,32,99,104,101,99,107,101,100,32,99,97,
- 115,101,45,105,110,115,101,110,115,105,116,105,118,101,108,121,
- 46,70,114,4,0,0,0,114,4,0,0,0,114,4,0,0,
- 0,114,4,0,0,0,114,5,0,0,0,114,6,0,0,0,
- 34,0,0,0,115,2,0,0,0,0,2,41,4,218,3,115,
- 121,115,218,8,112,108,97,116,102,111,114,109,218,10,115,116,
- 97,114,116,115,119,105,116,104,218,27,95,67,65,83,69,95,
- 73,78,83,69,78,83,73,84,73,86,69,95,80,76,65,84,
- 70,79,82,77,83,41,1,114,6,0,0,0,114,4,0,0,
- 0,114,4,0,0,0,114,5,0,0,0,218,16,95,109,97,
- 107,101,95,114,101,108,97,120,95,99,97,115,101,28,0,0,
- 0,115,8,0,0,0,0,1,18,1,15,4,12,3,114,11,
- 0,0,0,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,131,1,0,100,1,0,64,106,1,0,100,2,0,
- 100,3,0,131,2,0,83,41,4,122,42,67,111,110,118,101,
+ 99,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,
+ 0,64,0,0,0,115,236,1,0,0,100,0,90,0,100,91,
+ 90,1,100,4,100,5,132,0,90,2,100,6,100,7,132,0,
+ 90,3,100,8,100,9,132,0,90,4,100,10,100,11,132,0,
+ 90,5,100,12,100,13,132,0,90,6,100,14,100,15,132,0,
+ 90,7,100,16,100,17,132,0,90,8,100,18,100,19,132,0,
+ 90,9,100,20,100,21,132,0,90,10,100,92,100,23,100,24,
+ 132,1,90,11,101,12,101,11,106,13,131,1,90,14,100,25,
+ 106,15,100,26,100,27,131,2,100,28,23,0,90,16,101,17,
+ 106,18,101,16,100,27,131,2,90,19,100,29,90,20,100,30,
+ 90,21,100,31,103,1,90,22,100,32,103,1,90,23,101,23,
+ 4,0,90,24,90,25,100,93,100,33,100,34,156,1,100,35,
+ 100,36,132,3,90,26,100,37,100,38,132,0,90,27,100,39,
+ 100,40,132,0,90,28,100,41,100,42,132,0,90,29,100,43,
+ 100,44,132,0,90,30,100,45,100,46,132,0,90,31,100,47,
+ 100,48,132,0,90,32,100,94,100,49,100,50,132,1,90,33,
+ 100,95,100,51,100,52,132,1,90,34,100,96,100,54,100,55,
+ 132,1,90,35,100,56,100,57,132,0,90,36,101,37,131,0,
+ 90,38,100,97,100,33,101,38,100,58,156,2,100,59,100,60,
+ 132,3,90,39,71,0,100,61,100,62,132,0,100,62,131,2,
+ 90,40,71,0,100,63,100,64,132,0,100,64,131,2,90,41,
+ 71,0,100,65,100,66,132,0,100,66,101,41,131,3,90,42,
+ 71,0,100,67,100,68,132,0,100,68,131,2,90,43,71,0,
+ 100,69,100,70,132,0,100,70,101,43,101,42,131,4,90,44,
+ 71,0,100,71,100,72,132,0,100,72,101,43,101,41,131,4,
+ 90,45,103,0,90,46,71,0,100,73,100,74,132,0,100,74,
+ 101,43,101,41,131,4,90,47,71,0,100,75,100,76,132,0,
+ 100,76,131,2,90,48,71,0,100,77,100,78,132,0,100,78,
+ 131,2,90,49,71,0,100,79,100,80,132,0,100,80,131,2,
+ 90,50,71,0,100,81,100,82,132,0,100,82,131,2,90,51,
+ 100,98,100,83,100,84,132,1,90,52,100,85,100,86,132,0,
+ 90,53,100,87,100,88,132,0,90,54,100,89,100,90,132,0,
+ 90,55,100,33,83,0,41,99,97,94,1,0,0,67,111,114,
+ 101,32,105,109,112,108,101,109,101,110,116,97,116,105,111,110,
+ 32,111,102,32,112,97,116,104,45,98,97,115,101,100,32,105,
+ 109,112,111,114,116,46,10,10,84,104,105,115,32,109,111,100,
+ 117,108,101,32,105,115,32,78,79,84,32,109,101,97,110,116,
+ 32,116,111,32,98,101,32,100,105,114,101,99,116,108,121,32,
+ 105,109,112,111,114,116,101,100,33,32,73,116,32,104,97,115,
+ 32,98,101,101,110,32,100,101,115,105,103,110,101,100,32,115,
+ 117,99,104,10,116,104,97,116,32,105,116,32,99,97,110,32,
+ 98,101,32,98,111,111,116,115,116,114,97,112,112,101,100,32,
+ 105,110,116,111,32,80,121,116,104,111,110,32,97,115,32,116,
+ 104,101,32,105,109,112,108,101,109,101,110,116,97,116,105,111,
+ 110,32,111,102,32,105,109,112,111,114,116,46,32,65,115,10,
+ 115,117,99,104,32,105,116,32,114,101,113,117,105,114,101,115,
+ 32,116,104,101,32,105,110,106,101,99,116,105,111,110,32,111,
+ 102,32,115,112,101,99,105,102,105,99,32,109,111,100,117,108,
+ 101,115,32,97,110,100,32,97,116,116,114,105,98,117,116,101,
+ 115,32,105,110,32,111,114,100,101,114,32,116,111,10,119,111,
+ 114,107,46,32,79,110,101,32,115,104,111,117,108,100,32,117,
+ 115,101,32,105,109,112,111,114,116,108,105,98,32,97,115,32,
+ 116,104,101,32,112,117,98,108,105,99,45,102,97,99,105,110,
+ 103,32,118,101,114,115,105,111,110,32,111,102,32,116,104,105,
+ 115,32,109,111,100,117,108,101,46,10,10,218,3,119,105,110,
+ 218,6,99,121,103,119,105,110,218,6,100,97,114,119,105,110,
+ 99,0,0,0,0,0,0,0,0,1,0,0,0,2,0,0,
+ 0,67,0,0,0,115,34,0,0,0,116,0,106,1,106,2,
+ 116,3,131,1,114,22,100,1,100,2,132,0,125,0,110,8,
+ 100,3,100,2,132,0,125,0,124,0,83,0,41,4,78,99,
+ 0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,
+ 83,0,0,0,115,10,0,0,0,100,1,116,0,106,1,107,
+ 6,83,0,41,2,122,53,84,114,117,101,32,105,102,32,102,
+ 105,108,101,110,97,109,101,115,32,109,117,115,116,32,98,101,
+ 32,99,104,101,99,107,101,100,32,99,97,115,101,45,105,110,
+ 115,101,110,115,105,116,105,118,101,108,121,46,115,12,0,0,
+ 0,80,89,84,72,79,78,67,65,83,69,79,75,41,2,218,
+ 3,95,111,115,90,7,101,110,118,105,114,111,110,169,0,114,
+ 4,0,0,0,114,4,0,0,0,250,38,60,102,114,111,122,
+ 101,110,32,105,109,112,111,114,116,108,105,98,46,95,98,111,
+ 111,116,115,116,114,97,112,95,101,120,116,101,114,110,97,108,
+ 62,218,11,95,114,101,108,97,120,95,99,97,115,101,30,0,
+ 0,0,115,2,0,0,0,0,2,122,37,95,109,97,107,101,
+ 95,114,101,108,97,120,95,99,97,115,101,46,60,108,111,99,
+ 97,108,115,62,46,95,114,101,108,97,120,95,99,97,115,101,
+ 99,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,
+ 0,83,0,0,0,115,4,0,0,0,100,1,83,0,41,2,
+ 122,53,84,114,117,101,32,105,102,32,102,105,108,101,110,97,
+ 109,101,115,32,109,117,115,116,32,98,101,32,99,104,101,99,
+ 107,101,100,32,99,97,115,101,45,105,110,115,101,110,115,105,
+ 116,105,118,101,108,121,46,70,114,4,0,0,0,114,4,0,
+ 0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,
+ 0,114,6,0,0,0,34,0,0,0,115,2,0,0,0,0,
+ 2,41,4,218,3,115,121,115,218,8,112,108,97,116,102,111,
+ 114,109,218,10,115,116,97,114,116,115,119,105,116,104,218,27,
+ 95,67,65,83,69,95,73,78,83,69,78,83,73,84,73,86,
+ 69,95,80,76,65,84,70,79,82,77,83,41,1,114,6,0,
+ 0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,
+ 0,218,16,95,109,97,107,101,95,114,101,108,97,120,95,99,
+ 97,115,101,28,0,0,0,115,8,0,0,0,0,1,12,1,
+ 10,4,8,3,114,11,0,0,0,99,1,0,0,0,0,0,
+ 0,0,1,0,0,0,3,0,0,0,67,0,0,0,115,20,
+ 0,0,0,116,0,124,0,131,1,100,1,64,0,106,1,100,
+ 2,100,3,131,2,83,0,41,4,122,42,67,111,110,118,101,
114,116,32,97,32,51,50,45,98,105,116,32,105,110,116,101,
103,101,114,32,116,111,32,108,105,116,116,108,101,45,101,110,
100,105,97,110,46,108,3,0,0,0,255,127,255,127,3,0,
@@ -120,2477 +103,2324 @@
0,0,218,7,95,119,95,108,111,110,103,40,0,0,0,115,
2,0,0,0,0,2,114,17,0,0,0,99,1,0,0,0,
0,0,0,0,1,0,0,0,3,0,0,0,67,0,0,0,
- 115,16,0,0,0,116,0,0,106,1,0,124,0,0,100,1,
- 0,131,2,0,83,41,2,122,47,67,111,110,118,101,114,116,
- 32,52,32,98,121,116,101,115,32,105,110,32,108,105,116,116,
- 108,101,45,101,110,100,105,97,110,32,116,111,32,97,110,32,
- 105,110,116,101,103,101,114,46,114,13,0,0,0,41,2,114,
- 14,0,0,0,218,10,102,114,111,109,95,98,121,116,101,115,
- 41,1,90,9,105,110,116,95,98,121,116,101,115,114,4,0,
- 0,0,114,4,0,0,0,114,5,0,0,0,218,7,95,114,
- 95,108,111,110,103,45,0,0,0,115,2,0,0,0,0,2,
- 114,19,0,0,0,99,0,0,0,0,0,0,0,0,1,0,
- 0,0,3,0,0,0,71,0,0,0,115,26,0,0,0,116,
- 0,0,106,1,0,100,1,0,100,2,0,132,0,0,124,0,
- 0,68,131,1,0,131,1,0,83,41,3,122,31,82,101,112,
- 108,97,99,101,109,101,110,116,32,102,111,114,32,111,115,46,
- 112,97,116,104,46,106,111,105,110,40,41,46,99,1,0,0,
- 0,0,0,0,0,2,0,0,0,4,0,0,0,83,0,0,
- 0,115,37,0,0,0,103,0,0,124,0,0,93,27,0,125,
- 1,0,124,1,0,114,6,0,124,1,0,106,0,0,116,1,
- 0,131,1,0,145,2,0,113,6,0,83,114,4,0,0,0,
- 41,2,218,6,114,115,116,114,105,112,218,15,112,97,116,104,
- 95,115,101,112,97,114,97,116,111,114,115,41,2,218,2,46,
- 48,218,4,112,97,114,116,114,4,0,0,0,114,4,0,0,
- 0,114,5,0,0,0,250,10,60,108,105,115,116,99,111,109,
- 112,62,52,0,0,0,115,2,0,0,0,9,1,122,30,95,
- 112,97,116,104,95,106,111,105,110,46,60,108,111,99,97,108,
- 115,62,46,60,108,105,115,116,99,111,109,112,62,41,2,218,
- 8,112,97,116,104,95,115,101,112,218,4,106,111,105,110,41,
- 1,218,10,112,97,116,104,95,112,97,114,116,115,114,4,0,
- 0,0,114,4,0,0,0,114,5,0,0,0,218,10,95,112,
- 97,116,104,95,106,111,105,110,50,0,0,0,115,4,0,0,
- 0,0,2,15,1,114,28,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,
- 134,0,0,0,116,0,0,116,1,0,131,1,0,100,1,0,
- 107,2,0,114,52,0,124,0,0,106,2,0,116,3,0,131,
- 1,0,92,3,0,125,1,0,125,2,0,125,3,0,124,1,
- 0,124,3,0,102,2,0,83,120,69,0,116,4,0,124,0,
- 0,131,1,0,68,93,55,0,125,4,0,124,4,0,116,1,
- 0,107,6,0,114,65,0,124,0,0,106,5,0,124,4,0,
- 100,2,0,100,1,0,131,1,1,92,2,0,125,1,0,125,
- 3,0,124,1,0,124,3,0,102,2,0,83,113,65,0,87,
- 100,3,0,124,0,0,102,2,0,83,41,4,122,32,82,101,
- 112,108,97,99,101,109,101,110,116,32,102,111,114,32,111,115,
- 46,112,97,116,104,46,115,112,108,105,116,40,41,46,233,1,
- 0,0,0,90,8,109,97,120,115,112,108,105,116,218,0,41,
- 6,218,3,108,101,110,114,21,0,0,0,218,10,114,112,97,
- 114,116,105,116,105,111,110,114,25,0,0,0,218,8,114,101,
- 118,101,114,115,101,100,218,6,114,115,112,108,105,116,41,5,
- 218,4,112,97,116,104,90,5,102,114,111,110,116,218,1,95,
- 218,4,116,97,105,108,114,16,0,0,0,114,4,0,0,0,
- 114,4,0,0,0,114,5,0,0,0,218,11,95,112,97,116,
- 104,95,115,112,108,105,116,56,0,0,0,115,16,0,0,0,
- 0,2,18,1,24,1,10,1,19,1,12,1,27,1,14,1,
- 114,38,0,0,0,99,1,0,0,0,0,0,0,0,1,0,
- 0,0,2,0,0,0,67,0,0,0,115,13,0,0,0,116,
- 0,0,106,1,0,124,0,0,131,1,0,83,41,1,122,126,
- 83,116,97,116,32,116,104,101,32,112,97,116,104,46,10,10,
- 32,32,32,32,77,97,100,101,32,97,32,115,101,112,97,114,
- 97,116,101,32,102,117,110,99,116,105,111,110,32,116,111,32,
- 109,97,107,101,32,105,116,32,101,97,115,105,101,114,32,116,
- 111,32,111,118,101,114,114,105,100,101,32,105,110,32,101,120,
- 112,101,114,105,109,101,110,116,115,10,32,32,32,32,40,101,
- 46,103,46,32,99,97,99,104,101,32,115,116,97,116,32,114,
- 101,115,117,108,116,115,41,46,10,10,32,32,32,32,41,2,
- 114,3,0,0,0,90,4,115,116,97,116,41,1,114,35,0,
+ 115,12,0,0,0,116,0,106,1,124,0,100,1,131,2,83,
+ 0,41,2,122,47,67,111,110,118,101,114,116,32,52,32,98,
+ 121,116,101,115,32,105,110,32,108,105,116,116,108,101,45,101,
+ 110,100,105,97,110,32,116,111,32,97,110,32,105,110,116,101,
+ 103,101,114,46,114,13,0,0,0,41,2,114,14,0,0,0,
+ 218,10,102,114,111,109,95,98,121,116,101,115,41,1,90,9,
+ 105,110,116,95,98,121,116,101,115,114,4,0,0,0,114,4,
+ 0,0,0,114,5,0,0,0,218,7,95,114,95,108,111,110,
+ 103,45,0,0,0,115,2,0,0,0,0,2,114,19,0,0,
+ 0,99,0,0,0,0,0,0,0,0,1,0,0,0,3,0,
+ 0,0,71,0,0,0,115,20,0,0,0,116,0,106,1,100,
+ 1,100,2,132,0,124,0,68,0,131,1,131,1,83,0,41,
+ 3,122,31,82,101,112,108,97,99,101,109,101,110,116,32,102,
+ 111,114,32,111,115,46,112,97,116,104,46,106,111,105,110,40,
+ 41,46,99,1,0,0,0,0,0,0,0,2,0,0,0,4,
+ 0,0,0,83,0,0,0,115,26,0,0,0,103,0,124,0,
+ 93,18,125,1,124,1,114,4,124,1,106,0,116,1,131,1,
+ 145,2,113,4,83,0,114,4,0,0,0,41,2,218,6,114,
+ 115,116,114,105,112,218,15,112,97,116,104,95,115,101,112,97,
+ 114,97,116,111,114,115,41,2,218,2,46,48,218,4,112,97,
+ 114,116,114,4,0,0,0,114,4,0,0,0,114,5,0,0,
+ 0,250,10,60,108,105,115,116,99,111,109,112,62,52,0,0,
+ 0,115,2,0,0,0,6,1,122,30,95,112,97,116,104,95,
+ 106,111,105,110,46,60,108,111,99,97,108,115,62,46,60,108,
+ 105,115,116,99,111,109,112,62,41,2,218,8,112,97,116,104,
+ 95,115,101,112,218,4,106,111,105,110,41,1,218,10,112,97,
+ 116,104,95,112,97,114,116,115,114,4,0,0,0,114,4,0,
+ 0,0,114,5,0,0,0,218,10,95,112,97,116,104,95,106,
+ 111,105,110,50,0,0,0,115,4,0,0,0,0,2,10,1,
+ 114,28,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,98,0,0,0,116,
+ 0,116,1,131,1,100,1,107,2,114,36,124,0,106,2,116,
+ 3,131,1,92,3,125,1,125,2,125,3,124,1,124,3,102,
+ 2,83,0,120,52,116,4,124,0,131,1,68,0,93,40,125,
+ 4,124,4,116,1,107,6,114,46,124,0,106,5,124,4,100,
+ 2,100,1,144,1,131,1,92,2,125,1,125,3,124,1,124,
+ 3,102,2,83,0,113,46,87,0,100,3,124,0,102,2,83,
+ 0,41,4,122,32,82,101,112,108,97,99,101,109,101,110,116,
+ 32,102,111,114,32,111,115,46,112,97,116,104,46,115,112,108,
+ 105,116,40,41,46,233,1,0,0,0,90,8,109,97,120,115,
+ 112,108,105,116,218,0,41,6,218,3,108,101,110,114,21,0,
+ 0,0,218,10,114,112,97,114,116,105,116,105,111,110,114,25,
+ 0,0,0,218,8,114,101,118,101,114,115,101,100,218,6,114,
+ 115,112,108,105,116,41,5,218,4,112,97,116,104,90,5,102,
+ 114,111,110,116,218,1,95,218,4,116,97,105,108,114,16,0,
0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,
- 0,218,10,95,112,97,116,104,95,115,116,97,116,68,0,0,
- 0,115,2,0,0,0,0,7,114,39,0,0,0,99,2,0,
- 0,0,0,0,0,0,3,0,0,0,11,0,0,0,67,0,
- 0,0,115,58,0,0,0,121,16,0,116,0,0,124,0,0,
- 131,1,0,125,2,0,87,110,22,0,4,116,1,0,107,10,
- 0,114,40,0,1,1,1,100,1,0,83,89,110,1,0,88,
- 124,2,0,106,2,0,100,2,0,64,124,1,0,107,2,0,
- 83,41,3,122,49,84,101,115,116,32,119,104,101,116,104,101,
- 114,32,116,104,101,32,112,97,116,104,32,105,115,32,116,104,
- 101,32,115,112,101,99,105,102,105,101,100,32,109,111,100,101,
- 32,116,121,112,101,46,70,105,0,240,0,0,41,3,114,39,
- 0,0,0,218,7,79,83,69,114,114,111,114,218,7,115,116,
- 95,109,111,100,101,41,3,114,35,0,0,0,218,4,109,111,
- 100,101,90,9,115,116,97,116,95,105,110,102,111,114,4,0,
- 0,0,114,4,0,0,0,114,5,0,0,0,218,18,95,112,
- 97,116,104,95,105,115,95,109,111,100,101,95,116,121,112,101,
- 78,0,0,0,115,10,0,0,0,0,2,3,1,16,1,13,
- 1,9,1,114,43,0,0,0,99,1,0,0,0,0,0,0,
- 0,1,0,0,0,3,0,0,0,67,0,0,0,115,13,0,
- 0,0,116,0,0,124,0,0,100,1,0,131,2,0,83,41,
- 2,122,31,82,101,112,108,97,99,101,109,101,110,116,32,102,
- 111,114,32,111,115,46,112,97,116,104,46,105,115,102,105,108,
- 101,46,105,0,128,0,0,41,1,114,43,0,0,0,41,1,
- 114,35,0,0,0,114,4,0,0,0,114,4,0,0,0,114,
- 5,0,0,0,218,12,95,112,97,116,104,95,105,115,102,105,
- 108,101,87,0,0,0,115,2,0,0,0,0,2,114,44,0,
+ 0,218,11,95,112,97,116,104,95,115,112,108,105,116,56,0,
+ 0,0,115,16,0,0,0,0,2,12,1,16,1,8,1,14,
+ 1,8,1,20,1,12,1,114,38,0,0,0,99,1,0,0,
+ 0,0,0,0,0,1,0,0,0,2,0,0,0,67,0,0,
+ 0,115,10,0,0,0,116,0,106,1,124,0,131,1,83,0,
+ 41,1,122,126,83,116,97,116,32,116,104,101,32,112,97,116,
+ 104,46,10,10,32,32,32,32,77,97,100,101,32,97,32,115,
+ 101,112,97,114,97,116,101,32,102,117,110,99,116,105,111,110,
+ 32,116,111,32,109,97,107,101,32,105,116,32,101,97,115,105,
+ 101,114,32,116,111,32,111,118,101,114,114,105,100,101,32,105,
+ 110,32,101,120,112,101,114,105,109,101,110,116,115,10,32,32,
+ 32,32,40,101,46,103,46,32,99,97,99,104,101,32,115,116,
+ 97,116,32,114,101,115,117,108,116,115,41,46,10,10,32,32,
+ 32,32,41,2,114,3,0,0,0,90,4,115,116,97,116,41,
+ 1,114,35,0,0,0,114,4,0,0,0,114,4,0,0,0,
+ 114,5,0,0,0,218,10,95,112,97,116,104,95,115,116,97,
+ 116,68,0,0,0,115,2,0,0,0,0,7,114,39,0,0,
+ 0,99,2,0,0,0,0,0,0,0,3,0,0,0,11,0,
+ 0,0,67,0,0,0,115,48,0,0,0,121,12,116,0,124,
+ 0,131,1,125,2,87,0,110,20,4,0,116,1,107,10,114,
+ 32,1,0,1,0,1,0,100,1,83,0,88,0,124,2,106,
+ 2,100,2,64,0,124,1,107,2,83,0,41,3,122,49,84,
+ 101,115,116,32,119,104,101,116,104,101,114,32,116,104,101,32,
+ 112,97,116,104,32,105,115,32,116,104,101,32,115,112,101,99,
+ 105,102,105,101,100,32,109,111,100,101,32,116,121,112,101,46,
+ 70,105,0,240,0,0,41,3,114,39,0,0,0,218,7,79,
+ 83,69,114,114,111,114,218,7,115,116,95,109,111,100,101,41,
+ 3,114,35,0,0,0,218,4,109,111,100,101,90,9,115,116,
+ 97,116,95,105,110,102,111,114,4,0,0,0,114,4,0,0,
+ 0,114,5,0,0,0,218,18,95,112,97,116,104,95,105,115,
+ 95,109,111,100,101,95,116,121,112,101,78,0,0,0,115,10,
+ 0,0,0,0,2,2,1,12,1,14,1,6,1,114,43,0,
0,0,99,1,0,0,0,0,0,0,0,1,0,0,0,3,
- 0,0,0,67,0,0,0,115,31,0,0,0,124,0,0,115,
- 18,0,116,0,0,106,1,0,131,0,0,125,0,0,116,2,
- 0,124,0,0,100,1,0,131,2,0,83,41,2,122,30,82,
- 101,112,108,97,99,101,109,101,110,116,32,102,111,114,32,111,
- 115,46,112,97,116,104,46,105,115,100,105,114,46,105,0,64,
- 0,0,41,3,114,3,0,0,0,218,6,103,101,116,99,119,
- 100,114,43,0,0,0,41,1,114,35,0,0,0,114,4,0,
- 0,0,114,4,0,0,0,114,5,0,0,0,218,11,95,112,
- 97,116,104,95,105,115,100,105,114,92,0,0,0,115,6,0,
- 0,0,0,2,6,1,12,1,114,46,0,0,0,105,182,1,
- 0,0,99,3,0,0,0,0,0,0,0,6,0,0,0,17,
- 0,0,0,67,0,0,0,115,193,0,0,0,100,1,0,106,
- 0,0,124,0,0,116,1,0,124,0,0,131,1,0,131,2,
- 0,125,3,0,116,2,0,106,3,0,124,3,0,116,2,0,
- 106,4,0,116,2,0,106,5,0,66,116,2,0,106,6,0,
- 66,124,2,0,100,2,0,64,131,3,0,125,4,0,121,61,
- 0,116,7,0,106,8,0,124,4,0,100,3,0,131,2,0,
- 143,20,0,125,5,0,124,5,0,106,9,0,124,1,0,131,
- 1,0,1,87,100,4,0,81,82,88,116,2,0,106,10,0,
- 124,3,0,124,0,0,131,2,0,1,87,110,59,0,4,116,
- 11,0,107,10,0,114,188,0,1,1,1,121,17,0,116,2,
- 0,106,12,0,124,3,0,131,1,0,1,87,110,18,0,4,
- 116,11,0,107,10,0,114,180,0,1,1,1,89,110,1,0,
- 88,130,0,0,89,110,1,0,88,100,4,0,83,41,5,122,
- 162,66,101,115,116,45,101,102,102,111,114,116,32,102,117,110,
- 99,116,105,111,110,32,116,111,32,119,114,105,116,101,32,100,
- 97,116,97,32,116,111,32,97,32,112,97,116,104,32,97,116,
- 111,109,105,99,97,108,108,121,46,10,32,32,32,32,66,101,
- 32,112,114,101,112,97,114,101,100,32,116,111,32,104,97,110,
- 100,108,101,32,97,32,70,105,108,101,69,120,105,115,116,115,
- 69,114,114,111,114,32,105,102,32,99,111,110,99,117,114,114,
- 101,110,116,32,119,114,105,116,105,110,103,32,111,102,32,116,
- 104,101,10,32,32,32,32,116,101,109,112,111,114,97,114,121,
- 32,102,105,108,101,32,105,115,32,97,116,116,101,109,112,116,
- 101,100,46,122,5,123,125,46,123,125,105,182,1,0,0,90,
- 2,119,98,78,41,13,218,6,102,111,114,109,97,116,218,2,
- 105,100,114,3,0,0,0,90,4,111,112,101,110,90,6,79,
- 95,69,88,67,76,90,7,79,95,67,82,69,65,84,90,8,
- 79,95,87,82,79,78,76,89,218,3,95,105,111,218,6,70,
- 105,108,101,73,79,218,5,119,114,105,116,101,218,7,114,101,
- 112,108,97,99,101,114,40,0,0,0,90,6,117,110,108,105,
- 110,107,41,6,114,35,0,0,0,218,4,100,97,116,97,114,
- 42,0,0,0,90,8,112,97,116,104,95,116,109,112,90,2,
- 102,100,218,4,102,105,108,101,114,4,0,0,0,114,4,0,
- 0,0,114,5,0,0,0,218,13,95,119,114,105,116,101,95,
- 97,116,111,109,105,99,99,0,0,0,115,26,0,0,0,0,
- 5,24,1,9,1,33,1,3,3,21,1,20,1,20,1,13,
- 1,3,1,17,1,13,1,5,1,114,55,0,0,0,105,23,
- 13,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,4,111,112,116,45,122,3,46,112,121,122,4,46,112,
- 121,99,78,218,12,111,112,116,105,109,105,122,97,116,105,111,
- 110,99,2,0,0,0,1,0,0,0,11,0,0,0,6,0,
- 0,0,67,0,0,0,115,87,1,0,0,124,1,0,100,1,
- 0,107,9,0,114,76,0,116,0,0,106,1,0,100,2,0,
- 116,2,0,131,2,0,1,124,2,0,100,1,0,107,9,0,
- 114,58,0,100,3,0,125,3,0,116,3,0,124,3,0,131,
- 1,0,130,1,0,124,1,0,114,70,0,100,4,0,110,3,
- 0,100,5,0,125,2,0,116,4,0,124,0,0,131,1,0,
- 92,2,0,125,4,0,125,5,0,124,5,0,106,5,0,100,
- 6,0,131,1,0,92,3,0,125,6,0,125,7,0,125,8,
- 0,116,6,0,106,7,0,106,8,0,125,9,0,124,9,0,
- 100,1,0,107,8,0,114,154,0,116,9,0,100,7,0,131,
- 1,0,130,1,0,100,4,0,106,10,0,124,6,0,114,172,
- 0,124,6,0,110,3,0,124,8,0,124,7,0,124,9,0,
- 103,3,0,131,1,0,125,10,0,124,2,0,100,1,0,107,
- 8,0,114,241,0,116,6,0,106,11,0,106,12,0,100,8,
- 0,107,2,0,114,229,0,100,4,0,125,2,0,110,12,0,
- 116,6,0,106,11,0,106,12,0,125,2,0,116,13,0,124,
- 2,0,131,1,0,125,2,0,124,2,0,100,4,0,107,3,
- 0,114,63,1,124,2,0,106,14,0,131,0,0,115,42,1,
- 116,15,0,100,9,0,106,16,0,124,2,0,131,1,0,131,
- 1,0,130,1,0,100,10,0,106,16,0,124,10,0,116,17,
- 0,124,2,0,131,3,0,125,10,0,116,18,0,124,4,0,
- 116,19,0,124,10,0,116,20,0,100,8,0,25,23,131,3,
- 0,83,41,11,97,254,2,0,0,71,105,118,101,110,32,116,
- 104,101,32,112,97,116,104,32,116,111,32,97,32,46,112,121,
- 32,102,105,108,101,44,32,114,101,116,117,114,110,32,116,104,
- 101,32,112,97,116,104,32,116,111,32,105,116,115,32,46,112,
- 121,99,32,102,105,108,101,46,10,10,32,32,32,32,84,104,
- 101,32,46,112,121,32,102,105,108,101,32,100,111,101,115,32,
- 110,111,116,32,110,101,101,100,32,116,111,32,101,120,105,115,
- 116,59,32,116,104,105,115,32,115,105,109,112,108,121,32,114,
- 101,116,117,114,110,115,32,116,104,101,32,112,97,116,104,32,
- 116,111,32,116,104,101,10,32,32,32,32,46,112,121,99,32,
- 102,105,108,101,32,99,97,108,99,117,108,97,116,101,100,32,
- 97,115,32,105,102,32,116,104,101,32,46,112,121,32,102,105,
- 108,101,32,119,101,114,101,32,105,109,112,111,114,116,101,100,
- 46,10,10,32,32,32,32,84,104,101,32,39,111,112,116,105,
- 109,105,122,97,116,105,111,110,39,32,112,97,114,97,109,101,
- 116,101,114,32,99,111,110,116,114,111,108,115,32,116,104,101,
- 32,112,114,101,115,117,109,101,100,32,111,112,116,105,109,105,
- 122,97,116,105,111,110,32,108,101,118,101,108,32,111,102,10,
- 32,32,32,32,116,104,101,32,98,121,116,101,99,111,100,101,
- 32,102,105,108,101,46,32,73,102,32,39,111,112,116,105,109,
- 105,122,97,116,105,111,110,39,32,105,115,32,110,111,116,32,
- 78,111,110,101,44,32,116,104,101,32,115,116,114,105,110,103,
- 32,114,101,112,114,101,115,101,110,116,97,116,105,111,110,10,
- 32,32,32,32,111,102,32,116,104,101,32,97,114,103,117,109,
- 101,110,116,32,105,115,32,116,97,107,101,110,32,97,110,100,
- 32,118,101,114,105,102,105,101,100,32,116,111,32,98,101,32,
- 97,108,112,104,97,110,117,109,101,114,105,99,32,40,101,108,
- 115,101,32,86,97,108,117,101,69,114,114,111,114,10,32,32,
- 32,32,105,115,32,114,97,105,115,101,100,41,46,10,10,32,
- 32,32,32,84,104,101,32,100,101,98,117,103,95,111,118,101,
- 114,114,105,100,101,32,112,97,114,97,109,101,116,101,114,32,
- 105,115,32,100,101,112,114,101,99,97,116,101,100,46,32,73,
- 102,32,100,101,98,117,103,95,111,118,101,114,114,105,100,101,
- 32,105,115,32,110,111,116,32,78,111,110,101,44,10,32,32,
- 32,32,97,32,84,114,117,101,32,118,97,108,117,101,32,105,
- 115,32,116,104,101,32,115,97,109,101,32,97,115,32,115,101,
- 116,116,105,110,103,32,39,111,112,116,105,109,105,122,97,116,
- 105,111,110,39,32,116,111,32,116,104,101,32,101,109,112,116,
- 121,32,115,116,114,105,110,103,10,32,32,32,32,119,104,105,
- 108,101,32,97,32,70,97,108,115,101,32,118,97,108,117,101,
- 32,105,115,32,101,113,117,105,118,97,108,101,110,116,32,116,
- 111,32,115,101,116,116,105,110,103,32,39,111,112,116,105,109,
- 105,122,97,116,105,111,110,39,32,116,111,32,39,49,39,46,
- 10,10,32,32,32,32,73,102,32,115,121,115,46,105,109,112,
- 108,101,109,101,110,116,97,116,105,111,110,46,99,97,99,104,
- 101,95,116,97,103,32,105,115,32,78,111,110,101,32,116,104,
- 101,110,32,78,111,116,73,109,112,108,101,109,101,110,116,101,
- 100,69,114,114,111,114,32,105,115,32,114,97,105,115,101,100,
- 46,10,10,32,32,32,32,78,122,70,116,104,101,32,100,101,
- 98,117,103,95,111,118,101,114,114,105,100,101,32,112,97,114,
- 97,109,101,116,101,114,32,105,115,32,100,101,112,114,101,99,
- 97,116,101,100,59,32,117,115,101,32,39,111,112,116,105,109,
- 105,122,97,116,105,111,110,39,32,105,110,115,116,101,97,100,
- 122,50,100,101,98,117,103,95,111,118,101,114,114,105,100,101,
- 32,111,114,32,111,112,116,105,109,105,122,97,116,105,111,110,
- 32,109,117,115,116,32,98,101,32,115,101,116,32,116,111,32,
- 78,111,110,101,114,30,0,0,0,114,29,0,0,0,218,1,
- 46,122,36,115,121,115,46,105,109,112,108,101,109,101,110,116,
+ 0,0,0,67,0,0,0,115,10,0,0,0,116,0,124,0,
+ 100,1,131,2,83,0,41,2,122,31,82,101,112,108,97,99,
+ 101,109,101,110,116,32,102,111,114,32,111,115,46,112,97,116,
+ 104,46,105,115,102,105,108,101,46,105,0,128,0,0,41,1,
+ 114,43,0,0,0,41,1,114,35,0,0,0,114,4,0,0,
+ 0,114,4,0,0,0,114,5,0,0,0,218,12,95,112,97,
+ 116,104,95,105,115,102,105,108,101,87,0,0,0,115,2,0,
+ 0,0,0,2,114,44,0,0,0,99,1,0,0,0,0,0,
+ 0,0,1,0,0,0,3,0,0,0,67,0,0,0,115,22,
+ 0,0,0,124,0,115,12,116,0,106,1,131,0,125,0,116,
+ 2,124,0,100,1,131,2,83,0,41,2,122,30,82,101,112,
+ 108,97,99,101,109,101,110,116,32,102,111,114,32,111,115,46,
+ 112,97,116,104,46,105,115,100,105,114,46,105,0,64,0,0,
+ 41,3,114,3,0,0,0,218,6,103,101,116,99,119,100,114,
+ 43,0,0,0,41,1,114,35,0,0,0,114,4,0,0,0,
+ 114,4,0,0,0,114,5,0,0,0,218,11,95,112,97,116,
+ 104,95,105,115,100,105,114,92,0,0,0,115,6,0,0,0,
+ 0,2,4,1,8,1,114,46,0,0,0,233,182,1,0,0,
+ 99,3,0,0,0,0,0,0,0,6,0,0,0,17,0,0,
+ 0,67,0,0,0,115,162,0,0,0,100,1,106,0,124,0,
+ 116,1,124,0,131,1,131,2,125,3,116,2,106,3,124,3,
+ 116,2,106,4,116,2,106,5,66,0,116,2,106,6,66,0,
+ 124,2,100,2,64,0,131,3,125,4,121,50,116,7,106,8,
+ 124,4,100,3,131,2,143,16,125,5,124,5,106,9,124,1,
+ 131,1,1,0,87,0,100,4,81,0,82,0,88,0,116,2,
+ 106,10,124,3,124,0,131,2,1,0,87,0,110,58,4,0,
+ 116,11,107,10,114,156,1,0,1,0,1,0,121,14,116,2,
+ 106,12,124,3,131,1,1,0,87,0,110,20,4,0,116,11,
+ 107,10,114,148,1,0,1,0,1,0,89,0,110,2,88,0,
+ 130,0,89,0,110,2,88,0,100,4,83,0,41,5,122,162,
+ 66,101,115,116,45,101,102,102,111,114,116,32,102,117,110,99,
+ 116,105,111,110,32,116,111,32,119,114,105,116,101,32,100,97,
+ 116,97,32,116,111,32,97,32,112,97,116,104,32,97,116,111,
+ 109,105,99,97,108,108,121,46,10,32,32,32,32,66,101,32,
+ 112,114,101,112,97,114,101,100,32,116,111,32,104,97,110,100,
+ 108,101,32,97,32,70,105,108,101,69,120,105,115,116,115,69,
+ 114,114,111,114,32,105,102,32,99,111,110,99,117,114,114,101,
+ 110,116,32,119,114,105,116,105,110,103,32,111,102,32,116,104,
+ 101,10,32,32,32,32,116,101,109,112,111,114,97,114,121,32,
+ 102,105,108,101,32,105,115,32,97,116,116,101,109,112,116,101,
+ 100,46,122,5,123,125,46,123,125,105,182,1,0,0,90,2,
+ 119,98,78,41,13,218,6,102,111,114,109,97,116,218,2,105,
+ 100,114,3,0,0,0,90,4,111,112,101,110,90,6,79,95,
+ 69,88,67,76,90,7,79,95,67,82,69,65,84,90,8,79,
+ 95,87,82,79,78,76,89,218,3,95,105,111,218,6,70,105,
+ 108,101,73,79,218,5,119,114,105,116,101,218,7,114,101,112,
+ 108,97,99,101,114,40,0,0,0,90,6,117,110,108,105,110,
+ 107,41,6,114,35,0,0,0,218,4,100,97,116,97,114,42,
+ 0,0,0,90,8,112,97,116,104,95,116,109,112,90,2,102,
+ 100,218,4,102,105,108,101,114,4,0,0,0,114,4,0,0,
+ 0,114,5,0,0,0,218,13,95,119,114,105,116,101,95,97,
+ 116,111,109,105,99,99,0,0,0,115,26,0,0,0,0,5,
+ 16,1,6,1,26,1,2,3,14,1,20,1,16,1,14,1,
+ 2,1,14,1,14,1,6,1,114,56,0,0,0,105,44,13,
+ 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,4,111,112,116,45,122,3,46,112,121,122,4,46,112,121,
+ 99,78,41,1,218,12,111,112,116,105,109,105,122,97,116,105,
+ 111,110,99,2,0,0,0,1,0,0,0,11,0,0,0,6,
+ 0,0,0,67,0,0,0,115,234,0,0,0,124,1,100,1,
+ 107,9,114,52,116,0,106,1,100,2,116,2,131,2,1,0,
+ 124,2,100,1,107,9,114,40,100,3,125,3,116,3,124,3,
+ 131,1,130,1,124,1,114,48,100,4,110,2,100,5,125,2,
+ 116,4,124,0,131,1,92,2,125,4,125,5,124,5,106,5,
+ 100,6,131,1,92,3,125,6,125,7,125,8,116,6,106,7,
+ 106,8,125,9,124,9,100,1,107,8,114,104,116,9,100,7,
+ 131,1,130,1,100,4,106,10,124,6,114,116,124,6,110,2,
+ 124,8,124,7,124,9,103,3,131,1,125,10,124,2,100,1,
+ 107,8,114,162,116,6,106,11,106,12,100,8,107,2,114,154,
+ 100,4,125,2,110,8,116,6,106,11,106,12,125,2,116,13,
+ 124,2,131,1,125,2,124,2,100,4,107,3,114,214,124,2,
+ 106,14,131,0,115,200,116,15,100,9,106,16,124,2,131,1,
+ 131,1,130,1,100,10,106,16,124,10,116,17,124,2,131,3,
+ 125,10,116,18,124,4,116,19,124,10,116,20,100,8,25,0,
+ 23,0,131,3,83,0,41,11,97,254,2,0,0,71,105,118,
+ 101,110,32,116,104,101,32,112,97,116,104,32,116,111,32,97,
+ 32,46,112,121,32,102,105,108,101,44,32,114,101,116,117,114,
+ 110,32,116,104,101,32,112,97,116,104,32,116,111,32,105,116,
+ 115,32,46,112,121,99,32,102,105,108,101,46,10,10,32,32,
+ 32,32,84,104,101,32,46,112,121,32,102,105,108,101,32,100,
+ 111,101,115,32,110,111,116,32,110,101,101,100,32,116,111,32,
+ 101,120,105,115,116,59,32,116,104,105,115,32,115,105,109,112,
+ 108,121,32,114,101,116,117,114,110,115,32,116,104,101,32,112,
+ 97,116,104,32,116,111,32,116,104,101,10,32,32,32,32,46,
+ 112,121,99,32,102,105,108,101,32,99,97,108,99,117,108,97,
+ 116,101,100,32,97,115,32,105,102,32,116,104,101,32,46,112,
+ 121,32,102,105,108,101,32,119,101,114,101,32,105,109,112,111,
+ 114,116,101,100,46,10,10,32,32,32,32,84,104,101,32,39,
+ 111,112,116,105,109,105,122,97,116,105,111,110,39,32,112,97,
+ 114,97,109,101,116,101,114,32,99,111,110,116,114,111,108,115,
+ 32,116,104,101,32,112,114,101,115,117,109,101,100,32,111,112,
+ 116,105,109,105,122,97,116,105,111,110,32,108,101,118,101,108,
+ 32,111,102,10,32,32,32,32,116,104,101,32,98,121,116,101,
+ 99,111,100,101,32,102,105,108,101,46,32,73,102,32,39,111,
+ 112,116,105,109,105,122,97,116,105,111,110,39,32,105,115,32,
+ 110,111,116,32,78,111,110,101,44,32,116,104,101,32,115,116,
+ 114,105,110,103,32,114,101,112,114,101,115,101,110,116,97,116,
+ 105,111,110,10,32,32,32,32,111,102,32,116,104,101,32,97,
+ 114,103,117,109,101,110,116,32,105,115,32,116,97,107,101,110,
+ 32,97,110,100,32,118,101,114,105,102,105,101,100,32,116,111,
+ 32,98,101,32,97,108,112,104,97,110,117,109,101,114,105,99,
+ 32,40,101,108,115,101,32,86,97,108,117,101,69,114,114,111,
+ 114,10,32,32,32,32,105,115,32,114,97,105,115,101,100,41,
+ 46,10,10,32,32,32,32,84,104,101,32,100,101,98,117,103,
+ 95,111,118,101,114,114,105,100,101,32,112,97,114,97,109,101,
+ 116,101,114,32,105,115,32,100,101,112,114,101,99,97,116,101,
+ 100,46,32,73,102,32,100,101,98,117,103,95,111,118,101,114,
+ 114,105,100,101,32,105,115,32,110,111,116,32,78,111,110,101,
+ 44,10,32,32,32,32,97,32,84,114,117,101,32,118,97,108,
+ 117,101,32,105,115,32,116,104,101,32,115,97,109,101,32,97,
+ 115,32,115,101,116,116,105,110,103,32,39,111,112,116,105,109,
+ 105,122,97,116,105,111,110,39,32,116,111,32,116,104,101,32,
+ 101,109,112,116,121,32,115,116,114,105,110,103,10,32,32,32,
+ 32,119,104,105,108,101,32,97,32,70,97,108,115,101,32,118,
+ 97,108,117,101,32,105,115,32,101,113,117,105,118,97,108,101,
+ 110,116,32,116,111,32,115,101,116,116,105,110,103,32,39,111,
+ 112,116,105,109,105,122,97,116,105,111,110,39,32,116,111,32,
+ 39,49,39,46,10,10,32,32,32,32,73,102,32,115,121,115,
+ 46,105,109,112,108,101,109,101,110,116,97,116,105,111,110,46,
+ 99,97,99,104,101,95,116,97,103,32,105,115,32,78,111,110,
+ 101,32,116,104,101,110,32,78,111,116,73,109,112,108,101,109,
+ 101,110,116,101,100,69,114,114,111,114,32,105,115,32,114,97,
+ 105,115,101,100,46,10,10,32,32,32,32,78,122,70,116,104,
+ 101,32,100,101,98,117,103,95,111,118,101,114,114,105,100,101,
+ 32,112,97,114,97,109,101,116,101,114,32,105,115,32,100,101,
+ 112,114,101,99,97,116,101,100,59,32,117,115,101,32,39,111,
+ 112,116,105,109,105,122,97,116,105,111,110,39,32,105,110,115,
+ 116,101,97,100,122,50,100,101,98,117,103,95,111,118,101,114,
+ 114,105,100,101,32,111,114,32,111,112,116,105,109,105,122,97,
+ 116,105,111,110,32,109,117,115,116,32,98,101,32,115,101,116,
+ 32,116,111,32,78,111,110,101,114,30,0,0,0,114,29,0,
+ 0,0,218,1,46,122,36,115,121,115,46,105,109,112,108,101,
+ 109,101,110,116,97,116,105,111,110,46,99,97,99,104,101,95,
+ 116,97,103,32,105,115,32,78,111,110,101,233,0,0,0,0,
+ 122,24,123,33,114,125,32,105,115,32,110,111,116,32,97,108,
+ 112,104,97,110,117,109,101,114,105,99,122,7,123,125,46,123,
+ 125,123,125,41,21,218,9,95,119,97,114,110,105,110,103,115,
+ 218,4,119,97,114,110,218,18,68,101,112,114,101,99,97,116,
+ 105,111,110,87,97,114,110,105,110,103,218,9,84,121,112,101,
+ 69,114,114,111,114,114,38,0,0,0,114,32,0,0,0,114,
+ 7,0,0,0,218,14,105,109,112,108,101,109,101,110,116,97,
+ 116,105,111,110,218,9,99,97,99,104,101,95,116,97,103,218,
+ 19,78,111,116,73,109,112,108,101,109,101,110,116,101,100,69,
+ 114,114,111,114,114,26,0,0,0,218,5,102,108,97,103,115,
+ 218,8,111,112,116,105,109,105,122,101,218,3,115,116,114,218,
+ 7,105,115,97,108,110,117,109,218,10,86,97,108,117,101,69,
+ 114,114,111,114,114,48,0,0,0,218,4,95,79,80,84,114,
+ 28,0,0,0,218,8,95,80,89,67,65,67,72,69,218,17,
+ 66,89,84,69,67,79,68,69,95,83,85,70,70,73,88,69,
+ 83,41,11,114,35,0,0,0,90,14,100,101,98,117,103,95,
+ 111,118,101,114,114,105,100,101,114,58,0,0,0,218,7,109,
+ 101,115,115,97,103,101,218,4,104,101,97,100,114,37,0,0,
+ 0,90,4,98,97,115,101,218,3,115,101,112,218,4,114,101,
+ 115,116,90,3,116,97,103,90,15,97,108,109,111,115,116,95,
+ 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,249,0,0,0,115,46,
+ 0,0,0,0,18,8,1,6,1,6,1,8,1,4,1,8,
+ 1,12,1,12,1,16,1,8,1,8,1,8,1,24,1,8,
+ 1,12,1,6,2,8,1,8,1,8,1,8,1,14,1,14,
+ 1,114,80,0,0,0,99,1,0,0,0,0,0,0,0,8,
+ 0,0,0,5,0,0,0,67,0,0,0,115,220,0,0,0,
+ 116,0,106,1,106,2,100,1,107,8,114,20,116,3,100,2,
+ 131,1,130,1,116,4,124,0,131,1,92,2,125,1,125,2,
+ 116,4,124,1,131,1,92,2,125,1,125,3,124,3,116,5,
+ 107,3,114,68,116,6,100,3,106,7,116,5,124,0,131,2,
+ 131,1,130,1,124,2,106,8,100,4,131,1,125,4,124,4,
+ 100,11,107,7,114,102,116,6,100,7,106,7,124,2,131,1,
+ 131,1,130,1,110,86,124,4,100,6,107,2,114,188,124,2,
+ 106,9,100,4,100,5,131,2,100,12,25,0,125,5,124,5,
+ 106,10,116,11,131,1,115,150,116,6,100,8,106,7,116,11,
+ 131,1,131,1,130,1,124,5,116,12,116,11,131,1,100,1,
+ 133,2,25,0,125,6,124,6,106,13,131,0,115,188,116,6,
+ 100,9,106,7,124,5,131,1,131,1,130,1,124,2,106,14,
+ 100,4,131,1,100,10,25,0,125,7,116,15,124,1,124,7,
+ 116,16,100,10,25,0,23,0,131,2,83,0,41,13,97,110,
+ 1,0,0,71,105,118,101,110,32,116,104,101,32,112,97,116,
+ 104,32,116,111,32,97,32,46,112,121,99,46,32,102,105,108,
+ 101,44,32,114,101,116,117,114,110,32,116,104,101,32,112,97,
+ 116,104,32,116,111,32,105,116,115,32,46,112,121,32,102,105,
+ 108,101,46,10,10,32,32,32,32,84,104,101,32,46,112,121,
+ 99,32,102,105,108,101,32,100,111,101,115,32,110,111,116,32,
+ 110,101,101,100,32,116,111,32,101,120,105,115,116,59,32,116,
+ 104,105,115,32,115,105,109,112,108,121,32,114,101,116,117,114,
+ 110,115,32,116,104,101,32,112,97,116,104,32,116,111,10,32,
+ 32,32,32,116,104,101,32,46,112,121,32,102,105,108,101,32,
+ 99,97,108,99,117,108,97,116,101,100,32,116,111,32,99,111,
+ 114,114,101,115,112,111,110,100,32,116,111,32,116,104,101,32,
+ 46,112,121,99,32,102,105,108,101,46,32,32,73,102,32,112,
+ 97,116,104,32,100,111,101,115,10,32,32,32,32,110,111,116,
+ 32,99,111,110,102,111,114,109,32,116,111,32,80,69,80,32,
+ 51,49,52,55,47,52,56,56,32,102,111,114,109,97,116,44,
+ 32,86,97,108,117,101,69,114,114,111,114,32,119,105,108,108,
+ 32,98,101,32,114,97,105,115,101,100,46,32,73,102,10,32,
+ 32,32,32,115,121,115,46,105,109,112,108,101,109,101,110,116,
97,116,105,111,110,46,99,97,99,104,101,95,116,97,103,32,
- 105,115,32,78,111,110,101,233,0,0,0,0,122,24,123,33,
- 114,125,32,105,115,32,110,111,116,32,97,108,112,104,97,110,
- 117,109,101,114,105,99,122,7,123,125,46,123,125,123,125,41,
- 21,218,9,95,119,97,114,110,105,110,103,115,218,4,119,97,
- 114,110,218,18,68,101,112,114,101,99,97,116,105,111,110,87,
- 97,114,110,105,110,103,218,9,84,121,112,101,69,114,114,111,
- 114,114,38,0,0,0,114,32,0,0,0,114,7,0,0,0,
- 218,14,105,109,112,108,101,109,101,110,116,97,116,105,111,110,
- 218,9,99,97,99,104,101,95,116,97,103,218,19,78,111,116,
+ 105,115,32,78,111,110,101,32,116,104,101,110,32,78,111,116,
73,109,112,108,101,109,101,110,116,101,100,69,114,114,111,114,
- 114,26,0,0,0,218,5,102,108,97,103,115,218,8,111,112,
- 116,105,109,105,122,101,218,3,115,116,114,218,7,105,115,97,
- 108,110,117,109,218,10,86,97,108,117,101,69,114,114,111,114,
- 114,47,0,0,0,218,4,95,79,80,84,114,28,0,0,0,
- 218,8,95,80,89,67,65,67,72,69,218,17,66,89,84,69,
- 67,79,68,69,95,83,85,70,70,73,88,69,83,41,11,114,
- 35,0,0,0,90,14,100,101,98,117,103,95,111,118,101,114,
- 114,105,100,101,114,57,0,0,0,218,7,109,101,115,115,97,
- 103,101,218,4,104,101,97,100,114,37,0,0,0,90,4,98,
- 97,115,101,218,3,115,101,112,218,4,114,101,115,116,90,3,
- 116,97,103,90,15,97,108,109,111,115,116,95,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,247,0,0,0,115,46,0,0,0,0,
- 18,12,1,9,1,7,1,12,1,6,1,12,1,18,1,18,
- 1,24,1,12,1,12,1,12,1,36,1,12,1,18,1,9,
- 2,12,1,12,1,12,1,12,1,21,1,21,1,114,79,0,
- 0,0,99,1,0,0,0,0,0,0,0,8,0,0,0,5,
- 0,0,0,67,0,0,0,115,62,1,0,0,116,0,0,106,
- 1,0,106,2,0,100,1,0,107,8,0,114,30,0,116,3,
- 0,100,2,0,131,1,0,130,1,0,116,4,0,124,0,0,
- 131,1,0,92,2,0,125,1,0,125,2,0,116,4,0,124,
- 1,0,131,1,0,92,2,0,125,1,0,125,3,0,124,3,
- 0,116,5,0,107,3,0,114,102,0,116,6,0,100,3,0,
- 106,7,0,116,5,0,124,0,0,131,2,0,131,1,0,130,
- 1,0,124,2,0,106,8,0,100,4,0,131,1,0,125,4,
- 0,124,4,0,100,11,0,107,7,0,114,153,0,116,6,0,
- 100,7,0,106,7,0,124,2,0,131,1,0,131,1,0,130,
- 1,0,110,125,0,124,4,0,100,6,0,107,2,0,114,22,
- 1,124,2,0,106,9,0,100,4,0,100,5,0,131,2,0,
- 100,12,0,25,125,5,0,124,5,0,106,10,0,116,11,0,
- 131,1,0,115,223,0,116,6,0,100,8,0,106,7,0,116,
- 11,0,131,1,0,131,1,0,130,1,0,124,5,0,116,12,
- 0,116,11,0,131,1,0,100,1,0,133,2,0,25,125,6,
- 0,124,6,0,106,13,0,131,0,0,115,22,1,116,6,0,
- 100,9,0,106,7,0,124,5,0,131,1,0,131,1,0,130,
- 1,0,124,2,0,106,14,0,100,4,0,131,1,0,100,10,
- 0,25,125,7,0,116,15,0,124,1,0,124,7,0,116,16,
- 0,100,10,0,25,23,131,2,0,83,41,13,97,110,1,0,
- 0,71,105,118,101,110,32,116,104,101,32,112,97,116,104,32,
- 116,111,32,97,32,46,112,121,99,46,32,102,105,108,101,44,
- 32,114,101,116,117,114,110,32,116,104,101,32,112,97,116,104,
- 32,116,111,32,105,116,115,32,46,112,121,32,102,105,108,101,
- 46,10,10,32,32,32,32,84,104,101,32,46,112,121,99,32,
- 102,105,108,101,32,100,111,101,115,32,110,111,116,32,110,101,
- 101,100,32,116,111,32,101,120,105,115,116,59,32,116,104,105,
- 115,32,115,105,109,112,108,121,32,114,101,116,117,114,110,115,
- 32,116,104,101,32,112,97,116,104,32,116,111,10,32,32,32,
- 32,116,104,101,32,46,112,121,32,102,105,108,101,32,99,97,
- 108,99,117,108,97,116,101,100,32,116,111,32,99,111,114,114,
- 101,115,112,111,110,100,32,116,111,32,116,104,101,32,46,112,
- 121,99,32,102,105,108,101,46,32,32,73,102,32,112,97,116,
- 104,32,100,111,101,115,10,32,32,32,32,110,111,116,32,99,
- 111,110,102,111,114,109,32,116,111,32,80,69,80,32,51,49,
- 52,55,47,52,56,56,32,102,111,114,109,97,116,44,32,86,
- 97,108,117,101,69,114,114,111,114,32,119,105,108,108,32,98,
- 101,32,114,97,105,115,101,100,46,32,73,102,10,32,32,32,
- 32,115,121,115,46,105,109,112,108,101,109,101,110,116,97,116,
- 105,111,110,46,99,97,99,104,101,95,116,97,103,32,105,115,
- 32,78,111,110,101,32,116,104,101,110,32,78,111,116,73,109,
- 112,108,101,109,101,110,116,101,100,69,114,114,111,114,32,105,
- 115,32,114,97,105,115,101,100,46,10,10,32,32,32,32,78,
- 122,36,115,121,115,46,105,109,112,108,101,109,101,110,116,97,
- 116,105,111,110,46,99,97,99,104,101,95,116,97,103,32,105,
- 115,32,78,111,110,101,122,37,123,125,32,110,111,116,32,98,
- 111,116,116,111,109,45,108,101,118,101,108,32,100,105,114,101,
- 99,116,111,114,121,32,105,110,32,123,33,114,125,114,58,0,
- 0,0,114,56,0,0,0,233,3,0,0,0,122,33,101,120,
- 112,101,99,116,101,100,32,111,110,108,121,32,50,32,111,114,
- 32,51,32,100,111,116,115,32,105,110,32,123,33,114,125,122,
- 57,111,112,116,105,109,105,122,97,116,105,111,110,32,112,111,
- 114,116,105,111,110,32,111,102,32,102,105,108,101,110,97,109,
- 101,32,100,111,101,115,32,110,111,116,32,115,116,97,114,116,
- 32,119,105,116,104,32,123,33,114,125,122,52,111,112,116,105,
- 109,105,122,97,116,105,111,110,32,108,101,118,101,108,32,123,
- 33,114,125,32,105,115,32,110,111,116,32,97,110,32,97,108,
- 112,104,97,110,117,109,101,114,105,99,32,118,97,108,117,101,
- 114,59,0,0,0,62,2,0,0,0,114,56,0,0,0,114,
- 80,0,0,0,233,254,255,255,255,41,17,114,7,0,0,0,
- 114,64,0,0,0,114,65,0,0,0,114,66,0,0,0,114,
- 38,0,0,0,114,73,0,0,0,114,71,0,0,0,114,47,
- 0,0,0,218,5,99,111,117,110,116,114,34,0,0,0,114,
- 9,0,0,0,114,72,0,0,0,114,31,0,0,0,114,70,
- 0,0,0,218,9,112,97,114,116,105,116,105,111,110,114,28,
- 0,0,0,218,15,83,79,85,82,67,69,95,83,85,70,70,
- 73,88,69,83,41,8,114,35,0,0,0,114,76,0,0,0,
- 90,16,112,121,99,97,99,104,101,95,102,105,108,101,110,97,
- 109,101,90,7,112,121,99,97,99,104,101,90,9,100,111,116,
- 95,99,111,117,110,116,114,57,0,0,0,90,9,111,112,116,
- 95,108,101,118,101,108,90,13,98,97,115,101,95,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,115,111,117,114,99,101,95,102,114,111,
- 109,95,99,97,99,104,101,35,1,0,0,115,44,0,0,0,
- 0,9,18,1,12,1,18,1,18,1,12,1,9,1,15,1,
- 15,1,12,1,9,1,15,1,12,1,22,1,15,1,9,1,
- 12,1,22,1,12,1,9,1,12,1,19,1,114,85,0,0,
- 0,99,1,0,0,0,0,0,0,0,5,0,0,0,12,0,
- 0,0,67,0,0,0,115,164,0,0,0,116,0,0,124,0,
- 0,131,1,0,100,1,0,107,2,0,114,22,0,100,2,0,
- 83,124,0,0,106,1,0,100,3,0,131,1,0,92,3,0,
- 125,1,0,125,2,0,125,3,0,124,1,0,12,115,81,0,
- 124,3,0,106,2,0,131,0,0,100,7,0,100,8,0,133,
- 2,0,25,100,6,0,107,3,0,114,85,0,124,0,0,83,
- 121,16,0,116,3,0,124,0,0,131,1,0,125,4,0,87,
- 110,40,0,4,116,4,0,116,5,0,102,2,0,107,10,0,
- 114,143,0,1,1,1,124,0,0,100,2,0,100,9,0,133,
- 2,0,25,125,4,0,89,110,1,0,88,116,6,0,124,4,
- 0,131,1,0,114,160,0,124,4,0,83,124,0,0,83,41,
- 10,122,188,67,111,110,118,101,114,116,32,97,32,98,121,116,
- 101,99,111,100,101,32,102,105,108,101,32,112,97,116,104,32,
- 116,111,32,97,32,115,111,117,114,99,101,32,112,97,116,104,
- 32,40,105,102,32,112,111,115,115,105,98,108,101,41,46,10,
- 10,32,32,32,32,84,104,105,115,32,102,117,110,99,116,105,
- 111,110,32,101,120,105,115,116,115,32,112,117,114,101,108,121,
- 32,102,111,114,32,98,97,99,107,119,97,114,100,115,45,99,
- 111,109,112,97,116,105,98,105,108,105,116,121,32,102,111,114,
- 10,32,32,32,32,80,121,73,109,112,111,114,116,95,69,120,
- 101,99,67,111,100,101,77,111,100,117,108,101,87,105,116,104,
- 70,105,108,101,110,97,109,101,115,40,41,32,105,110,32,116,
- 104,101,32,67,32,65,80,73,46,10,10,32,32,32,32,114,
- 59,0,0,0,78,114,58,0,0,0,114,80,0,0,0,114,
- 29,0,0,0,90,2,112,121,233,253,255,255,255,233,255,255,
- 255,255,114,87,0,0,0,41,7,114,31,0,0,0,114,32,
- 0,0,0,218,5,108,111,119,101,114,114,85,0,0,0,114,
- 66,0,0,0,114,71,0,0,0,114,44,0,0,0,41,5,
- 218,13,98,121,116,101,99,111,100,101,95,112,97,116,104,114,
- 78,0,0,0,114,36,0,0,0,90,9,101,120,116,101,110,
- 115,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,68,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,91,
- 0,0,0,99,1,0,0,0,0,0,0,0,1,0,0,0,
- 11,0,0,0,67,0,0,0,115,92,0,0,0,124,0,0,
- 106,0,0,116,1,0,116,2,0,131,1,0,131,1,0,114,
- 59,0,121,14,0,116,3,0,124,0,0,131,1,0,83,87,
- 113,88,0,4,116,4,0,107,10,0,114,55,0,1,1,1,
- 89,113,88,0,88,110,29,0,124,0,0,106,0,0,116,1,
- 0,116,5,0,131,1,0,131,1,0,114,84,0,124,0,0,
- 83,100,0,0,83,100,0,0,83,41,1,78,41,6,218,8,
- 101,110,100,115,119,105,116,104,218,5,116,117,112,108,101,114,
- 84,0,0,0,114,79,0,0,0,114,66,0,0,0,114,74,
- 0,0,0,41,1,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,11,
- 95,103,101,116,95,99,97,99,104,101,100,87,1,0,0,115,
- 16,0,0,0,0,1,21,1,3,1,14,1,13,1,8,1,
- 21,1,4,2,114,95,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,0,0,124,0,0,131,1,0,106,
- 1,0,125,1,0,87,110,24,0,4,116,2,0,107,10,0,
- 114,45,0,1,1,1,100,1,0,125,1,0,89,110,1,0,
- 88,124,1,0,100,2,0,79,125,1,0,124,1,0,83,41,
- 3,122,51,67,97,108,99,117,108,97,116,101,32,116,104,101,
- 32,109,111,100,101,32,112,101,114,109,105,115,115,105,111,110,
- 115,32,102,111,114,32,97,32,98,121,116,101,99,111,100,101,
- 32,102,105,108,101,46,105,182,1,0,0,233,128,0,0,0,
- 41,3,114,39,0,0,0,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,99,1,0,0,115,12,0,0,
- 0,0,2,3,1,19,1,13,1,11,3,10,1,114,97,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,115,75,0,0,0,116,0,0,106,
- 1,0,106,2,0,124,1,0,107,5,0,114,71,0,124,0,
- 0,106,3,0,100,6,0,131,1,0,115,43,0,100,3,0,
- 124,0,0,23,125,0,0,116,4,0,124,0,0,106,5,0,
- 124,2,0,140,0,0,100,4,0,116,0,0,106,6,0,131,
- 1,1,1,100,5,0,83,41,7,122,61,80,114,105,110,116,
- 32,116,104,101,32,109,101,115,115,97,103,101,32,116,111,32,
- 115,116,100,101,114,114,32,105,102,32,45,118,47,80,89,84,
- 72,79,78,86,69,82,66,79,83,69,32,105,115,32,116,117,
- 114,110,101,100,32,111,110,46,250,1,35,250,7,105,109,112,
- 111,114,116,32,122,2,35,32,114,54,0,0,0,78,41,2,
- 114,99,0,0,0,114,100,0,0,0,41,7,114,7,0,0,
- 0,114,67,0,0,0,218,7,118,101,114,98,111,115,101,114,
- 9,0,0,0,218,5,112,114,105,110,116,114,47,0,0,0,
- 218,6,115,116,100,101,114,114,41,3,114,75,0,0,0,114,
- 98,0,0,0,218,4,97,114,103,115,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,111,1,0,0,115,
- 8,0,0,0,0,2,18,1,15,1,10,1,114,105,0,0,
- 0,99,1,0,0,0,0,0,0,0,3,0,0,0,11,0,
- 0,0,3,0,0,0,115,84,0,0,0,100,1,0,135,0,
- 0,102,1,0,100,2,0,100,3,0,134,1,0,125,1,0,
- 121,13,0,116,0,0,106,1,0,125,2,0,87,110,30,0,
- 4,116,2,0,107,10,0,114,66,0,1,1,1,100,4,0,
- 100,5,0,132,0,0,125,2,0,89,110,1,0,88,124,2,
- 0,124,1,0,136,0,0,131,2,0,1,124,1,0,83,41,
- 6,122,252,68,101,99,111,114,97,116,111,114,32,116,111,32,
- 118,101,114,105,102,121,32,116,104,97,116,32,116,104,101,32,
- 109,111,100,117,108,101,32,98,101,105,110,103,32,114,101,113,
- 117,101,115,116,101,100,32,109,97,116,99,104,101,115,32,116,
- 104,101,32,111,110,101,32,116,104,101,10,32,32,32,32,108,
- 111,97,100,101,114,32,99,97,110,32,104,97,110,100,108,101,
- 46,10,10,32,32,32,32,84,104,101,32,102,105,114,115,116,
- 32,97,114,103,117,109,101,110,116,32,40,115,101,108,102,41,
- 32,109,117,115,116,32,100,101,102,105,110,101,32,95,110,97,
- 109,101,32,119,104,105,99,104,32,116,104,101,32,115,101,99,
- 111,110,100,32,97,114,103,117,109,101,110,116,32,105,115,10,
- 32,32,32,32,99,111,109,112,97,114,101,100,32,97,103,97,
- 105,110,115,116,46,32,73,102,32,116,104,101,32,99,111,109,
- 112,97,114,105,115,111,110,32,102,97,105,108,115,32,116,104,
- 101,110,32,73,109,112,111,114,116,69,114,114,111,114,32,105,
- 115,32,114,97,105,115,101,100,46,10,10,32,32,32,32,78,
- 99,2,0,0,0,0,0,0,0,4,0,0,0,5,0,0,
- 0,31,0,0,0,115,89,0,0,0,124,1,0,100,0,0,
- 107,8,0,114,24,0,124,0,0,106,0,0,125,1,0,110,
- 46,0,124,0,0,106,0,0,124,1,0,107,3,0,114,70,
- 0,116,1,0,100,1,0,124,0,0,106,0,0,124,1,0,
- 102,2,0,22,100,2,0,124,1,0,131,1,1,130,1,0,
- 136,0,0,124,0,0,124,1,0,124,2,0,124,3,0,142,
- 2,0,83,41,3,78,122,30,108,111,97,100,101,114,32,102,
- 111,114,32,37,115,32,99,97,110,110,111,116,32,104,97,110,
- 100,108,101,32,37,115,218,4,110,97,109,101,41,2,114,106,
- 0,0,0,218,11,73,109,112,111,114,116,69,114,114,111,114,
- 41,4,218,4,115,101,108,102,114,106,0,0,0,114,104,0,
- 0,0,90,6,107,119,97,114,103,115,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,127,1,0,0,115,12,0,0,0,0,1,12,1,
- 12,1,15,1,6,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,99,2,0,0,0,0,0,0,0,3,0,0,0,7,
- 0,0,0,83,0,0,0,115,92,0,0,0,120,66,0,100,
- 1,0,100,2,0,100,3,0,100,4,0,103,4,0,68,93,
- 46,0,125,2,0,116,0,0,124,1,0,124,2,0,131,2,
- 0,114,19,0,116,1,0,124,0,0,124,2,0,116,2,0,
- 124,1,0,124,2,0,131,2,0,131,3,0,1,113,19,0,
- 87,124,0,0,106,3,0,106,4,0,124,1,0,106,3,0,
- 131,1,0,1,100,0,0,83,41,5,78,218,10,95,95,109,
- 111,100,117,108,101,95,95,218,8,95,95,110,97,109,101,95,
- 95,218,12,95,95,113,117,97,108,110,97,109,101,95,95,218,
- 7,95,95,100,111,99,95,95,41,5,218,7,104,97,115,97,
- 116,116,114,218,7,115,101,116,97,116,116,114,218,7,103,101,
- 116,97,116,116,114,218,8,95,95,100,105,99,116,95,95,218,
- 6,117,112,100,97,116,101,41,3,90,3,110,101,119,90,3,
- 111,108,100,114,52,0,0,0,114,4,0,0,0,114,4,0,
- 0,0,114,5,0,0,0,218,5,95,119,114,97,112,138,1,
- 0,0,115,8,0,0,0,0,1,25,1,15,1,29,1,122,
- 26,95,99,104,101,99,107,95,110,97,109,101,46,60,108,111,
- 99,97,108,115,62,46,95,119,114,97,112,41,3,218,10,95,
- 98,111,111,116,115,116,114,97,112,114,120,0,0,0,218,9,
- 78,97,109,101,69,114,114,111,114,41,3,114,109,0,0,0,
- 114,110,0,0,0,114,120,0,0,0,114,4,0,0,0,41,
- 1,114,109,0,0,0,114,5,0,0,0,218,11,95,99,104,
- 101,99,107,95,110,97,109,101,119,1,0,0,115,14,0,0,
- 0,0,8,21,7,3,1,13,1,13,2,17,5,13,1,114,
- 123,0,0,0,99,2,0,0,0,0,0,0,0,5,0,0,
- 0,4,0,0,0,67,0,0,0,115,84,0,0,0,124,0,
- 0,106,0,0,124,1,0,131,1,0,92,2,0,125,2,0,
- 125,3,0,124,2,0,100,1,0,107,8,0,114,80,0,116,
- 1,0,124,3,0,131,1,0,114,80,0,100,2,0,125,4,
- 0,116,2,0,106,3,0,124,4,0,106,4,0,124,3,0,
- 100,3,0,25,131,1,0,116,5,0,131,2,0,1,124,2,
- 0,83,41,4,122,155,84,114,121,32,116,111,32,102,105,110,
- 100,32,97,32,108,111,97,100,101,114,32,102,111,114,32,116,
- 104,101,32,115,112,101,99,105,102,105,101,100,32,109,111,100,
- 117,108,101,32,98,121,32,100,101,108,101,103,97,116,105,110,
- 103,32,116,111,10,32,32,32,32,115,101,108,102,46,102,105,
- 110,100,95,108,111,97,100,101,114,40,41,46,10,10,32,32,
- 32,32,84,104,105,115,32,109,101,116,104,111,100,32,105,115,
- 32,100,101,112,114,101,99,97,116,101,100,32,105,110,32,102,
- 97,118,111,114,32,111,102,32,102,105,110,100,101,114,46,102,
- 105,110,100,95,115,112,101,99,40,41,46,10,10,32,32,32,
- 32,78,122,44,78,111,116,32,105,109,112,111,114,116,105,110,
- 103,32,100,105,114,101,99,116,111,114,121,32,123,125,58,32,
- 109,105,115,115,105,110,103,32,95,95,105,110,105,116,95,95,
- 114,59,0,0,0,41,6,218,11,102,105,110,100,95,108,111,
- 97,100,101,114,114,31,0,0,0,114,60,0,0,0,114,61,
- 0,0,0,114,47,0,0,0,218,13,73,109,112,111,114,116,
- 87,97,114,110,105,110,103,41,5,114,108,0,0,0,218,8,
- 102,117,108,108,110,97,109,101,218,6,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,147,1,0,0,115,10,0,0,0,0,10,21,1,24,1,
- 6,1,29,1,114,130,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,240,
- 1,0,0,105,0,0,125,4,0,124,2,0,100,1,0,107,
- 9,0,114,31,0,124,2,0,124,4,0,100,2,0,60,110,
- 6,0,100,3,0,125,2,0,124,3,0,100,1,0,107,9,
- 0,114,59,0,124,3,0,124,4,0,100,4,0,60,124,0,
- 0,100,1,0,100,5,0,133,2,0,25,125,5,0,124,0,
- 0,100,5,0,100,6,0,133,2,0,25,125,6,0,124,0,
- 0,100,6,0,100,7,0,133,2,0,25,125,7,0,124,5,
- 0,116,0,0,107,3,0,114,168,0,100,8,0,106,1,0,
- 124,2,0,124,5,0,131,2,0,125,8,0,116,2,0,100,
- 9,0,124,8,0,131,2,0,1,116,3,0,124,8,0,124,
- 4,0,141,1,0,130,1,0,110,119,0,116,4,0,124,6,
- 0,131,1,0,100,5,0,107,3,0,114,229,0,100,10,0,
- 106,1,0,124,2,0,131,1,0,125,8,0,116,2,0,100,
- 9,0,124,8,0,131,2,0,1,116,5,0,124,8,0,131,
- 1,0,130,1,0,110,58,0,116,4,0,124,7,0,131,1,
- 0,100,5,0,107,3,0,114,31,1,100,11,0,106,1,0,
- 124,2,0,131,1,0,125,8,0,116,2,0,100,9,0,124,
- 8,0,131,2,0,1,116,5,0,124,8,0,131,1,0,130,
- 1,0,124,1,0,100,1,0,107,9,0,114,226,1,121,20,
- 0,116,6,0,124,1,0,100,12,0,25,131,1,0,125,9,
- 0,87,110,18,0,4,116,7,0,107,10,0,114,83,1,1,
- 1,1,89,110,62,0,88,116,8,0,124,6,0,131,1,0,
- 124,9,0,107,3,0,114,145,1,100,13,0,106,1,0,124,
- 2,0,131,1,0,125,8,0,116,2,0,100,9,0,124,8,
- 0,131,2,0,1,116,3,0,124,8,0,124,4,0,141,1,
- 0,130,1,0,121,18,0,124,1,0,100,14,0,25,100,15,
- 0,64,125,10,0,87,110,18,0,4,116,7,0,107,10,0,
- 114,183,1,1,1,1,89,110,43,0,88,116,8,0,124,7,
- 0,131,1,0,124,10,0,107,3,0,114,226,1,116,3,0,
- 100,13,0,106,1,0,124,2,0,131,1,0,124,4,0,141,
- 1,0,130,1,0,124,0,0,100,7,0,100,1,0,133,2,
- 0,25,83,41,16,97,122,1,0,0,86,97,108,105,100,97,
- 116,101,32,116,104,101,32,104,101,97,100,101,114,32,111,102,
- 32,116,104,101,32,112,97,115,115,101,100,45,105,110,32,98,
- 121,116,101,99,111,100,101,32,97,103,97,105,110,115,116,32,
- 115,111,117,114,99,101,95,115,116,97,116,115,32,40,105,102,
- 10,32,32,32,32,103,105,118,101,110,41,32,97,110,100,32,
- 114,101,116,117,114,110,105,110,103,32,116,104,101,32,98,121,
- 116,101,99,111,100,101,32,116,104,97,116,32,99,97,110,32,
- 98,101,32,99,111,109,112,105,108,101,100,32,98,121,32,99,
- 111,109,112,105,108,101,40,41,46,10,10,32,32,32,32,65,
- 108,108,32,111,116,104,101,114,32,97,114,103,117,109,101,110,
- 116,115,32,97,114,101,32,117,115,101,100,32,116,111,32,101,
- 110,104,97,110,99,101,32,101,114,114,111,114,32,114,101,112,
- 111,114,116,105,110,103,46,10,10,32,32,32,32,73,109,112,
- 111,114,116,69,114,114,111,114,32,105,115,32,114,97,105,115,
- 101,100,32,119,104,101,110,32,116,104,101,32,109,97,103,105,
- 99,32,110,117,109,98,101,114,32,105,115,32,105,110,99,111,
- 114,114,101,99,116,32,111,114,32,116,104,101,32,98,121,116,
- 101,99,111,100,101,32,105,115,10,32,32,32,32,102,111,117,
- 110,100,32,116,111,32,98,101,32,115,116,97,108,101,46,32,
- 69,79,70,69,114,114,111,114,32,105,115,32,114,97,105,115,
- 101,100,32,119,104,101,110,32,116,104,101,32,100,97,116,97,
- 32,105,115,32,102,111,117,110,100,32,116,111,32,98,101,10,
- 32,32,32,32,116,114,117,110,99,97,116,101,100,46,10,10,
- 32,32,32,32,78,114,106,0,0,0,122,10,60,98,121,116,
- 101,99,111,100,101,62,114,35,0,0,0,114,12,0,0,0,
- 233,8,0,0,0,233,12,0,0,0,122,30,98,97,100,32,
- 109,97,103,105,99,32,110,117,109,98,101,114,32,105,110,32,
- 123,33,114,125,58,32,123,33,114,125,122,2,123,125,122,43,
- 114,101,97,99,104,101,100,32,69,79,70,32,119,104,105,108,
- 101,32,114,101,97,100,105,110,103,32,116,105,109,101,115,116,
- 97,109,112,32,105,110,32,123,33,114,125,122,48,114,101,97,
- 99,104,101,100,32,69,79,70,32,119,104,105,108,101,32,114,
- 101,97,100,105,110,103,32,115,105,122,101,32,111,102,32,115,
- 111,117,114,99,101,32,105,110,32,123,33,114,125,218,5,109,
- 116,105,109,101,122,26,98,121,116,101,99,111,100,101,32,105,
- 115,32,115,116,97,108,101,32,102,111,114,32,123,33,114,125,
- 218,4,115,105,122,101,108,3,0,0,0,255,127,255,127,3,
- 0,41,9,218,12,77,65,71,73,67,95,78,85,77,66,69,
- 82,114,47,0,0,0,114,105,0,0,0,114,107,0,0,0,
- 114,31,0,0,0,218,8,69,79,70,69,114,114,111,114,114,
- 14,0,0,0,218,8,75,101,121,69,114,114,111,114,114,19,
- 0,0,0,41,11,114,53,0,0,0,218,12,115,111,117,114,
- 99,101,95,115,116,97,116,115,114,106,0,0,0,114,35,0,
- 0,0,90,11,101,120,99,95,100,101,116,97,105,108,115,90,
- 5,109,97,103,105,99,90,13,114,97,119,95,116,105,109,101,
- 115,116,97,109,112,90,8,114,97,119,95,115,105,122,101,114,
- 75,0,0,0,218,12,115,111,117,114,99,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,
+ 32,105,115,32,114,97,105,115,101,100,46,10,10,32,32,32,
+ 32,78,122,36,115,121,115,46,105,109,112,108,101,109,101,110,
+ 116,97,116,105,111,110,46,99,97,99,104,101,95,116,97,103,
+ 32,105,115,32,78,111,110,101,122,37,123,125,32,110,111,116,
+ 32,98,111,116,116,111,109,45,108,101,118,101,108,32,100,105,
+ 114,101,99,116,111,114,121,32,105,110,32,123,33,114,125,114,
+ 59,0,0,0,114,57,0,0,0,233,3,0,0,0,122,33,
+ 101,120,112,101,99,116,101,100,32,111,110,108,121,32,50,32,
+ 111,114,32,51,32,100,111,116,115,32,105,110,32,123,33,114,
+ 125,122,57,111,112,116,105,109,105,122,97,116,105,111,110,32,
+ 112,111,114,116,105,111,110,32,111,102,32,102,105,108,101,110,
+ 97,109,101,32,100,111,101,115,32,110,111,116,32,115,116,97,
+ 114,116,32,119,105,116,104,32,123,33,114,125,122,52,111,112,
+ 116,105,109,105,122,97,116,105,111,110,32,108,101,118,101,108,
+ 32,123,33,114,125,32,105,115,32,110,111,116,32,97,110,32,
+ 97,108,112,104,97,110,117,109,101,114,105,99,32,118,97,108,
+ 117,101,114,60,0,0,0,62,2,0,0,0,114,57,0,0,
+ 0,114,81,0,0,0,233,254,255,255,255,41,17,114,7,0,
+ 0,0,114,65,0,0,0,114,66,0,0,0,114,67,0,0,
+ 0,114,38,0,0,0,114,74,0,0,0,114,72,0,0,0,
+ 114,48,0,0,0,218,5,99,111,117,110,116,114,34,0,0,
+ 0,114,9,0,0,0,114,73,0,0,0,114,31,0,0,0,
+ 114,71,0,0,0,218,9,112,97,114,116,105,116,105,111,110,
+ 114,28,0,0,0,218,15,83,79,85,82,67,69,95,83,85,
+ 70,70,73,88,69,83,41,8,114,35,0,0,0,114,77,0,
+ 0,0,90,16,112,121,99,97,99,104,101,95,102,105,108,101,
+ 110,97,109,101,90,7,112,121,99,97,99,104,101,90,9,100,
+ 111,116,95,99,111,117,110,116,114,58,0,0,0,90,9,111,
+ 112,116,95,108,101,118,101,108,90,13,98,97,115,101,95,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,115,111,117,114,99,101,95,102,
+ 114,111,109,95,99,97,99,104,101,37,1,0,0,115,44,0,
+ 0,0,0,9,12,1,8,1,12,1,12,1,8,1,6,1,
+ 10,1,10,1,8,1,6,1,10,1,8,1,16,1,10,1,
+ 6,1,8,1,16,1,8,1,6,1,8,1,14,1,114,86,
+ 0,0,0,99,1,0,0,0,0,0,0,0,5,0,0,0,
+ 12,0,0,0,67,0,0,0,115,128,0,0,0,116,0,124,
+ 0,131,1,100,1,107,2,114,16,100,2,83,0,124,0,106,
+ 1,100,3,131,1,92,3,125,1,125,2,125,3,124,1,12,
+ 0,115,58,124,3,106,2,131,0,100,7,100,8,133,2,25,
+ 0,100,6,107,3,114,62,124,0,83,0,121,12,116,3,124,
+ 0,131,1,125,4,87,0,110,36,4,0,116,4,116,5,102,
+ 2,107,10,114,110,1,0,1,0,1,0,124,0,100,2,100,
+ 9,133,2,25,0,125,4,89,0,110,2,88,0,116,6,124,
+ 4,131,1,114,124,124,4,83,0,124,0,83,0,41,10,122,
+ 188,67,111,110,118,101,114,116,32,97,32,98,121,116,101,99,
+ 111,100,101,32,102,105,108,101,32,112,97,116,104,32,116,111,
+ 32,97,32,115,111,117,114,99,101,32,112,97,116,104,32,40,
+ 105,102,32,112,111,115,115,105,98,108,101,41,46,10,10,32,
+ 32,32,32,84,104,105,115,32,102,117,110,99,116,105,111,110,
+ 32,101,120,105,115,116,115,32,112,117,114,101,108,121,32,102,
+ 111,114,32,98,97,99,107,119,97,114,100,115,45,99,111,109,
+ 112,97,116,105,98,105,108,105,116,121,32,102,111,114,10,32,
+ 32,32,32,80,121,73,109,112,111,114,116,95,69,120,101,99,
+ 67,111,100,101,77,111,100,117,108,101,87,105,116,104,70,105,
+ 108,101,110,97,109,101,115,40,41,32,105,110,32,116,104,101,
+ 32,67,32,65,80,73,46,10,10,32,32,32,32,114,60,0,
+ 0,0,78,114,59,0,0,0,114,81,0,0,0,114,29,0,
+ 0,0,90,2,112,121,233,253,255,255,255,233,255,255,255,255,
+ 114,88,0,0,0,41,7,114,31,0,0,0,114,32,0,0,
+ 0,218,5,108,111,119,101,114,114,86,0,0,0,114,67,0,
+ 0,0,114,72,0,0,0,114,44,0,0,0,41,5,218,13,
+ 98,121,116,101,99,111,100,101,95,112,97,116,104,114,79,0,
+ 0,0,114,36,0,0,0,90,9,101,120,116,101,110,115,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,70,
+ 1,0,0,115,20,0,0,0,0,7,12,1,4,1,16,1,
+ 26,1,4,1,2,1,12,1,18,1,18,1,114,92,0,0,
+ 0,99,1,0,0,0,0,0,0,0,1,0,0,0,11,0,
+ 0,0,67,0,0,0,115,74,0,0,0,124,0,106,0,116,
+ 1,116,2,131,1,131,1,114,46,121,8,116,3,124,0,131,
+ 1,83,0,4,0,116,4,107,10,114,42,1,0,1,0,1,
+ 0,89,0,113,70,88,0,110,24,124,0,106,0,116,1,116,
+ 5,131,1,131,1,114,66,124,0,83,0,110,4,100,0,83,
+ 0,100,0,83,0,41,1,78,41,6,218,8,101,110,100,115,
+ 119,105,116,104,218,5,116,117,112,108,101,114,85,0,0,0,
+ 114,80,0,0,0,114,67,0,0,0,114,75,0,0,0,41,
+ 1,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,11,95,103,101,116,
+ 95,99,97,99,104,101,100,89,1,0,0,115,16,0,0,0,
+ 0,1,14,1,2,1,8,1,14,1,8,1,14,1,6,2,
+ 114,96,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,52,0,0,0,121,
+ 14,116,0,124,0,131,1,106,1,125,1,87,0,110,24,4,
+ 0,116,2,107,10,114,38,1,0,1,0,1,0,100,1,125,
+ 1,89,0,110,2,88,0,124,1,100,2,79,0,125,1,124,
+ 1,83,0,41,3,122,51,67,97,108,99,117,108,97,116,101,
+ 32,116,104,101,32,109,111,100,101,32,112,101,114,109,105,115,
+ 115,105,111,110,115,32,102,111,114,32,97,32,98,121,116,101,
+ 99,111,100,101,32,102,105,108,101,46,105,182,1,0,0,233,
+ 128,0,0,0,41,3,114,39,0,0,0,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,101,1,0,0,
+ 115,12,0,0,0,0,2,2,1,14,1,14,1,10,3,8,
+ 1,114,98,0,0,0,99,1,0,0,0,0,0,0,0,3,
+ 0,0,0,11,0,0,0,3,0,0,0,115,68,0,0,0,
+ 100,6,135,0,102,1,100,2,100,3,132,9,125,1,121,10,
+ 116,0,106,1,125,2,87,0,110,28,4,0,116,2,107,10,
+ 114,52,1,0,1,0,1,0,100,4,100,5,132,0,125,2,
+ 89,0,110,2,88,0,124,2,124,1,136,0,131,2,1,0,
+ 124,1,83,0,41,7,122,252,68,101,99,111,114,97,116,111,
+ 114,32,116,111,32,118,101,114,105,102,121,32,116,104,97,116,
+ 32,116,104,101,32,109,111,100,117,108,101,32,98,101,105,110,
+ 103,32,114,101,113,117,101,115,116,101,100,32,109,97,116,99,
+ 104,101,115,32,116,104,101,32,111,110,101,32,116,104,101,10,
+ 32,32,32,32,108,111,97,100,101,114,32,99,97,110,32,104,
+ 97,110,100,108,101,46,10,10,32,32,32,32,84,104,101,32,
+ 102,105,114,115,116,32,97,114,103,117,109,101,110,116,32,40,
+ 115,101,108,102,41,32,109,117,115,116,32,100,101,102,105,110,
+ 101,32,95,110,97,109,101,32,119,104,105,99,104,32,116,104,
+ 101,32,115,101,99,111,110,100,32,97,114,103,117,109,101,110,
+ 116,32,105,115,10,32,32,32,32,99,111,109,112,97,114,101,
+ 100,32,97,103,97,105,110,115,116,46,32,73,102,32,116,104,
+ 101,32,99,111,109,112,97,114,105,115,111,110,32,102,97,105,
+ 108,115,32,116,104,101,110,32,73,109,112,111,114,116,69,114,
+ 114,111,114,32,105,115,32,114,97,105,115,101,100,46,10,10,
+ 32,32,32,32,78,99,2,0,0,0,0,0,0,0,4,0,
+ 0,0,5,0,0,0,31,0,0,0,115,64,0,0,0,124,
+ 1,100,0,107,8,114,16,124,0,106,0,125,1,110,34,124,
+ 0,106,0,124,1,107,3,114,50,116,1,100,1,124,0,106,
+ 0,124,1,102,2,22,0,100,2,124,1,144,1,131,1,130,
+ 1,136,0,124,0,124,1,124,2,124,3,142,2,83,0,41,
+ 3,78,122,30,108,111,97,100,101,114,32,102,111,114,32,37,
+ 115,32,99,97,110,110,111,116,32,104,97,110,100,108,101,32,
+ 37,115,218,4,110,97,109,101,41,2,114,99,0,0,0,218,
+ 11,73,109,112,111,114,116,69,114,114,111,114,41,4,218,4,
+ 115,101,108,102,114,99,0,0,0,218,4,97,114,103,115,90,
+ 6,107,119,97,114,103,115,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,
+ 121,1,0,0,115,12,0,0,0,0,1,8,1,8,1,10,
+ 1,4,1,20,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,99,
+ 2,0,0,0,0,0,0,0,3,0,0,0,7,0,0,0,
+ 83,0,0,0,115,60,0,0,0,120,40,100,5,68,0,93,
+ 32,125,2,116,0,124,1,124,2,131,2,114,6,116,1,124,
+ 0,124,2,116,2,124,1,124,2,131,2,131,3,1,0,113,
+ 6,87,0,124,0,106,3,106,4,124,1,106,3,131,1,1,
+ 0,100,0,83,0,41,6,78,218,10,95,95,109,111,100,117,
+ 108,101,95,95,218,8,95,95,110,97,109,101,95,95,218,12,
+ 95,95,113,117,97,108,110,97,109,101,95,95,218,7,95,95,
+ 100,111,99,95,95,41,4,122,10,95,95,109,111,100,117,108,
+ 101,95,95,122,8,95,95,110,97,109,101,95,95,122,12,95,
+ 95,113,117,97,108,110,97,109,101,95,95,122,7,95,95,100,
+ 111,99,95,95,41,5,218,7,104,97,115,97,116,116,114,218,
+ 7,115,101,116,97,116,116,114,218,7,103,101,116,97,116,116,
+ 114,218,8,95,95,100,105,99,116,95,95,218,6,117,112,100,
+ 97,116,101,41,3,90,3,110,101,119,90,3,111,108,100,114,
+ 53,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,
+ 0,0,0,218,5,95,119,114,97,112,132,1,0,0,115,8,
+ 0,0,0,0,1,10,1,10,1,22,1,122,26,95,99,104,
+ 101,99,107,95,110,97,109,101,46,60,108,111,99,97,108,115,
+ 62,46,95,119,114,97,112,41,1,78,41,3,218,10,95,98,
+ 111,111,116,115,116,114,97,112,114,114,0,0,0,218,9,78,
+ 97,109,101,69,114,114,111,114,41,3,114,103,0,0,0,114,
+ 104,0,0,0,114,114,0,0,0,114,4,0,0,0,41,1,
+ 114,103,0,0,0,114,5,0,0,0,218,11,95,99,104,101,
+ 99,107,95,110,97,109,101,113,1,0,0,115,14,0,0,0,
+ 0,8,14,7,2,1,10,1,14,2,14,5,10,1,114,117,
+ 0,0,0,99,2,0,0,0,0,0,0,0,5,0,0,0,
+ 4,0,0,0,67,0,0,0,115,60,0,0,0,124,0,106,
+ 0,124,1,131,1,92,2,125,2,125,3,124,2,100,1,107,
+ 8,114,56,116,1,124,3,131,1,114,56,100,2,125,4,116,
+ 2,106,3,124,4,106,4,124,3,100,3,25,0,131,1,116,
+ 5,131,2,1,0,124,2,83,0,41,4,122,155,84,114,121,
+ 32,116,111,32,102,105,110,100,32,97,32,108,111,97,100,101,
+ 114,32,102,111,114,32,116,104,101,32,115,112,101,99,105,102,
+ 105,101,100,32,109,111,100,117,108,101,32,98,121,32,100,101,
+ 108,101,103,97,116,105,110,103,32,116,111,10,32,32,32,32,
+ 115,101,108,102,46,102,105,110,100,95,108,111,97,100,101,114,
+ 40,41,46,10,10,32,32,32,32,84,104,105,115,32,109,101,
+ 116,104,111,100,32,105,115,32,100,101,112,114,101,99,97,116,
+ 101,100,32,105,110,32,102,97,118,111,114,32,111,102,32,102,
+ 105,110,100,101,114,46,102,105,110,100,95,115,112,101,99,40,
+ 41,46,10,10,32,32,32,32,78,122,44,78,111,116,32,105,
+ 109,112,111,114,116,105,110,103,32,100,105,114,101,99,116,111,
+ 114,121,32,123,125,58,32,109,105,115,115,105,110,103,32,95,
+ 95,105,110,105,116,95,95,114,60,0,0,0,41,6,218,11,
+ 102,105,110,100,95,108,111,97,100,101,114,114,31,0,0,0,
+ 114,61,0,0,0,114,62,0,0,0,114,48,0,0,0,218,
+ 13,73,109,112,111,114,116,87,97,114,110,105,110,103,41,5,
+ 114,101,0,0,0,218,8,102,117,108,108,110,97,109,101,218,
+ 6,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,141,1,0,0,115,10,0,0,
+ 0,0,10,14,1,16,1,4,1,22,1,114,124,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,128,1,0,0,105,0,125,4,124,2,
+ 100,1,107,9,114,22,124,2,124,4,100,2,60,0,110,4,
+ 100,3,125,2,124,3,100,1,107,9,114,42,124,3,124,4,
+ 100,4,60,0,124,0,100,1,100,5,133,2,25,0,125,5,
+ 124,0,100,5,100,6,133,2,25,0,125,6,124,0,100,6,
+ 100,7,133,2,25,0,125,7,124,5,116,0,107,3,114,122,
+ 100,8,106,1,124,2,124,5,131,2,125,8,116,2,106,3,
+ 100,9,124,8,131,2,1,0,116,4,124,8,124,4,141,1,
+ 130,1,110,86,116,5,124,6,131,1,100,5,107,3,114,166,
+ 100,10,106,1,124,2,131,1,125,8,116,2,106,3,100,9,
+ 124,8,131,2,1,0,116,6,124,8,131,1,130,1,110,42,
+ 116,5,124,7,131,1,100,5,107,3,114,208,100,11,106,1,
+ 124,2,131,1,125,8,116,2,106,3,100,9,124,8,131,2,
+ 1,0,116,6,124,8,131,1,130,1,124,1,100,1,107,9,
+ 144,1,114,116,121,16,116,7,124,1,100,12,25,0,131,1,
+ 125,9,87,0,110,20,4,0,116,8,107,10,114,254,1,0,
+ 1,0,1,0,89,0,110,48,88,0,116,9,124,6,131,1,
+ 124,9,107,3,144,1,114,46,100,13,106,1,124,2,131,1,
+ 125,8,116,2,106,3,100,9,124,8,131,2,1,0,116,4,
+ 124,8,124,4,141,1,130,1,121,16,124,1,100,14,25,0,
+ 100,15,64,0,125,10,87,0,110,22,4,0,116,8,107,10,
+ 144,1,114,84,1,0,1,0,1,0,89,0,110,32,88,0,
+ 116,9,124,7,131,1,124,10,107,3,144,1,114,116,116,4,
+ 100,13,106,1,124,2,131,1,124,4,141,1,130,1,124,0,
+ 100,7,100,1,133,2,25,0,83,0,41,16,97,122,1,0,
+ 0,86,97,108,105,100,97,116,101,32,116,104,101,32,104,101,
+ 97,100,101,114,32,111,102,32,116,104,101,32,112,97,115,115,
+ 101,100,45,105,110,32,98,121,116,101,99,111,100,101,32,97,
+ 103,97,105,110,115,116,32,115,111,117,114,99,101,95,115,116,
+ 97,116,115,32,40,105,102,10,32,32,32,32,103,105,118,101,
+ 110,41,32,97,110,100,32,114,101,116,117,114,110,105,110,103,
+ 32,116,104,101,32,98,121,116,101,99,111,100,101,32,116,104,
+ 97,116,32,99,97,110,32,98,101,32,99,111,109,112,105,108,
+ 101,100,32,98,121,32,99,111,109,112,105,108,101,40,41,46,
+ 10,10,32,32,32,32,65,108,108,32,111,116,104,101,114,32,
+ 97,114,103,117,109,101,110,116,115,32,97,114,101,32,117,115,
+ 101,100,32,116,111,32,101,110,104,97,110,99,101,32,101,114,
+ 114,111,114,32,114,101,112,111,114,116,105,110,103,46,10,10,
+ 32,32,32,32,73,109,112,111,114,116,69,114,114,111,114,32,
+ 105,115,32,114,97,105,115,101,100,32,119,104,101,110,32,116,
+ 104,101,32,109,97,103,105,99,32,110,117,109,98,101,114,32,
+ 105,115,32,105,110,99,111,114,114,101,99,116,32,111,114,32,
+ 116,104,101,32,98,121,116,101,99,111,100,101,32,105,115,10,
+ 32,32,32,32,102,111,117,110,100,32,116,111,32,98,101,32,
+ 115,116,97,108,101,46,32,69,79,70,69,114,114,111,114,32,
+ 105,115,32,114,97,105,115,101,100,32,119,104,101,110,32,116,
+ 104,101,32,100,97,116,97,32,105,115,32,102,111,117,110,100,
+ 32,116,111,32,98,101,10,32,32,32,32,116,114,117,110,99,
+ 97,116,101,100,46,10,10,32,32,32,32,78,114,99,0,0,
+ 0,122,10,60,98,121,116,101,99,111,100,101,62,114,35,0,
+ 0,0,114,12,0,0,0,233,8,0,0,0,233,12,0,0,
+ 0,122,30,98,97,100,32,109,97,103,105,99,32,110,117,109,
+ 98,101,114,32,105,110,32,123,33,114,125,58,32,123,33,114,
+ 125,122,2,123,125,122,43,114,101,97,99,104,101,100,32,69,
+ 79,70,32,119,104,105,108,101,32,114,101,97,100,105,110,103,
+ 32,116,105,109,101,115,116,97,109,112,32,105,110,32,123,33,
+ 114,125,122,48,114,101,97,99,104,101,100,32,69,79,70,32,
+ 119,104,105,108,101,32,114,101,97,100,105,110,103,32,115,105,
+ 122,101,32,111,102,32,115,111,117,114,99,101,32,105,110,32,
+ 123,33,114,125,218,5,109,116,105,109,101,122,26,98,121,116,
+ 101,99,111,100,101,32,105,115,32,115,116,97,108,101,32,102,
+ 111,114,32,123,33,114,125,218,4,115,105,122,101,108,3,0,
+ 0,0,255,127,255,127,3,0,41,10,218,12,77,65,71,73,
+ 67,95,78,85,77,66,69,82,114,48,0,0,0,114,115,0,
+ 0,0,218,16,95,118,101,114,98,111,115,101,95,109,101,115,
+ 115,97,103,101,114,100,0,0,0,114,31,0,0,0,218,8,
+ 69,79,70,69,114,114,111,114,114,14,0,0,0,218,8,75,
+ 101,121,69,114,114,111,114,114,19,0,0,0,41,11,114,54,
+ 0,0,0,218,12,115,111,117,114,99,101,95,115,116,97,116,
+ 115,114,99,0,0,0,114,35,0,0,0,90,11,101,120,99,
+ 95,100,101,116,97,105,108,115,90,5,109,97,103,105,99,90,
+ 13,114,97,119,95,116,105,109,101,115,116,97,109,112,90,8,
+ 114,97,119,95,115,105,122,101,114,76,0,0,0,218,12,115,
+ 111,117,114,99,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,158,1,0,0,115,76,0,0,0,0,11,4,1,8,
+ 1,10,3,4,1,8,1,8,1,12,1,12,1,12,1,8,
+ 1,12,1,12,1,12,1,12,1,10,1,12,1,10,1,12,
+ 1,10,1,12,1,8,1,10,1,2,1,16,1,14,1,6,
+ 2,14,1,10,1,12,1,10,1,2,1,16,1,16,1,6,
+ 2,14,1,10,1,6,1,114,136,0,0,0,99,4,0,0,
+ 0,0,0,0,0,5,0,0,0,6,0,0,0,67,0,0,
+ 0,115,86,0,0,0,116,0,106,1,124,0,131,1,125,4,
+ 116,2,124,4,116,3,131,2,114,58,116,4,106,5,100,1,
+ 124,2,131,2,1,0,124,3,100,2,107,9,114,52,116,6,
+ 106,7,124,4,124,3,131,2,1,0,124,4,83,0,110,24,
+ 116,8,100,3,106,9,124,2,131,1,100,4,124,1,100,5,
+ 124,2,144,2,131,1,130,1,100,2,83,0,41,6,122,60,
+ 67,111,109,112,105,108,101,32,98,121,116,101,99,111,100,101,
+ 32,97,115,32,114,101,116,117,114,110,101,100,32,98,121,32,
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,164,1,0,0,115,76,0,
- 0,0,0,11,6,1,12,1,13,3,6,1,12,1,10,1,
- 16,1,16,1,16,1,12,1,18,1,13,1,18,1,18,1,
- 15,1,13,1,15,1,18,1,15,1,13,1,12,1,12,1,
- 3,1,20,1,13,1,5,2,18,1,15,1,13,1,15,1,
- 3,1,18,1,13,1,5,2,18,1,15,1,9,1,114,141,
- 0,0,0,99,4,0,0,0,0,0,0,0,5,0,0,0,
- 6,0,0,0,67,0,0,0,115,112,0,0,0,116,0,0,
- 106,1,0,124,0,0,131,1,0,125,4,0,116,2,0,124,
- 4,0,116,3,0,131,2,0,114,75,0,116,4,0,100,1,
- 0,124,2,0,131,2,0,1,124,3,0,100,2,0,107,9,
- 0,114,71,0,116,5,0,106,6,0,124,4,0,124,3,0,
- 131,2,0,1,124,4,0,83,116,7,0,100,3,0,106,8,
- 0,124,2,0,131,1,0,100,4,0,124,1,0,100,5,0,
- 124,2,0,131,1,2,130,1,0,100,2,0,83,41,6,122,
- 60,67,111,109,112,105,108,101,32,98,121,116,101,99,111,100,
- 101,32,97,115,32,114,101,116,117,114,110,101,100,32,98,121,
- 32,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,40,41,46,122,21,99,
- 111,100,101,32,111,98,106,101,99,116,32,102,114,111,109,32,
- 123,33,114,125,78,122,23,78,111,110,45,99,111,100,101,32,
- 111,98,106,101,99,116,32,105,110,32,123,33,114,125,114,106,
- 0,0,0,114,35,0,0,0,41,9,218,7,109,97,114,115,
- 104,97,108,90,5,108,111,97,100,115,218,10,105,115,105,110,
- 115,116,97,110,99,101,218,10,95,99,111,100,101,95,116,121,
- 112,101,114,105,0,0,0,218,4,95,105,109,112,90,16,95,
- 102,105,120,95,99,111,95,102,105,108,101,110,97,109,101,114,
- 107,0,0,0,114,47,0,0,0,41,5,114,53,0,0,0,
- 114,106,0,0,0,114,89,0,0,0,114,90,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,219,1,0,0,115,16,0,0,0,
- 0,2,15,1,15,1,13,1,12,1,16,1,4,2,18,1,
- 114,147,0,0,0,114,59,0,0,0,99,3,0,0,0,0,
- 0,0,0,4,0,0,0,3,0,0,0,67,0,0,0,115,
- 76,0,0,0,116,0,0,116,1,0,131,1,0,125,3,0,
- 124,3,0,106,2,0,116,3,0,124,1,0,131,1,0,131,
- 1,0,1,124,3,0,106,2,0,116,3,0,124,2,0,131,
- 1,0,131,1,0,1,124,3,0,106,2,0,116,4,0,106,
- 5,0,124,0,0,131,1,0,131,1,0,1,124,3,0,83,
+ 100,101,95,104,101,97,100,101,114,40,41,46,122,21,99,111,
+ 100,101,32,111,98,106,101,99,116,32,102,114,111,109,32,123,
+ 33,114,125,78,122,23,78,111,110,45,99,111,100,101,32,111,
+ 98,106,101,99,116,32,105,110,32,123,33,114,125,114,99,0,
+ 0,0,114,35,0,0,0,41,10,218,7,109,97,114,115,104,
+ 97,108,90,5,108,111,97,100,115,218,10,105,115,105,110,115,
+ 116,97,110,99,101,218,10,95,99,111,100,101,95,116,121,112,
+ 101,114,115,0,0,0,114,130,0,0,0,218,4,95,105,109,
+ 112,90,16,95,102,105,120,95,99,111,95,102,105,108,101,110,
+ 97,109,101,114,100,0,0,0,114,48,0,0,0,41,5,114,
+ 54,0,0,0,114,99,0,0,0,114,90,0,0,0,114,91,
+ 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,213,1,0,0,115,
+ 16,0,0,0,0,2,10,1,10,1,12,1,8,1,12,1,
+ 6,2,12,1,114,142,0,0,0,114,60,0,0,0,99,3,
+ 0,0,0,0,0,0,0,4,0,0,0,3,0,0,0,67,
+ 0,0,0,115,56,0,0,0,116,0,116,1,131,1,125,3,
+ 124,3,106,2,116,3,124,1,131,1,131,1,1,0,124,3,
+ 106,2,116,3,124,2,131,1,131,1,1,0,124,3,106,2,
+ 116,4,106,5,124,0,131,1,131,1,1,0,124,3,83,0,
41,1,122,80,67,111,109,112,105,108,101,32,97,32,99,111,
100,101,32,111,98,106,101,99,116,32,105,110,116,111,32,98,
121,116,101,99,111,100,101,32,102,111,114,32,119,114,105,116,
105,110,103,32,111,117,116,32,116,111,32,97,32,98,121,116,
101,45,99,111,109,112,105,108,101,100,10,32,32,32,32,102,
105,108,101,46,41,6,218,9,98,121,116,101,97,114,114,97,
- 121,114,135,0,0,0,218,6,101,120,116,101,110,100,114,17,
- 0,0,0,114,142,0,0,0,90,5,100,117,109,112,115,41,
- 4,114,146,0,0,0,114,133,0,0,0,114,140,0,0,0,
- 114,53,0,0,0,114,4,0,0,0,114,4,0,0,0,114,
+ 121,114,129,0,0,0,218,6,101,120,116,101,110,100,114,17,
+ 0,0,0,114,137,0,0,0,90,5,100,117,109,112,115,41,
+ 4,114,141,0,0,0,114,127,0,0,0,114,135,0,0,0,
+ 114,54,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,231,1,0,0,115,10,0,0,0,
- 0,3,12,1,19,1,19,1,22,1,114,150,0,0,0,99,
+ 121,116,101,99,111,100,101,225,1,0,0,115,10,0,0,0,
+ 0,3,8,1,14,1,14,1,16,1,114,145,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,100,1,0,100,2,0,108,
- 0,0,125,1,0,116,1,0,106,2,0,124,0,0,131,1,
- 0,106,3,0,125,2,0,124,1,0,106,4,0,124,2,0,
- 131,1,0,125,3,0,116,1,0,106,5,0,100,2,0,100,
- 3,0,131,2,0,125,4,0,124,4,0,106,6,0,124,0,
- 0,106,6,0,124,3,0,100,1,0,25,131,1,0,131,1,
- 0,83,41,4,122,121,68,101,99,111,100,101,32,98,121,116,
- 101,115,32,114,101,112,114,101,115,101,110,116,105,110,103,32,
- 115,111,117,114,99,101,32,99,111,100,101,32,97,110,100,32,
- 114,101,116,117,114,110,32,116,104,101,32,115,116,114,105,110,
- 103,46,10,10,32,32,32,32,85,110,105,118,101,114,115,97,
- 108,32,110,101,119,108,105,110,101,32,115,117,112,112,111,114,
- 116,32,105,115,32,117,115,101,100,32,105,110,32,116,104,101,
- 32,100,101,99,111,100,105,110,103,46,10,32,32,32,32,114,
- 59,0,0,0,78,84,41,7,218,8,116,111,107,101,110,105,
- 122,101,114,49,0,0,0,90,7,66,121,116,101,115,73,79,
- 90,8,114,101,97,100,108,105,110,101,90,15,100,101,116,101,
- 99,116,95,101,110,99,111,100,105,110,103,90,25,73,110,99,
- 114,101,109,101,110,116,97,108,78,101,119,108,105,110,101,68,
- 101,99,111,100,101,114,218,6,100,101,99,111,100,101,41,5,
- 218,12,115,111,117,114,99,101,95,98,121,116,101,115,114,151,
- 0,0,0,90,21,115,111,117,114,99,101,95,98,121,116,101,
- 115,95,114,101,97,100,108,105,110,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,241,1,0,0,115,10,0,0,0,0,5,12,1,
- 18,1,15,1,18,1,114,155,0,0,0,114,127,0,0,0,
- 218,26,115,117,98,109,111,100,117,108,101,95,115,101,97,114,
- 99,104,95,108,111,99,97,116,105,111,110,115,99,2,0,0,
- 0,2,0,0,0,9,0,0,0,19,0,0,0,67,0,0,
- 0,115,89,1,0,0,124,1,0,100,1,0,107,8,0,114,
- 73,0,100,2,0,125,1,0,116,0,0,124,2,0,100,3,
- 0,131,2,0,114,73,0,121,19,0,124,2,0,106,1,0,
- 124,0,0,131,1,0,125,1,0,87,110,18,0,4,116,2,
- 0,107,10,0,114,72,0,1,1,1,89,110,1,0,88,116,
- 3,0,106,4,0,124,0,0,124,2,0,100,4,0,124,1,
- 0,131,2,1,125,4,0,100,5,0,124,4,0,95,5,0,
- 124,2,0,100,1,0,107,8,0,114,194,0,120,73,0,116,
- 6,0,131,0,0,68,93,58,0,92,2,0,125,5,0,125,
- 6,0,124,1,0,106,7,0,116,8,0,124,6,0,131,1,
- 0,131,1,0,114,128,0,124,5,0,124,0,0,124,1,0,
- 131,2,0,125,2,0,124,2,0,124,4,0,95,9,0,80,
- 113,128,0,87,100,1,0,83,124,3,0,116,10,0,107,8,
- 0,114,23,1,116,0,0,124,2,0,100,6,0,131,2,0,
- 114,32,1,121,19,0,124,2,0,106,11,0,124,0,0,131,
- 1,0,125,7,0,87,110,18,0,4,116,2,0,107,10,0,
- 114,4,1,1,1,1,89,113,32,1,88,124,7,0,114,32,
- 1,103,0,0,124,4,0,95,12,0,110,9,0,124,3,0,
- 124,4,0,95,12,0,124,4,0,106,12,0,103,0,0,107,
- 2,0,114,85,1,124,1,0,114,85,1,116,13,0,124,1,
- 0,131,1,0,100,7,0,25,125,8,0,124,4,0,106,12,
- 0,106,14,0,124,8,0,131,1,0,1,124,4,0,83,41,
- 8,97,61,1,0,0,82,101,116,117,114,110,32,97,32,109,
- 111,100,117,108,101,32,115,112,101,99,32,98,97,115,101,100,
- 32,111,110,32,97,32,102,105,108,101,32,108,111,99,97,116,
- 105,111,110,46,10,10,32,32,32,32,84,111,32,105,110,100,
- 105,99,97,116,101,32,116,104,97,116,32,116,104,101,32,109,
- 111,100,117,108,101,32,105,115,32,97,32,112,97,99,107,97,
- 103,101,44,32,115,101,116,10,32,32,32,32,115,117,98,109,
- 111,100,117,108,101,95,115,101,97,114,99,104,95,108,111,99,
- 97,116,105,111,110,115,32,116,111,32,97,32,108,105,115,116,
- 32,111,102,32,100,105,114,101,99,116,111,114,121,32,112,97,
- 116,104,115,46,32,32,65,110,10,32,32,32,32,101,109,112,
- 116,121,32,108,105,115,116,32,105,115,32,115,117,102,102,105,
- 99,105,101,110,116,44,32,116,104,111,117,103,104,32,105,116,
- 115,32,110,111,116,32,111,116,104,101,114,119,105,115,101,32,
- 117,115,101,102,117,108,32,116,111,32,116,104,101,10,32,32,
- 32,32,105,109,112,111,114,116,32,115,121,115,116,101,109,46,
- 10,10,32,32,32,32,84,104,101,32,108,111,97,100,101,114,
- 32,109,117,115,116,32,116,97,107,101,32,97,32,115,112,101,
- 99,32,97,115,32,105,116,115,32,111,110,108,121,32,95,95,
- 105,110,105,116,95,95,40,41,32,97,114,103,46,10,10,32,
- 32,32,32,78,122,9,60,117,110,107,110,111,119,110,62,218,
- 12,103,101,116,95,102,105,108,101,110,97,109,101,218,6,111,
- 114,105,103,105,110,84,218,10,105,115,95,112,97,99,107,97,
- 103,101,114,59,0,0,0,41,15,114,115,0,0,0,114,157,
- 0,0,0,114,107,0,0,0,114,121,0,0,0,218,10,77,
- 111,100,117,108,101,83,112,101,99,90,13,95,115,101,116,95,
- 102,105,108,101,97,116,116,114,218,27,95,103,101,116,95,115,
- 117,112,112,111,114,116,101,100,95,102,105,108,101,95,108,111,
- 97,100,101,114,115,114,92,0,0,0,114,93,0,0,0,114,
- 127,0,0,0,218,9,95,80,79,80,85,76,65,84,69,114,
- 159,0,0,0,114,156,0,0,0,114,38,0,0,0,218,6,
- 97,112,112,101,110,100,41,9,114,106,0,0,0,90,8,108,
- 111,99,97,116,105,111,110,114,127,0,0,0,114,156,0,0,
- 0,218,4,115,112,101,99,218,12,108,111,97,100,101,114,95,
- 99,108,97,115,115,218,8,115,117,102,102,105,120,101,115,114,
- 159,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,218,23,115,112,
- 101,99,95,102,114,111,109,95,102,105,108,101,95,108,111,99,
- 97,116,105,111,110,2,2,0,0,115,60,0,0,0,0,12,
- 12,4,6,1,15,2,3,1,19,1,13,1,5,8,24,1,
- 9,3,12,1,22,1,21,1,15,1,9,1,5,2,4,3,
- 12,2,15,1,3,1,19,1,13,1,5,2,6,1,12,2,
- 9,1,15,1,6,1,16,1,16,2,114,167,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,121,0,0,0,101,0,0,90,1,0,100,
- 0,0,90,2,0,100,1,0,90,3,0,100,2,0,90,4,
- 0,100,3,0,90,5,0,100,4,0,90,6,0,101,7,0,
- 100,5,0,100,6,0,132,0,0,131,1,0,90,8,0,101,
- 7,0,100,7,0,100,8,0,132,0,0,131,1,0,90,9,
- 0,101,7,0,100,9,0,100,9,0,100,10,0,100,11,0,
- 132,2,0,131,1,0,90,10,0,101,7,0,100,9,0,100,
- 12,0,100,13,0,132,1,0,131,1,0,90,11,0,100,9,
- 0,83,41,14,218,21,87,105,110,100,111,119,115,82,101,103,
- 105,115,116,114,121,70,105,110,100,101,114,122,62,77,101,116,
- 97,32,112,97,116,104,32,102,105,110,100,101,114,32,102,111,
- 114,32,109,111,100,117,108,101,115,32,100,101,99,108,97,114,
- 101,100,32,105,110,32,116,104,101,32,87,105,110,100,111,119,
- 115,32,114,101,103,105,115,116,114,121,46,122,59,83,111,102,
- 116,119,97,114,101,92,80,121,116,104,111,110,92,80,121,116,
- 104,111,110,67,111,114,101,92,123,115,121,115,95,118,101,114,
- 115,105,111,110,125,92,77,111,100,117,108,101,115,92,123,102,
- 117,108,108,110,97,109,101,125,122,65,83,111,102,116,119,97,
+ 67,0,0,0,115,62,0,0,0,100,1,100,2,108,0,125,
+ 1,116,1,106,2,124,0,131,1,106,3,125,2,124,1,106,
+ 4,124,2,131,1,125,3,116,1,106,5,100,2,100,3,131,
+ 2,125,4,124,4,106,6,124,0,106,6,124,3,100,1,25,
+ 0,131,1,131,1,83,0,41,4,122,121,68,101,99,111,100,
+ 101,32,98,121,116,101,115,32,114,101,112,114,101,115,101,110,
+ 116,105,110,103,32,115,111,117,114,99,101,32,99,111,100,101,
+ 32,97,110,100,32,114,101,116,117,114,110,32,116,104,101,32,
+ 115,116,114,105,110,103,46,10,10,32,32,32,32,85,110,105,
+ 118,101,114,115,97,108,32,110,101,119,108,105,110,101,32,115,
+ 117,112,112,111,114,116,32,105,115,32,117,115,101,100,32,105,
+ 110,32,116,104,101,32,100,101,99,111,100,105,110,103,46,10,
+ 32,32,32,32,114,60,0,0,0,78,84,41,7,218,8,116,
+ 111,107,101,110,105,122,101,114,50,0,0,0,90,7,66,121,
+ 116,101,115,73,79,90,8,114,101,97,100,108,105,110,101,90,
+ 15,100,101,116,101,99,116,95,101,110,99,111,100,105,110,103,
+ 90,25,73,110,99,114,101,109,101,110,116,97,108,78,101,119,
+ 108,105,110,101,68,101,99,111,100,101,114,218,6,100,101,99,
+ 111,100,101,41,5,218,12,115,111,117,114,99,101,95,98,121,
+ 116,101,115,114,146,0,0,0,90,21,115,111,117,114,99,101,
+ 95,98,121,116,101,115,95,114,101,97,100,108,105,110,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,235,1,0,0,115,10,0,0,
+ 0,0,5,8,1,12,1,10,1,12,1,114,150,0,0,0,
+ 41,2,114,121,0,0,0,218,26,115,117,98,109,111,100,117,
+ 108,101,95,115,101,97,114,99,104,95,108,111,99,97,116,105,
+ 111,110,115,99,2,0,0,0,2,0,0,0,9,0,0,0,
+ 19,0,0,0,67,0,0,0,115,8,1,0,0,124,1,100,
+ 1,107,8,114,58,100,2,125,1,116,0,124,2,100,3,131,
+ 2,114,58,121,14,124,2,106,1,124,0,131,1,125,1,87,
+ 0,110,20,4,0,116,2,107,10,114,56,1,0,1,0,1,
+ 0,89,0,110,2,88,0,116,3,106,4,124,0,124,2,100,
+ 4,124,1,144,1,131,2,125,4,100,5,124,4,95,5,124,
+ 2,100,1,107,8,114,146,120,54,116,6,131,0,68,0,93,
+ 40,92,2,125,5,125,6,124,1,106,7,116,8,124,6,131,
+ 1,131,1,114,98,124,5,124,0,124,1,131,2,125,2,124,
+ 2,124,4,95,9,80,0,113,98,87,0,100,1,83,0,124,
+ 3,116,10,107,8,114,212,116,0,124,2,100,6,131,2,114,
+ 218,121,14,124,2,106,11,124,0,131,1,125,7,87,0,110,
+ 20,4,0,116,2,107,10,114,198,1,0,1,0,1,0,89,
+ 0,113,218,88,0,124,7,114,218,103,0,124,4,95,12,110,
+ 6,124,3,124,4,95,12,124,4,106,12,103,0,107,2,144,
+ 1,114,4,124,1,144,1,114,4,116,13,124,1,131,1,100,
+ 7,25,0,125,8,124,4,106,12,106,14,124,8,131,1,1,
+ 0,124,4,83,0,41,8,97,61,1,0,0,82,101,116,117,
+ 114,110,32,97,32,109,111,100,117,108,101,32,115,112,101,99,
+ 32,98,97,115,101,100,32,111,110,32,97,32,102,105,108,101,
+ 32,108,111,99,97,116,105,111,110,46,10,10,32,32,32,32,
+ 84,111,32,105,110,100,105,99,97,116,101,32,116,104,97,116,
+ 32,116,104,101,32,109,111,100,117,108,101,32,105,115,32,97,
+ 32,112,97,99,107,97,103,101,44,32,115,101,116,10,32,32,
+ 32,32,115,117,98,109,111,100,117,108,101,95,115,101,97,114,
+ 99,104,95,108,111,99,97,116,105,111,110,115,32,116,111,32,
+ 97,32,108,105,115,116,32,111,102,32,100,105,114,101,99,116,
+ 111,114,121,32,112,97,116,104,115,46,32,32,65,110,10,32,
+ 32,32,32,101,109,112,116,121,32,108,105,115,116,32,105,115,
+ 32,115,117,102,102,105,99,105,101,110,116,44,32,116,104,111,
+ 117,103,104,32,105,116,115,32,110,111,116,32,111,116,104,101,
+ 114,119,105,115,101,32,117,115,101,102,117,108,32,116,111,32,
+ 116,104,101,10,32,32,32,32,105,109,112,111,114,116,32,115,
+ 121,115,116,101,109,46,10,10,32,32,32,32,84,104,101,32,
+ 108,111,97,100,101,114,32,109,117,115,116,32,116,97,107,101,
+ 32,97,32,115,112,101,99,32,97,115,32,105,116,115,32,111,
+ 110,108,121,32,95,95,105,110,105,116,95,95,40,41,32,97,
+ 114,103,46,10,10,32,32,32,32,78,122,9,60,117,110,107,
+ 110,111,119,110,62,218,12,103,101,116,95,102,105,108,101,110,
+ 97,109,101,218,6,111,114,105,103,105,110,84,218,10,105,115,
+ 95,112,97,99,107,97,103,101,114,60,0,0,0,41,15,114,
+ 109,0,0,0,114,152,0,0,0,114,100,0,0,0,114,115,
+ 0,0,0,218,10,77,111,100,117,108,101,83,112,101,99,90,
+ 13,95,115,101,116,95,102,105,108,101,97,116,116,114,218,27,
+ 95,103,101,116,95,115,117,112,112,111,114,116,101,100,95,102,
+ 105,108,101,95,108,111,97,100,101,114,115,114,93,0,0,0,
+ 114,94,0,0,0,114,121,0,0,0,218,9,95,80,79,80,
+ 85,76,65,84,69,114,154,0,0,0,114,151,0,0,0,114,
+ 38,0,0,0,218,6,97,112,112,101,110,100,41,9,114,99,
+ 0,0,0,90,8,108,111,99,97,116,105,111,110,114,121,0,
+ 0,0,114,151,0,0,0,218,4,115,112,101,99,218,12,108,
+ 111,97,100,101,114,95,99,108,97,115,115,218,8,115,117,102,
+ 102,105,120,101,115,114,154,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,218,23,115,112,101,99,95,102,114,111,109,95,102,105,
+ 108,101,95,108,111,99,97,116,105,111,110,252,1,0,0,115,
+ 60,0,0,0,0,12,8,4,4,1,10,2,2,1,14,1,
+ 14,1,6,8,18,1,6,3,8,1,16,1,14,1,10,1,
+ 6,1,6,2,4,3,8,2,10,1,2,1,14,1,14,1,
+ 6,2,4,1,8,2,6,1,12,1,6,1,12,1,12,2,
+ 114,162,0,0,0,99,0,0,0,0,0,0,0,0,0,0,
+ 0,0,4,0,0,0,64,0,0,0,115,80,0,0,0,101,
+ 0,90,1,100,0,90,2,100,1,90,3,100,2,90,4,100,
+ 3,90,5,100,4,90,6,101,7,100,5,100,6,132,0,131,
+ 1,90,8,101,7,100,7,100,8,132,0,131,1,90,9,101,
+ 7,100,14,100,10,100,11,132,1,131,1,90,10,101,7,100,
+ 15,100,12,100,13,132,1,131,1,90,11,100,9,83,0,41,
+ 16,218,21,87,105,110,100,111,119,115,82,101,103,105,115,116,
+ 114,121,70,105,110,100,101,114,122,62,77,101,116,97,32,112,
+ 97,116,104,32,102,105,110,100,101,114,32,102,111,114,32,109,
+ 111,100,117,108,101,115,32,100,101,99,108,97,114,101,100,32,
+ 105,110,32,116,104,101,32,87,105,110,100,111,119,115,32,114,
+ 101,103,105,115,116,114,121,46,122,59,83,111,102,116,119,97,
114,101,92,80,121,116,104,111,110,92,80,121,116,104,111,110,
67,111,114,101,92,123,115,121,115,95,118,101,114,115,105,111,
110,125,92,77,111,100,117,108,101,115,92,123,102,117,108,108,
- 110,97,109,101,125,92,68,101,98,117,103,70,99,2,0,0,
- 0,0,0,0,0,2,0,0,0,11,0,0,0,67,0,0,
- 0,115,67,0,0,0,121,23,0,116,0,0,106,1,0,116,
- 0,0,106,2,0,124,1,0,131,2,0,83,87,110,37,0,
- 4,116,3,0,107,10,0,114,62,0,1,1,1,116,0,0,
- 106,1,0,116,0,0,106,4,0,124,1,0,131,2,0,83,
- 89,110,1,0,88,100,0,0,83,41,1,78,41,5,218,7,
- 95,119,105,110,114,101,103,90,7,79,112,101,110,75,101,121,
- 90,17,72,75,69,89,95,67,85,82,82,69,78,84,95,85,
- 83,69,82,114,40,0,0,0,90,18,72,75,69,89,95,76,
- 79,67,65,76,95,77,65,67,72,73,78,69,41,2,218,3,
- 99,108,115,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,80,2,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,0,0,0,6,0,0,0,16,0,0,0,67,
- 0,0,0,115,143,0,0,0,124,0,0,106,0,0,114,21,
- 0,124,0,0,106,1,0,125,2,0,110,9,0,124,0,0,
- 106,2,0,125,2,0,124,2,0,106,3,0,100,1,0,124,
- 1,0,100,2,0,116,4,0,106,5,0,100,0,0,100,3,
- 0,133,2,0,25,131,0,2,125,3,0,121,47,0,124,0,
- 0,106,6,0,124,3,0,131,1,0,143,25,0,125,4,0,
- 116,7,0,106,8,0,124,4,0,100,4,0,131,2,0,125,
- 5,0,87,100,0,0,81,82,88,87,110,22,0,4,116,9,
- 0,107,10,0,114,138,0,1,1,1,100,0,0,83,89,110,
- 1,0,88,124,5,0,83,41,5,78,114,126,0,0,0,90,
- 11,115,121,115,95,118,101,114,115,105,111,110,114,80,0,0,
- 0,114,30,0,0,0,41,10,218,11,68,69,66,85,71,95,
- 66,85,73,76,68,218,18,82,69,71,73,83,84,82,89,95,
- 75,69,89,95,68,69,66,85,71,218,12,82,69,71,73,83,
- 84,82,89,95,75,69,89,114,47,0,0,0,114,7,0,0,
- 0,218,7,118,101,114,115,105,111,110,114,172,0,0,0,114,
- 169,0,0,0,90,10,81,117,101,114,121,86,97,108,117,101,
- 114,40,0,0,0,41,6,114,170,0,0,0,114,126,0,0,
- 0,90,12,114,101,103,105,115,116,114,121,95,107,101,121,114,
- 171,0,0,0,90,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,87,2,0,0,115,22,0,0,0,0,2,
- 9,1,12,2,9,1,15,1,22,1,3,1,18,1,29,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,101,103,105,115,116,114,121,78,99,4,0,
- 0,0,0,0,0,0,8,0,0,0,14,0,0,0,67,0,
- 0,0,115,158,0,0,0,124,0,0,106,0,0,124,1,0,
- 131,1,0,125,4,0,124,4,0,100,0,0,107,8,0,114,
- 31,0,100,0,0,83,121,14,0,116,1,0,124,4,0,131,
- 1,0,1,87,110,22,0,4,116,2,0,107,10,0,114,69,
- 0,1,1,1,100,0,0,83,89,110,1,0,88,120,81,0,
- 116,3,0,131,0,0,68,93,70,0,92,2,0,125,5,0,
- 125,6,0,124,4,0,106,4,0,116,5,0,124,6,0,131,
- 1,0,131,1,0,114,80,0,116,6,0,106,7,0,124,1,
- 0,124,5,0,124,1,0,124,4,0,131,2,0,100,1,0,
- 124,4,0,131,2,1,125,7,0,124,7,0,83,113,80,0,
- 87,100,0,0,83,41,2,78,114,158,0,0,0,41,8,114,
- 178,0,0,0,114,39,0,0,0,114,40,0,0,0,114,161,
- 0,0,0,114,92,0,0,0,114,93,0,0,0,114,121,0,
- 0,0,218,16,115,112,101,99,95,102,114,111,109,95,108,111,
- 97,100,101,114,41,8,114,170,0,0,0,114,126,0,0,0,
- 114,35,0,0,0,218,6,116,97,114,103,101,116,114,177,0,
- 0,0,114,127,0,0,0,114,166,0,0,0,114,164,0,0,
- 0,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,102,2,0,0,115,
- 26,0,0,0,0,2,15,1,12,1,4,1,3,1,14,1,
- 13,1,9,1,22,1,21,1,9,1,15,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,46,102,105,110,100,95,115,112,101,99,99,
- 3,0,0,0,0,0,0,0,4,0,0,0,3,0,0,0,
- 67,0,0,0,115,45,0,0,0,124,0,0,106,0,0,124,
- 1,0,124,2,0,131,2,0,125,3,0,124,3,0,100,1,
- 0,107,9,0,114,37,0,124,3,0,106,1,0,83,100,1,
- 0,83,100,1,0,83,41,2,122,108,70,105,110,100,32,109,
+ 110,97,109,101,125,122,65,83,111,102,116,119,97,114,101,92,
+ 80,121,116,104,111,110,92,80,121,116,104,111,110,67,111,114,
+ 101,92,123,115,121,115,95,118,101,114,115,105,111,110,125,92,
+ 77,111,100,117,108,101,115,92,123,102,117,108,108,110,97,109,
+ 101,125,92,68,101,98,117,103,70,99,2,0,0,0,0,0,
+ 0,0,2,0,0,0,11,0,0,0,67,0,0,0,115,50,
+ 0,0,0,121,14,116,0,106,1,116,0,106,2,124,1,131,
+ 2,83,0,4,0,116,3,107,10,114,44,1,0,1,0,1,
+ 0,116,0,106,1,116,0,106,4,124,1,131,2,83,0,88,
+ 0,100,0,83,0,41,1,78,41,5,218,7,95,119,105,110,
+ 114,101,103,90,7,79,112,101,110,75,101,121,90,17,72,75,
+ 69,89,95,67,85,82,82,69,78,84,95,85,83,69,82,114,
+ 40,0,0,0,90,18,72,75,69,89,95,76,79,67,65,76,
+ 95,77,65,67,72,73,78,69,41,2,218,3,99,108,115,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,74,2,0,0,115,8,0,0,0,0,2,2,1,
+ 14,1,14,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,
+ 0,0,0,6,0,0,0,16,0,0,0,67,0,0,0,115,
+ 116,0,0,0,124,0,106,0,114,14,124,0,106,1,125,2,
+ 110,6,124,0,106,2,125,2,124,2,106,3,100,1,124,1,
+ 100,2,100,3,116,4,106,5,100,0,100,4,133,2,25,0,
+ 22,0,144,2,131,0,125,3,121,38,124,0,106,6,124,3,
+ 131,1,143,18,125,4,116,7,106,8,124,4,100,5,131,2,
+ 125,5,87,0,100,0,81,0,82,0,88,0,87,0,110,20,
+ 4,0,116,9,107,10,114,110,1,0,1,0,1,0,100,0,
+ 83,0,88,0,124,5,83,0,41,6,78,114,120,0,0,0,
+ 90,11,115,121,115,95,118,101,114,115,105,111,110,122,5,37,
+ 100,46,37,100,114,57,0,0,0,114,30,0,0,0,41,10,
+ 218,11,68,69,66,85,71,95,66,85,73,76,68,218,18,82,
+ 69,71,73,83,84,82,89,95,75,69,89,95,68,69,66,85,
+ 71,218,12,82,69,71,73,83,84,82,89,95,75,69,89,114,
+ 48,0,0,0,114,7,0,0,0,218,12,118,101,114,115,105,
+ 111,110,95,105,110,102,111,114,167,0,0,0,114,164,0,0,
+ 0,90,10,81,117,101,114,121,86,97,108,117,101,114,40,0,
+ 0,0,41,6,114,165,0,0,0,114,120,0,0,0,90,12,
+ 114,101,103,105,115,116,114,121,95,107,101,121,114,166,0,0,
+ 0,90,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,81,2,0,0,115,22,0,0,0,0,2,6,1,8,
+ 2,6,1,10,1,22,1,2,1,12,1,26,1,14,1,6,
+ 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,101,103,105,115,116,114,121,78,99,4,0,0,0,0,
+ 0,0,0,8,0,0,0,14,0,0,0,67,0,0,0,115,
+ 122,0,0,0,124,0,106,0,124,1,131,1,125,4,124,4,
+ 100,0,107,8,114,22,100,0,83,0,121,12,116,1,124,4,
+ 131,1,1,0,87,0,110,20,4,0,116,2,107,10,114,54,
+ 1,0,1,0,1,0,100,0,83,0,88,0,120,60,116,3,
+ 131,0,68,0,93,50,92,2,125,5,125,6,124,4,106,4,
+ 116,5,124,6,131,1,131,1,114,64,116,6,106,7,124,1,
+ 124,5,124,1,124,4,131,2,100,1,124,4,144,1,131,2,
+ 125,7,124,7,83,0,113,64,87,0,100,0,83,0,41,2,
+ 78,114,153,0,0,0,41,8,114,173,0,0,0,114,39,0,
+ 0,0,114,40,0,0,0,114,156,0,0,0,114,93,0,0,
+ 0,114,94,0,0,0,114,115,0,0,0,218,16,115,112,101,
+ 99,95,102,114,111,109,95,108,111,97,100,101,114,41,8,114,
+ 165,0,0,0,114,120,0,0,0,114,35,0,0,0,218,6,
+ 116,97,114,103,101,116,114,172,0,0,0,114,121,0,0,0,
+ 114,161,0,0,0,114,159,0,0,0,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,96,2,0,0,115,26,0,0,0,0,2,10,
+ 1,8,1,4,1,2,1,12,1,14,1,6,1,16,1,14,
+ 1,6,1,10,1,8,1,122,31,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,115,112,101,99,99,3,0,0,0,0,0,0,
+ 0,4,0,0,0,3,0,0,0,67,0,0,0,115,36,0,
+ 0,0,124,0,106,0,124,1,124,2,131,2,125,3,124,3,
+ 100,1,107,9,114,28,124,3,106,1,83,0,110,4,100,1,
+ 83,0,100,1,83,0,41,2,122,108,70,105,110,100,32,109,
111,100,117,108,101,32,110,97,109,101,100,32,105,110,32,116,
104,101,32,114,101,103,105,115,116,114,121,46,10,10,32,32,
32,32,32,32,32,32,84,104,105,115,32,109,101,116,104,111,
100,32,105,115,32,100,101,112,114,101,99,97,116,101,100,46,
32,32,85,115,101,32,101,120,101,99,95,109,111,100,117,108,
101,40,41,32,105,110,115,116,101,97,100,46,10,10,32,32,
- 32,32,32,32,32,32,78,41,2,114,181,0,0,0,114,127,
- 0,0,0,41,4,114,170,0,0,0,114,126,0,0,0,114,
- 35,0,0,0,114,164,0,0,0,114,4,0,0,0,114,4,
+ 32,32,32,32,32,32,78,41,2,114,176,0,0,0,114,121,
+ 0,0,0,41,4,114,165,0,0,0,114,120,0,0,0,114,
+ 35,0,0,0,114,159,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,118,2,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,
+ 111,100,117,108,101,112,2,0,0,115,8,0,0,0,0,7,
+ 12,1,8,1,8,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,112,0,0,0,
- 114,111,0,0,0,114,113,0,0,0,114,114,0,0,0,114,
- 175,0,0,0,114,174,0,0,0,114,173,0,0,0,218,11,
- 99,108,97,115,115,109,101,116,104,111,100,114,172,0,0,0,
- 114,178,0,0,0,114,181,0,0,0,114,182,0,0,0,114,
- 4,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,
- 0,0,0,114,168,0,0,0,68,2,0,0,115,20,0,0,
- 0,12,2,6,3,6,3,6,2,6,2,18,7,18,15,3,
- 1,21,15,3,1,114,168,0,0,0,99,0,0,0,0,0,
- 0,0,0,0,0,0,0,2,0,0,0,64,0,0,0,115,
- 70,0,0,0,101,0,0,90,1,0,100,0,0,90,2,0,
- 100,1,0,90,3,0,100,2,0,100,3,0,132,0,0,90,
- 4,0,100,4,0,100,5,0,132,0,0,90,5,0,100,6,
- 0,100,7,0,132,0,0,90,6,0,100,8,0,100,9,0,
- 132,0,0,90,7,0,100,10,0,83,41,11,218,13,95,76,
- 111,97,100,101,114,66,97,115,105,99,115,122,83,66,97,115,
- 101,32,99,108,97,115,115,32,111,102,32,99,111,109,109,111,
- 110,32,99,111,100,101,32,110,101,101,100,101,100,32,98,121,
- 32,98,111,116,104,32,83,111,117,114,99,101,76,111,97,100,
- 101,114,32,97,110,100,10,32,32,32,32,83,111,117,114,99,
- 101,108,101,115,115,70,105,108,101,76,111,97,100,101,114,46,
- 99,2,0,0,0,0,0,0,0,5,0,0,0,3,0,0,
- 0,67,0,0,0,115,88,0,0,0,116,0,0,124,0,0,
- 106,1,0,124,1,0,131,1,0,131,1,0,100,1,0,25,
- 125,2,0,124,2,0,106,2,0,100,2,0,100,1,0,131,
- 2,0,100,3,0,25,125,3,0,124,1,0,106,3,0,100,
- 2,0,131,1,0,100,4,0,25,125,4,0,124,3,0,100,
- 5,0,107,2,0,111,87,0,124,4,0,100,5,0,107,3,
- 0,83,41,6,122,141,67,111,110,99,114,101,116,101,32,105,
- 109,112,108,101,109,101,110,116,97,116,105,111,110,32,111,102,
- 32,73,110,115,112,101,99,116,76,111,97,100,101,114,46,105,
- 115,95,112,97,99,107,97,103,101,32,98,121,32,99,104,101,
- 99,107,105,110,103,32,105,102,10,32,32,32,32,32,32,32,
- 32,116,104,101,32,112,97,116,104,32,114,101,116,117,114,110,
- 101,100,32,98,121,32,103,101,116,95,102,105,108,101,110,97,
- 109,101,32,104,97,115,32,97,32,102,105,108,101,110,97,109,
- 101,32,111,102,32,39,95,95,105,110,105,116,95,95,46,112,
- 121,39,46,114,29,0,0,0,114,58,0,0,0,114,59,0,
- 0,0,114,56,0,0,0,218,8,95,95,105,110,105,116,95,
- 95,41,4,114,38,0,0,0,114,157,0,0,0,114,34,0,
- 0,0,114,32,0,0,0,41,5,114,108,0,0,0,114,126,
- 0,0,0,114,94,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,159,0,0,0,137,2,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,2,0,0,0,1,0,
- 0,0,67,0,0,0,115,4,0,0,0,100,1,0,83,41,
- 2,122,42,85,115,101,32,100,101,102,97,117,108,116,32,115,
- 101,109,97,110,116,105,99,115,32,102,111,114,32,109,111,100,
- 117,108,101,32,99,114,101,97,116,105,111,110,46,78,114,4,
- 0,0,0,41,2,114,108,0,0,0,114,164,0,0,0,114,
- 4,0,0,0,114,4,0,0,0,114,5,0,0,0,218,13,
- 99,114,101,97,116,101,95,109,111,100,117,108,101,145,2,0,
- 0,115,0,0,0,0,122,27,95,76,111,97,100,101,114,66,
- 97,115,105,99,115,46,99,114,101,97,116,101,95,109,111,100,
- 117,108,101,99,2,0,0,0,0,0,0,0,3,0,0,0,
- 4,0,0,0,67,0,0,0,115,80,0,0,0,124,0,0,
- 106,0,0,124,1,0,106,1,0,131,1,0,125,2,0,124,
- 2,0,100,1,0,107,8,0,114,54,0,116,2,0,100,2,
- 0,106,3,0,124,1,0,106,1,0,131,1,0,131,1,0,
- 130,1,0,116,4,0,106,5,0,116,6,0,124,2,0,124,
- 1,0,106,7,0,131,3,0,1,100,1,0,83,41,3,122,
- 19,69,120,101,99,117,116,101,32,116,104,101,32,109,111,100,
- 117,108,101,46,78,122,52,99,97,110,110,111,116,32,108,111,
- 97,100,32,109,111,100,117,108,101,32,123,33,114,125,32,119,
- 104,101,110,32,103,101,116,95,99,111,100,101,40,41,32,114,
- 101,116,117,114,110,115,32,78,111,110,101,41,8,218,8,103,
- 101,116,95,99,111,100,101,114,112,0,0,0,114,107,0,0,
- 0,114,47,0,0,0,114,121,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,218,4,101,120,101,99,114,118,0,0,
- 0,41,3,114,108,0,0,0,218,6,109,111,100,117,108,101,
- 114,146,0,0,0,114,4,0,0,0,114,4,0,0,0,114,
- 5,0,0,0,218,11,101,120,101,99,95,109,111,100,117,108,
- 101,148,2,0,0,115,10,0,0,0,0,2,18,1,12,1,
- 9,1,15,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,99,
- 2,0,0,0,0,0,0,0,2,0,0,0,3,0,0,0,
- 67,0,0,0,115,16,0,0,0,116,0,0,106,1,0,124,
- 0,0,124,1,0,131,2,0,83,41,1,78,41,2,114,121,
- 0,0,0,218,17,95,108,111,97,100,95,109,111,100,117,108,
- 101,95,115,104,105,109,41,2,114,108,0,0,0,114,126,0,
- 0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,
- 0,218,11,108,111,97,100,95,109,111,100,117,108,101,156,2,
- 0,0,115,2,0,0,0,0,1,122,25,95,76,111,97,100,
- 101,114,66,97,115,105,99,115,46,108,111,97,100,95,109,111,
- 100,117,108,101,78,41,8,114,112,0,0,0,114,111,0,0,
- 0,114,113,0,0,0,114,114,0,0,0,114,159,0,0,0,
- 114,186,0,0,0,114,191,0,0,0,114,193,0,0,0,114,
- 4,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,
- 0,0,0,114,184,0,0,0,132,2,0,0,115,10,0,0,
- 0,12,3,6,2,12,8,12,3,12,8,114,184,0,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,0,0,90,2,0,100,1,0,100,2,0,132,0,0,90,
- 3,0,100,3,0,100,4,0,132,0,0,90,4,0,100,5,
- 0,100,6,0,132,0,0,90,5,0,100,7,0,100,8,0,
- 132,0,0,90,6,0,100,9,0,100,10,0,132,0,0,90,
- 7,0,100,11,0,100,18,0,100,13,0,100,14,0,132,0,
- 1,90,8,0,100,15,0,100,16,0,132,0,0,90,9,0,
- 100,17,0,83,41,19,218,12,83,111,117,114,99,101,76,111,
- 97,100,101,114,99,2,0,0,0,0,0,0,0,2,0,0,
- 0,1,0,0,0,67,0,0,0,115,10,0,0,0,116,0,
- 0,130,1,0,100,1,0,83,41,2,122,178,79,112,116,105,
- 111,110,97,108,32,109,101,116,104,111,100,32,116,104,97,116,
- 32,114,101,116,117,114,110,115,32,116,104,101,32,109,111,100,
- 105,102,105,99,97,116,105,111,110,32,116,105,109,101,32,40,
- 97,110,32,105,110,116,41,32,102,111,114,32,116,104,101,10,
- 32,32,32,32,32,32,32,32,115,112,101,99,105,102,105,101,
- 100,32,112,97,116,104,44,32,119,104,101,114,101,32,112,97,
- 116,104,32,105,115,32,97,32,115,116,114,46,10,10,32,32,
- 32,32,32,32,32,32,82,97,105,115,101,115,32,73,79,69,
- 114,114,111,114,32,119,104,101,110,32,116,104,101,32,112,97,
- 116,104,32,99,97,110,110,111,116,32,98,101,32,104,97,110,
- 100,108,101,100,46,10,32,32,32,32,32,32,32,32,78,41,
- 1,218,7,73,79,69,114,114,111,114,41,2,114,108,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,162,2,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,19,0,0,0,100,
- 1,0,124,0,0,106,0,0,124,1,0,131,1,0,105,1,
- 0,83,41,2,97,170,1,0,0,79,112,116,105,111,110,97,
- 108,32,109,101,116,104,111,100,32,114,101,116,117,114,110,105,
- 110,103,32,97,32,109,101,116,97,100,97,116,97,32,100,105,
- 99,116,32,102,111,114,32,116,104,101,32,115,112,101,99,105,
- 102,105,101,100,32,112,97,116,104,10,32,32,32,32,32,32,
- 32,32,116,111,32,98,121,32,116,104,101,32,112,97,116,104,
- 32,40,115,116,114,41,46,10,32,32,32,32,32,32,32,32,
- 80,111,115,115,105,98,108,101,32,107,101,121,115,58,10,32,
- 32,32,32,32,32,32,32,45,32,39,109,116,105,109,101,39,
- 32,40,109,97,110,100,97,116,111,114,121,41,32,105,115,32,
- 116,104,101,32,110,117,109,101,114,105,99,32,116,105,109,101,
- 115,116,97,109,112,32,111,102,32,108,97,115,116,32,115,111,
- 117,114,99,101,10,32,32,32,32,32,32,32,32,32,32,99,
- 111,100,101,32,109,111,100,105,102,105,99,97,116,105,111,110,
- 59,10,32,32,32,32,32,32,32,32,45,32,39,115,105,122,
- 101,39,32,40,111,112,116,105,111,110,97,108,41,32,105,115,
- 32,116,104,101,32,115,105,122,101,32,105,110,32,98,121,116,
- 101,115,32,111,102,32,116,104,101,32,115,111,117,114,99,101,
- 32,99,111,100,101,46,10,10,32,32,32,32,32,32,32,32,
+ 110,100,95,109,111,100,117,108,101,41,2,78,78,41,1,78,
+ 41,12,114,106,0,0,0,114,105,0,0,0,114,107,0,0,
+ 0,114,108,0,0,0,114,170,0,0,0,114,169,0,0,0,
+ 114,168,0,0,0,218,11,99,108,97,115,115,109,101,116,104,
+ 111,100,114,167,0,0,0,114,173,0,0,0,114,176,0,0,
+ 0,114,177,0,0,0,114,4,0,0,0,114,4,0,0,0,
+ 114,4,0,0,0,114,5,0,0,0,114,163,0,0,0,62,
+ 2,0,0,115,20,0,0,0,8,2,4,3,4,3,4,2,
+ 4,2,12,7,12,15,2,1,12,15,2,1,114,163,0,0,
+ 0,99,0,0,0,0,0,0,0,0,0,0,0,0,2,0,
+ 0,0,64,0,0,0,115,48,0,0,0,101,0,90,1,100,
+ 0,90,2,100,1,90,3,100,2,100,3,132,0,90,4,100,
+ 4,100,5,132,0,90,5,100,6,100,7,132,0,90,6,100,
+ 8,100,9,132,0,90,7,100,10,83,0,41,11,218,13,95,
+ 76,111,97,100,101,114,66,97,115,105,99,115,122,83,66,97,
+ 115,101,32,99,108,97,115,115,32,111,102,32,99,111,109,109,
+ 111,110,32,99,111,100,101,32,110,101,101,100,101,100,32,98,
+ 121,32,98,111,116,104,32,83,111,117,114,99,101,76,111,97,
+ 100,101,114,32,97,110,100,10,32,32,32,32,83,111,117,114,
+ 99,101,108,101,115,115,70,105,108,101,76,111,97,100,101,114,
+ 46,99,2,0,0,0,0,0,0,0,5,0,0,0,3,0,
+ 0,0,67,0,0,0,115,64,0,0,0,116,0,124,0,106,
+ 1,124,1,131,1,131,1,100,1,25,0,125,2,124,2,106,
+ 2,100,2,100,1,131,2,100,3,25,0,125,3,124,1,106,
+ 3,100,2,131,1,100,4,25,0,125,4,124,3,100,5,107,
+ 2,111,62,124,4,100,5,107,3,83,0,41,6,122,141,67,
+ 111,110,99,114,101,116,101,32,105,109,112,108,101,109,101,110,
+ 116,97,116,105,111,110,32,111,102,32,73,110,115,112,101,99,
+ 116,76,111,97,100,101,114,46,105,115,95,112,97,99,107,97,
+ 103,101,32,98,121,32,99,104,101,99,107,105,110,103,32,105,
+ 102,10,32,32,32,32,32,32,32,32,116,104,101,32,112,97,
+ 116,104,32,114,101,116,117,114,110,101,100,32,98,121,32,103,
+ 101,116,95,102,105,108,101,110,97,109,101,32,104,97,115,32,
+ 97,32,102,105,108,101,110,97,109,101,32,111,102,32,39,95,
+ 95,105,110,105,116,95,95,46,112,121,39,46,114,29,0,0,
+ 0,114,59,0,0,0,114,60,0,0,0,114,57,0,0,0,
+ 218,8,95,95,105,110,105,116,95,95,41,4,114,38,0,0,
+ 0,114,152,0,0,0,114,34,0,0,0,114,32,0,0,0,
+ 41,5,114,101,0,0,0,114,120,0,0,0,114,95,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,154,0,0,0,131,
+ 2,0,0,115,8,0,0,0,0,3,18,1,16,1,14,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,2,0,0,0,1,0,0,0,67,0,0,0,115,
+ 4,0,0,0,100,1,83,0,41,2,122,42,85,115,101,32,
+ 100,101,102,97,117,108,116,32,115,101,109,97,110,116,105,99,
+ 115,32,102,111,114,32,109,111,100,117,108,101,32,99,114,101,
+ 97,116,105,111,110,46,78,114,4,0,0,0,41,2,114,101,
+ 0,0,0,114,159,0,0,0,114,4,0,0,0,114,4,0,
+ 0,0,114,5,0,0,0,218,13,99,114,101,97,116,101,95,
+ 109,111,100,117,108,101,139,2,0,0,115,0,0,0,0,122,
+ 27,95,76,111,97,100,101,114,66,97,115,105,99,115,46,99,
+ 114,101,97,116,101,95,109,111,100,117,108,101,99,2,0,0,
+ 0,0,0,0,0,3,0,0,0,4,0,0,0,67,0,0,
+ 0,115,56,0,0,0,124,0,106,0,124,1,106,1,131,1,
+ 125,2,124,2,100,1,107,8,114,36,116,2,100,2,106,3,
+ 124,1,106,1,131,1,131,1,130,1,116,4,106,5,116,6,
+ 124,2,124,1,106,7,131,3,1,0,100,1,83,0,41,3,
+ 122,19,69,120,101,99,117,116,101,32,116,104,101,32,109,111,
+ 100,117,108,101,46,78,122,52,99,97,110,110,111,116,32,108,
+ 111,97,100,32,109,111,100,117,108,101,32,123,33,114,125,32,
+ 119,104,101,110,32,103,101,116,95,99,111,100,101,40,41,32,
+ 114,101,116,117,114,110,115,32,78,111,110,101,41,8,218,8,
+ 103,101,116,95,99,111,100,101,114,106,0,0,0,114,100,0,
+ 0,0,114,48,0,0,0,114,115,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,218,4,101,120,101,99,114,112,0,
+ 0,0,41,3,114,101,0,0,0,218,6,109,111,100,117,108,
+ 101,114,141,0,0,0,114,4,0,0,0,114,4,0,0,0,
+ 114,5,0,0,0,218,11,101,120,101,99,95,109,111,100,117,
+ 108,101,142,2,0,0,115,10,0,0,0,0,2,12,1,8,
+ 1,6,1,10,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,
+ 99,2,0,0,0,0,0,0,0,2,0,0,0,3,0,0,
+ 0,67,0,0,0,115,12,0,0,0,116,0,106,1,124,0,
+ 124,1,131,2,83,0,41,1,122,26,84,104,105,115,32,109,
+ 111,100,117,108,101,32,105,115,32,100,101,112,114,101,99,97,
+ 116,101,100,46,41,2,114,115,0,0,0,218,17,95,108,111,
+ 97,100,95,109,111,100,117,108,101,95,115,104,105,109,41,2,
+ 114,101,0,0,0,114,120,0,0,0,114,4,0,0,0,114,
+ 4,0,0,0,114,5,0,0,0,218,11,108,111,97,100,95,
+ 109,111,100,117,108,101,150,2,0,0,115,2,0,0,0,0,
+ 2,122,25,95,76,111,97,100,101,114,66,97,115,105,99,115,
+ 46,108,111,97,100,95,109,111,100,117,108,101,78,41,8,114,
+ 106,0,0,0,114,105,0,0,0,114,107,0,0,0,114,108,
+ 0,0,0,114,154,0,0,0,114,181,0,0,0,114,186,0,
+ 0,0,114,188,0,0,0,114,4,0,0,0,114,4,0,0,
+ 0,114,4,0,0,0,114,5,0,0,0,114,179,0,0,0,
+ 126,2,0,0,115,10,0,0,0,8,3,4,2,8,8,8,
+ 3,8,8,114,179,0,0,0,99,0,0,0,0,0,0,0,
+ 0,0,0,0,0,3,0,0,0,64,0,0,0,115,74,0,
+ 0,0,101,0,90,1,100,0,90,2,100,1,100,2,132,0,
+ 90,3,100,3,100,4,132,0,90,4,100,5,100,6,132,0,
+ 90,5,100,7,100,8,132,0,90,6,100,9,100,10,132,0,
+ 90,7,100,18,100,12,156,1,100,13,100,14,132,2,90,8,
+ 100,15,100,16,132,0,90,9,100,17,83,0,41,19,218,12,
+ 83,111,117,114,99,101,76,111,97,100,101,114,99,2,0,0,
+ 0,0,0,0,0,2,0,0,0,1,0,0,0,67,0,0,
+ 0,115,8,0,0,0,116,0,130,1,100,1,83,0,41,2,
+ 122,178,79,112,116,105,111,110,97,108,32,109,101,116,104,111,
+ 100,32,116,104,97,116,32,114,101,116,117,114,110,115,32,116,
+ 104,101,32,109,111,100,105,102,105,99,97,116,105,111,110,32,
+ 116,105,109,101,32,40,97,110,32,105,110,116,41,32,102,111,
+ 114,32,116,104,101,10,32,32,32,32,32,32,32,32,115,112,
+ 101,99,105,102,105,101,100,32,112,97,116,104,44,32,119,104,
+ 101,114,101,32,112,97,116,104,32,105,115,32,97,32,115,116,
+ 114,46,10,10,32,32,32,32,32,32,32,32,82,97,105,115,
+ 101,115,32,73,79,69,114,114,111,114,32,119,104,101,110,32,
+ 116,104,101,32,112,97,116,104,32,99,97,110,110,111,116,32,
+ 98,101,32,104,97,110,100,108,101,100,46,10,32,32,32,32,
+ 32,32,32,32,78,41,1,218,7,73,79,69,114,114,111,114,
+ 41,2,114,101,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,157,2,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,14,0,0,0,100,1,124,0,106,0,124,1,131,1,105,
+ 1,83,0,41,2,97,170,1,0,0,79,112,116,105,111,110,
+ 97,108,32,109,101,116,104,111,100,32,114,101,116,117,114,110,
+ 105,110,103,32,97,32,109,101,116,97,100,97,116,97,32,100,
+ 105,99,116,32,102,111,114,32,116,104,101,32,115,112,101,99,
+ 105,102,105,101,100,32,112,97,116,104,10,32,32,32,32,32,
+ 32,32,32,116,111,32,98,121,32,116,104,101,32,112,97,116,
+ 104,32,40,115,116,114,41,46,10,32,32,32,32,32,32,32,
+ 32,80,111,115,115,105,98,108,101,32,107,101,121,115,58,10,
+ 32,32,32,32,32,32,32,32,45,32,39,109,116,105,109,101,
+ 39,32,40,109,97,110,100,97,116,111,114,121,41,32,105,115,
+ 32,116,104,101,32,110,117,109,101,114,105,99,32,116,105,109,
+ 101,115,116,97,109,112,32,111,102,32,108,97,115,116,32,115,
+ 111,117,114,99,101,10,32,32,32,32,32,32,32,32,32,32,
+ 99,111,100,101,32,109,111,100,105,102,105,99,97,116,105,111,
+ 110,59,10,32,32,32,32,32,32,32,32,45,32,39,115,105,
+ 122,101,39,32,40,111,112,116,105,111,110,97,108,41,32,105,
+ 115,32,116,104,101,32,115,105,122,101,32,105,110,32,98,121,
+ 116,101,115,32,111,102,32,116,104,101,32,115,111,117,114,99,
+ 101,32,99,111,100,101,46,10,10,32,32,32,32,32,32,32,
+ 32,73,109,112,108,101,109,101,110,116,105,110,103,32,116,104,
+ 105,115,32,109,101,116,104,111,100,32,97,108,108,111,119,115,
+ 32,116,104,101,32,108,111,97,100,101,114,32,116,111,32,114,
+ 101,97,100,32,98,121,116,101,99,111,100,101,32,102,105,108,
+ 101,115,46,10,32,32,32,32,32,32,32,32,82,97,105,115,
+ 101,115,32,73,79,69,114,114,111,114,32,119,104,101,110,32,
+ 116,104,101,32,112,97,116,104,32,99,97,110,110,111,116,32,
+ 98,101,32,104,97,110,100,108,101,100,46,10,32,32,32,32,
+ 32,32,32,32,114,127,0,0,0,41,1,114,191,0,0,0,
+ 41,2,114,101,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,165,2,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,12,0,0,0,124,0,106,0,124,2,124,3,131,2,83,
+ 0,41,1,122,228,79,112,116,105,111,110,97,108,32,109,101,
+ 116,104,111,100,32,119,104,105,99,104,32,119,114,105,116,101,
+ 115,32,100,97,116,97,32,40,98,121,116,101,115,41,32,116,
+ 111,32,97,32,102,105,108,101,32,112,97,116,104,32,40,97,
+ 32,115,116,114,41,46,10,10,32,32,32,32,32,32,32,32,
73,109,112,108,101,109,101,110,116,105,110,103,32,116,104,105,
115,32,109,101,116,104,111,100,32,97,108,108,111,119,115,32,
- 116,104,101,32,108,111,97,100,101,114,32,116,111,32,114,101,
- 97,100,32,98,121,116,101,99,111,100,101,32,102,105,108,101,
- 115,46,10,32,32,32,32,32,32,32,32,82,97,105,115,101,
- 115,32,73,79,69,114,114,111,114,32,119,104,101,110,32,116,
- 104,101,32,112,97,116,104,32,99,97,110,110,111,116,32,98,
- 101,32,104,97,110,100,108,101,100,46,10,32,32,32,32,32,
- 32,32,32,114,133,0,0,0,41,1,114,196,0,0,0,41,
- 2,114,108,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,170,2,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,
- 16,0,0,0,124,0,0,106,0,0,124,2,0,124,3,0,
- 131,2,0,83,41,1,122,228,79,112,116,105,111,110,97,108,
- 32,109,101,116,104,111,100,32,119,104,105,99,104,32,119,114,
- 105,116,101,115,32,100,97,116,97,32,40,98,121,116,101,115,
- 41,32,116,111,32,97,32,102,105,108,101,32,112,97,116,104,
- 32,40,97,32,115,116,114,41,46,10,10,32,32,32,32,32,
- 32,32,32,73,109,112,108,101,109,101,110,116,105,110,103,32,
- 116,104,105,115,32,109,101,116,104,111,100,32,97,108,108,111,
- 119,115,32,102,111,114,32,116,104,101,32,119,114,105,116,105,
- 110,103,32,111,102,32,98,121,116,101,99,111,100,101,32,102,
- 105,108,101,115,46,10,10,32,32,32,32,32,32,32,32,84,
- 104,101,32,115,111,117,114,99,101,32,112,97,116,104,32,105,
- 115,32,110,101,101,100,101,100,32,105,110,32,111,114,100,101,
- 114,32,116,111,32,99,111,114,114,101,99,116,108,121,32,116,
- 114,97,110,115,102,101,114,32,112,101,114,109,105,115,115,105,
- 111,110,115,10,32,32,32,32,32,32,32,32,41,1,218,8,
- 115,101,116,95,100,97,116,97,41,4,114,108,0,0,0,114,
- 90,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,183,2,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,
- 0,0,0,115,4,0,0,0,100,1,0,83,41,2,122,150,
- 79,112,116,105,111,110,97,108,32,109,101,116,104,111,100,32,
- 119,104,105,99,104,32,119,114,105,116,101,115,32,100,97,116,
- 97,32,40,98,121,116,101,115,41,32,116,111,32,97,32,102,
- 105,108,101,32,112,97,116,104,32,40,97,32,115,116,114,41,
- 46,10,10,32,32,32,32,32,32,32,32,73,109,112,108,101,
- 109,101,110,116,105,110,103,32,116,104,105,115,32,109,101,116,
- 104,111,100,32,97,108,108,111,119,115,32,102,111,114,32,116,
- 104,101,32,119,114,105,116,105,110,103,32,111,102,32,98,121,
- 116,101,99,111,100,101,32,102,105,108,101,115,46,10,32,32,
- 32,32,32,32,32,32,78,114,4,0,0,0,41,3,114,108,
- 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,198,0,0,
- 0,193,2,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,
- 0,124,1,0,131,1,0,125,2,0,121,19,0,124,0,0,
- 106,1,0,124,2,0,131,1,0,125,3,0,87,110,58,0,
- 4,116,2,0,107,10,0,114,94,0,1,125,4,0,1,122,
- 26,0,116,3,0,100,1,0,100,2,0,124,1,0,131,1,
- 1,124,4,0,130,2,0,87,89,100,3,0,100,3,0,125,
- 4,0,126,4,0,88,110,1,0,88,116,4,0,124,3,0,
- 131,1,0,83,41,4,122,52,67,111,110,99,114,101,116,101,
- 32,105,109,112,108,101,109,101,110,116,97,116,105,111,110,32,
- 111,102,32,73,110,115,112,101,99,116,76,111,97,100,101,114,
- 46,103,101,116,95,115,111,117,114,99,101,46,122,39,115,111,
- 117,114,99,101,32,110,111,116,32,97,118,97,105,108,97,98,
- 108,101,32,116,104,114,111,117,103,104,32,103,101,116,95,100,
- 97,116,97,40,41,114,106,0,0,0,78,41,5,114,157,0,
- 0,0,218,8,103,101,116,95,100,97,116,97,114,40,0,0,
- 0,114,107,0,0,0,114,155,0,0,0,41,5,114,108,0,
- 0,0,114,126,0,0,0,114,35,0,0,0,114,153,0,0,
- 0,218,3,101,120,99,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,200,2,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,105,109,105,122,101,114,29,0,0,
- 0,99,3,0,0,0,1,0,0,0,4,0,0,0,9,0,
- 0,0,67,0,0,0,115,34,0,0,0,116,0,0,106,1,
- 0,116,2,0,124,1,0,124,2,0,100,1,0,100,2,0,
- 100,3,0,100,4,0,124,3,0,131,4,2,83,41,5,122,
- 130,82,101,116,117,114,110,32,116,104,101,32,99,111,100,101,
- 32,111,98,106,101,99,116,32,99,111,109,112,105,108,101,100,
- 32,102,114,111,109,32,115,111,117,114,99,101,46,10,10,32,
- 32,32,32,32,32,32,32,84,104,101,32,39,100,97,116,97,
- 39,32,97,114,103,117,109,101,110,116,32,99,97,110,32,98,
- 101,32,97,110,121,32,111,98,106,101,99,116,32,116,121,112,
- 101,32,116,104,97,116,32,99,111,109,112,105,108,101,40,41,
- 32,115,117,112,112,111,114,116,115,46,10,32,32,32,32,32,
- 32,32,32,114,189,0,0,0,218,12,100,111,110,116,95,105,
- 110,104,101,114,105,116,84,114,68,0,0,0,41,3,114,121,
- 0,0,0,114,188,0,0,0,218,7,99,111,109,112,105,108,
- 101,41,4,114,108,0,0,0,114,53,0,0,0,114,35,0,
- 0,0,114,203,0,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,210,2,0,0,115,4,0,0,0,0,
- 5,21,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,43,0,0,
- 0,67,0,0,0,115,174,1,0,0,124,0,0,106,0,0,
- 124,1,0,131,1,0,125,2,0,100,1,0,125,3,0,121,
- 16,0,116,1,0,124,2,0,131,1,0,125,4,0,87,110,
- 24,0,4,116,2,0,107,10,0,114,63,0,1,1,1,100,
- 1,0,125,4,0,89,110,202,0,88,121,19,0,124,0,0,
- 106,3,0,124,2,0,131,1,0,125,5,0,87,110,18,0,
- 4,116,4,0,107,10,0,114,103,0,1,1,1,89,110,162,
- 0,88,116,5,0,124,5,0,100,2,0,25,131,1,0,125,
- 3,0,121,19,0,124,0,0,106,6,0,124,4,0,131,1,
- 0,125,6,0,87,110,18,0,4,116,7,0,107,10,0,114,
- 159,0,1,1,1,89,110,106,0,88,121,34,0,116,8,0,
- 124,6,0,100,3,0,124,5,0,100,4,0,124,1,0,100,
- 5,0,124,4,0,131,1,3,125,7,0,87,110,24,0,4,
- 116,9,0,116,10,0,102,2,0,107,10,0,114,220,0,1,
- 1,1,89,110,45,0,88,116,11,0,100,6,0,124,4,0,
- 124,2,0,131,3,0,1,116,12,0,124,7,0,100,4,0,
- 124,1,0,100,7,0,124,4,0,100,8,0,124,2,0,131,
- 1,3,83,124,0,0,106,6,0,124,2,0,131,1,0,125,
- 8,0,124,0,0,106,13,0,124,8,0,124,2,0,131,2,
- 0,125,9,0,116,11,0,100,9,0,124,2,0,131,2,0,
- 1,116,14,0,106,15,0,12,114,170,1,124,4,0,100,1,
- 0,107,9,0,114,170,1,124,3,0,100,1,0,107,9,0,
- 114,170,1,116,16,0,124,9,0,124,3,0,116,17,0,124,
- 8,0,131,1,0,131,3,0,125,6,0,121,36,0,124,0,
- 0,106,18,0,124,2,0,124,4,0,124,6,0,131,3,0,
- 1,116,11,0,100,10,0,124,4,0,131,2,0,1,87,110,
- 18,0,4,116,2,0,107,10,0,114,169,1,1,1,1,89,
- 110,1,0,88,124,9,0,83,41,11,122,190,67,111,110,99,
- 114,101,116,101,32,105,109,112,108,101,109,101,110,116,97,116,
- 105,111,110,32,111,102,32,73,110,115,112,101,99,116,76,111,
- 97,100,101,114,46,103,101,116,95,99,111,100,101,46,10,10,
- 32,32,32,32,32,32,32,32,82,101,97,100,105,110,103,32,
- 111,102,32,98,121,116,101,99,111,100,101,32,114,101,113,117,
- 105,114,101,115,32,112,97,116,104,95,115,116,97,116,115,32,
- 116,111,32,98,101,32,105,109,112,108,101,109,101,110,116,101,
- 100,46,32,84,111,32,119,114,105,116,101,10,32,32,32,32,
- 32,32,32,32,98,121,116,101,99,111,100,101,44,32,115,101,
- 116,95,100,97,116,97,32,109,117,115,116,32,97,108,115,111,
+ 102,111,114,32,116,104,101,32,119,114,105,116,105,110,103,32,
+ 111,102,32,98,121,116,101,99,111,100,101,32,102,105,108,101,
+ 115,46,10,10,32,32,32,32,32,32,32,32,84,104,101,32,
+ 115,111,117,114,99,101,32,112,97,116,104,32,105,115,32,110,
+ 101,101,100,101,100,32,105,110,32,111,114,100,101,114,32,116,
+ 111,32,99,111,114,114,101,99,116,108,121,32,116,114,97,110,
+ 115,102,101,114,32,112,101,114,109,105,115,115,105,111,110,115,
+ 10,32,32,32,32,32,32,32,32,41,1,218,8,115,101,116,
+ 95,100,97,116,97,41,4,114,101,0,0,0,114,91,0,0,
+ 0,90,10,99,97,99,104,101,95,112,97,116,104,114,54,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,178,2,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,0,0,0,
+ 115,4,0,0,0,100,1,83,0,41,2,122,150,79,112,116,
+ 105,111,110,97,108,32,109,101,116,104,111,100,32,119,104,105,
+ 99,104,32,119,114,105,116,101,115,32,100,97,116,97,32,40,
+ 98,121,116,101,115,41,32,116,111,32,97,32,102,105,108,101,
+ 32,112,97,116,104,32,40,97,32,115,116,114,41,46,10,10,
+ 32,32,32,32,32,32,32,32,73,109,112,108,101,109,101,110,
+ 116,105,110,103,32,116,104,105,115,32,109,101,116,104,111,100,
+ 32,97,108,108,111,119,115,32,102,111,114,32,116,104,101,32,
+ 119,114,105,116,105,110,103,32,111,102,32,98,121,116,101,99,
+ 111,100,101,32,102,105,108,101,115,46,10,32,32,32,32,32,
+ 32,32,32,78,114,4,0,0,0,41,3,114,101,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,193,0,0,0,188,2,
+ 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,84,0,0,0,124,0,106,0,124,1,131,1,
+ 125,2,121,14,124,0,106,1,124,2,131,1,125,3,87,0,
+ 110,50,4,0,116,2,107,10,114,74,1,0,125,4,1,0,
+ 122,22,116,3,100,1,100,2,124,1,144,1,131,1,124,4,
+ 130,2,87,0,89,0,100,3,100,3,125,4,126,4,88,0,
+ 110,2,88,0,116,4,124,3,131,1,83,0,41,4,122,52,
+ 67,111,110,99,114,101,116,101,32,105,109,112,108,101,109,101,
+ 110,116,97,116,105,111,110,32,111,102,32,73,110,115,112,101,
+ 99,116,76,111,97,100,101,114,46,103,101,116,95,115,111,117,
+ 114,99,101,46,122,39,115,111,117,114,99,101,32,110,111,116,
+ 32,97,118,97,105,108,97,98,108,101,32,116,104,114,111,117,
+ 103,104,32,103,101,116,95,100,97,116,97,40,41,114,99,0,
+ 0,0,78,41,5,114,152,0,0,0,218,8,103,101,116,95,
+ 100,97,116,97,114,40,0,0,0,114,100,0,0,0,114,150,
+ 0,0,0,41,5,114,101,0,0,0,114,120,0,0,0,114,
+ 35,0,0,0,114,148,0,0,0,218,3,101,120,99,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,195,2,0,0,115,14,0,
+ 0,0,0,2,10,1,2,1,14,1,16,1,6,1,28,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,114,29,0,0,0,41,1,
+ 218,9,95,111,112,116,105,109,105,122,101,99,3,0,0,0,
+ 1,0,0,0,4,0,0,0,9,0,0,0,67,0,0,0,
+ 115,26,0,0,0,116,0,106,1,116,2,124,1,124,2,100,
+ 1,100,2,100,3,100,4,124,3,144,2,131,4,83,0,41,
+ 5,122,130,82,101,116,117,114,110,32,116,104,101,32,99,111,
+ 100,101,32,111,98,106,101,99,116,32,99,111,109,112,105,108,
+ 101,100,32,102,114,111,109,32,115,111,117,114,99,101,46,10,
+ 10,32,32,32,32,32,32,32,32,84,104,101,32,39,100,97,
+ 116,97,39,32,97,114,103,117,109,101,110,116,32,99,97,110,
+ 32,98,101,32,97,110,121,32,111,98,106,101,99,116,32,116,
+ 121,112,101,32,116,104,97,116,32,99,111,109,112,105,108,101,
+ 40,41,32,115,117,112,112,111,114,116,115,46,10,32,32,32,
+ 32,32,32,32,32,114,184,0,0,0,218,12,100,111,110,116,
+ 95,105,110,104,101,114,105,116,84,114,69,0,0,0,41,3,
+ 114,115,0,0,0,114,183,0,0,0,218,7,99,111,109,112,
+ 105,108,101,41,4,114,101,0,0,0,114,54,0,0,0,114,
+ 35,0,0,0,114,198,0,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,205,2,0,0,115,4,0,0,
+ 0,0,5,14,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,43,
+ 0,0,0,67,0,0,0,115,106,1,0,0,124,0,106,0,
+ 124,1,131,1,125,2,100,1,125,3,121,12,116,1,124,2,
+ 131,1,125,4,87,0,110,24,4,0,116,2,107,10,114,50,
+ 1,0,1,0,1,0,100,1,125,4,89,0,110,174,88,0,
+ 121,14,124,0,106,3,124,2,131,1,125,5,87,0,110,20,
+ 4,0,116,4,107,10,114,86,1,0,1,0,1,0,89,0,
+ 110,138,88,0,116,5,124,5,100,2,25,0,131,1,125,3,
+ 121,14,124,0,106,6,124,4,131,1,125,6,87,0,110,20,
+ 4,0,116,7,107,10,114,134,1,0,1,0,1,0,89,0,
+ 110,90,88,0,121,26,116,8,124,6,100,3,124,5,100,4,
+ 124,1,100,5,124,4,144,3,131,1,125,7,87,0,110,24,
+ 4,0,116,9,116,10,102,2,107,10,114,186,1,0,1,0,
+ 1,0,89,0,110,38,88,0,116,11,106,12,100,6,124,4,
+ 124,2,131,3,1,0,116,13,124,7,100,4,124,1,100,7,
+ 124,4,100,8,124,2,144,3,131,1,83,0,124,0,106,6,
+ 124,2,131,1,125,8,124,0,106,14,124,8,124,2,131,2,
+ 125,9,116,11,106,12,100,9,124,2,131,2,1,0,116,15,
+ 106,16,12,0,144,1,114,102,124,4,100,1,107,9,144,1,
+ 114,102,124,3,100,1,107,9,144,1,114,102,116,17,124,9,
+ 124,3,116,18,124,8,131,1,131,3,125,6,121,30,124,0,
+ 106,19,124,2,124,4,124,6,131,3,1,0,116,11,106,12,
+ 100,10,124,4,131,2,1,0,87,0,110,22,4,0,116,2,
+ 107,10,144,1,114,100,1,0,1,0,1,0,89,0,110,2,
+ 88,0,124,9,83,0,41,11,122,190,67,111,110,99,114,101,
+ 116,101,32,105,109,112,108,101,109,101,110,116,97,116,105,111,
+ 110,32,111,102,32,73,110,115,112,101,99,116,76,111,97,100,
+ 101,114,46,103,101,116,95,99,111,100,101,46,10,10,32,32,
+ 32,32,32,32,32,32,82,101,97,100,105,110,103,32,111,102,
+ 32,98,121,116,101,99,111,100,101,32,114,101,113,117,105,114,
+ 101,115,32,112,97,116,104,95,115,116,97,116,115,32,116,111,
32,98,101,32,105,109,112,108,101,109,101,110,116,101,100,46,
- 10,10,32,32,32,32,32,32,32,32,78,114,133,0,0,0,
- 114,138,0,0,0,114,106,0,0,0,114,35,0,0,0,122,
- 13,123,125,32,109,97,116,99,104,101,115,32,123,125,114,89,
- 0,0,0,114,90,0,0,0,122,19,99,111,100,101,32,111,
- 98,106,101,99,116,32,102,114,111,109,32,123,125,122,10,119,
- 114,111,116,101,32,123,33,114,125,41,19,114,157,0,0,0,
- 114,79,0,0,0,114,66,0,0,0,114,197,0,0,0,114,
- 195,0,0,0,114,14,0,0,0,114,200,0,0,0,114,40,
- 0,0,0,114,141,0,0,0,114,107,0,0,0,114,136,0,
- 0,0,114,105,0,0,0,114,147,0,0,0,114,206,0,0,
- 0,114,7,0,0,0,218,19,100,111,110,116,95,119,114,105,
- 116,101,95,98,121,116,101,99,111,100,101,114,150,0,0,0,
- 114,31,0,0,0,114,199,0,0,0,41,10,114,108,0,0,
- 0,114,126,0,0,0,114,90,0,0,0,114,139,0,0,0,
- 114,89,0,0,0,218,2,115,116,114,53,0,0,0,218,10,
- 98,121,116,101,115,95,100,97,116,97,114,153,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,187,0,0,0,
- 218,2,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,1,7,1,15,
- 1,18,1,13,1,22,1,12,1,9,1,15,1,3,1,19,
- 1,17,1,13,1,5,1,122,21,83,111,117,114,99,101,76,
- 111,97,100,101,114,46,103,101,116,95,99,111,100,101,78,114,
- 87,0,0,0,41,10,114,112,0,0,0,114,111,0,0,0,
- 114,113,0,0,0,114,196,0,0,0,114,197,0,0,0,114,
- 199,0,0,0,114,198,0,0,0,114,202,0,0,0,114,206,
- 0,0,0,114,187,0,0,0,114,4,0,0,0,114,4,0,
- 0,0,114,4,0,0,0,114,5,0,0,0,114,194,0,0,
- 0,160,2,0,0,115,14,0,0,0,12,2,12,8,12,13,
- 12,10,12,7,12,10,18,8,114,194,0,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,0,100,0,0,
- 90,2,0,100,1,0,90,3,0,100,2,0,100,3,0,132,
- 0,0,90,4,0,100,4,0,100,5,0,132,0,0,90,5,
- 0,100,6,0,100,7,0,132,0,0,90,6,0,101,7,0,
- 135,0,0,102,1,0,100,8,0,100,9,0,134,0,0,131,
- 1,0,90,8,0,101,7,0,100,10,0,100,11,0,132,0,
- 0,131,1,0,90,9,0,100,12,0,100,13,0,132,0,0,
- 90,10,0,135,0,0,83,41,14,218,10,70,105,108,101,76,
- 111,97,100,101,114,122,103,66,97,115,101,32,102,105,108,101,
- 32,108,111,97,100,101,114,32,99,108,97,115,115,32,119,104,
- 105,99,104,32,105,109,112,108,101,109,101,110,116,115,32,116,
- 104,101,32,108,111,97,100,101,114,32,112,114,111,116,111,99,
- 111,108,32,109,101,116,104,111,100,115,32,116,104,97,116,10,
- 32,32,32,32,114,101,113,117,105,114,101,32,102,105,108,101,
- 32,115,121,115,116,101,109,32,117,115,97,103,101,46,99,3,
- 0,0,0,0,0,0,0,3,0,0,0,2,0,0,0,67,
- 0,0,0,115,22,0,0,0,124,1,0,124,0,0,95,0,
- 0,124,2,0,124,0,0,95,1,0,100,1,0,83,41,2,
- 122,75,67,97,99,104,101,32,116,104,101,32,109,111,100,117,
- 108,101,32,110,97,109,101,32,97,110,100,32,116,104,101,32,
- 112,97,116,104,32,116,111,32,116,104,101,32,102,105,108,101,
- 32,102,111,117,110,100,32,98,121,32,116,104,101,10,32,32,
- 32,32,32,32,32,32,102,105,110,100,101,114,46,78,41,2,
- 114,106,0,0,0,114,35,0,0,0,41,3,114,108,0,0,
- 0,114,126,0,0,0,114,35,0,0,0,114,4,0,0,0,
- 114,4,0,0,0,114,5,0,0,0,114,185,0,0,0,19,
- 3,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,2,0,
- 0,0,67,0,0,0,115,34,0,0,0,124,0,0,106,0,
- 0,124,1,0,106,0,0,107,2,0,111,33,0,124,0,0,
- 106,1,0,124,1,0,106,1,0,107,2,0,83,41,1,78,
- 41,2,218,9,95,95,99,108,97,115,115,95,95,114,118,0,
- 0,0,41,2,114,108,0,0,0,218,5,111,116,104,101,114,
+ 32,84,111,32,119,114,105,116,101,10,32,32,32,32,32,32,
+ 32,32,98,121,116,101,99,111,100,101,44,32,115,101,116,95,
+ 100,97,116,97,32,109,117,115,116,32,97,108,115,111,32,98,
+ 101,32,105,109,112,108,101,109,101,110,116,101,100,46,10,10,
+ 32,32,32,32,32,32,32,32,78,114,127,0,0,0,114,133,
+ 0,0,0,114,99,0,0,0,114,35,0,0,0,122,13,123,
+ 125,32,109,97,116,99,104,101,115,32,123,125,114,90,0,0,
+ 0,114,91,0,0,0,122,19,99,111,100,101,32,111,98,106,
+ 101,99,116,32,102,114,111,109,32,123,125,122,10,119,114,111,
+ 116,101,32,123,33,114,125,41,20,114,152,0,0,0,114,80,
+ 0,0,0,114,67,0,0,0,114,192,0,0,0,114,190,0,
+ 0,0,114,14,0,0,0,114,195,0,0,0,114,40,0,0,
+ 0,114,136,0,0,0,114,100,0,0,0,114,131,0,0,0,
+ 114,115,0,0,0,114,130,0,0,0,114,142,0,0,0,114,
+ 201,0,0,0,114,7,0,0,0,218,19,100,111,110,116,95,
+ 119,114,105,116,101,95,98,121,116,101,99,111,100,101,114,145,
+ 0,0,0,114,31,0,0,0,114,194,0,0,0,41,10,114,
+ 101,0,0,0,114,120,0,0,0,114,91,0,0,0,114,134,
+ 0,0,0,114,90,0,0,0,218,2,115,116,114,54,0,0,
+ 0,218,10,98,121,116,101,115,95,100,97,116,97,114,148,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,182,
+ 0,0,0,213,2,0,0,115,78,0,0,0,0,7,10,1,
+ 4,1,2,1,12,1,14,1,10,2,2,1,14,1,14,1,
+ 6,2,12,1,2,1,14,1,14,1,6,2,2,1,6,1,
+ 8,1,12,1,18,1,6,2,8,1,6,1,10,1,4,1,
+ 8,1,10,1,12,1,12,1,20,1,10,1,6,1,10,1,
+ 2,1,14,1,16,1,16,1,6,1,122,21,83,111,117,114,
+ 99,101,76,111,97,100,101,114,46,103,101,116,95,99,111,100,
+ 101,78,114,88,0,0,0,41,10,114,106,0,0,0,114,105,
+ 0,0,0,114,107,0,0,0,114,191,0,0,0,114,192,0,
+ 0,0,114,194,0,0,0,114,193,0,0,0,114,197,0,0,
+ 0,114,201,0,0,0,114,182,0,0,0,114,4,0,0,0,
+ 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,
+ 189,0,0,0,155,2,0,0,115,14,0,0,0,8,2,8,
+ 8,8,13,8,10,8,7,8,10,14,8,114,189,0,0,0,
+ 99,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,
+ 0,0,0,0,0,115,76,0,0,0,101,0,90,1,100,0,
+ 90,2,100,1,90,3,100,2,100,3,132,0,90,4,100,4,
+ 100,5,132,0,90,5,100,6,100,7,132,0,90,6,101,7,
+ 135,0,102,1,100,8,100,9,132,8,131,1,90,8,101,7,
+ 100,10,100,11,132,0,131,1,90,9,100,12,100,13,132,0,
+ 90,10,135,0,83,0,41,14,218,10,70,105,108,101,76,111,
+ 97,100,101,114,122,103,66,97,115,101,32,102,105,108,101,32,
+ 108,111,97,100,101,114,32,99,108,97,115,115,32,119,104,105,
+ 99,104,32,105,109,112,108,101,109,101,110,116,115,32,116,104,
+ 101,32,108,111,97,100,101,114,32,112,114,111,116,111,99,111,
+ 108,32,109,101,116,104,111,100,115,32,116,104,97,116,10,32,
+ 32,32,32,114,101,113,117,105,114,101,32,102,105,108,101,32,
+ 115,121,115,116,101,109,32,117,115,97,103,101,46,99,3,0,
+ 0,0,0,0,0,0,3,0,0,0,2,0,0,0,67,0,
+ 0,0,115,16,0,0,0,124,1,124,0,95,0,124,2,124,
+ 0,95,1,100,1,83,0,41,2,122,75,67,97,99,104,101,
+ 32,116,104,101,32,109,111,100,117,108,101,32,110,97,109,101,
+ 32,97,110,100,32,116,104,101,32,112,97,116,104,32,116,111,
+ 32,116,104,101,32,102,105,108,101,32,102,111,117,110,100,32,
+ 98,121,32,116,104,101,10,32,32,32,32,32,32,32,32,102,
+ 105,110,100,101,114,46,78,41,2,114,99,0,0,0,114,35,
+ 0,0,0,41,3,114,101,0,0,0,114,120,0,0,0,114,
+ 35,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,
+ 0,0,0,114,180,0,0,0,14,3,0,0,115,4,0,0,
+ 0,0,3,6,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,2,0,0,0,67,0,0,0,115,
+ 24,0,0,0,124,0,106,0,124,1,106,0,107,2,111,22,
+ 124,0,106,1,124,1,106,1,107,2,83,0,41,1,78,41,
+ 2,218,9,95,95,99,108,97,115,115,95,95,114,112,0,0,
+ 0,41,2,114,101,0,0,0,218,5,111,116,104,101,114,114,
+ 4,0,0,0,114,4,0,0,0,114,5,0,0,0,218,6,
+ 95,95,101,113,95,95,20,3,0,0,115,4,0,0,0,0,
+ 1,12,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,20,0,0,0,
+ 116,0,124,0,106,1,131,1,116,0,124,0,106,2,131,1,
+ 65,0,83,0,41,1,78,41,3,218,4,104,97,115,104,114,
+ 99,0,0,0,114,35,0,0,0,41,1,114,101,0,0,0,
114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,218,
- 6,95,95,101,113,95,95,25,3,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,106,1,0,131,1,0,116,0,0,
- 124,0,0,106,2,0,131,1,0,65,83,41,1,78,41,3,
- 218,4,104,97,115,104,114,106,0,0,0,114,35,0,0,0,
- 41,1,114,108,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,
- 29,3,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,0,0,0,116,0,0,116,1,0,
- 124,0,0,131,2,0,106,2,0,124,1,0,131,1,0,83,
- 41,1,122,100,76,111,97,100,32,97,32,109,111,100,117,108,
- 101,32,102,114,111,109,32,97,32,102,105,108,101,46,10,10,
- 32,32,32,32,32,32,32,32,84,104,105,115,32,109,101,116,
- 104,111,100,32,105,115,32,100,101,112,114,101,99,97,116,101,
- 100,46,32,32,85,115,101,32,101,120,101,99,95,109,111,100,
- 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,3,218,5,115,117,112,101,
- 114,114,210,0,0,0,114,193,0,0,0,41,2,114,108,0,
- 0,0,114,126,0,0,0,41,1,114,211,0,0,0,114,4,
- 0,0,0,114,5,0,0,0,114,193,0,0,0,32,3,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,0,0,0,124,0,0,106,0,0,
- 83,41,1,122,58,82,101,116,117,114,110,32,116,104,101,32,
+ 8,95,95,104,97,115,104,95,95,24,3,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,16,
+ 0,0,0,116,0,116,1,124,0,131,2,106,2,124,1,131,
+ 1,83,0,41,1,122,100,76,111,97,100,32,97,32,109,111,
+ 100,117,108,101,32,102,114,111,109,32,97,32,102,105,108,101,
+ 46,10,10,32,32,32,32,32,32,32,32,84,104,105,115,32,
+ 109,101,116,104,111,100,32,105,115,32,100,101,112,114,101,99,
+ 97,116,101,100,46,32,32,85,115,101,32,101,120,101,99,95,
+ 109,111,100,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,3,218,5,115,
+ 117,112,101,114,114,205,0,0,0,114,188,0,0,0,41,2,
+ 114,101,0,0,0,114,120,0,0,0,41,1,114,206,0,0,
+ 0,114,4,0,0,0,114,5,0,0,0,114,188,0,0,0,
+ 27,3,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,6,0,0,0,124,0,106,
+ 0,83,0,41,1,122,58,82,101,116,117,114,110,32,116,104,
+ 101,32,112,97,116,104,32,116,111,32,116,104,101,32,115,111,
+ 117,114,99,101,32,102,105,108,101,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,101,0,0,0,114,
+ 120,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,
+ 0,0,0,114,152,0,0,0,39,3,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,9,0,0,0,67,0,0,
+ 0,115,32,0,0,0,116,0,106,1,124,1,100,1,131,2,
+ 143,10,125,2,124,2,106,2,131,0,83,0,81,0,82,0,
+ 88,0,100,2,83,0,41,3,122,39,82,101,116,117,114,110,
+ 32,116,104,101,32,100,97,116,97,32,102,114,111,109,32,112,
+ 97,116,104,32,97,115,32,114,97,119,32,98,121,116,101,115,
+ 46,218,1,114,78,41,3,114,50,0,0,0,114,51,0,0,
+ 0,90,4,114,101,97,100,41,3,114,101,0,0,0,114,35,
+ 0,0,0,114,55,0,0,0,114,4,0,0,0,114,4,0,
+ 0,0,114,5,0,0,0,114,195,0,0,0,44,3,0,0,
+ 115,4,0,0,0,0,2,14,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,106,0,0,0,114,105,0,0,0,114,107,0,0,0,114,
+ 108,0,0,0,114,180,0,0,0,114,208,0,0,0,114,210,
+ 0,0,0,114,117,0,0,0,114,188,0,0,0,114,152,0,
+ 0,0,114,195,0,0,0,114,4,0,0,0,114,4,0,0,
+ 0,41,1,114,206,0,0,0,114,5,0,0,0,114,205,0,
+ 0,0,9,3,0,0,115,14,0,0,0,8,3,4,2,8,
+ 6,8,4,8,3,16,12,12,5,114,205,0,0,0,99,0,
+ 0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,64,
+ 0,0,0,115,46,0,0,0,101,0,90,1,100,0,90,2,
+ 100,1,90,3,100,2,100,3,132,0,90,4,100,4,100,5,
+ 132,0,90,5,100,6,100,7,156,1,100,8,100,9,132,2,
+ 90,6,100,10,83,0,41,11,218,16,83,111,117,114,99,101,
+ 70,105,108,101,76,111,97,100,101,114,122,62,67,111,110,99,
+ 114,101,116,101,32,105,109,112,108,101,109,101,110,116,97,116,
+ 105,111,110,32,111,102,32,83,111,117,114,99,101,76,111,97,
+ 100,101,114,32,117,115,105,110,103,32,116,104,101,32,102,105,
+ 108,101,32,115,121,115,116,101,109,46,99,2,0,0,0,0,
+ 0,0,0,3,0,0,0,3,0,0,0,67,0,0,0,115,
+ 22,0,0,0,116,0,124,1,131,1,125,2,124,2,106,1,
+ 124,2,106,2,100,1,156,2,83,0,41,2,122,33,82,101,
+ 116,117,114,110,32,116,104,101,32,109,101,116,97,100,97,116,
+ 97,32,102,111,114,32,116,104,101,32,112,97,116,104,46,41,
+ 2,122,5,109,116,105,109,101,122,4,115,105,122,101,41,3,
+ 114,39,0,0,0,218,8,115,116,95,109,116,105,109,101,90,
+ 7,115,116,95,115,105,122,101,41,3,114,101,0,0,0,114,
+ 35,0,0,0,114,203,0,0,0,114,4,0,0,0,114,4,
+ 0,0,0,114,5,0,0,0,114,192,0,0,0,54,3,0,
+ 0,115,4,0,0,0,0,2,8,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,0,0,0,67,0,0,0,115,26,0,0,
+ 0,116,0,124,1,131,1,125,4,124,0,106,1,124,2,124,
+ 3,100,1,124,4,144,1,131,2,83,0,41,2,78,218,5,
+ 95,109,111,100,101,41,2,114,98,0,0,0,114,193,0,0,
+ 0,41,5,114,101,0,0,0,114,91,0,0,0,114,90,0,
+ 0,0,114,54,0,0,0,114,42,0,0,0,114,4,0,0,
+ 0,114,4,0,0,0,114,5,0,0,0,114,194,0,0,0,
+ 59,3,0,0,115,4,0,0,0,0,2,8,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,105,
+ 182,1,0,0,41,1,114,215,0,0,0,99,3,0,0,0,
+ 1,0,0,0,9,0,0,0,17,0,0,0,67,0,0,0,
+ 115,250,0,0,0,116,0,124,1,131,1,92,2,125,4,125,
+ 5,103,0,125,6,120,40,124,4,114,56,116,1,124,4,131,
+ 1,12,0,114,56,116,0,124,4,131,1,92,2,125,4,125,
+ 7,124,6,106,2,124,7,131,1,1,0,113,18,87,0,120,
+ 108,116,3,124,6,131,1,68,0,93,96,125,7,116,4,124,
+ 4,124,7,131,2,125,4,121,14,116,5,106,6,124,4,131,
+ 1,1,0,87,0,113,68,4,0,116,7,107,10,114,118,1,
+ 0,1,0,1,0,119,68,89,0,113,68,4,0,116,8,107,
+ 10,114,162,1,0,125,8,1,0,122,18,116,9,106,10,100,
+ 1,124,4,124,8,131,3,1,0,100,2,83,0,100,2,125,
+ 8,126,8,88,0,113,68,88,0,113,68,87,0,121,28,116,
+ 11,124,1,124,2,124,3,131,3,1,0,116,9,106,10,100,
+ 3,124,1,131,2,1,0,87,0,110,48,4,0,116,8,107,
+ 10,114,244,1,0,125,8,1,0,122,20,116,9,106,10,100,
+ 1,124,1,124,8,131,3,1,0,87,0,89,0,100,2,100,
+ 2,125,8,126,8,88,0,110,2,88,0,100,2,83,0,41,
+ 4,122,27,87,114,105,116,101,32,98,121,116,101,115,32,100,
+ 97,116,97,32,116,111,32,97,32,102,105,108,101,46,122,27,
+ 99,111,117,108,100,32,110,111,116,32,99,114,101,97,116,101,
+ 32,123,33,114,125,58,32,123,33,114,125,78,122,12,99,114,
+ 101,97,116,101,100,32,123,33,114,125,41,12,114,38,0,0,
+ 0,114,46,0,0,0,114,158,0,0,0,114,33,0,0,0,
+ 114,28,0,0,0,114,3,0,0,0,90,5,109,107,100,105,
+ 114,218,15,70,105,108,101,69,120,105,115,116,115,69,114,114,
+ 111,114,114,40,0,0,0,114,115,0,0,0,114,130,0,0,
+ 0,114,56,0,0,0,41,9,114,101,0,0,0,114,35,0,
+ 0,0,114,54,0,0,0,114,215,0,0,0,218,6,112,97,
+ 114,101,110,116,114,95,0,0,0,114,27,0,0,0,114,23,
+ 0,0,0,114,196,0,0,0,114,4,0,0,0,114,4,0,
+ 0,0,114,5,0,0,0,114,193,0,0,0,64,3,0,0,
+ 115,42,0,0,0,0,2,12,1,4,2,16,1,12,1,14,
+ 2,14,1,10,1,2,1,14,1,14,2,6,1,16,3,6,
+ 1,8,1,20,1,2,1,12,1,16,1,16,2,8,1,122,
+ 25,83,111,117,114,99,101,70,105,108,101,76,111,97,100,101,
+ 114,46,115,101,116,95,100,97,116,97,78,41,7,114,106,0,
+ 0,0,114,105,0,0,0,114,107,0,0,0,114,108,0,0,
+ 0,114,192,0,0,0,114,194,0,0,0,114,193,0,0,0,
+ 114,4,0,0,0,114,4,0,0,0,114,4,0,0,0,114,
+ 5,0,0,0,114,213,0,0,0,50,3,0,0,115,8,0,
+ 0,0,8,2,4,2,8,5,8,5,114,213,0,0,0,99,
+ 0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,
+ 64,0,0,0,115,32,0,0,0,101,0,90,1,100,0,90,
+ 2,100,1,90,3,100,2,100,3,132,0,90,4,100,4,100,
+ 5,132,0,90,5,100,6,83,0,41,7,218,20,83,111,117,
+ 114,99,101,108,101,115,115,70,105,108,101,76,111,97,100,101,
+ 114,122,45,76,111,97,100,101,114,32,119,104,105,99,104,32,
+ 104,97,110,100,108,101,115,32,115,111,117,114,99,101,108,101,
+ 115,115,32,102,105,108,101,32,105,109,112,111,114,116,115,46,
+ 99,2,0,0,0,0,0,0,0,5,0,0,0,6,0,0,
+ 0,67,0,0,0,115,56,0,0,0,124,0,106,0,124,1,
+ 131,1,125,2,124,0,106,1,124,2,131,1,125,3,116,2,
+ 124,3,100,1,124,1,100,2,124,2,144,2,131,1,125,4,
+ 116,3,124,4,100,1,124,1,100,3,124,2,144,2,131,1,
+ 83,0,41,4,78,114,99,0,0,0,114,35,0,0,0,114,
+ 90,0,0,0,41,4,114,152,0,0,0,114,195,0,0,0,
+ 114,136,0,0,0,114,142,0,0,0,41,5,114,101,0,0,
+ 0,114,120,0,0,0,114,35,0,0,0,114,54,0,0,0,
+ 114,204,0,0,0,114,4,0,0,0,114,4,0,0,0,114,
+ 5,0,0,0,114,182,0,0,0,99,3,0,0,115,8,0,
+ 0,0,0,1,10,1,10,1,18,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,0,0,
+ 0,0,2,0,0,0,1,0,0,0,67,0,0,0,115,4,
+ 0,0,0,100,1,83,0,41,2,122,39,82,101,116,117,114,
+ 110,32,78,111,110,101,32,97,115,32,116,104,101,114,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,101,0,0,0,114,
+ 120,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,
+ 0,0,0,114,197,0,0,0,105,3,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,106,0,0,0,114,105,0,0,
+ 0,114,107,0,0,0,114,108,0,0,0,114,182,0,0,0,
+ 114,197,0,0,0,114,4,0,0,0,114,4,0,0,0,114,
+ 4,0,0,0,114,5,0,0,0,114,218,0,0,0,95,3,
+ 0,0,115,6,0,0,0,8,2,4,2,8,6,114,218,0,
+ 0,0,99,0,0,0,0,0,0,0,0,0,0,0,0,3,
+ 0,0,0,64,0,0,0,115,92,0,0,0,101,0,90,1,
+ 100,0,90,2,100,1,90,3,100,2,100,3,132,0,90,4,
+ 100,4,100,5,132,0,90,5,100,6,100,7,132,0,90,6,
+ 100,8,100,9,132,0,90,7,100,10,100,11,132,0,90,8,
+ 100,12,100,13,132,0,90,9,100,14,100,15,132,0,90,10,
+ 100,16,100,17,132,0,90,11,101,12,100,18,100,19,132,0,
+ 131,1,90,13,100,20,83,0,41,21,218,19,69,120,116,101,
+ 110,115,105,111,110,70,105,108,101,76,111,97,100,101,114,122,
+ 93,76,111,97,100,101,114,32,102,111,114,32,101,120,116,101,
+ 110,115,105,111,110,32,109,111,100,117,108,101,115,46,10,10,
+ 32,32,32,32,84,104,101,32,99,111,110,115,116,114,117,99,
+ 116,111,114,32,105,115,32,100,101,115,105,103,110,101,100,32,
+ 116,111,32,119,111,114,107,32,119,105,116,104,32,70,105,108,
+ 101,70,105,110,100,101,114,46,10,10,32,32,32,32,99,3,
+ 0,0,0,0,0,0,0,3,0,0,0,2,0,0,0,67,
+ 0,0,0,115,16,0,0,0,124,1,124,0,95,0,124,2,
+ 124,0,95,1,100,0,83,0,41,1,78,41,2,114,99,0,
+ 0,0,114,35,0,0,0,41,3,114,101,0,0,0,114,99,
+ 0,0,0,114,35,0,0,0,114,4,0,0,0,114,4,0,
+ 0,0,114,5,0,0,0,114,180,0,0,0,122,3,0,0,
+ 115,4,0,0,0,0,1,6,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,0,0,2,0,0,0,67,0,0,0,115,24,0,0,
+ 0,124,0,106,0,124,1,106,0,107,2,111,22,124,0,106,
+ 1,124,1,106,1,107,2,83,0,41,1,78,41,2,114,206,
+ 0,0,0,114,112,0,0,0,41,2,114,101,0,0,0,114,
+ 207,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,
+ 0,0,0,114,208,0,0,0,126,3,0,0,115,4,0,0,
+ 0,0,1,12,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,20,0,0,0,116,0,124,0,106,
+ 1,131,1,116,0,124,0,106,2,131,1,65,0,83,0,41,
+ 1,78,41,3,114,209,0,0,0,114,99,0,0,0,114,35,
+ 0,0,0,41,1,114,101,0,0,0,114,4,0,0,0,114,
+ 4,0,0,0,114,5,0,0,0,114,210,0,0,0,130,3,
+ 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,
+ 3,0,0,0,4,0,0,0,67,0,0,0,115,36,0,0,
+ 0,116,0,106,1,116,2,106,3,124,1,131,2,125,2,116,
+ 0,106,4,100,1,124,1,106,5,124,0,106,6,131,3,1,
+ 0,124,2,83,0,41,2,122,38,67,114,101,97,116,101,32,
+ 97,110,32,117,110,105,116,105,97,108,105,122,101,100,32,101,
+ 120,116,101,110,115,105,111,110,32,109,111,100,117,108,101,122,
+ 38,101,120,116,101,110,115,105,111,110,32,109,111,100,117,108,
+ 101,32,123,33,114,125,32,108,111,97,100,101,100,32,102,114,
+ 111,109,32,123,33,114,125,41,7,114,115,0,0,0,114,183,
+ 0,0,0,114,140,0,0,0,90,14,99,114,101,97,116,101,
+ 95,100,121,110,97,109,105,99,114,130,0,0,0,114,99,0,
+ 0,0,114,35,0,0,0,41,3,114,101,0,0,0,114,159,
+ 0,0,0,114,185,0,0,0,114,4,0,0,0,114,4,0,
+ 0,0,114,5,0,0,0,114,181,0,0,0,133,3,0,0,
+ 115,10,0,0,0,0,2,4,1,10,1,6,1,12,1,122,
+ 33,69,120,116,101,110,115,105,111,110,70,105,108,101,76,111,
+ 97,100,101,114,46,99,114,101,97,116,101,95,109,111,100,117,
+ 108,101,99,2,0,0,0,0,0,0,0,2,0,0,0,4,
+ 0,0,0,67,0,0,0,115,36,0,0,0,116,0,106,1,
+ 116,2,106,3,124,1,131,2,1,0,116,0,106,4,100,1,
+ 124,0,106,5,124,0,106,6,131,3,1,0,100,2,83,0,
+ 41,3,122,30,73,110,105,116,105,97,108,105,122,101,32,97,
+ 110,32,101,120,116,101,110,115,105,111,110,32,109,111,100,117,
+ 108,101,122,40,101,120,116,101,110,115,105,111,110,32,109,111,
+ 100,117,108,101,32,123,33,114,125,32,101,120,101,99,117,116,
+ 101,100,32,102,114,111,109,32,123,33,114,125,78,41,7,114,
+ 115,0,0,0,114,183,0,0,0,114,140,0,0,0,90,12,
+ 101,120,101,99,95,100,121,110,97,109,105,99,114,130,0,0,
+ 0,114,99,0,0,0,114,35,0,0,0,41,2,114,101,0,
+ 0,0,114,185,0,0,0,114,4,0,0,0,114,4,0,0,
+ 0,114,5,0,0,0,114,186,0,0,0,141,3,0,0,115,
+ 6,0,0,0,0,2,14,1,6,1,122,31,69,120,116,101,
+ 110,115,105,111,110,70,105,108,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,0,4,0,0,0,3,0,0,0,
+ 115,36,0,0,0,116,0,124,0,106,1,131,1,100,1,25,
+ 0,137,0,116,2,135,0,102,1,100,2,100,3,132,8,116,
+ 3,68,0,131,1,131,1,83,0,41,4,122,49,82,101,116,
+ 117,114,110,32,84,114,117,101,32,105,102,32,116,104,101,32,
+ 101,120,116,101,110,115,105,111,110,32,109,111,100,117,108,101,
+ 32,105,115,32,97,32,112,97,99,107,97,103,101,46,114,29,
+ 0,0,0,99,1,0,0,0,0,0,0,0,2,0,0,0,
+ 4,0,0,0,51,0,0,0,115,26,0,0,0,124,0,93,
+ 18,125,1,136,0,100,0,124,1,23,0,107,2,86,0,1,
+ 0,113,2,100,1,83,0,41,2,114,180,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,250,9,60,103,101,110,
+ 101,120,112,114,62,150,3,0,0,115,2,0,0,0,4,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,110,101,120,
+ 112,114,62,41,4,114,38,0,0,0,114,35,0,0,0,218,
+ 3,97,110,121,218,18,69,88,84,69,78,83,73,79,78,95,
+ 83,85,70,70,73,88,69,83,41,2,114,101,0,0,0,114,
+ 120,0,0,0,114,4,0,0,0,41,1,114,221,0,0,0,
+ 114,5,0,0,0,114,154,0,0,0,147,3,0,0,115,6,
+ 0,0,0,0,2,14,1,12,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,0,0,0,
+ 0,0,2,0,0,0,1,0,0,0,67,0,0,0,115,4,
+ 0,0,0,100,1,83,0,41,2,122,63,82,101,116,117,114,
+ 110,32,78,111,110,101,32,97,115,32,97,110,32,101,120,116,
+ 101,110,115,105,111,110,32,109,111,100,117,108,101,32,99,97,
+ 110,110,111,116,32,99,114,101,97,116,101,32,97,32,99,111,
+ 100,101,32,111,98,106,101,99,116,46,78,114,4,0,0,0,
+ 41,2,114,101,0,0,0,114,120,0,0,0,114,4,0,0,
+ 0,114,4,0,0,0,114,5,0,0,0,114,182,0,0,0,
+ 153,3,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,0,115,4,
+ 0,0,0,100,1,83,0,41,2,122,53,82,101,116,117,114,
+ 110,32,78,111,110,101,32,97,115,32,101,120,116,101,110,115,
+ 105,111,110,32,109,111,100,117,108,101,115,32,104,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,101,0,0,0,114,120,0,
+ 0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,
+ 0,114,197,0,0,0,157,3,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,0,1,0,
+ 0,0,67,0,0,0,115,6,0,0,0,124,0,106,0,83,
+ 0,41,1,122,58,82,101,116,117,114,110,32,116,104,101,32,
112,97,116,104,32,116,111,32,116,104,101,32,115,111,117,114,
99,101,32,102,105,108,101,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,108,0,0,0,114,126,0,
+ 1,114,35,0,0,0,41,2,114,101,0,0,0,114,120,0,
0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,
- 0,114,157,0,0,0,44,3,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,9,0,0,0,67,0,0,0,115,
- 42,0,0,0,116,0,0,106,1,0,124,1,0,100,1,0,
- 131,2,0,143,17,0,125,2,0,124,2,0,106,2,0,131,
- 0,0,83,87,100,2,0,81,82,88,100,2,0,83,41,3,
- 122,39,82,101,116,117,114,110,32,116,104,101,32,100,97,116,
- 97,32,102,114,111,109,32,112,97,116,104,32,97,115,32,114,
- 97,119,32,98,121,116,101,115,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,108,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,
- 200,0,0,0,49,3,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,112,0,0,0,114,111,0,
- 0,0,114,113,0,0,0,114,114,0,0,0,114,185,0,0,
- 0,114,213,0,0,0,114,215,0,0,0,114,123,0,0,0,
- 114,193,0,0,0,114,157,0,0,0,114,200,0,0,0,114,
- 4,0,0,0,114,4,0,0,0,41,1,114,211,0,0,0,
- 114,5,0,0,0,114,210,0,0,0,14,3,0,0,115,14,
- 0,0,0,12,3,6,2,12,6,12,4,12,3,24,12,18,
- 5,114,210,0,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,0,90,2,0,100,1,0,90,
- 3,0,100,2,0,100,3,0,132,0,0,90,4,0,100,4,
- 0,100,5,0,132,0,0,90,5,0,100,6,0,100,7,0,
- 100,8,0,100,9,0,132,0,1,90,6,0,100,10,0,83,
- 41,11,218,16,83,111,117,114,99,101,70,105,108,101,76,111,
- 97,100,101,114,122,62,67,111,110,99,114,101,116,101,32,105,
- 109,112,108,101,109,101,110,116,97,116,105,111,110,32,111,102,
- 32,83,111,117,114,99,101,76,111,97,100,101,114,32,117,115,
- 105,110,103,32,116,104,101,32,102,105,108,101,32,115,121,115,
- 116,101,109,46,99,2,0,0,0,0,0,0,0,3,0,0,
- 0,4,0,0,0,67,0,0,0,115,34,0,0,0,116,0,
- 0,124,1,0,131,1,0,125,2,0,100,1,0,124,2,0,
- 106,1,0,100,2,0,124,2,0,106,2,0,105,2,0,83,
- 41,3,122,33,82,101,116,117,114,110,32,116,104,101,32,109,
- 101,116,97,100,97,116,97,32,102,111,114,32,116,104,101,32,
- 112,97,116,104,46,114,133,0,0,0,114,134,0,0,0,41,
- 3,114,39,0,0,0,218,8,115,116,95,109,116,105,109,101,
- 90,7,115,116,95,115,105,122,101,41,3,114,108,0,0,0,
- 114,35,0,0,0,114,208,0,0,0,114,4,0,0,0,114,
- 4,0,0,0,114,5,0,0,0,114,197,0,0,0,59,3,
- 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,0,0,0,67,0,0,0,115,34,0,
- 0,0,116,0,0,124,1,0,131,1,0,125,4,0,124,0,
- 0,106,1,0,124,2,0,124,3,0,100,1,0,124,4,0,
- 131,2,1,83,41,2,78,218,5,95,109,111,100,101,41,2,
- 114,97,0,0,0,114,198,0,0,0,41,5,114,108,0,0,
- 0,114,90,0,0,0,114,89,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,199,0,0,0,64,3,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,220,0,0,0,105,182,1,
- 0,0,99,3,0,0,0,1,0,0,0,9,0,0,0,17,
- 0,0,0,67,0,0,0,115,53,1,0,0,116,0,0,124,
- 1,0,131,1,0,92,2,0,125,4,0,125,5,0,103,0,
- 0,125,6,0,120,54,0,124,4,0,114,80,0,116,1,0,
- 124,4,0,131,1,0,12,114,80,0,116,0,0,124,4,0,
- 131,1,0,92,2,0,125,4,0,125,7,0,124,6,0,106,
- 2,0,124,7,0,131,1,0,1,113,27,0,87,120,132,0,
- 116,3,0,124,6,0,131,1,0,68,93,118,0,125,7,0,
- 116,4,0,124,4,0,124,7,0,131,2,0,125,4,0,121,
- 17,0,116,5,0,106,6,0,124,4,0,131,1,0,1,87,
- 113,94,0,4,116,7,0,107,10,0,114,155,0,1,1,1,
- 119,94,0,89,113,94,0,4,116,8,0,107,10,0,114,211,
- 0,1,125,8,0,1,122,25,0,116,9,0,100,1,0,124,
- 4,0,124,8,0,131,3,0,1,100,2,0,83,87,89,100,
- 2,0,100,2,0,125,8,0,126,8,0,88,113,94,0,88,
- 113,94,0,87,121,33,0,116,10,0,124,1,0,124,2,0,
- 124,3,0,131,3,0,1,116,9,0,100,3,0,124,1,0,
- 131,2,0,1,87,110,53,0,4,116,8,0,107,10,0,114,
- 48,1,1,125,8,0,1,122,21,0,116,9,0,100,1,0,
- 124,1,0,124,8,0,131,3,0,1,87,89,100,2,0,100,
- 2,0,125,8,0,126,8,0,88,110,1,0,88,100,2,0,
- 83,41,4,122,27,87,114,105,116,101,32,98,121,116,101,115,
- 32,100,97,116,97,32,116,111,32,97,32,102,105,108,101,46,
- 122,27,99,111,117,108,100,32,110,111,116,32,99,114,101,97,
- 116,101,32,123,33,114,125,58,32,123,33,114,125,78,122,12,
- 99,114,101,97,116,101,100,32,123,33,114,125,41,11,114,38,
- 0,0,0,114,46,0,0,0,114,163,0,0,0,114,33,0,
- 0,0,114,28,0,0,0,114,3,0,0,0,90,5,109,107,
- 100,105,114,218,15,70,105,108,101,69,120,105,115,116,115,69,
- 114,114,111,114,114,40,0,0,0,114,105,0,0,0,114,55,
- 0,0,0,41,9,114,108,0,0,0,114,35,0,0,0,114,
- 53,0,0,0,114,220,0,0,0,218,6,112,97,114,101,110,
- 116,114,94,0,0,0,114,27,0,0,0,114,23,0,0,0,
- 114,201,0,0,0,114,4,0,0,0,114,4,0,0,0,114,
- 5,0,0,0,114,198,0,0,0,69,3,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,114,46,115,101,116,95,100,
- 97,116,97,78,41,7,114,112,0,0,0,114,111,0,0,0,
- 114,113,0,0,0,114,114,0,0,0,114,197,0,0,0,114,
- 199,0,0,0,114,198,0,0,0,114,4,0,0,0,114,4,
- 0,0,0,114,4,0,0,0,114,5,0,0,0,114,218,0,
- 0,0,55,3,0,0,115,8,0,0,0,12,2,6,2,12,
- 5,12,5,114,218,0,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,0,0,90,2,0,100,1,
- 0,90,3,0,100,2,0,100,3,0,132,0,0,90,4,0,
- 100,4,0,100,5,0,132,0,0,90,5,0,100,6,0,83,
- 41,7,218,20,83,111,117,114,99,101,108,101,115,115,70,105,
- 108,101,76,111,97,100,101,114,122,45,76,111,97,100,101,114,
- 32,119,104,105,99,104,32,104,97,110,100,108,101,115,32,115,
- 111,117,114,99,101,108,101,115,115,32,102,105,108,101,32,105,
- 109,112,111,114,116,115,46,99,2,0,0,0,0,0,0,0,
- 5,0,0,0,6,0,0,0,67,0,0,0,115,76,0,0,
- 0,124,0,0,106,0,0,124,1,0,131,1,0,125,2,0,
- 124,0,0,106,1,0,124,2,0,131,1,0,125,3,0,116,
- 2,0,124,3,0,100,1,0,124,1,0,100,2,0,124,2,
- 0,131,1,2,125,4,0,116,3,0,124,4,0,100,1,0,
- 124,1,0,100,3,0,124,2,0,131,1,2,83,41,4,78,
- 114,106,0,0,0,114,35,0,0,0,114,89,0,0,0,41,
- 4,114,157,0,0,0,114,200,0,0,0,114,141,0,0,0,
- 114,147,0,0,0,41,5,114,108,0,0,0,114,126,0,0,
- 0,114,35,0,0,0,114,53,0,0,0,114,209,0,0,0,
- 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,
- 187,0,0,0,102,3,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,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,122,39,82,101,116,117,114,110,32,78,111,110,
- 101,32,97,115,32,116,104,101,114,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,108,0,0,0,114,126,0,0,0,114,
- 4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,202,
- 0,0,0,108,3,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,112,0,0,0,114,111,0,0,0,114,113,0,0,
- 0,114,114,0,0,0,114,187,0,0,0,114,202,0,0,0,
- 114,4,0,0,0,114,4,0,0,0,114,4,0,0,0,114,
- 5,0,0,0,114,223,0,0,0,98,3,0,0,115,6,0,
- 0,0,12,2,6,2,12,6,114,223,0,0,0,99,0,0,
- 0,0,0,0,0,0,0,0,0,0,3,0,0,0,64,0,
- 0,0,115,136,0,0,0,101,0,0,90,1,0,100,0,0,
- 90,2,0,100,1,0,90,3,0,100,2,0,100,3,0,132,
- 0,0,90,4,0,100,4,0,100,5,0,132,0,0,90,5,
- 0,100,6,0,100,7,0,132,0,0,90,6,0,100,8,0,
- 100,9,0,132,0,0,90,7,0,100,10,0,100,11,0,132,
- 0,0,90,8,0,100,12,0,100,13,0,132,0,0,90,9,
- 0,100,14,0,100,15,0,132,0,0,90,10,0,100,16,0,
- 100,17,0,132,0,0,90,11,0,101,12,0,100,18,0,100,
- 19,0,132,0,0,131,1,0,90,13,0,100,20,0,83,41,
- 21,218,19,69,120,116,101,110,115,105,111,110,70,105,108,101,
- 76,111,97,100,101,114,122,93,76,111,97,100,101,114,32,102,
- 111,114,32,101,120,116,101,110,115,105,111,110,32,109,111,100,
- 117,108,101,115,46,10,10,32,32,32,32,84,104,101,32,99,
- 111,110,115,116,114,117,99,116,111,114,32,105,115,32,100,101,
- 115,105,103,110,101,100,32,116,111,32,119,111,114,107,32,119,
- 105,116,104,32,70,105,108,101,70,105,110,100,101,114,46,10,
- 10,32,32,32,32,99,3,0,0,0,0,0,0,0,3,0,
- 0,0,2,0,0,0,67,0,0,0,115,22,0,0,0,124,
- 1,0,124,0,0,95,0,0,124,2,0,124,0,0,95,1,
- 0,100,0,0,83,41,1,78,41,2,114,106,0,0,0,114,
- 35,0,0,0,41,3,114,108,0,0,0,114,106,0,0,0,
- 114,35,0,0,0,114,4,0,0,0,114,4,0,0,0,114,
- 5,0,0,0,114,185,0,0,0,125,3,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,0,
- 0,2,0,0,0,67,0,0,0,115,34,0,0,0,124,0,
- 0,106,0,0,124,1,0,106,0,0,107,2,0,111,33,0,
- 124,0,0,106,1,0,124,1,0,106,1,0,107,2,0,83,
- 41,1,78,41,2,114,211,0,0,0,114,118,0,0,0,41,
- 2,114,108,0,0,0,114,212,0,0,0,114,4,0,0,0,
- 114,4,0,0,0,114,5,0,0,0,114,213,0,0,0,129,
- 3,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,0,
- 0,0,116,0,0,124,0,0,106,1,0,131,1,0,116,0,
- 0,124,0,0,106,2,0,131,1,0,65,83,41,1,78,41,
- 3,114,214,0,0,0,114,106,0,0,0,114,35,0,0,0,
- 41,1,114,108,0,0,0,114,4,0,0,0,114,4,0,0,
- 0,114,5,0,0,0,114,215,0,0,0,133,3,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,3,0,0,
- 0,4,0,0,0,67,0,0,0,115,47,0,0,0,116,0,
- 0,106,1,0,116,2,0,106,3,0,124,1,0,131,2,0,
- 125,2,0,116,4,0,100,1,0,124,1,0,106,5,0,124,
- 0,0,106,6,0,131,3,0,1,124,2,0,83,41,2,122,
- 38,67,114,101,97,116,101,32,97,110,32,117,110,105,116,105,
- 97,108,105,122,101,100,32,101,120,116,101,110,115,105,111,110,
- 32,109,111,100,117,108,101,122,38,101,120,116,101,110,115,105,
- 111,110,32,109,111,100,117,108,101,32,123,33,114,125,32,108,
- 111,97,100,101,100,32,102,114,111,109,32,123,33,114,125,41,
- 7,114,121,0,0,0,114,188,0,0,0,114,145,0,0,0,
- 90,14,99,114,101,97,116,101,95,100,121,110,97,109,105,99,
- 114,105,0,0,0,114,106,0,0,0,114,35,0,0,0,41,
- 3,114,108,0,0,0,114,164,0,0,0,114,190,0,0,0,
- 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,
- 186,0,0,0,136,3,0,0,115,10,0,0,0,0,2,6,
- 1,15,1,6,1,16,1,122,33,69,120,116,101,110,115,105,
- 111,110,70,105,108,101,76,111,97,100,101,114,46,99,114,101,
- 97,116,101,95,109,111,100,117,108,101,99,2,0,0,0,0,
- 0,0,0,2,0,0,0,4,0,0,0,67,0,0,0,115,
- 45,0,0,0,116,0,0,106,1,0,116,2,0,106,3,0,
- 124,1,0,131,2,0,1,116,4,0,100,1,0,124,0,0,
- 106,5,0,124,0,0,106,6,0,131,3,0,1,100,2,0,
- 83,41,3,122,30,73,110,105,116,105,97,108,105,122,101,32,
- 97,110,32,101,120,116,101,110,115,105,111,110,32,109,111,100,
- 117,108,101,122,40,101,120,116,101,110,115,105,111,110,32,109,
- 111,100,117,108,101,32,123,33,114,125,32,101,120,101,99,117,
- 116,101,100,32,102,114,111,109,32,123,33,114,125,78,41,7,
- 114,121,0,0,0,114,188,0,0,0,114,145,0,0,0,90,
- 12,101,120,101,99,95,100,121,110,97,109,105,99,114,105,0,
- 0,0,114,106,0,0,0,114,35,0,0,0,41,2,114,108,
- 0,0,0,114,190,0,0,0,114,4,0,0,0,114,4,0,
- 0,0,114,5,0,0,0,114,191,0,0,0,144,3,0,0,
- 115,6,0,0,0,0,2,19,1,6,1,122,31,69,120,116,
- 101,110,115,105,111,110,70,105,108,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,0,4,0,0,0,3,0,0,
- 0,115,48,0,0,0,116,0,0,124,0,0,106,1,0,131,
- 1,0,100,1,0,25,137,0,0,116,2,0,135,0,0,102,
- 1,0,100,2,0,100,3,0,134,0,0,116,3,0,68,131,
- 1,0,131,1,0,83,41,4,122,49,82,101,116,117,114,110,
- 32,84,114,117,101,32,105,102,32,116,104,101,32,101,120,116,
- 101,110,115,105,111,110,32,109,111,100,117,108,101,32,105,115,
- 32,97,32,112,97,99,107,97,103,101,46,114,29,0,0,0,
- 99,1,0,0,0,0,0,0,0,2,0,0,0,4,0,0,
- 0,51,0,0,0,115,31,0,0,0,124,0,0,93,21,0,
- 125,1,0,136,0,0,100,0,0,124,1,0,23,107,2,0,
- 86,1,113,3,0,100,1,0,83,41,2,114,185,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,250,9,60,103,
- 101,110,101,120,112,114,62,153,3,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,110,
- 101,120,112,114,62,41,4,114,38,0,0,0,114,35,0,0,
- 0,218,3,97,110,121,218,18,69,88,84,69,78,83,73,79,
- 78,95,83,85,70,70,73,88,69,83,41,2,114,108,0,0,
- 0,114,126,0,0,0,114,4,0,0,0,41,1,114,226,0,
- 0,0,114,5,0,0,0,114,159,0,0,0,150,3,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,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,122,63,82,101,116,
- 117,114,110,32,78,111,110,101,32,97,115,32,97,110,32,101,
- 120,116,101,110,115,105,111,110,32,109,111,100,117,108,101,32,
- 99,97,110,110,111,116,32,99,114,101,97,116,101,32,97,32,
- 99,111,100,101,32,111,98,106,101,99,116,46,78,114,4,0,
- 0,0,41,2,114,108,0,0,0,114,126,0,0,0,114,4,
- 0,0,0,114,4,0,0,0,114,5,0,0,0,114,187,0,
- 0,0,156,3,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,0,
- 115,4,0,0,0,100,1,0,83,41,2,122,53,82,101,116,
- 117,114,110,32,78,111,110,101,32,97,115,32,101,120,116,101,
- 110,115,105,111,110,32,109,111,100,117,108,101,115,32,104,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,108,0,0,0,114,
- 126,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,
- 0,0,0,114,202,0,0,0,160,3,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,0,
- 1,0,0,0,67,0,0,0,115,7,0,0,0,124,0,0,
- 106,0,0,83,41,1,122,58,82,101,116,117,114,110,32,116,
- 104,101,32,112,97,116,104,32,116,111,32,116,104,101,32,115,
- 111,117,114,99,101,32,102,105,108,101,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,108,0,0,0,
- 114,126,0,0,0,114,4,0,0,0,114,4,0,0,0,114,
- 5,0,0,0,114,157,0,0,0,164,3,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,14,114,112,0,0,0,114,111,
- 0,0,0,114,113,0,0,0,114,114,0,0,0,114,185,0,
- 0,0,114,213,0,0,0,114,215,0,0,0,114,186,0,0,
- 0,114,191,0,0,0,114,159,0,0,0,114,187,0,0,0,
- 114,202,0,0,0,114,123,0,0,0,114,157,0,0,0,114,
- 4,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,
- 0,0,0,114,224,0,0,0,117,3,0,0,115,20,0,0,
- 0,12,6,6,2,12,4,12,4,12,3,12,8,12,6,12,
- 6,12,4,12,4,114,224,0,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,0,90,1,0,100,0,0,90,2,0,
- 100,1,0,90,3,0,100,2,0,100,3,0,132,0,0,90,
- 4,0,100,4,0,100,5,0,132,0,0,90,5,0,100,6,
- 0,100,7,0,132,0,0,90,6,0,100,8,0,100,9,0,
- 132,0,0,90,7,0,100,10,0,100,11,0,132,0,0,90,
- 8,0,100,12,0,100,13,0,132,0,0,90,9,0,100,14,
- 0,100,15,0,132,0,0,90,10,0,100,16,0,100,17,0,
- 132,0,0,90,11,0,100,18,0,100,19,0,132,0,0,90,
- 12,0,100,20,0,83,41,21,218,14,95,78,97,109,101,115,
- 112,97,99,101,80,97,116,104,97,38,1,0,0,82,101,112,
- 114,101,115,101,110,116,115,32,97,32,110,97,109,101,115,112,
- 97,99,101,32,112,97,99,107,97,103,101,39,115,32,112,97,
- 116,104,46,32,32,73,116,32,117,115,101,115,32,116,104,101,
- 32,109,111,100,117,108,101,32,110,97,109,101,10,32,32,32,
- 32,116,111,32,102,105,110,100,32,105,116,115,32,112,97,114,
- 101,110,116,32,109,111,100,117,108,101,44,32,97,110,100,32,
- 102,114,111,109,32,116,104,101,114,101,32,105,116,32,108,111,
- 111,107,115,32,117,112,32,116,104,101,32,112,97,114,101,110,
- 116,39,115,10,32,32,32,32,95,95,112,97,116,104,95,95,
- 46,32,32,87,104,101,110,32,116,104,105,115,32,99,104,97,
- 110,103,101,115,44,32,116,104,101,32,109,111,100,117,108,101,
- 39,115,32,111,119,110,32,112,97,116,104,32,105,115,32,114,
- 101,99,111,109,112,117,116,101,100,44,10,32,32,32,32,117,
- 115,105,110,103,32,112,97,116,104,95,102,105,110,100,101,114,
- 46,32,32,70,111,114,32,116,111,112,45,108,101,118,101,108,
- 32,109,111,100,117,108,101,115,44,32,116,104,101,32,112,97,
- 114,101,110,116,32,109,111,100,117,108,101,39,115,32,112,97,
- 116,104,10,32,32,32,32,105,115,32,115,121,115,46,112,97,
- 116,104,46,99,4,0,0,0,0,0,0,0,4,0,0,0,
- 2,0,0,0,67,0,0,0,115,52,0,0,0,124,1,0,
- 124,0,0,95,0,0,124,2,0,124,0,0,95,1,0,116,
- 2,0,124,0,0,106,3,0,131,0,0,131,1,0,124,0,
- 0,95,4,0,124,3,0,124,0,0,95,5,0,100,0,0,
- 83,41,1,78,41,6,218,5,95,110,97,109,101,218,5,95,
- 112,97,116,104,114,93,0,0,0,218,16,95,103,101,116,95,
- 112,97,114,101,110,116,95,112,97,116,104,218,17,95,108,97,
- 115,116,95,112,97,114,101,110,116,95,112,97,116,104,218,12,
- 95,112,97,116,104,95,102,105,110,100,101,114,41,4,114,108,
- 0,0,0,114,106,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,185,0,0,0,177,3,
- 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,0,0,0,115,53,0,
- 0,0,124,0,0,106,0,0,106,1,0,100,1,0,131,1,
- 0,92,3,0,125,1,0,125,2,0,125,3,0,124,2,0,
- 100,2,0,107,2,0,114,43,0,100,6,0,83,124,1,0,
- 100,5,0,102,2,0,83,41,7,122,62,82,101,116,117,114,
- 110,115,32,97,32,116,117,112,108,101,32,111,102,32,40,112,
- 97,114,101,110,116,45,109,111,100,117,108,101,45,110,97,109,
- 101,44,32,112,97,114,101,110,116,45,112,97,116,104,45,97,
- 116,116,114,45,110,97,109,101,41,114,58,0,0,0,114,30,
- 0,0,0,114,7,0,0,0,114,35,0,0,0,90,8,95,
- 95,112,97,116,104,95,95,41,2,122,3,115,121,115,122,4,
- 112,97,116,104,41,2,114,231,0,0,0,114,32,0,0,0,
- 41,4,114,108,0,0,0,114,222,0,0,0,218,3,100,111,
- 116,90,2,109,101,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,183,3,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,116,104,
- 95,110,97,109,101,115,99,1,0,0,0,0,0,0,0,3,
- 0,0,0,3,0,0,0,67,0,0,0,115,38,0,0,0,
- 124,0,0,106,0,0,131,0,0,92,2,0,125,1,0,125,
- 2,0,116,1,0,116,2,0,106,3,0,124,1,0,25,124,
- 2,0,131,2,0,83,41,1,78,41,4,114,238,0,0,0,
- 114,117,0,0,0,114,7,0,0,0,218,7,109,111,100,117,
- 108,101,115,41,3,114,108,0,0,0,90,18,112,97,114,101,
- 110,116,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,233,0,
- 0,0,193,3,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,0,0,0,115,118,0,0,0,116,0,0,124,0,0,
- 106,1,0,131,0,0,131,1,0,125,1,0,124,1,0,124,
- 0,0,106,2,0,107,3,0,114,111,0,124,0,0,106,3,
- 0,124,0,0,106,4,0,124,1,0,131,2,0,125,2,0,
- 124,2,0,100,0,0,107,9,0,114,102,0,124,2,0,106,
- 5,0,100,0,0,107,8,0,114,102,0,124,2,0,106,6,
- 0,114,102,0,124,2,0,106,6,0,124,0,0,95,7,0,
- 124,1,0,124,0,0,95,2,0,124,0,0,106,7,0,83,
- 41,1,78,41,8,114,93,0,0,0,114,233,0,0,0,114,
- 234,0,0,0,114,235,0,0,0,114,231,0,0,0,114,127,
- 0,0,0,114,156,0,0,0,114,232,0,0,0,41,3,114,
- 108,0,0,0,90,11,112,97,114,101,110,116,95,112,97,116,
- 104,114,164,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,197,3,0,0,115,16,0,0,0,0,2,18,1,
- 15,1,21,3,27,1,9,1,12,1,9,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,99,1,0,0,0,0,0,
- 0,0,1,0,0,0,2,0,0,0,67,0,0,0,115,16,
- 0,0,0,116,0,0,124,0,0,106,1,0,131,0,0,131,
- 1,0,83,41,1,78,41,2,218,4,105,116,101,114,114,240,
- 0,0,0,41,1,114,108,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,210,3,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,0,0,0,115,16,0,0,
- 0,116,0,0,124,0,0,106,1,0,131,0,0,131,1,0,
- 83,41,1,78,41,2,114,31,0,0,0,114,240,0,0,0,
- 41,1,114,108,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,213,
- 3,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,0,0,0,100,1,0,106,
- 0,0,124,0,0,106,1,0,131,1,0,83,41,2,78,122,
- 20,95,78,97,109,101,115,112,97,99,101,80,97,116,104,40,
- 123,33,114,125,41,41,2,114,47,0,0,0,114,232,0,0,
- 0,41,1,114,108,0,0,0,114,4,0,0,0,114,4,0,
- 0,0,114,5,0,0,0,218,8,95,95,114,101,112,114,95,
- 95,216,3,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,0,124,
- 1,0,124,0,0,106,0,0,131,0,0,107,6,0,83,41,
- 1,78,41,1,114,240,0,0,0,41,2,114,108,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,219,3,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,0,0,
- 115,20,0,0,0,124,0,0,106,0,0,106,1,0,124,1,
- 0,131,1,0,1,100,0,0,83,41,1,78,41,2,114,232,
- 0,0,0,114,163,0,0,0,41,2,114,108,0,0,0,114,
- 245,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,
- 0,0,0,114,163,0,0,0,222,3,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,112,0,
- 0,0,114,111,0,0,0,114,113,0,0,0,114,114,0,0,
- 0,114,185,0,0,0,114,238,0,0,0,114,233,0,0,0,
- 114,240,0,0,0,114,242,0,0,0,114,243,0,0,0,114,
- 244,0,0,0,114,246,0,0,0,114,163,0,0,0,114,4,
- 0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,
- 0,0,114,230,0,0,0,170,3,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,230,0,0,0,99,0,0,0,0,0,0,
- 0,0,0,0,0,0,3,0,0,0,64,0,0,0,115,118,
- 0,0,0,101,0,0,90,1,0,100,0,0,90,2,0,100,
- 1,0,100,2,0,132,0,0,90,3,0,101,4,0,100,3,
- 0,100,4,0,132,0,0,131,1,0,90,5,0,100,5,0,
- 100,6,0,132,0,0,90,6,0,100,7,0,100,8,0,132,
- 0,0,90,7,0,100,9,0,100,10,0,132,0,0,90,8,
- 0,100,11,0,100,12,0,132,0,0,90,9,0,100,13,0,
- 100,14,0,132,0,0,90,10,0,100,15,0,100,16,0,132,
- 0,0,90,11,0,100,17,0,83,41,18,218,16,95,78,97,
- 109,101,115,112,97,99,101,76,111,97,100,101,114,99,4,0,
- 0,0,0,0,0,0,4,0,0,0,4,0,0,0,67,0,
- 0,0,115,25,0,0,0,116,0,0,124,1,0,124,2,0,
- 124,3,0,131,3,0,124,0,0,95,1,0,100,0,0,83,
- 41,1,78,41,2,114,230,0,0,0,114,232,0,0,0,41,
- 4,114,108,0,0,0,114,106,0,0,0,114,35,0,0,0,
- 114,236,0,0,0,114,4,0,0,0,114,4,0,0,0,114,
- 5,0,0,0,114,185,0,0,0,228,3,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,0,0,100,1,0,106,0,0,124,
- 1,0,106,1,0,131,1,0,83,41,2,122,115,82,101,116,
- 117,114,110,32,114,101,112,114,32,102,111,114,32,116,104,101,
- 32,109,111,100,117,108,101,46,10,10,32,32,32,32,32,32,
- 32,32,84,104,101,32,109,101,116,104,111,100,32,105,115,32,
- 100,101,112,114,101,99,97,116,101,100,46,32,32,84,104,101,
- 32,105,109,112,111,114,116,32,109,97,99,104,105,110,101,114,
- 121,32,100,111,101,115,32,116,104,101,32,106,111,98,32,105,
- 116,115,101,108,102,46,10,10,32,32,32,32,32,32,32,32,
- 122,25,60,109,111,100,117,108,101,32,123,33,114,125,32,40,
- 110,97,109,101,115,112,97,99,101,41,62,41,2,114,47,0,
- 0,0,114,112,0,0,0,41,2,114,170,0,0,0,114,190,
- 0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,
- 0,0,218,11,109,111,100,117,108,101,95,114,101,112,114,231,
- 3,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,108,0,0,0,114,126,0,0,0,114,4,0,0,0,
- 114,4,0,0,0,114,5,0,0,0,114,159,0,0,0,240,
- 3,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,108,0,0,0,114,126,0,0,0,114,4,
- 0,0,0,114,4,0,0,0,114,5,0,0,0,114,202,0,
- 0,0,243,3,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,115,
- 22,0,0,0,116,0,0,100,1,0,100,2,0,100,3,0,
- 100,4,0,100,5,0,131,3,1,83,41,6,78,114,30,0,
- 0,0,122,8,60,115,116,114,105,110,103,62,114,189,0,0,
- 0,114,204,0,0,0,84,41,1,114,205,0,0,0,41,2,
- 114,108,0,0,0,114,126,0,0,0,114,4,0,0,0,114,
- 4,0,0,0,114,5,0,0,0,114,187,0,0,0,246,3,
- 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,1,
- 0,83,41,2,122,42,85,115,101,32,100,101,102,97,117,108,
- 116,32,115,101,109,97,110,116,105,99,115,32,102,111,114,32,
- 109,111,100,117,108,101,32,99,114,101,97,116,105,111,110,46,
- 78,114,4,0,0,0,41,2,114,108,0,0,0,114,164,0,
- 0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,
- 0,114,186,0,0,0,249,3,0,0,115,0,0,0,0,122,
- 30,95,78,97,109,101,115,112,97,99,101,76,111,97,100,101,
- 114,46,99,114,101,97,116,101,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,4,0,0,0,100,0,0,83,41,1,78,
- 114,4,0,0,0,41,2,114,108,0,0,0,114,190,0,0,
+ 0,114,152,0,0,0,161,3,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,14,114,106,0,0,0,114,105,0,0,0,
+ 114,107,0,0,0,114,108,0,0,0,114,180,0,0,0,114,
+ 208,0,0,0,114,210,0,0,0,114,181,0,0,0,114,186,
+ 0,0,0,114,154,0,0,0,114,182,0,0,0,114,197,0,
+ 0,0,114,117,0,0,0,114,152,0,0,0,114,4,0,0,
0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,
- 114,191,0,0,0,252,3,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,0,3,0,0,0,67,
- 0,0,0,115,32,0,0,0,116,0,0,100,1,0,124,0,
- 0,106,1,0,131,2,0,1,116,2,0,106,3,0,124,0,
- 0,124,1,0,131,2,0,83,41,2,122,98,76,111,97,100,
- 32,97,32,110,97,109,101,115,112,97,99,101,32,109,111,100,
- 117,108,101,46,10,10,32,32,32,32,32,32,32,32,84,104,
- 105,115,32,109,101,116,104,111,100,32,105,115,32,100,101,112,
- 114,101,99,97,116,101,100,46,32,32,85,115,101,32,101,120,
- 101,99,95,109,111,100,117,108,101,40,41,32,105,110,115,116,
- 101,97,100,46,10,10,32,32,32,32,32,32,32,32,122,38,
- 110,97,109,101,115,112,97,99,101,32,109,111,100,117,108,101,
- 32,108,111,97,100,101,100,32,119,105,116,104,32,112,97,116,
- 104,32,123,33,114,125,41,4,114,105,0,0,0,114,232,0,
- 0,0,114,121,0,0,0,114,192,0,0,0,41,2,114,108,
- 0,0,0,114,126,0,0,0,114,4,0,0,0,114,4,0,
- 0,0,114,5,0,0,0,114,193,0,0,0,255,3,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,12,114,112,0,0,0,114,
- 111,0,0,0,114,113,0,0,0,114,185,0,0,0,114,183,
- 0,0,0,114,248,0,0,0,114,159,0,0,0,114,202,0,
- 0,0,114,187,0,0,0,114,186,0,0,0,114,191,0,0,
- 0,114,193,0,0,0,114,4,0,0,0,114,4,0,0,0,
- 114,4,0,0,0,114,5,0,0,0,114,247,0,0,0,227,
- 3,0,0,115,16,0,0,0,12,1,12,3,18,9,12,3,
- 12,3,12,3,12,3,12,3,114,247,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,0,90,1,0,100,0,0,
- 90,2,0,100,1,0,90,3,0,101,4,0,100,2,0,100,
- 3,0,132,0,0,131,1,0,90,5,0,101,4,0,100,4,
- 0,100,5,0,132,0,0,131,1,0,90,6,0,101,4,0,
- 100,6,0,100,7,0,132,0,0,131,1,0,90,7,0,101,
- 4,0,100,8,0,100,9,0,132,0,0,131,1,0,90,8,
- 0,101,4,0,100,10,0,100,11,0,100,12,0,132,1,0,
- 131,1,0,90,9,0,101,4,0,100,10,0,100,10,0,100,
- 13,0,100,14,0,132,2,0,131,1,0,90,10,0,101,4,
- 0,100,10,0,100,15,0,100,16,0,132,1,0,131,1,0,
- 90,11,0,100,10,0,83,41,17,218,10,80,97,116,104,70,
- 105,110,100,101,114,122,62,77,101,116,97,32,112,97,116,104,
- 32,102,105,110,100,101,114,32,102,111,114,32,115,121,115,46,
- 112,97,116,104,32,97,110,100,32,112,97,99,107,97,103,101,
- 32,95,95,112,97,116,104,95,95,32,97,116,116,114,105,98,
- 117,116,101,115,46,99,1,0,0,0,0,0,0,0,2,0,
- 0,0,4,0,0,0,67,0,0,0,115,55,0,0,0,120,
- 48,0,116,0,0,106,1,0,106,2,0,131,0,0,68,93,
- 31,0,125,1,0,116,3,0,124,1,0,100,1,0,131,2,
- 0,114,16,0,124,1,0,106,4,0,131,0,0,1,113,16,
- 0,87,100,2,0,83,41,3,122,125,67,97,108,108,32,116,
- 104,101,32,105,110,118,97,108,105,100,97,116,101,95,99,97,
- 99,104,101,115,40,41,32,109,101,116,104,111,100,32,111,110,
- 32,97,108,108,32,112,97,116,104,32,101,110,116,114,121,32,
- 102,105,110,100,101,114,115,10,32,32,32,32,32,32,32,32,
- 115,116,111,114,101,100,32,105,110,32,115,121,115,46,112,97,
- 116,104,95,105,109,112,111,114,116,101,114,95,99,97,99,104,
- 101,115,32,40,119,104,101,114,101,32,105,109,112,108,101,109,
- 101,110,116,101,100,41,46,218,17,105,110,118,97,108,105,100,
- 97,116,101,95,99,97,99,104,101,115,78,41,5,114,7,0,
- 0,0,218,19,112,97,116,104,95,105,109,112,111,114,116,101,
- 114,95,99,97,99,104,101,218,6,118,97,108,117,101,115,114,
- 115,0,0,0,114,250,0,0,0,41,2,114,170,0,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,250,0,0,0,16,4,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,12,0,0,0,67,0,0,0,115,107,
- 0,0,0,116,0,0,106,1,0,100,1,0,107,9,0,114,
- 41,0,116,0,0,106,1,0,12,114,41,0,116,2,0,106,
- 3,0,100,2,0,116,4,0,131,2,0,1,120,59,0,116,
- 0,0,106,1,0,68,93,44,0,125,2,0,121,14,0,124,
- 2,0,124,1,0,131,1,0,83,87,113,51,0,4,116,5,
- 0,107,10,0,114,94,0,1,1,1,119,51,0,89,113,51,
- 0,88,113,51,0,87,100,1,0,83,100,1,0,83,41,3,
- 122,113,83,101,97,114,99,104,32,115,101,113,117,101,110,99,
- 101,32,111,102,32,104,111,111,107,115,32,102,111,114,32,97,
- 32,102,105,110,100,101,114,32,102,111,114,32,39,112,97,116,
- 104,39,46,10,10,32,32,32,32,32,32,32,32,73,102,32,
- 39,104,111,111,107,115,39,32,105,115,32,102,97,108,115,101,
- 32,116,104,101,110,32,117,115,101,32,115,121,115,46,112,97,
- 116,104,95,104,111,111,107,115,46,10,10,32,32,32,32,32,
- 32,32,32,78,122,23,115,121,115,46,112,97,116,104,95,104,
- 111,111,107,115,32,105,115,32,101,109,112,116,121,41,6,114,
- 7,0,0,0,218,10,112,97,116,104,95,104,111,111,107,115,
- 114,60,0,0,0,114,61,0,0,0,114,125,0,0,0,114,
- 107,0,0,0,41,3,114,170,0,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,24,4,0,0,115,16,0,0,0,0,7,25,1,16,
- 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,99,2,0,0,0,0,0,0,0,3,0,0,0,
- 19,0,0,0,67,0,0,0,115,123,0,0,0,124,1,0,
- 100,1,0,107,2,0,114,53,0,121,16,0,116,0,0,106,
- 1,0,131,0,0,125,1,0,87,110,22,0,4,116,2,0,
- 107,10,0,114,52,0,1,1,1,100,2,0,83,89,110,1,
- 0,88,121,17,0,116,3,0,106,4,0,124,1,0,25,125,
- 2,0,87,110,46,0,4,116,5,0,107,10,0,114,118,0,
- 1,1,1,124,0,0,106,6,0,124,1,0,131,1,0,125,
- 2,0,124,2,0,116,3,0,106,4,0,124,1,0,60,89,
- 110,1,0,88,124,2,0,83,41,3,122,210,71,101,116,32,
- 116,104,101,32,102,105,110,100,101,114,32,102,111,114,32,116,
- 104,101,32,112,97,116,104,32,101,110,116,114,121,32,102,114,
- 111,109,32,115,121,115,46,112,97,116,104,95,105,109,112,111,
- 114,116,101,114,95,99,97,99,104,101,46,10,10,32,32,32,
- 32,32,32,32,32,73,102,32,116,104,101,32,112,97,116,104,
- 32,101,110,116,114,121,32,105,115,32,110,111,116,32,105,110,
- 32,116,104,101,32,99,97,99,104,101,44,32,102,105,110,100,
- 32,116,104,101,32,97,112,112,114,111,112,114,105,97,116,101,
- 32,102,105,110,100,101,114,10,32,32,32,32,32,32,32,32,
- 97,110,100,32,99,97,99,104,101,32,105,116,46,32,73,102,
- 32,110,111,32,102,105,110,100,101,114,32,105,115,32,97,118,
- 97,105,108,97,98,108,101,44,32,115,116,111,114,101,32,78,
- 111,110,101,46,10,10,32,32,32,32,32,32,32,32,114,30,
- 0,0,0,78,41,7,114,3,0,0,0,114,45,0,0,0,
- 218,17,70,105,108,101,78,111,116,70,111,117,110,100,69,114,
- 114,111,114,114,7,0,0,0,114,251,0,0,0,114,137,0,
- 0,0,114,255,0,0,0,41,3,114,170,0,0,0,114,35,
- 0,0,0,114,253,0,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,41,4,0,
- 0,115,22,0,0,0,0,8,12,1,3,1,16,1,13,3,
- 9,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,95,99,97,99,104,101,99,3,0,
- 0,0,0,0,0,0,6,0,0,0,3,0,0,0,67,0,
- 0,0,115,119,0,0,0,116,0,0,124,2,0,100,1,0,
- 131,2,0,114,39,0,124,2,0,106,1,0,124,1,0,131,
- 1,0,92,2,0,125,3,0,125,4,0,110,21,0,124,2,
- 0,106,2,0,124,1,0,131,1,0,125,3,0,103,0,0,
- 125,4,0,124,3,0,100,0,0,107,9,0,114,88,0,116,
- 3,0,106,4,0,124,1,0,124,3,0,131,2,0,83,116,
- 3,0,106,5,0,124,1,0,100,0,0,131,2,0,125,5,
- 0,124,4,0,124,5,0,95,6,0,124,5,0,83,41,2,
- 78,114,124,0,0,0,41,7,114,115,0,0,0,114,124,0,
- 0,0,114,182,0,0,0,114,121,0,0,0,114,179,0,0,
- 0,114,160,0,0,0,114,156,0,0,0,41,6,114,170,0,
- 0,0,114,126,0,0,0,114,253,0,0,0,114,127,0,0,
- 0,114,128,0,0,0,114,164,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,63,4,0,0,
- 115,18,0,0,0,0,4,15,1,24,2,15,1,6,1,12,
- 1,16,1,18,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,101,99,78,99,4,0,0,0,0,0,0,0,9,0,
- 0,0,5,0,0,0,67,0,0,0,115,243,0,0,0,103,
- 0,0,125,4,0,120,230,0,124,2,0,68,93,191,0,125,
- 5,0,116,0,0,124,5,0,116,1,0,116,2,0,102,2,
- 0,131,2,0,115,43,0,113,13,0,124,0,0,106,3,0,
- 124,5,0,131,1,0,125,6,0,124,6,0,100,1,0,107,
- 9,0,114,13,0,116,4,0,124,6,0,100,2,0,131,2,
- 0,114,106,0,124,6,0,106,5,0,124,1,0,124,3,0,
- 131,2,0,125,7,0,110,18,0,124,0,0,106,6,0,124,
- 1,0,124,6,0,131,2,0,125,7,0,124,7,0,100,1,
- 0,107,8,0,114,139,0,113,13,0,124,7,0,106,7,0,
- 100,1,0,107,9,0,114,158,0,124,7,0,83,124,7,0,
- 106,8,0,125,8,0,124,8,0,100,1,0,107,8,0,114,
- 191,0,116,9,0,100,3,0,131,1,0,130,1,0,124,4,
- 0,106,10,0,124,8,0,131,1,0,1,113,13,0,87,116,
- 11,0,106,12,0,124,1,0,100,1,0,131,2,0,125,7,
- 0,124,4,0,124,7,0,95,8,0,124,7,0,83,100,1,
- 0,83,41,4,122,63,70,105,110,100,32,116,104,101,32,108,
- 111,97,100,101,114,32,111,114,32,110,97,109,101,115,112,97,
- 99,101,95,112,97,116,104,32,102,111,114,32,116,104,105,115,
- 32,109,111,100,117,108,101,47,112,97,99,107,97,103,101,32,
- 110,97,109,101,46,78,114,181,0,0,0,122,19,115,112,101,
- 99,32,109,105,115,115,105,110,103,32,108,111,97,100,101,114,
- 41,13,114,143,0,0,0,114,69,0,0,0,218,5,98,121,
- 116,101,115,114,1,1,0,0,114,115,0,0,0,114,181,0,
- 0,0,114,2,1,0,0,114,127,0,0,0,114,156,0,0,
- 0,114,107,0,0,0,114,149,0,0,0,114,121,0,0,0,
- 114,160,0,0,0,41,9,114,170,0,0,0,114,126,0,0,
- 0,114,35,0,0,0,114,180,0,0,0,218,14,110,97,109,
- 101,115,112,97,99,101,95,112,97,116,104,90,5,101,110,116,
- 114,121,114,253,0,0,0,114,164,0,0,0,114,128,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,78,4,0,0,115,
- 40,0,0,0,0,5,6,1,13,1,21,1,3,1,15,1,
- 12,1,15,1,21,2,18,1,12,1,3,1,15,1,4,1,
- 9,1,12,1,12,5,17,2,18,1,9,1,122,20,80,97,
- 116,104,70,105,110,100,101,114,46,95,103,101,116,95,115,112,
- 101,99,99,4,0,0,0,0,0,0,0,6,0,0,0,4,
- 0,0,0,67,0,0,0,115,140,0,0,0,124,2,0,100,
- 1,0,107,8,0,114,21,0,116,0,0,106,1,0,125,2,
- 0,124,0,0,106,2,0,124,1,0,124,2,0,124,3,0,
- 131,3,0,125,4,0,124,4,0,100,1,0,107,8,0,114,
- 58,0,100,1,0,83,124,4,0,106,3,0,100,1,0,107,
- 8,0,114,132,0,124,4,0,106,4,0,125,5,0,124,5,
- 0,114,125,0,100,2,0,124,4,0,95,5,0,116,6,0,
- 124,1,0,124,5,0,124,0,0,106,2,0,131,3,0,124,
- 4,0,95,4,0,124,4,0,83,100,1,0,83,110,4,0,
- 124,4,0,83,100,1,0,83,41,3,122,98,102,105,110,100,
- 32,116,104,101,32,109,111,100,117,108,101,32,111,110,32,115,
- 121,115,46,112,97,116,104,32,111,114,32,39,112,97,116,104,
- 39,32,98,97,115,101,100,32,111,110,32,115,121,115,46,112,
- 97,116,104,95,104,111,111,107,115,32,97,110,100,10,32,32,
- 32,32,32,32,32,32,115,121,115,46,112,97,116,104,95,105,
- 109,112,111,114,116,101,114,95,99,97,99,104,101,46,78,90,
- 9,110,97,109,101,115,112,97,99,101,41,7,114,7,0,0,
- 0,114,35,0,0,0,114,5,1,0,0,114,127,0,0,0,
- 114,156,0,0,0,114,158,0,0,0,114,230,0,0,0,41,
- 6,114,170,0,0,0,114,126,0,0,0,114,35,0,0,0,
- 114,180,0,0,0,114,164,0,0,0,114,4,1,0,0,114,
- 4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,181,
- 0,0,0,110,4,0,0,115,26,0,0,0,0,4,12,1,
- 9,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,99,99,3,0,0,
- 0,0,0,0,0,4,0,0,0,3,0,0,0,67,0,0,
- 0,115,41,0,0,0,124,0,0,106,0,0,124,1,0,124,
- 2,0,131,2,0,125,3,0,124,3,0,100,1,0,107,8,
- 0,114,34,0,100,1,0,83,124,3,0,106,1,0,83,41,
- 2,122,170,102,105,110,100,32,116,104,101,32,109,111,100,117,
- 108,101,32,111,110,32,115,121,115,46,112,97,116,104,32,111,
- 114,32,39,112,97,116,104,39,32,98,97,115,101,100,32,111,
- 110,32,115,121,115,46,112,97,116,104,95,104,111,111,107,115,
- 32,97,110,100,10,32,32,32,32,32,32,32,32,115,121,115,
- 46,112,97,116,104,95,105,109,112,111,114,116,101,114,95,99,
- 97,99,104,101,46,10,10,32,32,32,32,32,32,32,32,84,
- 104,105,115,32,109,101,116,104,111,100,32,105,115,32,100,101,
- 112,114,101,99,97,116,101,100,46,32,32,85,115,101,32,102,
- 105,110,100,95,115,112,101,99,40,41,32,105,110,115,116,101,
- 97,100,46,10,10,32,32,32,32,32,32,32,32,78,41,2,
- 114,181,0,0,0,114,127,0,0,0,41,4,114,170,0,0,
- 0,114,126,0,0,0,114,35,0,0,0,114,164,0,0,0,
- 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,
- 182,0,0,0,132,4,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,
- 112,0,0,0,114,111,0,0,0,114,113,0,0,0,114,114,
- 0,0,0,114,183,0,0,0,114,250,0,0,0,114,255,0,
- 0,0,114,1,1,0,0,114,2,1,0,0,114,5,1,0,
- 0,114,181,0,0,0,114,182,0,0,0,114,4,0,0,0,
- 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,
- 249,0,0,0,12,4,0,0,115,22,0,0,0,12,2,6,
- 2,18,8,18,17,18,22,18,15,3,1,18,31,3,1,21,
- 21,3,1,114,249,0,0,0,99,0,0,0,0,0,0,0,
- 0,0,0,0,0,3,0,0,0,64,0,0,0,115,133,0,
- 0,0,101,0,0,90,1,0,100,0,0,90,2,0,100,1,
- 0,90,3,0,100,2,0,100,3,0,132,0,0,90,4,0,
- 100,4,0,100,5,0,132,0,0,90,5,0,101,6,0,90,
- 7,0,100,6,0,100,7,0,132,0,0,90,8,0,100,8,
- 0,100,9,0,132,0,0,90,9,0,100,10,0,100,11,0,
- 100,12,0,132,1,0,90,10,0,100,13,0,100,14,0,132,
- 0,0,90,11,0,101,12,0,100,15,0,100,16,0,132,0,
- 0,131,1,0,90,13,0,100,17,0,100,18,0,132,0,0,
- 90,14,0,100,10,0,83,41,19,218,10,70,105,108,101,70,
- 105,110,100,101,114,122,172,70,105,108,101,45,98,97,115,101,
- 100,32,102,105,110,100,101,114,46,10,10,32,32,32,32,73,
- 110,116,101,114,97,99,116,105,111,110,115,32,119,105,116,104,
- 32,116,104,101,32,102,105,108,101,32,115,121,115,116,101,109,
- 32,97,114,101,32,99,97,99,104,101,100,32,102,111,114,32,
- 112,101,114,102,111,114,109,97,110,99,101,44,32,98,101,105,
- 110,103,10,32,32,32,32,114,101,102,114,101,115,104,101,100,
- 32,119,104,101,110,32,116,104,101,32,100,105,114,101,99,116,
- 111,114,121,32,116,104,101,32,102,105,110,100,101,114,32,105,
- 115,32,104,97,110,100,108,105,110,103,32,104,97,115,32,98,
- 101,101,110,32,109,111,100,105,102,105,101,100,46,10,10,32,
- 32,32,32,99,2,0,0,0,0,0,0,0,5,0,0,0,
- 5,0,0,0,7,0,0,0,115,122,0,0,0,103,0,0,
- 125,3,0,120,52,0,124,2,0,68,93,44,0,92,2,0,
- 137,0,0,125,4,0,124,3,0,106,0,0,135,0,0,102,
- 1,0,100,1,0,100,2,0,134,0,0,124,4,0,68,131,
- 1,0,131,1,0,1,113,13,0,87,124,3,0,124,0,0,
- 95,1,0,124,1,0,112,79,0,100,3,0,124,0,0,95,
- 2,0,100,6,0,124,0,0,95,3,0,116,4,0,131,0,
- 0,124,0,0,95,5,0,116,4,0,131,0,0,124,0,0,
- 95,6,0,100,5,0,83,41,7,122,154,73,110,105,116,105,
- 97,108,105,122,101,32,119,105,116,104,32,116,104,101,32,112,
- 97,116,104,32,116,111,32,115,101,97,114,99,104,32,111,110,
- 32,97,110,100,32,97,32,118,97,114,105,97,98,108,101,32,
- 110,117,109,98,101,114,32,111,102,10,32,32,32,32,32,32,
- 32,32,50,45,116,117,112,108,101,115,32,99,111,110,116,97,
- 105,110,105,110,103,32,116,104,101,32,108,111,97,100,101,114,
- 32,97,110,100,32,116,104,101,32,102,105,108,101,32,115,117,
- 102,102,105,120,101,115,32,116,104,101,32,108,111,97,100,101,
- 114,10,32,32,32,32,32,32,32,32,114,101,99,111,103,110,
- 105,122,101,115,46,99,1,0,0,0,0,0,0,0,2,0,
- 0,0,3,0,0,0,51,0,0,0,115,27,0,0,0,124,
- 0,0,93,17,0,125,1,0,124,1,0,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,225,0,0,0,41,1,
- 114,127,0,0,0,114,4,0,0,0,114,5,0,0,0,114,
- 227,0,0,0,161,4,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,58,0,0,0,114,29,0,0,
- 0,78,114,87,0,0,0,41,7,114,149,0,0,0,218,8,
- 95,108,111,97,100,101,114,115,114,35,0,0,0,218,11,95,
- 112,97,116,104,95,109,116,105,109,101,218,3,115,101,116,218,
- 11,95,112,97,116,104,95,99,97,99,104,101,218,19,95,114,
- 101,108,97,120,101,100,95,112,97,116,104,95,99,97,99,104,
- 101,41,5,114,108,0,0,0,114,35,0,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,166,0,0,0,114,4,0,0,0,
- 41,1,114,127,0,0,0,114,5,0,0,0,114,185,0,0,
- 0,155,4,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,0,2,0,0,0,
- 67,0,0,0,115,13,0,0,0,100,3,0,124,0,0,95,
- 0,0,100,2,0,83,41,4,122,31,73,110,118,97,108,105,
- 100,97,116,101,32,116,104,101,32,100,105,114,101,99,116,111,
- 114,121,32,109,116,105,109,101,46,114,29,0,0,0,78,114,
- 87,0,0,0,41,1,114,8,1,0,0,41,1,114,108,0,
- 0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,
- 0,114,250,0,0,0,169,4,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,0,2,0,0,0,
- 67,0,0,0,115,59,0,0,0,124,0,0,106,0,0,124,
- 1,0,131,1,0,125,2,0,124,2,0,100,1,0,107,8,
- 0,114,37,0,100,1,0,103,0,0,102,2,0,83,124,2,
- 0,106,1,0,124,2,0,106,2,0,112,55,0,103,0,0,
- 102,2,0,83,41,2,122,197,84,114,121,32,116,111,32,102,
- 105,110,100,32,97,32,108,111,97,100,101,114,32,102,111,114,
- 32,116,104,101,32,115,112,101,99,105,102,105,101,100,32,109,
- 111,100,117,108,101,44,32,111,114,32,116,104,101,32,110,97,
- 109,101,115,112,97,99,101,10,32,32,32,32,32,32,32,32,
- 112,97,99,107,97,103,101,32,112,111,114,116,105,111,110,115,
- 46,32,82,101,116,117,114,110,115,32,40,108,111,97,100,101,
- 114,44,32,108,105,115,116,45,111,102,45,112,111,114,116,105,
- 111,110,115,41,46,10,10,32,32,32,32,32,32,32,32,84,
- 104,105,115,32,109,101,116,104,111,100,32,105,115,32,100,101,
- 112,114,101,99,97,116,101,100,46,32,32,85,115,101,32,102,
- 105,110,100,95,115,112,101,99,40,41,32,105,110,115,116,101,
- 97,100,46,10,10,32,32,32,32,32,32,32,32,78,41,3,
- 114,181,0,0,0,114,127,0,0,0,114,156,0,0,0,41,
- 3,114,108,0,0,0,114,126,0,0,0,114,164,0,0,0,
- 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,
- 124,0,0,0,175,4,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,0,0,0,67,0,
- 0,0,115,40,0,0,0,124,1,0,124,2,0,124,3,0,
- 131,2,0,125,6,0,116,0,0,124,2,0,124,3,0,100,
- 1,0,124,6,0,100,2,0,124,4,0,131,2,2,83,41,
- 3,78,114,127,0,0,0,114,156,0,0,0,41,1,114,167,
- 0,0,0,41,7,114,108,0,0,0,114,165,0,0,0,114,
- 126,0,0,0,114,35,0,0,0,90,4,115,109,115,108,114,
- 180,0,0,0,114,127,0,0,0,114,4,0,0,0,114,4,
- 0,0,0,114,5,0,0,0,114,5,1,0,0,187,4,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,234,1,0,0,100,1,0,
- 125,3,0,124,1,0,106,0,0,100,2,0,131,1,0,100,
- 3,0,25,125,4,0,121,34,0,116,1,0,124,0,0,106,
- 2,0,112,49,0,116,3,0,106,4,0,131,0,0,131,1,
- 0,106,5,0,125,5,0,87,110,24,0,4,116,6,0,107,
- 10,0,114,85,0,1,1,1,100,10,0,125,5,0,89,110,
- 1,0,88,124,5,0,124,0,0,106,7,0,107,3,0,114,
- 120,0,124,0,0,106,8,0,131,0,0,1,124,5,0,124,
- 0,0,95,7,0,116,9,0,131,0,0,114,153,0,124,0,
- 0,106,10,0,125,6,0,124,4,0,106,11,0,131,0,0,
- 125,7,0,110,15,0,124,0,0,106,12,0,125,6,0,124,
- 4,0,125,7,0,124,7,0,124,6,0,107,6,0,114,45,
- 1,116,13,0,124,0,0,106,2,0,124,4,0,131,2,0,
- 125,8,0,120,100,0,124,0,0,106,14,0,68,93,77,0,
- 92,2,0,125,9,0,125,10,0,100,5,0,124,9,0,23,
- 125,11,0,116,13,0,124,8,0,124,11,0,131,2,0,125,
- 12,0,116,15,0,124,12,0,131,1,0,114,208,0,124,0,
- 0,106,16,0,124,10,0,124,1,0,124,12,0,124,8,0,
- 103,1,0,124,2,0,131,5,0,83,113,208,0,87,116,17,
- 0,124,8,0,131,1,0,125,3,0,120,123,0,124,0,0,
- 106,14,0,68,93,112,0,92,2,0,125,9,0,125,10,0,
- 116,13,0,124,0,0,106,2,0,124,4,0,124,9,0,23,
- 131,2,0,125,12,0,116,18,0,100,6,0,106,19,0,124,
- 12,0,131,1,0,100,7,0,100,3,0,131,1,1,1,124,
- 7,0,124,9,0,23,124,6,0,107,6,0,114,55,1,116,
- 15,0,124,12,0,131,1,0,114,55,1,124,0,0,106,16,
- 0,124,10,0,124,1,0,124,12,0,100,8,0,124,2,0,
- 131,5,0,83,113,55,1,87,124,3,0,114,230,1,116,18,
- 0,100,9,0,106,19,0,124,8,0,131,1,0,131,1,0,
- 1,116,20,0,106,21,0,124,1,0,100,8,0,131,2,0,
- 125,13,0,124,8,0,103,1,0,124,13,0,95,22,0,124,
- 13,0,83,100,8,0,83,41,11,122,102,84,114,121,32,116,
- 111,32,102,105,110,100,32,97,32,115,112,101,99,32,102,111,
- 114,32,116,104,101,32,115,112,101,99,105,102,105,101,100,32,
- 109,111,100,117,108,101,46,32,32,82,101,116,117,114,110,115,
- 32,116,104,101,10,32,32,32,32,32,32,32,32,109,97,116,
- 99,104,105,110,103,32,115,112,101,99,44,32,111,114,32,78,
- 111,110,101,32,105,102,32,110,111,116,32,102,111,117,110,100,
- 46,70,114,58,0,0,0,114,56,0,0,0,114,29,0,0,
- 0,114,185,0,0,0,122,9,116,114,121,105,110,103,32,123,
- 125,114,98,0,0,0,78,122,25,112,111,115,115,105,98,108,
- 101,32,110,97,109,101,115,112,97,99,101,32,102,111,114,32,
- 123,125,114,87,0,0,0,41,23,114,32,0,0,0,114,39,
- 0,0,0,114,35,0,0,0,114,3,0,0,0,114,45,0,
- 0,0,114,219,0,0,0,114,40,0,0,0,114,8,1,0,
- 0,218,11,95,102,105,108,108,95,99,97,99,104,101,114,6,
- 0,0,0,114,11,1,0,0,114,88,0,0,0,114,10,1,
- 0,0,114,28,0,0,0,114,7,1,0,0,114,44,0,0,
- 0,114,5,1,0,0,114,46,0,0,0,114,105,0,0,0,
- 114,47,0,0,0,114,121,0,0,0,114,160,0,0,0,114,
- 156,0,0,0,41,14,114,108,0,0,0,114,126,0,0,0,
- 114,180,0,0,0,90,12,105,115,95,110,97,109,101,115,112,
- 97,99,101,90,11,116,97,105,108,95,109,111,100,117,108,101,
- 114,133,0,0,0,90,5,99,97,99,104,101,90,12,99,97,
- 99,104,101,95,109,111,100,117,108,101,90,9,98,97,115,101,
- 95,112,97,116,104,114,225,0,0,0,114,165,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,164,0,0,0,114,4,
- 0,0,0,114,4,0,0,0,114,5,0,0,0,114,181,0,
- 0,0,192,4,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,9,2,9,
- 1,9,1,15,2,9,1,6,2,12,1,18,1,22,1,10,
- 1,15,1,12,1,32,4,12,2,22,1,22,1,25,1,16,
- 1,12,1,29,1,6,1,19,1,18,1,12,1,4,1,122,
- 20,70,105,108,101,70,105,110,100,101,114,46,102,105,110,100,
- 95,115,112,101,99,99,1,0,0,0,0,0,0,0,9,0,
- 0,0,13,0,0,0,67,0,0,0,115,11,1,0,0,124,
- 0,0,106,0,0,125,1,0,121,31,0,116,1,0,106,2,
- 0,124,1,0,112,33,0,116,1,0,106,3,0,131,0,0,
- 131,1,0,125,2,0,87,110,33,0,4,116,4,0,116,5,
- 0,116,6,0,102,3,0,107,10,0,114,75,0,1,1,1,
- 103,0,0,125,2,0,89,110,1,0,88,116,7,0,106,8,
- 0,106,9,0,100,1,0,131,1,0,115,112,0,116,10,0,
- 124,2,0,131,1,0,124,0,0,95,11,0,110,111,0,116,
- 10,0,131,0,0,125,3,0,120,90,0,124,2,0,68,93,
- 82,0,125,4,0,124,4,0,106,12,0,100,2,0,131,1,
- 0,92,3,0,125,5,0,125,6,0,125,7,0,124,6,0,
- 114,191,0,100,3,0,106,13,0,124,5,0,124,7,0,106,
- 14,0,131,0,0,131,2,0,125,8,0,110,6,0,124,5,
- 0,125,8,0,124,3,0,106,15,0,124,8,0,131,1,0,
- 1,113,128,0,87,124,3,0,124,0,0,95,11,0,116,7,
- 0,106,8,0,106,9,0,116,16,0,131,1,0,114,7,1,
- 100,4,0,100,5,0,132,0,0,124,2,0,68,131,1,0,
- 124,0,0,95,17,0,100,6,0,83,41,7,122,68,70,105,
- 108,108,32,116,104,101,32,99,97,99,104,101,32,111,102,32,
- 112,111,116,101,110,116,105,97,108,32,109,111,100,117,108,101,
- 115,32,97,110,100,32,112,97,99,107,97,103,101,115,32,102,
- 111,114,32,116,104,105,115,32,100,105,114,101,99,116,111,114,
- 121,46,114,0,0,0,0,114,58,0,0,0,122,5,123,125,
- 46,123,125,99,1,0,0,0,0,0,0,0,2,0,0,0,
- 3,0,0,0,83,0,0,0,115,28,0,0,0,104,0,0,
- 124,0,0,93,18,0,125,1,0,124,1,0,106,0,0,131,
- 0,0,146,2,0,113,6,0,83,114,4,0,0,0,41,1,
- 114,88,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,10,5,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,41,18,114,35,0,0,0,114,3,0,0,0,90,7,108,
- 105,115,116,100,105,114,114,45,0,0,0,114,0,1,0,0,
- 218,15,80,101,114,109,105,115,115,105,111,110,69,114,114,111,
- 114,218,18,78,111,116,65,68,105,114,101,99,116,111,114,121,
- 69,114,114,111,114,114,7,0,0,0,114,8,0,0,0,114,
- 9,0,0,0,114,9,1,0,0,114,10,1,0,0,114,83,
- 0,0,0,114,47,0,0,0,114,88,0,0,0,218,3,97,
- 100,100,114,10,0,0,0,114,11,1,0,0,41,9,114,108,
- 0,0,0,114,35,0,0,0,90,8,99,111,110,116,101,110,
- 116,115,90,21,108,111,119,101,114,95,115,117,102,102,105,120,
- 95,99,111,110,116,101,110,116,115,114,245,0,0,0,114,106,
- 0,0,0,114,237,0,0,0,114,225,0,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,13,1,0,0,237,4,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,95,102,105,108,108,95,99,97,99,104,101,99,1,
- 0,0,0,0,0,0,0,3,0,0,0,3,0,0,0,7,
- 0,0,0,115,25,0,0,0,135,0,0,135,1,0,102,2,
- 0,100,1,0,100,2,0,134,0,0,125,2,0,124,2,0,
- 83,41,3,97,20,1,0,0,65,32,99,108,97,115,115,32,
- 109,101,116,104,111,100,32,119,104,105,99,104,32,114,101,116,
- 117,114,110,115,32,97,32,99,108,111,115,117,114,101,32,116,
- 111,32,117,115,101,32,111,110,32,115,121,115,46,112,97,116,
- 104,95,104,111,111,107,10,32,32,32,32,32,32,32,32,119,
- 104,105,99,104,32,119,105,108,108,32,114,101,116,117,114,110,
- 32,97,110,32,105,110,115,116,97,110,99,101,32,117,115,105,
- 110,103,32,116,104,101,32,115,112,101,99,105,102,105,101,100,
- 32,108,111,97,100,101,114,115,32,97,110,100,32,116,104,101,
- 32,112,97,116,104,10,32,32,32,32,32,32,32,32,99,97,
- 108,108,101,100,32,111,110,32,116,104,101,32,99,108,111,115,
- 117,114,101,46,10,10,32,32,32,32,32,32,32,32,73,102,
- 32,116,104,101,32,112,97,116,104,32,99,97,108,108,101,100,
- 32,111,110,32,116,104,101,32,99,108,111,115,117,114,101,32,
- 105,115,32,110,111,116,32,97,32,100,105,114,101,99,116,111,
- 114,121,44,32,73,109,112,111,114,116,69,114,114,111,114,32,
- 105,115,10,32,32,32,32,32,32,32,32,114,97,105,115,101,
- 100,46,10,10,32,32,32,32,32,32,32,32,99,1,0,0,
- 0,0,0,0,0,1,0,0,0,4,0,0,0,19,0,0,
- 0,115,43,0,0,0,116,0,0,124,0,0,131,1,0,115,
- 30,0,116,1,0,100,1,0,100,2,0,124,0,0,131,1,
- 1,130,1,0,136,0,0,124,0,0,136,1,0,140,1,0,
- 83,41,3,122,45,80,97,116,104,32,104,111,111,107,32,102,
- 111,114,32,105,109,112,111,114,116,108,105,98,46,109,97,99,
- 104,105,110,101,114,121,46,70,105,108,101,70,105,110,100,101,
- 114,46,122,30,111,110,108,121,32,100,105,114,101,99,116,111,
- 114,105,101,115,32,97,114,101,32,115,117,112,112,111,114,116,
- 101,100,114,35,0,0,0,41,2,114,46,0,0,0,114,107,
- 0,0,0,41,1,114,35,0,0,0,41,2,114,170,0,0,
- 0,114,12,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,22,5,0,0,115,6,
- 0,0,0,0,2,12,1,18,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,
- 111,107,95,102,111,114,95,70,105,108,101,70,105,110,100,101,
- 114,114,4,0,0,0,41,3,114,170,0,0,0,114,12,1,
- 0,0,114,18,1,0,0,114,4,0,0,0,41,2,114,170,
- 0,0,0,114,12,1,0,0,114,5,0,0,0,218,9,112,
- 97,116,104,95,104,111,111,107,12,5,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,
- 115,16,0,0,0,100,1,0,106,0,0,124,0,0,106,1,
- 0,131,1,0,83,41,2,78,122,16,70,105,108,101,70,105,
- 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,108,0,0,0,114,4,0,
- 0,0,114,4,0,0,0,114,5,0,0,0,114,244,0,0,
- 0,30,5,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,112,0,0,0,114,111,0,0,0,114,113,0,
- 0,0,114,114,0,0,0,114,185,0,0,0,114,250,0,0,
- 0,114,130,0,0,0,114,182,0,0,0,114,124,0,0,0,
- 114,5,1,0,0,114,181,0,0,0,114,13,1,0,0,114,
- 183,0,0,0,114,19,1,0,0,114,244,0,0,0,114,4,
- 0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,
- 0,0,114,6,1,0,0,146,4,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,6,1,0,0,99,4,0,0,0,0,0,
- 0,0,6,0,0,0,11,0,0,0,67,0,0,0,115,195,
- 0,0,0,124,0,0,106,0,0,100,1,0,131,1,0,125,
- 4,0,124,0,0,106,0,0,100,2,0,131,1,0,125,5,
- 0,124,4,0,115,99,0,124,5,0,114,54,0,124,5,0,
- 106,1,0,125,4,0,110,45,0,124,2,0,124,3,0,107,
- 2,0,114,84,0,116,2,0,124,1,0,124,2,0,131,2,
- 0,125,4,0,110,15,0,116,3,0,124,1,0,124,2,0,
- 131,2,0,125,4,0,124,5,0,115,126,0,116,4,0,124,
- 1,0,124,2,0,100,3,0,124,4,0,131,2,1,125,5,
- 0,121,44,0,124,5,0,124,0,0,100,2,0,60,124,4,
- 0,124,0,0,100,1,0,60,124,2,0,124,0,0,100,4,
- 0,60,124,3,0,124,0,0,100,5,0,60,87,110,18,0,
- 4,116,5,0,107,10,0,114,190,0,1,1,1,89,110,1,
- 0,88,100,0,0,83,41,6,78,218,10,95,95,108,111,97,
- 100,101,114,95,95,218,8,95,95,115,112,101,99,95,95,114,
- 127,0,0,0,90,8,95,95,102,105,108,101,95,95,90,10,
- 95,95,99,97,99,104,101,100,95,95,41,6,218,3,103,101,
- 116,114,127,0,0,0,114,223,0,0,0,114,218,0,0,0,
- 114,167,0,0,0,218,9,69,120,99,101,112,116,105,111,110,
- 41,6,90,2,110,115,114,106,0,0,0,90,8,112,97,116,
- 104,110,97,109,101,90,9,99,112,97,116,104,110,97,109,101,
- 114,127,0,0,0,114,164,0,0,0,114,4,0,0,0,114,
- 4,0,0,0,114,5,0,0,0,218,14,95,102,105,120,95,
- 117,112,95,109,111,100,117,108,101,36,5,0,0,115,34,0,
- 0,0,0,2,15,1,15,1,6,1,6,1,12,1,12,1,
- 18,2,15,1,6,1,21,1,3,1,10,1,10,1,10,1,
- 14,1,13,2,114,24,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,116,0,0,116,1,0,106,2,0,131,0,0,102,
- 2,0,125,0,0,116,3,0,116,4,0,102,2,0,125,1,
- 0,116,5,0,116,6,0,102,2,0,125,2,0,124,0,0,
- 124,1,0,124,2,0,103,3,0,83,41,1,122,95,82,101,
- 116,117,114,110,115,32,97,32,108,105,115,116,32,111,102,32,
- 102,105,108,101,45,98,97,115,101,100,32,109,111,100,117,108,
- 101,32,108,111,97,100,101,114,115,46,10,10,32,32,32,32,
- 69,97,99,104,32,105,116,101,109,32,105,115,32,97,32,116,
- 117,112,108,101,32,40,108,111,97,100,101,114,44,32,115,117,
- 102,102,105,120,101,115,41,46,10,32,32,32,32,41,7,114,
- 224,0,0,0,114,145,0,0,0,218,18,101,120,116,101,110,
- 115,105,111,110,95,115,117,102,102,105,120,101,115,114,218,0,
- 0,0,114,84,0,0,0,114,223,0,0,0,114,74,0,0,
- 0,41,3,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,
+ 114,219,0,0,0,114,3,0,0,115,20,0,0,0,8,6,
+ 4,2,8,4,8,4,8,3,8,8,8,6,8,6,8,4,
+ 8,4,114,219,0,0,0,99,0,0,0,0,0,0,0,0,
+ 0,0,0,0,2,0,0,0,64,0,0,0,115,96,0,0,
+ 0,101,0,90,1,100,0,90,2,100,1,90,3,100,2,100,
+ 3,132,0,90,4,100,4,100,5,132,0,90,5,100,6,100,
+ 7,132,0,90,6,100,8,100,9,132,0,90,7,100,10,100,
+ 11,132,0,90,8,100,12,100,13,132,0,90,9,100,14,100,
+ 15,132,0,90,10,100,16,100,17,132,0,90,11,100,18,100,
+ 19,132,0,90,12,100,20,100,21,132,0,90,13,100,22,83,
+ 0,41,23,218,14,95,78,97,109,101,115,112,97,99,101,80,
+ 97,116,104,97,38,1,0,0,82,101,112,114,101,115,101,110,
+ 116,115,32,97,32,110,97,109,101,115,112,97,99,101,32,112,
+ 97,99,107,97,103,101,39,115,32,112,97,116,104,46,32,32,
+ 73,116,32,117,115,101,115,32,116,104,101,32,109,111,100,117,
+ 108,101,32,110,97,109,101,10,32,32,32,32,116,111,32,102,
+ 105,110,100,32,105,116,115,32,112,97,114,101,110,116,32,109,
+ 111,100,117,108,101,44,32,97,110,100,32,102,114,111,109,32,
+ 116,104,101,114,101,32,105,116,32,108,111,111,107,115,32,117,
+ 112,32,116,104,101,32,112,97,114,101,110,116,39,115,10,32,
+ 32,32,32,95,95,112,97,116,104,95,95,46,32,32,87,104,
+ 101,110,32,116,104,105,115,32,99,104,97,110,103,101,115,44,
+ 32,116,104,101,32,109,111,100,117,108,101,39,115,32,111,119,
+ 110,32,112,97,116,104,32,105,115,32,114,101,99,111,109,112,
+ 117,116,101,100,44,10,32,32,32,32,117,115,105,110,103,32,
+ 112,97,116,104,95,102,105,110,100,101,114,46,32,32,70,111,
+ 114,32,116,111,112,45,108,101,118,101,108,32,109,111,100,117,
+ 108,101,115,44,32,116,104,101,32,112,97,114,101,110,116,32,
+ 109,111,100,117,108,101,39,115,32,112,97,116,104,10,32,32,
+ 32,32,105,115,32,115,121,115,46,112,97,116,104,46,99,4,
+ 0,0,0,0,0,0,0,4,0,0,0,2,0,0,0,67,
+ 0,0,0,115,36,0,0,0,124,1,124,0,95,0,124,2,
+ 124,0,95,1,116,2,124,0,106,3,131,0,131,1,124,0,
+ 95,4,124,3,124,0,95,5,100,0,83,0,41,1,78,41,
+ 6,218,5,95,110,97,109,101,218,5,95,112,97,116,104,114,
+ 94,0,0,0,218,16,95,103,101,116,95,112,97,114,101,110,
+ 116,95,112,97,116,104,218,17,95,108,97,115,116,95,112,97,
+ 114,101,110,116,95,112,97,116,104,218,12,95,112,97,116,104,
+ 95,102,105,110,100,101,114,41,4,114,101,0,0,0,114,99,
+ 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,180,0,0,0,174,3,0,0,115,8,0,
+ 0,0,0,1,6,1,6,1,14,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,0,0,0,115,38,0,0,0,124,0,106,
+ 0,106,1,100,1,131,1,92,3,125,1,125,2,125,3,124,
+ 2,100,2,107,2,114,30,100,6,83,0,124,1,100,5,102,
+ 2,83,0,41,7,122,62,82,101,116,117,114,110,115,32,97,
+ 32,116,117,112,108,101,32,111,102,32,40,112,97,114,101,110,
+ 116,45,109,111,100,117,108,101,45,110,97,109,101,44,32,112,
+ 97,114,101,110,116,45,112,97,116,104,45,97,116,116,114,45,
+ 110,97,109,101,41,114,59,0,0,0,114,30,0,0,0,114,
+ 7,0,0,0,114,35,0,0,0,90,8,95,95,112,97,116,
+ 104,95,95,41,2,122,3,115,121,115,122,4,112,97,116,104,
+ 41,2,114,226,0,0,0,114,32,0,0,0,41,4,114,101,
+ 0,0,0,114,217,0,0,0,218,3,100,111,116,90,2,109,
101,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,
- 114,161,0,0,0,59,5,0,0,115,8,0,0,0,0,5,
- 18,1,12,1,12,1,114,161,0,0,0,99,1,0,0,0,
- 0,0,0,0,12,0,0,0,12,0,0,0,67,0,0,0,
- 115,70,2,0,0,124,0,0,97,0,0,116,0,0,106,1,
- 0,97,1,0,116,0,0,106,2,0,97,2,0,116,1,0,
- 106,3,0,116,4,0,25,125,1,0,120,76,0,100,26,0,
- 68,93,68,0,125,2,0,124,2,0,116,1,0,106,3,0,
- 107,7,0,114,83,0,116,0,0,106,5,0,124,2,0,131,
- 1,0,125,3,0,110,13,0,116,1,0,106,3,0,124,2,
- 0,25,125,3,0,116,6,0,124,1,0,124,2,0,124,3,
- 0,131,3,0,1,113,44,0,87,100,5,0,100,6,0,103,
- 1,0,102,2,0,100,7,0,100,8,0,100,6,0,103,2,
- 0,102,2,0,102,2,0,125,4,0,120,149,0,124,4,0,
- 68,93,129,0,92,2,0,125,5,0,125,6,0,116,7,0,
- 100,9,0,100,10,0,132,0,0,124,6,0,68,131,1,0,
- 131,1,0,115,199,0,116,8,0,130,1,0,124,6,0,100,
- 11,0,25,125,7,0,124,5,0,116,1,0,106,3,0,107,
- 6,0,114,241,0,116,1,0,106,3,0,124,5,0,25,125,
- 8,0,80,113,156,0,121,20,0,116,0,0,106,5,0,124,
- 5,0,131,1,0,125,8,0,80,87,113,156,0,4,116,9,
- 0,107,10,0,114,28,1,1,1,1,119,156,0,89,113,156,
- 0,88,113,156,0,87,116,9,0,100,12,0,131,1,0,130,
- 1,0,116,6,0,124,1,0,100,13,0,124,8,0,131,3,
- 0,1,116,6,0,124,1,0,100,14,0,124,7,0,131,3,
- 0,1,116,6,0,124,1,0,100,15,0,100,16,0,106,10,
- 0,124,6,0,131,1,0,131,3,0,1,121,19,0,116,0,
- 0,106,5,0,100,17,0,131,1,0,125,9,0,87,110,24,
- 0,4,116,9,0,107,10,0,114,147,1,1,1,1,100,18,
- 0,125,9,0,89,110,1,0,88,116,6,0,124,1,0,100,
- 17,0,124,9,0,131,3,0,1,116,0,0,106,5,0,100,
- 19,0,131,1,0,125,10,0,116,6,0,124,1,0,100,19,
- 0,124,10,0,131,3,0,1,124,5,0,100,7,0,107,2,
- 0,114,238,1,116,0,0,106,5,0,100,20,0,131,1,0,
- 125,11,0,116,6,0,124,1,0,100,21,0,124,11,0,131,
- 3,0,1,116,6,0,124,1,0,100,22,0,116,11,0,131,
- 0,0,131,3,0,1,116,12,0,106,13,0,116,2,0,106,
- 14,0,131,0,0,131,1,0,1,124,5,0,100,7,0,107,
- 2,0,114,66,2,116,15,0,106,16,0,100,23,0,131,1,
- 0,1,100,24,0,116,12,0,107,6,0,114,66,2,100,25,
- 0,116,17,0,95,18,0,100,18,0,83,41,27,122,205,83,
- 101,116,117,112,32,116,104,101,32,112,97,116,104,45,98,97,
- 115,101,100,32,105,109,112,111,114,116,101,114,115,32,102,111,
- 114,32,105,109,112,111,114,116,108,105,98,32,98,121,32,105,
- 109,112,111,114,116,105,110,103,32,110,101,101,100,101,100,10,
- 32,32,32,32,98,117,105,108,116,45,105,110,32,109,111,100,
- 117,108,101,115,32,97,110,100,32,105,110,106,101,99,116,105,
- 110,103,32,116,104,101,109,32,105,110,116,111,32,116,104,101,
- 32,103,108,111,98,97,108,32,110,97,109,101,115,112,97,99,
- 101,46,10,10,32,32,32,32,79,116,104,101,114,32,99,111,
- 109,112,111,110,101,110,116,115,32,97,114,101,32,101,120,116,
- 114,97,99,116,101,100,32,102,114,111,109,32,116,104,101,32,
- 99,111,114,101,32,98,111,111,116,115,116,114,97,112,32,109,
- 111,100,117,108,101,46,10,10,32,32,32,32,114,49,0,0,
- 0,114,60,0,0,0,218,8,98,117,105,108,116,105,110,115,
- 114,142,0,0,0,90,5,112,111,115,105,120,250,1,47,218,
- 2,110,116,250,1,92,99,1,0,0,0,0,0,0,0,2,
- 0,0,0,3,0,0,0,115,0,0,0,115,33,0,0,0,
- 124,0,0,93,23,0,125,1,0,116,0,0,124,1,0,131,
- 1,0,100,0,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,77,0,0,0,114,4,0,0,
- 0,114,4,0,0,0,114,5,0,0,0,114,227,0,0,0,
- 95,5,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,59,0,0,0,122,30,105,109,112,
- 111,114,116,108,105,98,32,114,101,113,117,105,114,101,115,32,
- 112,111,115,105,120,32,111,114,32,110,116,114,3,0,0,0,
- 114,25,0,0,0,114,21,0,0,0,114,30,0,0,0,90,
- 7,95,116,104,114,101,97,100,78,90,8,95,119,101,97,107,
- 114,101,102,90,6,119,105,110,114,101,103,114,169,0,0,0,
- 114,6,0,0,0,122,4,46,112,121,119,122,6,95,100,46,
- 112,121,100,84,41,4,122,3,95,105,111,122,9,95,119,97,
- 114,110,105,110,103,115,122,8,98,117,105,108,116,105,110,115,
- 122,7,109,97,114,115,104,97,108,41,19,114,121,0,0,0,
- 114,7,0,0,0,114,145,0,0,0,114,239,0,0,0,114,
- 112,0,0,0,90,18,95,98,117,105,108,116,105,110,95,102,
- 114,111,109,95,110,97,109,101,114,116,0,0,0,218,3,97,
- 108,108,218,14,65,115,115,101,114,116,105,111,110,69,114,114,
- 111,114,114,107,0,0,0,114,26,0,0,0,114,11,0,0,
- 0,114,229,0,0,0,114,149,0,0,0,114,25,1,0,0,
- 114,84,0,0,0,114,163,0,0,0,114,168,0,0,0,114,
- 173,0,0,0,41,12,218,17,95,98,111,111,116,115,116,114,
- 97,112,95,109,111,100,117,108,101,90,11,115,101,108,102,95,
- 109,111,100,117,108,101,90,12,98,117,105,108,116,105,110,95,
- 110,97,109,101,90,14,98,117,105,108,116,105,110,95,109,111,
- 100,117,108,101,90,10,111,115,95,100,101,116,97,105,108,115,
- 90,10,98,117,105,108,116,105,110,95,111,115,114,21,0,0,
- 0,114,25,0,0,0,90,9,111,115,95,109,111,100,117,108,
- 101,90,13,116,104,114,101,97,100,95,109,111,100,117,108,101,
- 90,14,119,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,70,5,0,0,115,82,0,0,0,0,
- 8,6,1,9,1,9,3,13,1,13,1,15,1,18,2,13,
- 1,20,3,33,1,19,2,31,1,10,1,15,1,13,1,4,
- 2,3,1,15,1,5,1,13,1,12,2,12,1,16,1,16,
- 1,25,3,3,1,19,1,13,2,11,1,16,3,15,1,16,
- 3,12,1,15,1,16,3,19,1,19,1,12,1,13,1,12,
- 1,114,33,1,0,0,99,1,0,0,0,0,0,0,0,2,
- 0,0,0,3,0,0,0,67,0,0,0,115,116,0,0,0,
- 116,0,0,124,0,0,131,1,0,1,116,1,0,131,0,0,
- 125,1,0,116,2,0,106,3,0,106,4,0,116,5,0,106,
- 6,0,124,1,0,140,0,0,103,1,0,131,1,0,1,116,
- 7,0,106,8,0,100,1,0,107,2,0,114,78,0,116,2,
- 0,106,9,0,106,10,0,116,11,0,131,1,0,1,116,2,
- 0,106,9,0,106,10,0,116,12,0,131,1,0,1,116,5,
- 0,124,0,0,95,5,0,116,13,0,124,0,0,95,13,0,
- 100,2,0,83,41,3,122,41,73,110,115,116,97,108,108,32,
- 116,104,101,32,112,97,116,104,45,98,97,115,101,100,32,105,
- 109,112,111,114,116,32,99,111,109,112,111,110,101,110,116,115,
- 46,114,28,1,0,0,78,41,14,114,33,1,0,0,114,161,
- 0,0,0,114,7,0,0,0,114,254,0,0,0,114,149,0,
- 0,0,114,6,1,0,0,114,19,1,0,0,114,3,0,0,
- 0,114,112,0,0,0,218,9,109,101,116,97,95,112,97,116,
- 104,114,163,0,0,0,114,168,0,0,0,114,249,0,0,0,
- 114,218,0,0,0,41,2,114,32,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,138,5,0,0,115,16,0,0,
- 0,0,2,10,1,9,1,28,1,15,1,16,1,16,4,9,
- 1,114,35,1,0,0,41,3,122,3,119,105,110,114,1,0,
- 0,0,114,2,0,0,0,41,57,114,114,0,0,0,114,10,
- 0,0,0,114,11,0,0,0,114,17,0,0,0,114,19,0,
- 0,0,114,28,0,0,0,114,38,0,0,0,114,39,0,0,
- 0,114,43,0,0,0,114,44,0,0,0,114,46,0,0,0,
- 114,55,0,0,0,218,4,116,121,112,101,218,8,95,95,99,
- 111,100,101,95,95,114,144,0,0,0,114,15,0,0,0,114,
- 135,0,0,0,114,14,0,0,0,114,18,0,0,0,90,17,
- 95,82,65,87,95,77,65,71,73,67,95,78,85,77,66,69,
- 82,114,73,0,0,0,114,72,0,0,0,114,84,0,0,0,
- 114,74,0,0,0,90,23,68,69,66,85,71,95,66,89,84,
- 69,67,79,68,69,95,83,85,70,70,73,88,69,83,90,27,
- 79,80,84,73,77,73,90,69,68,95,66,89,84,69,67,79,
- 68,69,95,83,85,70,70,73,88,69,83,114,79,0,0,0,
- 114,85,0,0,0,114,91,0,0,0,114,95,0,0,0,114,
- 97,0,0,0,114,105,0,0,0,114,123,0,0,0,114,130,
- 0,0,0,114,141,0,0,0,114,147,0,0,0,114,150,0,
- 0,0,114,155,0,0,0,218,6,111,98,106,101,99,116,114,
- 162,0,0,0,114,167,0,0,0,114,168,0,0,0,114,184,
- 0,0,0,114,194,0,0,0,114,210,0,0,0,114,218,0,
- 0,0,114,223,0,0,0,114,229,0,0,0,114,224,0,0,
- 0,114,230,0,0,0,114,247,0,0,0,114,249,0,0,0,
- 114,6,1,0,0,114,24,1,0,0,114,161,0,0,0,114,
- 33,1,0,0,114,35,1,0,0,114,4,0,0,0,114,4,
- 0,0,0,114,4,0,0,0,114,5,0,0,0,218,8,60,
- 109,111,100,117,108,101,62,8,0,0,0,115,100,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,15,114,22,1,18,2,6,1,
- 6,2,9,2,9,2,10,2,21,44,12,33,12,19,12,12,
- 12,12,18,8,12,28,12,17,21,55,21,12,18,10,12,14,
- 9,3,12,1,15,65,19,64,19,28,22,110,19,41,25,43,
- 25,16,6,3,25,53,19,57,19,41,19,134,19,146,15,23,
- 12,11,12,68,
+ 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,180,3,0,0,115,8,0,
+ 0,0,0,2,18,1,8,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,116,104,95,110,97,109,
+ 101,115,99,1,0,0,0,0,0,0,0,3,0,0,0,3,
+ 0,0,0,67,0,0,0,115,28,0,0,0,124,0,106,0,
+ 131,0,92,2,125,1,125,2,116,1,116,2,106,3,124,1,
+ 25,0,124,2,131,2,83,0,41,1,78,41,4,114,233,0,
+ 0,0,114,111,0,0,0,114,7,0,0,0,218,7,109,111,
+ 100,117,108,101,115,41,3,114,101,0,0,0,90,18,112,97,
+ 114,101,110,116,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,
+ 228,0,0,0,190,3,0,0,115,4,0,0,0,0,1,12,
+ 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,0,0,0,115,80,0,0,0,116,0,124,0,
+ 106,1,131,0,131,1,125,1,124,1,124,0,106,2,107,3,
+ 114,74,124,0,106,3,124,0,106,4,124,1,131,2,125,2,
+ 124,2,100,0,107,9,114,68,124,2,106,5,100,0,107,8,
+ 114,68,124,2,106,6,114,68,124,2,106,6,124,0,95,7,
+ 124,1,124,0,95,2,124,0,106,7,83,0,41,1,78,41,
+ 8,114,94,0,0,0,114,228,0,0,0,114,229,0,0,0,
+ 114,230,0,0,0,114,226,0,0,0,114,121,0,0,0,114,
+ 151,0,0,0,114,227,0,0,0,41,3,114,101,0,0,0,
+ 90,11,112,97,114,101,110,116,95,112,97,116,104,114,159,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,194,
+ 3,0,0,115,16,0,0,0,0,2,12,1,10,1,14,3,
+ 18,1,6,1,8,1,6,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,99,1,0,0,0,0,0,0,0,1,0,
+ 0,0,2,0,0,0,67,0,0,0,115,12,0,0,0,116,
+ 0,124,0,106,1,131,0,131,1,83,0,41,1,78,41,2,
+ 218,4,105,116,101,114,114,235,0,0,0,41,1,114,101,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,207,3,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,
+ 3,0,0,0,0,0,0,0,3,0,0,0,3,0,0,0,
+ 67,0,0,0,115,14,0,0,0,124,2,124,0,106,0,124,
+ 1,60,0,100,0,83,0,41,1,78,41,1,114,227,0,0,
+ 0,41,3,114,101,0,0,0,218,5,105,110,100,101,120,114,
+ 35,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,
+ 0,0,0,218,11,95,95,115,101,116,105,116,101,109,95,95,
+ 210,3,0,0,115,2,0,0,0,0,1,122,26,95,78,97,
+ 109,101,115,112,97,99,101,80,97,116,104,46,95,95,115,101,
+ 116,105,116,101,109,95,95,99,1,0,0,0,0,0,0,0,
+ 1,0,0,0,2,0,0,0,67,0,0,0,115,12,0,0,
+ 0,116,0,124,0,106,1,131,0,131,1,83,0,41,1,78,
+ 41,2,114,31,0,0,0,114,235,0,0,0,41,1,114,101,
+ 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,213,3,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,12,0,0,0,100,1,106,0,124,0,106,1,
+ 131,1,83,0,41,2,78,122,20,95,78,97,109,101,115,112,
+ 97,99,101,80,97,116,104,40,123,33,114,125,41,41,2,114,
+ 48,0,0,0,114,227,0,0,0,41,1,114,101,0,0,0,
+ 114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,218,
+ 8,95,95,114,101,112,114,95,95,216,3,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,12,0,0,0,124,1,124,0,106,0,131,0,107,
+ 6,83,0,41,1,78,41,1,114,235,0,0,0,41,2,114,
+ 101,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,219,3,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,0,0,115,16,0,0,0,124,0,106,0,106,1,124,
+ 1,131,1,1,0,100,0,83,0,41,1,78,41,2,114,227,
+ 0,0,0,114,158,0,0,0,41,2,114,101,0,0,0,114,
+ 242,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,
+ 0,0,0,114,158,0,0,0,222,3,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,14,114,106,0,
+ 0,0,114,105,0,0,0,114,107,0,0,0,114,108,0,0,
+ 0,114,180,0,0,0,114,233,0,0,0,114,228,0,0,0,
+ 114,235,0,0,0,114,237,0,0,0,114,239,0,0,0,114,
+ 240,0,0,0,114,241,0,0,0,114,243,0,0,0,114,158,
+ 0,0,0,114,4,0,0,0,114,4,0,0,0,114,4,0,
+ 0,0,114,5,0,0,0,114,225,0,0,0,167,3,0,0,
+ 115,22,0,0,0,8,5,4,2,8,6,8,10,8,4,8,
+ 13,8,3,8,3,8,3,8,3,8,3,114,225,0,0,0,
+ 99,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,
+ 0,64,0,0,0,115,80,0,0,0,101,0,90,1,100,0,
+ 90,2,100,1,100,2,132,0,90,3,101,4,100,3,100,4,
+ 132,0,131,1,90,5,100,5,100,6,132,0,90,6,100,7,
+ 100,8,132,0,90,7,100,9,100,10,132,0,90,8,100,11,
+ 100,12,132,0,90,9,100,13,100,14,132,0,90,10,100,15,
+ 100,16,132,0,90,11,100,17,83,0,41,18,218,16,95,78,
+ 97,109,101,115,112,97,99,101,76,111,97,100,101,114,99,4,
+ 0,0,0,0,0,0,0,4,0,0,0,4,0,0,0,67,
+ 0,0,0,115,18,0,0,0,116,0,124,1,124,2,124,3,
+ 131,3,124,0,95,1,100,0,83,0,41,1,78,41,2,114,
+ 225,0,0,0,114,227,0,0,0,41,4,114,101,0,0,0,
+ 114,99,0,0,0,114,35,0,0,0,114,231,0,0,0,114,
+ 4,0,0,0,114,4,0,0,0,114,5,0,0,0,114,180,
+ 0,0,0,228,3,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,12,
+ 0,0,0,100,1,106,0,124,1,106,1,131,1,83,0,41,
+ 2,122,115,82,101,116,117,114,110,32,114,101,112,114,32,102,
+ 111,114,32,116,104,101,32,109,111,100,117,108,101,46,10,10,
+ 32,32,32,32,32,32,32,32,84,104,101,32,109,101,116,104,
+ 111,100,32,105,115,32,100,101,112,114,101,99,97,116,101,100,
+ 46,32,32,84,104,101,32,105,109,112,111,114,116,32,109,97,
+ 99,104,105,110,101,114,121,32,100,111,101,115,32,116,104,101,
+ 32,106,111,98,32,105,116,115,101,108,102,46,10,10,32,32,
+ 32,32,32,32,32,32,122,25,60,109,111,100,117,108,101,32,
+ 123,33,114,125,32,40,110,97,109,101,115,112,97,99,101,41,
+ 62,41,2,114,48,0,0,0,114,106,0,0,0,41,2,114,
+ 165,0,0,0,114,185,0,0,0,114,4,0,0,0,114,4,
+ 0,0,0,114,5,0,0,0,218,11,109,111,100,117,108,101,
+ 95,114,101,112,114,231,3,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,83,0,41,2,78,84,
+ 114,4,0,0,0,41,2,114,101,0,0,0,114,120,0,0,
+ 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,
+ 114,154,0,0,0,240,3,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,83,0,41,2,78,114,30,
+ 0,0,0,114,4,0,0,0,41,2,114,101,0,0,0,114,
+ 120,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,
+ 0,0,0,114,197,0,0,0,243,3,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,115,18,0,0,0,116,0,100,1,100,2,
+ 100,3,100,4,100,5,144,1,131,3,83,0,41,6,78,114,
+ 30,0,0,0,122,8,60,115,116,114,105,110,103,62,114,184,
+ 0,0,0,114,199,0,0,0,84,41,1,114,200,0,0,0,
+ 41,2,114,101,0,0,0,114,120,0,0,0,114,4,0,0,
+ 0,114,4,0,0,0,114,5,0,0,0,114,182,0,0,0,
+ 246,3,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,1,83,0,41,2,122,42,85,115,101,32,100,101,102,97,
+ 117,108,116,32,115,101,109,97,110,116,105,99,115,32,102,111,
+ 114,32,109,111,100,117,108,101,32,99,114,101,97,116,105,111,
+ 110,46,78,114,4,0,0,0,41,2,114,101,0,0,0,114,
+ 159,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,
+ 0,0,0,114,181,0,0,0,249,3,0,0,115,0,0,0,
+ 0,122,30,95,78,97,109,101,115,112,97,99,101,76,111,97,
+ 100,101,114,46,99,114,101,97,116,101,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,4,0,0,0,100,0,83,0,41,
+ 1,78,114,4,0,0,0,41,2,114,101,0,0,0,114,185,
+ 0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,
+ 0,0,114,186,0,0,0,252,3,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,0,3,0,0,
+ 0,67,0,0,0,115,26,0,0,0,116,0,106,1,100,1,
+ 124,0,106,2,131,2,1,0,116,0,106,3,124,0,124,1,
+ 131,2,83,0,41,2,122,98,76,111,97,100,32,97,32,110,
+ 97,109,101,115,112,97,99,101,32,109,111,100,117,108,101,46,
+ 10,10,32,32,32,32,32,32,32,32,84,104,105,115,32,109,
+ 101,116,104,111,100,32,105,115,32,100,101,112,114,101,99,97,
+ 116,101,100,46,32,32,85,115,101,32,101,120,101,99,95,109,
+ 111,100,117,108,101,40,41,32,105,110,115,116,101,97,100,46,
+ 10,10,32,32,32,32,32,32,32,32,122,38,110,97,109,101,
+ 115,112,97,99,101,32,109,111,100,117,108,101,32,108,111,97,
+ 100,101,100,32,119,105,116,104,32,112,97,116,104,32,123,33,
+ 114,125,41,4,114,115,0,0,0,114,130,0,0,0,114,227,
+ 0,0,0,114,187,0,0,0,41,2,114,101,0,0,0,114,
+ 120,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,
+ 0,0,0,114,188,0,0,0,255,3,0,0,115,6,0,0,
+ 0,0,7,6,1,8,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,12,114,106,0,0,0,114,105,0,
+ 0,0,114,107,0,0,0,114,180,0,0,0,114,178,0,0,
+ 0,114,245,0,0,0,114,154,0,0,0,114,197,0,0,0,
+ 114,182,0,0,0,114,181,0,0,0,114,186,0,0,0,114,
+ 188,0,0,0,114,4,0,0,0,114,4,0,0,0,114,4,
+ 0,0,0,114,5,0,0,0,114,244,0,0,0,227,3,0,
+ 0,115,16,0,0,0,8,1,8,3,12,9,8,3,8,3,
+ 8,3,8,3,8,3,114,244,0,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,90,1,100,0,90,2,100,1,90,
+ 3,101,4,100,2,100,3,132,0,131,1,90,5,101,4,100,
+ 4,100,5,132,0,131,1,90,6,101,4,100,6,100,7,132,
+ 0,131,1,90,7,101,4,100,8,100,9,132,0,131,1,90,
+ 8,101,4,100,17,100,11,100,12,132,1,131,1,90,9,101,
+ 4,100,18,100,13,100,14,132,1,131,1,90,10,101,4,100,
+ 19,100,15,100,16,132,1,131,1,90,11,100,10,83,0,41,
+ 20,218,10,80,97,116,104,70,105,110,100,101,114,122,62,77,
+ 101,116,97,32,112,97,116,104,32,102,105,110,100,101,114,32,
+ 102,111,114,32,115,121,115,46,112,97,116,104,32,97,110,100,
+ 32,112,97,99,107,97,103,101,32,95,95,112,97,116,104,95,
+ 95,32,97,116,116,114,105,98,117,116,101,115,46,99,1,0,
+ 0,0,0,0,0,0,2,0,0,0,4,0,0,0,67,0,
+ 0,0,115,42,0,0,0,120,36,116,0,106,1,106,2,131,
+ 0,68,0,93,22,125,1,116,3,124,1,100,1,131,2,114,
+ 12,124,1,106,4,131,0,1,0,113,12,87,0,100,2,83,
+ 0,41,3,122,125,67,97,108,108,32,116,104,101,32,105,110,
+ 118,97,108,105,100,97,116,101,95,99,97,99,104,101,115,40,
+ 41,32,109,101,116,104,111,100,32,111,110,32,97,108,108,32,
+ 112,97,116,104,32,101,110,116,114,121,32,102,105,110,100,101,
+ 114,115,10,32,32,32,32,32,32,32,32,115,116,111,114,101,
+ 100,32,105,110,32,115,121,115,46,112,97,116,104,95,105,109,
+ 112,111,114,116,101,114,95,99,97,99,104,101,115,32,40,119,
+ 104,101,114,101,32,105,109,112,108,101,109,101,110,116,101,100,
+ 41,46,218,17,105,110,118,97,108,105,100,97,116,101,95,99,
+ 97,99,104,101,115,78,41,5,114,7,0,0,0,218,19,112,
+ 97,116,104,95,105,109,112,111,114,116,101,114,95,99,97,99,
+ 104,101,218,6,118,97,108,117,101,115,114,109,0,0,0,114,
+ 247,0,0,0,41,2,114,165,0,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,247,0,0,0,17,4,0,0,115,6,0,0,0,
+ 0,4,16,1,10,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,12,0,0,0,67,0,0,0,115,86,0,0,0,116,0,
+ 106,1,100,1,107,9,114,30,116,0,106,1,12,0,114,30,
+ 116,2,106,3,100,2,116,4,131,2,1,0,120,50,116,0,
+ 106,1,68,0,93,36,125,2,121,8,124,2,124,1,131,1,
+ 83,0,4,0,116,5,107,10,114,72,1,0,1,0,1,0,
+ 119,38,89,0,113,38,88,0,113,38,87,0,100,1,83,0,
+ 100,1,83,0,41,3,122,113,83,101,97,114,99,104,32,115,
+ 101,113,117,101,110,99,101,32,111,102,32,104,111,111,107,115,
+ 32,102,111,114,32,97,32,102,105,110,100,101,114,32,102,111,
+ 114,32,39,112,97,116,104,39,46,10,10,32,32,32,32,32,
+ 32,32,32,73,102,32,39,104,111,111,107,115,39,32,105,115,
+ 32,102,97,108,115,101,32,116,104,101,110,32,117,115,101,32,
+ 115,121,115,46,112,97,116,104,95,104,111,111,107,115,46,10,
+ 10,32,32,32,32,32,32,32,32,78,122,23,115,121,115,46,
+ 112,97,116,104,95,104,111,111,107,115,32,105,115,32,101,109,
+ 112,116,121,41,6,114,7,0,0,0,218,10,112,97,116,104,
+ 95,104,111,111,107,115,114,61,0,0,0,114,62,0,0,0,
+ 114,119,0,0,0,114,100,0,0,0,41,3,114,165,0,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,25,4,0,0,115,16,0,0,
+ 0,0,7,18,1,12,1,12,1,2,1,8,1,14,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,99,2,0,0,0,0,0,
+ 0,0,3,0,0,0,19,0,0,0,67,0,0,0,115,102,
+ 0,0,0,124,1,100,1,107,2,114,42,121,12,116,0,106,
+ 1,131,0,125,1,87,0,110,20,4,0,116,2,107,10,114,
+ 40,1,0,1,0,1,0,100,2,83,0,88,0,121,14,116,
+ 3,106,4,124,1,25,0,125,2,87,0,110,40,4,0,116,
+ 5,107,10,114,96,1,0,1,0,1,0,124,0,106,6,124,
+ 1,131,1,125,2,124,2,116,3,106,4,124,1,60,0,89,
+ 0,110,2,88,0,124,2,83,0,41,3,122,210,71,101,116,
+ 32,116,104,101,32,102,105,110,100,101,114,32,102,111,114,32,
+ 116,104,101,32,112,97,116,104,32,101,110,116,114,121,32,102,
+ 114,111,109,32,115,121,115,46,112,97,116,104,95,105,109,112,
+ 111,114,116,101,114,95,99,97,99,104,101,46,10,10,32,32,
+ 32,32,32,32,32,32,73,102,32,116,104,101,32,112,97,116,
+ 104,32,101,110,116,114,121,32,105,115,32,110,111,116,32,105,
+ 110,32,116,104,101,32,99,97,99,104,101,44,32,102,105,110,
+ 100,32,116,104,101,32,97,112,112,114,111,112,114,105,97,116,
+ 101,32,102,105,110,100,101,114,10,32,32,32,32,32,32,32,
+ 32,97,110,100,32,99,97,99,104,101,32,105,116,46,32,73,
+ 102,32,110,111,32,102,105,110,100,101,114,32,105,115,32,97,
+ 118,97,105,108,97,98,108,101,44,32,115,116,111,114,101,32,
+ 78,111,110,101,46,10,10,32,32,32,32,32,32,32,32,114,
+ 30,0,0,0,78,41,7,114,3,0,0,0,114,45,0,0,
+ 0,218,17,70,105,108,101,78,111,116,70,111,117,110,100,69,
+ 114,114,111,114,114,7,0,0,0,114,248,0,0,0,114,132,
+ 0,0,0,114,252,0,0,0,41,3,114,165,0,0,0,114,
+ 35,0,0,0,114,250,0,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,42,4,
+ 0,0,115,22,0,0,0,0,8,8,1,2,1,12,1,14,
+ 3,6,1,2,1,14,1,14,1,10,1,16,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,95,99,97,99,104,101,99,3,
+ 0,0,0,0,0,0,0,6,0,0,0,3,0,0,0,67,
+ 0,0,0,115,82,0,0,0,116,0,124,2,100,1,131,2,
+ 114,26,124,2,106,1,124,1,131,1,92,2,125,3,125,4,
+ 110,14,124,2,106,2,124,1,131,1,125,3,103,0,125,4,
+ 124,3,100,0,107,9,114,60,116,3,106,4,124,1,124,3,
+ 131,2,83,0,116,3,106,5,124,1,100,0,131,2,125,5,
+ 124,4,124,5,95,6,124,5,83,0,41,2,78,114,118,0,
+ 0,0,41,7,114,109,0,0,0,114,118,0,0,0,114,177,
+ 0,0,0,114,115,0,0,0,114,174,0,0,0,114,155,0,
+ 0,0,114,151,0,0,0,41,6,114,165,0,0,0,114,120,
+ 0,0,0,114,250,0,0,0,114,121,0,0,0,114,122,0,
+ 0,0,114,159,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,64,4,0,0,115,18,0,0,
+ 0,0,4,10,1,16,2,10,1,4,1,8,1,12,1,12,
+ 1,6,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,101,99,
+ 78,99,4,0,0,0,0,0,0,0,9,0,0,0,5,0,
+ 0,0,67,0,0,0,115,170,0,0,0,103,0,125,4,120,
+ 160,124,2,68,0,93,130,125,5,116,0,124,5,116,1,116,
+ 2,102,2,131,2,115,30,113,10,124,0,106,3,124,5,131,
+ 1,125,6,124,6,100,1,107,9,114,10,116,4,124,6,100,
+ 2,131,2,114,72,124,6,106,5,124,1,124,3,131,2,125,
+ 7,110,12,124,0,106,6,124,1,124,6,131,2,125,7,124,
+ 7,100,1,107,8,114,94,113,10,124,7,106,7,100,1,107,
+ 9,114,108,124,7,83,0,124,7,106,8,125,8,124,8,100,
+ 1,107,8,114,130,116,9,100,3,131,1,130,1,124,4,106,
+ 10,124,8,131,1,1,0,113,10,87,0,116,11,106,12,124,
+ 1,100,1,131,2,125,7,124,4,124,7,95,8,124,7,83,
+ 0,100,1,83,0,41,4,122,63,70,105,110,100,32,116,104,
+ 101,32,108,111,97,100,101,114,32,111,114,32,110,97,109,101,
+ 115,112,97,99,101,95,112,97,116,104,32,102,111,114,32,116,
+ 104,105,115,32,109,111,100,117,108,101,47,112,97,99,107,97,
+ 103,101,32,110,97,109,101,46,78,114,176,0,0,0,122,19,
+ 115,112,101,99,32,109,105,115,115,105,110,103,32,108,111,97,
+ 100,101,114,41,13,114,138,0,0,0,114,70,0,0,0,218,
+ 5,98,121,116,101,115,114,254,0,0,0,114,109,0,0,0,
+ 114,176,0,0,0,114,255,0,0,0,114,121,0,0,0,114,
+ 151,0,0,0,114,100,0,0,0,114,144,0,0,0,114,115,
+ 0,0,0,114,155,0,0,0,41,9,114,165,0,0,0,114,
+ 120,0,0,0,114,35,0,0,0,114,175,0,0,0,218,14,
+ 110,97,109,101,115,112,97,99,101,95,112,97,116,104,90,5,
+ 101,110,116,114,121,114,250,0,0,0,114,159,0,0,0,114,
+ 122,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,79,4,
+ 0,0,115,40,0,0,0,0,5,4,1,10,1,14,1,2,
+ 1,10,1,8,1,10,1,14,2,12,1,8,1,2,1,10,
+ 1,4,1,6,1,8,1,8,5,14,2,12,1,6,1,122,
+ 20,80,97,116,104,70,105,110,100,101,114,46,95,103,101,116,
+ 95,115,112,101,99,99,4,0,0,0,0,0,0,0,6,0,
+ 0,0,4,0,0,0,67,0,0,0,115,104,0,0,0,124,
+ 2,100,1,107,8,114,14,116,0,106,1,125,2,124,0,106,
+ 2,124,1,124,2,124,3,131,3,125,4,124,4,100,1,107,
+ 8,114,42,100,1,83,0,110,58,124,4,106,3,100,1,107,
+ 8,114,96,124,4,106,4,125,5,124,5,114,90,100,2,124,
+ 4,95,5,116,6,124,1,124,5,124,0,106,2,131,3,124,
+ 4,95,4,124,4,83,0,113,100,100,1,83,0,110,4,124,
+ 4,83,0,100,1,83,0,41,3,122,98,102,105,110,100,32,
+ 116,104,101,32,109,111,100,117,108,101,32,111,110,32,115,121,
+ 115,46,112,97,116,104,32,111,114,32,39,112,97,116,104,39,
+ 32,98,97,115,101,100,32,111,110,32,115,121,115,46,112,97,
+ 116,104,95,104,111,111,107,115,32,97,110,100,10,32,32,32,
+ 32,32,32,32,32,115,121,115,46,112,97,116,104,95,105,109,
+ 112,111,114,116,101,114,95,99,97,99,104,101,46,78,90,9,
+ 110,97,109,101,115,112,97,99,101,41,7,114,7,0,0,0,
+ 114,35,0,0,0,114,2,1,0,0,114,121,0,0,0,114,
+ 151,0,0,0,114,153,0,0,0,114,225,0,0,0,41,6,
+ 114,165,0,0,0,114,120,0,0,0,114,35,0,0,0,114,
+ 175,0,0,0,114,159,0,0,0,114,1,1,0,0,114,4,
+ 0,0,0,114,4,0,0,0,114,5,0,0,0,114,176,0,
+ 0,0,111,4,0,0,115,26,0,0,0,0,4,8,1,6,
+ 1,14,1,8,1,6,1,10,1,6,1,4,3,6,1,16,
+ 1,6,2,6,2,122,20,80,97,116,104,70,105,110,100,101,
+ 114,46,102,105,110,100,95,115,112,101,99,99,3,0,0,0,
+ 0,0,0,0,4,0,0,0,3,0,0,0,67,0,0,0,
+ 115,30,0,0,0,124,0,106,0,124,1,124,2,131,2,125,
+ 3,124,3,100,1,107,8,114,24,100,1,83,0,124,3,106,
+ 1,83,0,41,2,122,170,102,105,110,100,32,116,104,101,32,
+ 109,111,100,117,108,101,32,111,110,32,115,121,115,46,112,97,
+ 116,104,32,111,114,32,39,112,97,116,104,39,32,98,97,115,
+ 101,100,32,111,110,32,115,121,115,46,112,97,116,104,95,104,
+ 111,111,107,115,32,97,110,100,10,32,32,32,32,32,32,32,
+ 32,115,121,115,46,112,97,116,104,95,105,109,112,111,114,116,
+ 101,114,95,99,97,99,104,101,46,10,10,32,32,32,32,32,
+ 32,32,32,84,104,105,115,32,109,101,116,104,111,100,32,105,
+ 115,32,100,101,112,114,101,99,97,116,101,100,46,32,32,85,
+ 115,101,32,102,105,110,100,95,115,112,101,99,40,41,32,105,
+ 110,115,116,101,97,100,46,10,10,32,32,32,32,32,32,32,
+ 32,78,41,2,114,176,0,0,0,114,121,0,0,0,41,4,
+ 114,165,0,0,0,114,120,0,0,0,114,35,0,0,0,114,
+ 159,0,0,0,114,4,0,0,0,114,4,0,0,0,114,5,
+ 0,0,0,114,177,0,0,0,133,4,0,0,115,8,0,0,
+ 0,0,8,12,1,8,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,1,78,41,2,78,78,41,1,78,41,12,114,106,0,
+ 0,0,114,105,0,0,0,114,107,0,0,0,114,108,0,0,
+ 0,114,178,0,0,0,114,247,0,0,0,114,252,0,0,0,
+ 114,254,0,0,0,114,255,0,0,0,114,2,1,0,0,114,
+ 176,0,0,0,114,177,0,0,0,114,4,0,0,0,114,4,
+ 0,0,0,114,4,0,0,0,114,5,0,0,0,114,246,0,
+ 0,0,13,4,0,0,115,22,0,0,0,8,2,4,2,12,
+ 8,12,17,12,22,12,15,2,1,12,31,2,1,12,21,2,
+ 1,114,246,0,0,0,99,0,0,0,0,0,0,0,0,0,
+ 0,0,0,3,0,0,0,64,0,0,0,115,90,0,0,0,
+ 101,0,90,1,100,0,90,2,100,1,90,3,100,2,100,3,
+ 132,0,90,4,100,4,100,5,132,0,90,5,101,6,90,7,
+ 100,6,100,7,132,0,90,8,100,8,100,9,132,0,90,9,
+ 100,19,100,11,100,12,132,1,90,10,100,13,100,14,132,0,
+ 90,11,101,12,100,15,100,16,132,0,131,1,90,13,100,17,
+ 100,18,132,0,90,14,100,10,83,0,41,20,218,10,70,105,
+ 108,101,70,105,110,100,101,114,122,172,70,105,108,101,45,98,
+ 97,115,101,100,32,102,105,110,100,101,114,46,10,10,32,32,
+ 32,32,73,110,116,101,114,97,99,116,105,111,110,115,32,119,
+ 105,116,104,32,116,104,101,32,102,105,108,101,32,115,121,115,
+ 116,101,109,32,97,114,101,32,99,97,99,104,101,100,32,102,
+ 111,114,32,112,101,114,102,111,114,109,97,110,99,101,44,32,
+ 98,101,105,110,103,10,32,32,32,32,114,101,102,114,101,115,
+ 104,101,100,32,119,104,101,110,32,116,104,101,32,100,105,114,
+ 101,99,116,111,114,121,32,116,104,101,32,102,105,110,100,101,
+ 114,32,105,115,32,104,97,110,100,108,105,110,103,32,104,97,
+ 115,32,98,101,101,110,32,109,111,100,105,102,105,101,100,46,
+ 10,10,32,32,32,32,99,2,0,0,0,0,0,0,0,5,
+ 0,0,0,5,0,0,0,7,0,0,0,115,88,0,0,0,
+ 103,0,125,3,120,40,124,2,68,0,93,32,92,2,137,0,
+ 125,4,124,3,106,0,135,0,102,1,100,1,100,2,132,8,
+ 124,4,68,0,131,1,131,1,1,0,113,10,87,0,124,3,
+ 124,0,95,1,124,1,112,58,100,3,124,0,95,2,100,6,
+ 124,0,95,3,116,4,131,0,124,0,95,5,116,4,131,0,
+ 124,0,95,6,100,5,83,0,41,7,122,154,73,110,105,116,
+ 105,97,108,105,122,101,32,119,105,116,104,32,116,104,101,32,
+ 112,97,116,104,32,116,111,32,115,101,97,114,99,104,32,111,
+ 110,32,97,110,100,32,97,32,118,97,114,105,97,98,108,101,
+ 32,110,117,109,98,101,114,32,111,102,10,32,32,32,32,32,
+ 32,32,32,50,45,116,117,112,108,101,115,32,99,111,110,116,
+ 97,105,110,105,110,103,32,116,104,101,32,108,111,97,100,101,
+ 114,32,97,110,100,32,116,104,101,32,102,105,108,101,32,115,
+ 117,102,102,105,120,101,115,32,116,104,101,32,108,111,97,100,
+ 101,114,10,32,32,32,32,32,32,32,32,114,101,99,111,103,
+ 110,105,122,101,115,46,99,1,0,0,0,0,0,0,0,2,
+ 0,0,0,3,0,0,0,51,0,0,0,115,22,0,0,0,
+ 124,0,93,14,125,1,124,1,136,0,102,2,86,0,1,0,
+ 113,2,100,0,83,0,41,1,78,114,4,0,0,0,41,2,
+ 114,22,0,0,0,114,220,0,0,0,41,1,114,121,0,0,
+ 0,114,4,0,0,0,114,5,0,0,0,114,222,0,0,0,
+ 162,4,0,0,115,2,0,0,0,4,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,59,0,0,0,114,29,0,0,0,78,114,88,
+ 0,0,0,41,7,114,144,0,0,0,218,8,95,108,111,97,
+ 100,101,114,115,114,35,0,0,0,218,11,95,112,97,116,104,
+ 95,109,116,105,109,101,218,3,115,101,116,218,11,95,112,97,
+ 116,104,95,99,97,99,104,101,218,19,95,114,101,108,97,120,
+ 101,100,95,112,97,116,104,95,99,97,99,104,101,41,5,114,
+ 101,0,0,0,114,35,0,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,161,0,0,0,114,4,0,0,0,41,1,114,121,
+ 0,0,0,114,5,0,0,0,114,180,0,0,0,156,4,0,
+ 0,115,16,0,0,0,0,4,4,1,14,1,28,1,6,2,
+ 10,1,6,1,8,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,0,2,0,0,0,67,0,0,0,
+ 115,10,0,0,0,100,3,124,0,95,0,100,2,83,0,41,
+ 4,122,31,73,110,118,97,108,105,100,97,116,101,32,116,104,
+ 101,32,100,105,114,101,99,116,111,114,121,32,109,116,105,109,
+ 101,46,114,29,0,0,0,78,114,88,0,0,0,41,1,114,
+ 5,1,0,0,41,1,114,101,0,0,0,114,4,0,0,0,
+ 114,4,0,0,0,114,5,0,0,0,114,247,0,0,0,170,
+ 4,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,0,2,0,0,0,67,0,0,0,115,42,0,
+ 0,0,124,0,106,0,124,1,131,1,125,2,124,2,100,1,
+ 107,8,114,26,100,1,103,0,102,2,83,0,124,2,106,1,
+ 124,2,106,2,112,38,103,0,102,2,83,0,41,2,122,197,
+ 84,114,121,32,116,111,32,102,105,110,100,32,97,32,108,111,
+ 97,100,101,114,32,102,111,114,32,116,104,101,32,115,112,101,
+ 99,105,102,105,101,100,32,109,111,100,117,108,101,44,32,111,
+ 114,32,116,104,101,32,110,97,109,101,115,112,97,99,101,10,
+ 32,32,32,32,32,32,32,32,112,97,99,107,97,103,101,32,
+ 112,111,114,116,105,111,110,115,46,32,82,101,116,117,114,110,
+ 115,32,40,108,111,97,100,101,114,44,32,108,105,115,116,45,
+ 111,102,45,112,111,114,116,105,111,110,115,41,46,10,10,32,
+ 32,32,32,32,32,32,32,84,104,105,115,32,109,101,116,104,
+ 111,100,32,105,115,32,100,101,112,114,101,99,97,116,101,100,
+ 46,32,32,85,115,101,32,102,105,110,100,95,115,112,101,99,
+ 40,41,32,105,110,115,116,101,97,100,46,10,10,32,32,32,
+ 32,32,32,32,32,78,41,3,114,176,0,0,0,114,121,0,
+ 0,0,114,151,0,0,0,41,3,114,101,0,0,0,114,120,
+ 0,0,0,114,159,0,0,0,114,4,0,0,0,114,4,0,
+ 0,0,114,5,0,0,0,114,118,0,0,0,176,4,0,0,
+ 115,8,0,0,0,0,7,10,1,8,1,8,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,0,0,0,67,0,0,0,115,30,0,0,0,124,
+ 1,124,2,124,3,131,2,125,6,116,0,124,2,124,3,100,
+ 1,124,6,100,2,124,4,144,2,131,2,83,0,41,3,78,
+ 114,121,0,0,0,114,151,0,0,0,41,1,114,162,0,0,
+ 0,41,7,114,101,0,0,0,114,160,0,0,0,114,120,0,
+ 0,0,114,35,0,0,0,90,4,115,109,115,108,114,175,0,
+ 0,0,114,121,0,0,0,114,4,0,0,0,114,4,0,0,
+ 0,114,5,0,0,0,114,2,1,0,0,188,4,0,0,115,
+ 6,0,0,0,0,1,10,1,12,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,100,1,0,0,100,1,125,3,124,
+ 1,106,0,100,2,131,1,100,3,25,0,125,4,121,24,116,
+ 1,124,0,106,2,112,34,116,3,106,4,131,0,131,1,106,
+ 5,125,5,87,0,110,24,4,0,116,6,107,10,114,66,1,
+ 0,1,0,1,0,100,10,125,5,89,0,110,2,88,0,124,
+ 5,124,0,106,7,107,3,114,92,124,0,106,8,131,0,1,
+ 0,124,5,124,0,95,7,116,9,131,0,114,114,124,0,106,
+ 10,125,6,124,4,106,11,131,0,125,7,110,10,124,0,106,
+ 12,125,6,124,4,125,7,124,7,124,6,107,6,114,218,116,
+ 13,124,0,106,2,124,4,131,2,125,8,120,72,124,0,106,
+ 14,68,0,93,54,92,2,125,9,125,10,100,5,124,9,23,
+ 0,125,11,116,13,124,8,124,11,131,2,125,12,116,15,124,
+ 12,131,1,114,152,124,0,106,16,124,10,124,1,124,12,124,
+ 8,103,1,124,2,131,5,83,0,113,152,87,0,116,17,124,
+ 8,131,1,125,3,120,90,124,0,106,14,68,0,93,80,92,
+ 2,125,9,125,10,116,13,124,0,106,2,124,4,124,9,23,
+ 0,131,2,125,12,116,18,106,19,100,6,124,12,100,7,100,
+ 3,144,1,131,2,1,0,124,7,124,9,23,0,124,6,107,
+ 6,114,226,116,15,124,12,131,1,114,226,124,0,106,16,124,
+ 10,124,1,124,12,100,8,124,2,131,5,83,0,113,226,87,
+ 0,124,3,144,1,114,96,116,18,106,19,100,9,124,8,131,
+ 2,1,0,116,18,106,20,124,1,100,8,131,2,125,13,124,
+ 8,103,1,124,13,95,21,124,13,83,0,100,8,83,0,41,
+ 11,122,102,84,114,121,32,116,111,32,102,105,110,100,32,97,
+ 32,115,112,101,99,32,102,111,114,32,116,104,101,32,115,112,
+ 101,99,105,102,105,101,100,32,109,111,100,117,108,101,46,32,
+ 32,82,101,116,117,114,110,115,32,116,104,101,10,32,32,32,
+ 32,32,32,32,32,109,97,116,99,104,105,110,103,32,115,112,
+ 101,99,44,32,111,114,32,78,111,110,101,32,105,102,32,110,
+ 111,116,32,102,111,117,110,100,46,70,114,59,0,0,0,114,
+ 57,0,0,0,114,29,0,0,0,114,180,0,0,0,122,9,
+ 116,114,121,105,110,103,32,123,125,90,9,118,101,114,98,111,
+ 115,105,116,121,78,122,25,112,111,115,115,105,98,108,101,32,
+ 110,97,109,101,115,112,97,99,101,32,102,111,114,32,123,125,
+ 114,88,0,0,0,41,22,114,32,0,0,0,114,39,0,0,
+ 0,114,35,0,0,0,114,3,0,0,0,114,45,0,0,0,
+ 114,214,0,0,0,114,40,0,0,0,114,5,1,0,0,218,
+ 11,95,102,105,108,108,95,99,97,99,104,101,114,6,0,0,
+ 0,114,8,1,0,0,114,89,0,0,0,114,7,1,0,0,
+ 114,28,0,0,0,114,4,1,0,0,114,44,0,0,0,114,
+ 2,1,0,0,114,46,0,0,0,114,115,0,0,0,114,130,
+ 0,0,0,114,155,0,0,0,114,151,0,0,0,41,14,114,
+ 101,0,0,0,114,120,0,0,0,114,175,0,0,0,90,12,
+ 105,115,95,110,97,109,101,115,112,97,99,101,90,11,116,97,
+ 105,108,95,109,111,100,117,108,101,114,127,0,0,0,90,5,
+ 99,97,99,104,101,90,12,99,97,99,104,101,95,109,111,100,
+ 117,108,101,90,9,98,97,115,101,95,112,97,116,104,114,220,
+ 0,0,0,114,160,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,159,0,0,0,114,4,0,0,0,114,4,0,0,
+ 0,114,5,0,0,0,114,176,0,0,0,193,4,0,0,115,
+ 70,0,0,0,0,3,4,1,14,1,2,1,24,1,14,1,
+ 10,1,10,1,8,1,6,2,6,1,6,1,10,2,6,1,
+ 4,2,8,1,12,1,16,1,8,1,10,1,8,1,24,4,
+ 8,2,16,1,16,1,18,1,12,1,8,1,10,1,12,1,
+ 6,1,12,1,12,1,8,1,4,1,122,20,70,105,108,101,
+ 70,105,110,100,101,114,46,102,105,110,100,95,115,112,101,99,
+ 99,1,0,0,0,0,0,0,0,9,0,0,0,13,0,0,
+ 0,67,0,0,0,115,194,0,0,0,124,0,106,0,125,1,
+ 121,22,116,1,106,2,124,1,112,22,116,1,106,3,131,0,
+ 131,1,125,2,87,0,110,30,4,0,116,4,116,5,116,6,
+ 102,3,107,10,114,58,1,0,1,0,1,0,103,0,125,2,
+ 89,0,110,2,88,0,116,7,106,8,106,9,100,1,131,1,
+ 115,84,116,10,124,2,131,1,124,0,95,11,110,78,116,10,
+ 131,0,125,3,120,64,124,2,68,0,93,56,125,4,124,4,
+ 106,12,100,2,131,1,92,3,125,5,125,6,125,7,124,6,
+ 114,138,100,3,106,13,124,5,124,7,106,14,131,0,131,2,
+ 125,8,110,4,124,5,125,8,124,3,106,15,124,8,131,1,
+ 1,0,113,96,87,0,124,3,124,0,95,11,116,7,106,8,
+ 106,9,116,16,131,1,114,190,100,4,100,5,132,0,124,2,
+ 68,0,131,1,124,0,95,17,100,6,83,0,41,7,122,68,
+ 70,105,108,108,32,116,104,101,32,99,97,99,104,101,32,111,
+ 102,32,112,111,116,101,110,116,105,97,108,32,109,111,100,117,
+ 108,101,115,32,97,110,100,32,112,97,99,107,97,103,101,115,
+ 32,102,111,114,32,116,104,105,115,32,100,105,114,101,99,116,
+ 111,114,121,46,114,0,0,0,0,114,59,0,0,0,122,5,
+ 123,125,46,123,125,99,1,0,0,0,0,0,0,0,2,0,
+ 0,0,3,0,0,0,83,0,0,0,115,20,0,0,0,104,
+ 0,124,0,93,12,125,1,124,1,106,0,131,0,146,2,113,
+ 4,83,0,114,4,0,0,0,41,1,114,89,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,12,5,0,0,115,2,0,0,0,6,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,41,18,114,35,0,
+ 0,0,114,3,0,0,0,90,7,108,105,115,116,100,105,114,
+ 114,45,0,0,0,114,253,0,0,0,218,15,80,101,114,109,
+ 105,115,115,105,111,110,69,114,114,111,114,218,18,78,111,116,
+ 65,68,105,114,101,99,116,111,114,121,69,114,114,111,114,114,
+ 7,0,0,0,114,8,0,0,0,114,9,0,0,0,114,6,
+ 1,0,0,114,7,1,0,0,114,84,0,0,0,114,48,0,
+ 0,0,114,89,0,0,0,218,3,97,100,100,114,10,0,0,
+ 0,114,8,1,0,0,41,9,114,101,0,0,0,114,35,0,
+ 0,0,90,8,99,111,110,116,101,110,116,115,90,21,108,111,
+ 119,101,114,95,115,117,102,102,105,120,95,99,111,110,116,101,
+ 110,116,115,114,242,0,0,0,114,99,0,0,0,114,232,0,
+ 0,0,114,220,0,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,10,1,0,0,239,4,0,0,115,34,0,0,0,0,2,
+ 6,1,2,1,22,1,20,3,10,3,12,1,12,7,6,1,
+ 10,1,16,1,4,1,18,2,4,1,14,1,6,1,12,1,
+ 122,22,70,105,108,101,70,105,110,100,101,114,46,95,102,105,
+ 108,108,95,99,97,99,104,101,99,1,0,0,0,0,0,0,
+ 0,3,0,0,0,3,0,0,0,7,0,0,0,115,18,0,
+ 0,0,135,0,135,1,102,2,100,1,100,2,132,8,125,2,
+ 124,2,83,0,41,3,97,20,1,0,0,65,32,99,108,97,
+ 115,115,32,109,101,116,104,111,100,32,119,104,105,99,104,32,
+ 114,101,116,117,114,110,115,32,97,32,99,108,111,115,117,114,
+ 101,32,116,111,32,117,115,101,32,111,110,32,115,121,115,46,
+ 112,97,116,104,95,104,111,111,107,10,32,32,32,32,32,32,
+ 32,32,119,104,105,99,104,32,119,105,108,108,32,114,101,116,
+ 117,114,110,32,97,110,32,105,110,115,116,97,110,99,101,32,
+ 117,115,105,110,103,32,116,104,101,32,115,112,101,99,105,102,
+ 105,101,100,32,108,111,97,100,101,114,115,32,97,110,100,32,
+ 116,104,101,32,112,97,116,104,10,32,32,32,32,32,32,32,
+ 32,99,97,108,108,101,100,32,111,110,32,116,104,101,32,99,
+ 108,111,115,117,114,101,46,10,10,32,32,32,32,32,32,32,
+ 32,73,102,32,116,104,101,32,112,97,116,104,32,99,97,108,
+ 108,101,100,32,111,110,32,116,104,101,32,99,108,111,115,117,
+ 114,101,32,105,115,32,110,111,116,32,97,32,100,105,114,101,
+ 99,116,111,114,121,44,32,73,109,112,111,114,116,69,114,114,
+ 111,114,32,105,115,10,32,32,32,32,32,32,32,32,114,97,
+ 105,115,101,100,46,10,10,32,32,32,32,32,32,32,32,99,
+ 1,0,0,0,0,0,0,0,1,0,0,0,4,0,0,0,
+ 19,0,0,0,115,32,0,0,0,116,0,124,0,131,1,115,
+ 22,116,1,100,1,100,2,124,0,144,1,131,1,130,1,136,
+ 0,124,0,136,1,140,1,83,0,41,3,122,45,80,97,116,
+ 104,32,104,111,111,107,32,102,111,114,32,105,109,112,111,114,
+ 116,108,105,98,46,109,97,99,104,105,110,101,114,121,46,70,
+ 105,108,101,70,105,110,100,101,114,46,122,30,111,110,108,121,
+ 32,100,105,114,101,99,116,111,114,105,101,115,32,97,114,101,
+ 32,115,117,112,112,111,114,116,101,100,114,35,0,0,0,41,
+ 2,114,46,0,0,0,114,100,0,0,0,41,1,114,35,0,
+ 0,0,41,2,114,165,0,0,0,114,9,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,24,5,0,0,115,6,0,0,0,0,2,8,1,14,
+ 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,111,107,95,102,111,114,95,70,
+ 105,108,101,70,105,110,100,101,114,114,4,0,0,0,41,3,
+ 114,165,0,0,0,114,9,1,0,0,114,15,1,0,0,114,
+ 4,0,0,0,41,2,114,165,0,0,0,114,9,1,0,0,
+ 114,5,0,0,0,218,9,112,97,116,104,95,104,111,111,107,
+ 14,5,0,0,115,4,0,0,0,0,10,14,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,115,12,0,0,0,100,1,106,
+ 0,124,0,106,1,131,1,83,0,41,2,78,122,16,70,105,
+ 108,101,70,105,110,100,101,114,40,123,33,114,125,41,41,2,
+ 114,48,0,0,0,114,35,0,0,0,41,1,114,101,0,0,
+ 0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,0,
+ 114,241,0,0,0,32,5,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,1,78,41,15,114,106,0,0,0,114,
+ 105,0,0,0,114,107,0,0,0,114,108,0,0,0,114,180,
+ 0,0,0,114,247,0,0,0,114,124,0,0,0,114,177,0,
+ 0,0,114,118,0,0,0,114,2,1,0,0,114,176,0,0,
+ 0,114,10,1,0,0,114,178,0,0,0,114,16,1,0,0,
+ 114,241,0,0,0,114,4,0,0,0,114,4,0,0,0,114,
+ 4,0,0,0,114,5,0,0,0,114,3,1,0,0,147,4,
+ 0,0,115,20,0,0,0,8,7,4,2,8,14,8,4,4,
+ 2,8,12,8,5,10,46,8,31,12,18,114,3,1,0,0,
+ 99,4,0,0,0,0,0,0,0,6,0,0,0,11,0,0,
+ 0,67,0,0,0,115,148,0,0,0,124,0,106,0,100,1,
+ 131,1,125,4,124,0,106,0,100,2,131,1,125,5,124,4,
+ 115,66,124,5,114,36,124,5,106,1,125,4,110,30,124,2,
+ 124,3,107,2,114,56,116,2,124,1,124,2,131,2,125,4,
+ 110,10,116,3,124,1,124,2,131,2,125,4,124,5,115,86,
+ 116,4,124,1,124,2,100,3,124,4,144,1,131,2,125,5,
+ 121,36,124,5,124,0,100,2,60,0,124,4,124,0,100,1,
+ 60,0,124,2,124,0,100,4,60,0,124,3,124,0,100,5,
+ 60,0,87,0,110,20,4,0,116,5,107,10,114,142,1,0,
+ 1,0,1,0,89,0,110,2,88,0,100,0,83,0,41,6,
+ 78,218,10,95,95,108,111,97,100,101,114,95,95,218,8,95,
+ 95,115,112,101,99,95,95,114,121,0,0,0,90,8,95,95,
+ 102,105,108,101,95,95,90,10,95,95,99,97,99,104,101,100,
+ 95,95,41,6,218,3,103,101,116,114,121,0,0,0,114,218,
+ 0,0,0,114,213,0,0,0,114,162,0,0,0,218,9,69,
+ 120,99,101,112,116,105,111,110,41,6,90,2,110,115,114,99,
+ 0,0,0,90,8,112,97,116,104,110,97,109,101,90,9,99,
+ 112,97,116,104,110,97,109,101,114,121,0,0,0,114,159,0,
+ 0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,
+ 0,218,14,95,102,105,120,95,117,112,95,109,111,100,117,108,
+ 101,38,5,0,0,115,34,0,0,0,0,2,10,1,10,1,
+ 4,1,4,1,8,1,8,1,12,2,10,1,4,1,16,1,
+ 2,1,8,1,8,1,8,1,12,1,14,2,114,21,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,38,0,0,0,116,0,116,1,106,
+ 2,131,0,102,2,125,0,116,3,116,4,102,2,125,1,116,
+ 5,116,6,102,2,125,2,124,0,124,1,124,2,103,3,83,
+ 0,41,1,122,95,82,101,116,117,114,110,115,32,97,32,108,
+ 105,115,116,32,111,102,32,102,105,108,101,45,98,97,115,101,
+ 100,32,109,111,100,117,108,101,32,108,111,97,100,101,114,115,
+ 46,10,10,32,32,32,32,69,97,99,104,32,105,116,101,109,
+ 32,105,115,32,97,32,116,117,112,108,101,32,40,108,111,97,
+ 100,101,114,44,32,115,117,102,102,105,120,101,115,41,46,10,
+ 32,32,32,32,41,7,114,219,0,0,0,114,140,0,0,0,
+ 218,18,101,120,116,101,110,115,105,111,110,95,115,117,102,102,
+ 105,120,101,115,114,213,0,0,0,114,85,0,0,0,114,218,
+ 0,0,0,114,75,0,0,0,41,3,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,156,0,0,0,61,5,0,0,
+ 115,8,0,0,0,0,5,12,1,8,1,8,1,114,156,0,
+ 0,0,99,1,0,0,0,0,0,0,0,12,0,0,0,12,
+ 0,0,0,67,0,0,0,115,188,1,0,0,124,0,97,0,
+ 116,0,106,1,97,1,116,0,106,2,97,2,116,1,106,3,
+ 116,4,25,0,125,1,120,56,100,26,68,0,93,48,125,2,
+ 124,2,116,1,106,3,107,7,114,58,116,0,106,5,124,2,
+ 131,1,125,3,110,10,116,1,106,3,124,2,25,0,125,3,
+ 116,6,124,1,124,2,124,3,131,3,1,0,113,32,87,0,
+ 100,5,100,6,103,1,102,2,100,7,100,8,100,6,103,2,
+ 102,2,102,2,125,4,120,118,124,4,68,0,93,102,92,2,
+ 125,5,125,6,116,7,100,9,100,10,132,0,124,6,68,0,
+ 131,1,131,1,115,142,116,8,130,1,124,6,100,11,25,0,
+ 125,7,124,5,116,1,106,3,107,6,114,174,116,1,106,3,
+ 124,5,25,0,125,8,80,0,113,112,121,16,116,0,106,5,
+ 124,5,131,1,125,8,80,0,87,0,113,112,4,0,116,9,
+ 107,10,114,212,1,0,1,0,1,0,119,112,89,0,113,112,
+ 88,0,113,112,87,0,116,9,100,12,131,1,130,1,116,6,
+ 124,1,100,13,124,8,131,3,1,0,116,6,124,1,100,14,
+ 124,7,131,3,1,0,116,6,124,1,100,15,100,16,106,10,
+ 124,6,131,1,131,3,1,0,121,14,116,0,106,5,100,17,
+ 131,1,125,9,87,0,110,26,4,0,116,9,107,10,144,1,
+ 114,52,1,0,1,0,1,0,100,18,125,9,89,0,110,2,
+ 88,0,116,6,124,1,100,17,124,9,131,3,1,0,116,0,
+ 106,5,100,19,131,1,125,10,116,6,124,1,100,19,124,10,
+ 131,3,1,0,124,5,100,7,107,2,144,1,114,120,116,0,
+ 106,5,100,20,131,1,125,11,116,6,124,1,100,21,124,11,
+ 131,3,1,0,116,6,124,1,100,22,116,11,131,0,131,3,
+ 1,0,116,12,106,13,116,2,106,14,131,0,131,1,1,0,
+ 124,5,100,7,107,2,144,1,114,184,116,15,106,16,100,23,
+ 131,1,1,0,100,24,116,12,107,6,144,1,114,184,100,25,
+ 116,17,95,18,100,18,83,0,41,27,122,205,83,101,116,117,
+ 112,32,116,104,101,32,112,97,116,104,45,98,97,115,101,100,
+ 32,105,109,112,111,114,116,101,114,115,32,102,111,114,32,105,
+ 109,112,111,114,116,108,105,98,32,98,121,32,105,109,112,111,
+ 114,116,105,110,103,32,110,101,101,100,101,100,10,32,32,32,
+ 32,98,117,105,108,116,45,105,110,32,109,111,100,117,108,101,
+ 115,32,97,110,100,32,105,110,106,101,99,116,105,110,103,32,
+ 116,104,101,109,32,105,110,116,111,32,116,104,101,32,103,108,
+ 111,98,97,108,32,110,97,109,101,115,112,97,99,101,46,10,
+ 10,32,32,32,32,79,116,104,101,114,32,99,111,109,112,111,
+ 110,101,110,116,115,32,97,114,101,32,101,120,116,114,97,99,
+ 116,101,100,32,102,114,111,109,32,116,104,101,32,99,111,114,
+ 101,32,98,111,111,116,115,116,114,97,112,32,109,111,100,117,
+ 108,101,46,10,10,32,32,32,32,114,50,0,0,0,114,61,
+ 0,0,0,218,8,98,117,105,108,116,105,110,115,114,137,0,
+ 0,0,90,5,112,111,115,105,120,250,1,47,218,2,110,116,
+ 250,1,92,99,1,0,0,0,0,0,0,0,2,0,0,0,
+ 3,0,0,0,115,0,0,0,115,26,0,0,0,124,0,93,
+ 18,125,1,116,0,124,1,131,1,100,0,107,2,86,0,1,
+ 0,113,2,100,1,83,0,41,2,114,29,0,0,0,78,41,
+ 1,114,31,0,0,0,41,2,114,22,0,0,0,114,78,0,
+ 0,0,114,4,0,0,0,114,4,0,0,0,114,5,0,0,
+ 0,114,222,0,0,0,97,5,0,0,115,2,0,0,0,4,
+ 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,60,0,0,
+ 0,122,30,105,109,112,111,114,116,108,105,98,32,114,101,113,
+ 117,105,114,101,115,32,112,111,115,105,120,32,111,114,32,110,
+ 116,114,3,0,0,0,114,25,0,0,0,114,21,0,0,0,
+ 114,30,0,0,0,90,7,95,116,104,114,101,97,100,78,90,
+ 8,95,119,101,97,107,114,101,102,90,6,119,105,110,114,101,
+ 103,114,164,0,0,0,114,6,0,0,0,122,4,46,112,121,
+ 119,122,6,95,100,46,112,121,100,84,41,4,122,3,95,105,
+ 111,122,9,95,119,97,114,110,105,110,103,115,122,8,98,117,
+ 105,108,116,105,110,115,122,7,109,97,114,115,104,97,108,41,
+ 19,114,115,0,0,0,114,7,0,0,0,114,140,0,0,0,
+ 114,234,0,0,0,114,106,0,0,0,90,18,95,98,117,105,
+ 108,116,105,110,95,102,114,111,109,95,110,97,109,101,114,110,
+ 0,0,0,218,3,97,108,108,218,14,65,115,115,101,114,116,
+ 105,111,110,69,114,114,111,114,114,100,0,0,0,114,26,0,
+ 0,0,114,11,0,0,0,114,224,0,0,0,114,144,0,0,
+ 0,114,22,1,0,0,114,85,0,0,0,114,158,0,0,0,
+ 114,163,0,0,0,114,168,0,0,0,41,12,218,17,95,98,
+ 111,111,116,115,116,114,97,112,95,109,111,100,117,108,101,90,
+ 11,115,101,108,102,95,109,111,100,117,108,101,90,12,98,117,
+ 105,108,116,105,110,95,110,97,109,101,90,14,98,117,105,108,
+ 116,105,110,95,109,111,100,117,108,101,90,10,111,115,95,100,
+ 101,116,97,105,108,115,90,10,98,117,105,108,116,105,110,95,
+ 111,115,114,21,0,0,0,114,25,0,0,0,90,9,111,115,
+ 95,109,111,100,117,108,101,90,13,116,104,114,101,97,100,95,
+ 109,111,100,117,108,101,90,14,119,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,72,5,0,0,
+ 115,82,0,0,0,0,8,4,1,6,1,6,3,10,1,10,
+ 1,10,1,12,2,10,1,16,3,22,1,14,2,22,1,8,
+ 1,10,1,10,1,4,2,2,1,10,1,6,1,14,1,12,
+ 2,8,1,12,1,12,1,18,3,2,1,14,1,16,2,10,
+ 1,12,3,10,1,12,3,10,1,10,1,12,3,14,1,14,
+ 1,10,1,10,1,10,1,114,30,1,0,0,99,1,0,0,
+ 0,0,0,0,0,2,0,0,0,3,0,0,0,67,0,0,
+ 0,115,84,0,0,0,116,0,124,0,131,1,1,0,116,1,
+ 131,0,125,1,116,2,106,3,106,4,116,5,106,6,124,1,
+ 140,0,103,1,131,1,1,0,116,7,106,8,100,1,107,2,
+ 114,56,116,2,106,9,106,10,116,11,131,1,1,0,116,2,
+ 106,9,106,10,116,12,131,1,1,0,116,5,124,0,95,5,
+ 116,13,124,0,95,13,100,2,83,0,41,3,122,41,73,110,
+ 115,116,97,108,108,32,116,104,101,32,112,97,116,104,45,98,
+ 97,115,101,100,32,105,109,112,111,114,116,32,99,111,109,112,
+ 111,110,101,110,116,115,46,114,25,1,0,0,78,41,14,114,
+ 30,1,0,0,114,156,0,0,0,114,7,0,0,0,114,251,
+ 0,0,0,114,144,0,0,0,114,3,1,0,0,114,16,1,
+ 0,0,114,3,0,0,0,114,106,0,0,0,218,9,109,101,
+ 116,97,95,112,97,116,104,114,158,0,0,0,114,163,0,0,
+ 0,114,246,0,0,0,114,213,0,0,0,41,2,114,29,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,140,5,
+ 0,0,115,16,0,0,0,0,2,8,1,6,1,20,1,10,
+ 1,12,1,12,4,6,1,114,32,1,0,0,41,3,122,3,
+ 119,105,110,114,1,0,0,0,114,2,0,0,0,41,1,114,
+ 47,0,0,0,41,1,78,41,3,78,78,78,41,3,78,78,
+ 78,41,2,114,60,0,0,0,114,60,0,0,0,41,1,78,
+ 41,1,78,41,56,114,108,0,0,0,114,10,0,0,0,114,
+ 11,0,0,0,114,17,0,0,0,114,19,0,0,0,114,28,
+ 0,0,0,114,38,0,0,0,114,39,0,0,0,114,43,0,
+ 0,0,114,44,0,0,0,114,46,0,0,0,114,56,0,0,
+ 0,218,4,116,121,112,101,218,8,95,95,99,111,100,101,95,
+ 95,114,139,0,0,0,114,15,0,0,0,114,129,0,0,0,
+ 114,14,0,0,0,114,18,0,0,0,90,17,95,82,65,87,
+ 95,77,65,71,73,67,95,78,85,77,66,69,82,114,74,0,
+ 0,0,114,73,0,0,0,114,85,0,0,0,114,75,0,0,
+ 0,90,23,68,69,66,85,71,95,66,89,84,69,67,79,68,
+ 69,95,83,85,70,70,73,88,69,83,90,27,79,80,84,73,
+ 77,73,90,69,68,95,66,89,84,69,67,79,68,69,95,83,
+ 85,70,70,73,88,69,83,114,80,0,0,0,114,86,0,0,
+ 0,114,92,0,0,0,114,96,0,0,0,114,98,0,0,0,
+ 114,117,0,0,0,114,124,0,0,0,114,136,0,0,0,114,
+ 142,0,0,0,114,145,0,0,0,114,150,0,0,0,218,6,
+ 111,98,106,101,99,116,114,157,0,0,0,114,162,0,0,0,
+ 114,163,0,0,0,114,179,0,0,0,114,189,0,0,0,114,
+ 205,0,0,0,114,213,0,0,0,114,218,0,0,0,114,224,
+ 0,0,0,114,219,0,0,0,114,225,0,0,0,114,244,0,
+ 0,0,114,246,0,0,0,114,3,1,0,0,114,21,1,0,
+ 0,114,156,0,0,0,114,30,1,0,0,114,32,1,0,0,
+ 114,4,0,0,0,114,4,0,0,0,114,4,0,0,0,114,
+ 5,0,0,0,218,8,60,109,111,100,117,108,101,62,8,0,
+ 0,0,115,102,0,0,0,4,17,4,3,8,12,8,5,8,
+ 5,8,6,8,12,8,10,8,9,8,5,8,7,10,22,10,
+ 116,16,1,12,2,4,1,4,2,6,2,6,2,8,2,16,
+ 44,8,33,8,19,8,12,8,12,8,28,8,17,10,55,10,
+ 12,10,10,8,14,6,3,4,1,14,65,14,64,14,29,16,
+ 110,14,41,18,45,18,16,4,3,18,53,14,60,14,42,14,
+ 127,0,7,14,127,0,20,10,23,8,11,8,68,
};
diff --git a/Python/makeopcodetargets.py b/Python/makeopcodetargets.py
index d9a0855..023c9e6 100755
--- a/Python/makeopcodetargets.py
+++ b/Python/makeopcodetargets.py
@@ -3,24 +3,34 @@
(for compilers supporting computed gotos or "labels-as-values", such as gcc).
"""
-# This code should stay compatible with Python 2.3, at least while
-# some of the buildbots have Python 2.3 as their system Python.
-
-import imp
import os
+import sys
-def find_module(modname):
- """Finds and returns a module in the local dist/checkout.
- """
- modpath = os.path.join(
- os.path.dirname(os.path.dirname(__file__)), "Lib")
- return imp.load_module(modname, *imp.find_module(modname, [modpath]))
+try:
+ from importlib.machinery import SourceFileLoader
+except ImportError:
+ import imp
+
+ def find_module(modname):
+ """Finds and returns a module in the local dist/checkout.
+ """
+ modpath = os.path.join(
+ os.path.dirname(os.path.dirname(__file__)), "Lib")
+ return imp.load_module(modname, *imp.find_module(modname, [modpath]))
+else:
+ def find_module(modname):
+ """Finds and returns a module in the local dist/checkout.
+ """
+ modpath = os.path.join(
+ os.path.dirname(os.path.dirname(__file__)), "Lib", modname + ".py")
+ return SourceFileLoader(modname, modpath).load_module()
+
def write_contents(f):
"""Write C code contents to the target file object.
"""
- opcode = find_module("opcode")
+ opcode = find_module('opcode')
targets = ['_unknown_opcode'] * 256
for opname, op in opcode.opmap.items():
targets[op] = "TARGET_%s" % opname
@@ -29,15 +39,17 @@
f.write("\n};\n")
-if __name__ == "__main__":
- import sys
- assert len(sys.argv) < 3, "Too many arguments"
+def main():
+ if len(sys.argv) >= 3:
+ sys.exit("Too many arguments")
if len(sys.argv) == 2:
target = sys.argv[1]
else:
target = "Python/opcode_targets.h"
- f = open(target, "w")
- try:
+ with open(target, "w") as f:
write_contents(f)
- finally:
- f.close()
+ print("Jump table written into %s" % target)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/Python/marshal.c b/Python/marshal.c
index 5b8de99..627a842 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -263,10 +263,10 @@
if (Py_REFCNT(v) == 1)
return 0;
- entry = _Py_hashtable_get_entry(p->hashtable, v);
+ entry = _Py_HASHTABLE_GET_ENTRY(p->hashtable, v);
if (entry != NULL) {
/* write the reference index to the stream */
- _Py_HASHTABLE_ENTRY_READ_DATA(p->hashtable, &w, sizeof(w), entry);
+ _Py_HASHTABLE_ENTRY_READ_DATA(p->hashtable, entry, w);
/* we don't store "long" indices in the dict */
assert(0 <= w && w <= 0x7fffffff);
w_byte(TYPE_REF, p);
@@ -571,7 +571,8 @@
w_init_refs(WFILE *wf, int version)
{
if (version >= 3) {
- wf->hashtable = _Py_hashtable_new(sizeof(int), _Py_hashtable_hash_ptr,
+ wf->hashtable = _Py_hashtable_new(sizeof(PyObject *), sizeof(int),
+ _Py_hashtable_hash_ptr,
_Py_hashtable_compare_direct);
if (wf->hashtable == NULL) {
PyErr_NoMemory();
@@ -582,9 +583,13 @@
}
static int
-w_decref_entry(_Py_hashtable_entry_t *entry, void *Py_UNUSED(data))
+w_decref_entry(_Py_hashtable_t *ht, _Py_hashtable_entry_t *entry,
+ void *Py_UNUSED(data))
{
- Py_XDECREF(entry->key);
+ PyObject *entry_key;
+
+ _Py_HASHTABLE_ENTRY_READ_KEY(ht, entry, entry_key);
+ Py_XDECREF(entry_key);
return 0;
}
@@ -643,7 +648,7 @@
PyObject *refs; /* a list */
} RFILE;
-static char *
+static const char *
r_string(Py_ssize_t n, RFILE *p)
{
Py_ssize_t read = -1;
@@ -729,7 +734,7 @@
c = getc(p->fp);
}
else {
- char *ptr = r_string(1, p);
+ const char *ptr = r_string(1, p);
if (ptr != NULL)
c = *(unsigned char *) ptr;
}
@@ -740,9 +745,9 @@
r_short(RFILE *p)
{
short x = -1;
- unsigned char *buffer;
+ const unsigned char *buffer;
- buffer = (unsigned char *) r_string(2, p);
+ buffer = (const unsigned char *) r_string(2, p);
if (buffer != NULL) {
x = buffer[0];
x |= buffer[1] << 8;
@@ -756,9 +761,9 @@
r_long(RFILE *p)
{
long x = -1;
- unsigned char *buffer;
+ const unsigned char *buffer;
- buffer = (unsigned char *) r_string(4, p);
+ buffer = (const unsigned char *) r_string(4, p);
if (buffer != NULL) {
x = buffer[0];
x |= (long)buffer[1] << 8;
@@ -978,7 +983,8 @@
case TYPE_FLOAT:
{
- char buf[256], *ptr;
+ char buf[256];
+ const char *ptr;
double dx;
n = r_byte(p);
if (n == EOF) {
@@ -1001,9 +1007,9 @@
case TYPE_BINARY_FLOAT:
{
- unsigned char *buf;
+ const unsigned char *buf;
double x;
- buf = (unsigned char *) r_string(8, p);
+ buf = (const unsigned char *) r_string(8, p);
if (buf == NULL)
break;
x = _PyFloat_Unpack8(buf, 1);
@@ -1016,7 +1022,8 @@
case TYPE_COMPLEX:
{
- char buf[256], *ptr;
+ char buf[256];
+ const char *ptr;
Py_complex c;
n = r_byte(p);
if (n == EOF) {
@@ -1053,15 +1060,15 @@
case TYPE_BINARY_COMPLEX:
{
- unsigned char *buf;
+ const unsigned char *buf;
Py_complex c;
- buf = (unsigned char *) r_string(8, p);
+ buf = (const unsigned char *) r_string(8, p);
if (buf == NULL)
break;
c.real = _PyFloat_Unpack8(buf, 1);
if (c.real == -1.0 && PyErr_Occurred())
break;
- buf = (unsigned char *) r_string(8, p);
+ buf = (const unsigned char *) r_string(8, p);
if (buf == NULL)
break;
c.imag = _PyFloat_Unpack8(buf, 1);
@@ -1074,7 +1081,7 @@
case TYPE_STRING:
{
- char *ptr;
+ const char *ptr;
n = r_long(p);
if (PyErr_Occurred())
break;
@@ -1119,7 +1126,7 @@
}
_read_ascii:
{
- char *ptr;
+ const char *ptr;
ptr = r_string(n, p);
if (ptr == NULL)
break;
@@ -1137,7 +1144,7 @@
is_interned = 1;
case TYPE_UNICODE:
{
- char *buffer;
+ const char *buffer;
n = r_long(p);
if (PyErr_Occurred())
@@ -1264,41 +1271,52 @@
PyErr_SetString(PyExc_ValueError, "bad marshal data (set size out of range)");
break;
}
- v = (type == TYPE_SET) ? PySet_New(NULL) : PyFrozenSet_New(NULL);
- if (type == TYPE_SET) {
- R_REF(v);
- } else {
- /* must use delayed registration of frozensets because they must
- * be init with a refcount of 1
- */
- idx = r_ref_reserve(flag, p);
- if (idx < 0)
- Py_CLEAR(v); /* signal error */
- }
- if (v == NULL)
- break;
- for (i = 0; i < n; i++) {
- v2 = r_object(p);
- if ( v2 == NULL ) {
- if (!PyErr_Occurred())
- PyErr_SetString(PyExc_TypeError,
- "NULL object in marshal data for set");
- Py_DECREF(v);
- v = NULL;
+ if (n == 0 && type == TYPE_FROZENSET) {
+ /* call frozenset() to get the empty frozenset singleton */
+ v = PyObject_CallFunction((PyObject*)&PyFrozenSet_Type, NULL);
+ if (v == NULL)
break;
- }
- if (PySet_Add(v, v2) == -1) {
- Py_DECREF(v);
- Py_DECREF(v2);
- v = NULL;
- break;
- }
- Py_DECREF(v2);
+ R_REF(v);
+ retval = v;
}
- if (type != TYPE_SET)
- v = r_ref_insert(v, idx, flag, p);
- retval = v;
+ else {
+ v = (type == TYPE_SET) ? PySet_New(NULL) : PyFrozenSet_New(NULL);
+ if (type == TYPE_SET) {
+ R_REF(v);
+ } else {
+ /* must use delayed registration of frozensets because they must
+ * be init with a refcount of 1
+ */
+ idx = r_ref_reserve(flag, p);
+ if (idx < 0)
+ Py_CLEAR(v); /* signal error */
+ }
+ if (v == NULL)
+ break;
+
+ for (i = 0; i < n; i++) {
+ v2 = r_object(p);
+ if ( v2 == NULL ) {
+ if (!PyErr_Occurred())
+ PyErr_SetString(PyExc_TypeError,
+ "NULL object in marshal data for set");
+ Py_DECREF(v);
+ v = NULL;
+ break;
+ }
+ if (PySet_Add(v, v2) == -1) {
+ Py_DECREF(v);
+ Py_DECREF(v2);
+ v = NULL;
+ break;
+ }
+ Py_DECREF(v2);
+ }
+ if (type != TYPE_SET)
+ v = r_ref_insert(v, idx, flag, p);
+ retval = v;
+ }
break;
case TYPE_CODE:
diff --git a/Python/modsupport.c b/Python/modsupport.c
index 0d09371..dac18be 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -318,7 +318,7 @@
case 'U': /* XXX deprecated alias */
{
PyObject *v;
- char *str = va_arg(*p_va, char *);
+ const char *str = va_arg(*p_va, const char *);
Py_ssize_t n;
if (**p_format == '#') {
++*p_format;
@@ -351,7 +351,7 @@
case 'y':
{
PyObject *v;
- char *str = va_arg(*p_va, char *);
+ const char *str = va_arg(*p_va, const char *);
Py_ssize_t n;
if (**p_format == '#') {
++*p_format;
diff --git a/Python/mystrtoul.c b/Python/mystrtoul.c
index 98429d4..a85790e 100644
--- a/Python/mystrtoul.c
+++ b/Python/mystrtoul.c
@@ -17,7 +17,7 @@
* smallmax[base] is the largest unsigned long i such that
* i * base doesn't overflow unsigned long.
*/
-static unsigned long smallmax[] = {
+static const unsigned long smallmax[] = {
0, /* bases 0 and 1 are invalid */
0,
ULONG_MAX / 2,
@@ -62,14 +62,14 @@
* Note that this is pessimistic if sizeof(long) > 4.
*/
#if SIZEOF_LONG == 4
-static int digitlimit[] = {
+static const int digitlimit[] = {
0, 0, 32, 20, 16, 13, 12, 11, 10, 10, /* 0 - 9 */
9, 9, 8, 8, 8, 8, 8, 7, 7, 7, /* 10 - 19 */
7, 7, 7, 7, 6, 6, 6, 6, 6, 6, /* 20 - 29 */
6, 6, 6, 6, 6, 6, 6}; /* 30 - 36 */
#elif SIZEOF_LONG == 8
/* [int(math.floor(math.log(2**64, i))) for i in range(2, 37)] */
-static int digitlimit[] = {
+static const int digitlimit[] = {
0, 0, 64, 40, 32, 27, 24, 22, 21, 20, /* 0 - 9 */
19, 18, 17, 17, 16, 16, 16, 15, 15, 15, /* 10 - 19 */
14, 14, 14, 14, 13, 13, 13, 13, 13, 13, /* 20 - 29 */
diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h
index 19259e1..6182e80 100644
--- a/Python/opcode_targets.h
+++ b/Python/opcode_targets.h
@@ -133,7 +133,7 @@
&&TARGET_CALL_FUNCTION,
&&TARGET_MAKE_FUNCTION,
&&TARGET_BUILD_SLICE,
- &&TARGET_MAKE_CLOSURE,
+ &&_unknown_opcode,
&&TARGET_LOAD_CLOSURE,
&&TARGET_LOAD_DEREF,
&&TARGET_STORE_DEREF,
@@ -154,8 +154,8 @@
&&TARGET_BUILD_TUPLE_UNPACK,
&&TARGET_BUILD_SET_UNPACK,
&&TARGET_SETUP_ASYNC_WITH,
- &&_unknown_opcode,
- &&_unknown_opcode,
+ &&TARGET_FORMAT_VALUE,
+ &&TARGET_BUILD_CONST_KEY_MAP,
&&_unknown_opcode,
&&_unknown_opcode,
&&_unknown_opcode,
diff --git a/Python/peephole.c b/Python/peephole.c
index 4e657fa..62625f7 100644
--- a/Python/peephole.c
+++ b/Python/peephole.c
@@ -8,8 +8,8 @@
#include "code.h"
#include "symtable.h"
#include "opcode.h"
+#include "wordcode_helpers.h"
-#define GETARG(arr, i) ((int)((arr[i+2]<<8) + arr[i+1]))
#define UNCONDITIONAL_JUMP(op) (op==JUMP_ABSOLUTE || op==JUMP_FORWARD)
#define CONDITIONAL_JUMP(op) (op==POP_JUMP_IF_FALSE || op==POP_JUMP_IF_TRUE \
|| op==JUMP_IF_FALSE_OR_POP || op==JUMP_IF_TRUE_OR_POP)
@@ -17,22 +17,15 @@
|| op==POP_JUMP_IF_FALSE || op==POP_JUMP_IF_TRUE \
|| op==JUMP_IF_FALSE_OR_POP || op==JUMP_IF_TRUE_OR_POP)
#define JUMPS_ON_TRUE(op) (op==POP_JUMP_IF_TRUE || op==JUMP_IF_TRUE_OR_POP)
-#define GETJUMPTGT(arr, i) (GETARG(arr,i) + (ABSOLUTE_JUMP(arr[i]) ? 0 : i+3))
-#define SETARG(arr, i, val) do { \
- assert(0 <= val && val <= 0xffff); \
- arr[i+2] = (unsigned char)(((unsigned int)val)>>8); \
- arr[i+1] = (unsigned char)(((unsigned int)val) & 255); \
-} while(0)
-#define CODESIZE(op) (HAS_ARG(op) ? 3 : 1)
-#define ISBASICBLOCK(blocks, start, bytes) \
- (blocks[start]==blocks[start+bytes-1])
+#define GETJUMPTGT(arr, i) (get_arg(arr, i) + (ABSOLUTE_JUMP(arr[i]) ? 0 : i+2))
+#define ISBASICBLOCK(blocks, start, end) \
+ (blocks[start]==blocks[end])
#define CONST_STACK_CREATE() { \
const_stack_size = 256; \
const_stack = PyMem_New(PyObject *, const_stack_size); \
- load_const_stack = PyMem_New(Py_ssize_t, const_stack_size); \
- if (!const_stack || !load_const_stack) { \
+ if (!const_stack) { \
PyErr_NoMemory(); \
goto exitError; \
} \
@@ -41,27 +34,23 @@
#define CONST_STACK_DELETE() do { \
if (const_stack) \
PyMem_Free(const_stack); \
- if (load_const_stack) \
- PyMem_Free(load_const_stack); \
} while(0)
-#define CONST_STACK_LEN() (const_stack_top + 1)
+#define CONST_STACK_LEN() ((unsigned)(const_stack_top + 1))
#define CONST_STACK_PUSH_OP(i) do { \
PyObject *_x; \
assert(codestr[i] == LOAD_CONST); \
- assert(PyList_GET_SIZE(consts) > GETARG(codestr, i)); \
- _x = PyList_GET_ITEM(consts, GETARG(codestr, i)); \
+ assert(PyList_GET_SIZE(consts) > (Py_ssize_t)get_arg(codestr, i)); \
+ _x = PyList_GET_ITEM(consts, get_arg(codestr, i)); \
if (++const_stack_top >= const_stack_size) { \
const_stack_size *= 2; \
PyMem_Resize(const_stack, PyObject *, const_stack_size); \
- PyMem_Resize(load_const_stack, Py_ssize_t, const_stack_size); \
- if (!const_stack || !load_const_stack) { \
+ if (!const_stack) { \
PyErr_NoMemory(); \
goto exitError; \
} \
} \
- load_const_stack[const_stack_top] = i; \
const_stack[const_stack_top] = _x; \
in_consts = 1; \
} while(0)
@@ -70,22 +59,108 @@
const_stack_top = -1; \
} while(0)
-#define CONST_STACK_TOP() \
- const_stack[const_stack_top]
-
#define CONST_STACK_LASTN(i) \
- &const_stack[const_stack_top - i + 1]
+ &const_stack[CONST_STACK_LEN() - i]
#define CONST_STACK_POP(i) do { \
- assert(const_stack_top + 1 >= i); \
+ assert(CONST_STACK_LEN() >= i); \
const_stack_top -= i; \
} while(0)
-#define CONST_STACK_OP_LASTN(i) \
- ((const_stack_top >= i - 1) ? load_const_stack[const_stack_top - i + 1] : -1)
+/* Scans back N consecutive LOAD_CONST instructions, skipping NOPs,
+ returns index of the Nth last's LOAD_CONST's EXTENDED_ARG prefix.
+ Callers are responsible to check CONST_STACK_LEN beforehand.
+*/
+static Py_ssize_t
+lastn_const_start(unsigned char *codestr, Py_ssize_t i, Py_ssize_t n)
+{
+ assert(n > 0 && (i&1) == 0);
+ for (;;) {
+ i -= 2;
+ assert(i >= 0);
+ if (codestr[i] == LOAD_CONST) {
+ if (!--n) {
+ while (i > 0 && codestr[i-2] == EXTENDED_ARG) {
+ i -= 2;
+ }
+ return i;
+ }
+ }
+ else {
+ assert(codestr[i] == NOP || codestr[i] == EXTENDED_ARG);
+ }
+ }
+}
+/* Scans through EXTENDED ARGs, seeking the index of the effective opcode */
+static Py_ssize_t
+find_op(unsigned char *codestr, Py_ssize_t i)
+{
+ assert((i&1) == 0);
+ while (codestr[i] == EXTENDED_ARG) {
+ i += 2;
+ }
+ return i;
+}
-/* Replace LOAD_CONST c1. LOAD_CONST c2 ... LOAD_CONST cn BUILD_TUPLE n
+/* Given the index of the effective opcode,
+ scan back to construct the oparg with EXTENDED_ARG */
+static unsigned int
+get_arg(unsigned char *codestr, Py_ssize_t i)
+{
+ unsigned int oparg = codestr[i+1];
+ assert((i&1) == 0);
+ if (i >= 2 && codestr[i-2] == EXTENDED_ARG) {
+ oparg |= codestr[i-1] << 8;
+ if (i >= 4 && codestr[i-4] == EXTENDED_ARG) {
+ oparg |= codestr[i-3] << 16;
+ if (i >= 6 && codestr[i-6] == EXTENDED_ARG) {
+ oparg |= codestr[i-5] << 24;
+ }
+ }
+ }
+ return oparg;
+}
+
+/* Given the index of the effective opcode,
+ attempt to replace the argument, taking into account EXTENDED_ARG.
+ Returns -1 on failure, or the new op index on success */
+static Py_ssize_t
+set_arg(unsigned char *codestr, Py_ssize_t i, unsigned int oparg)
+{
+ unsigned int curarg = get_arg(codestr, i);
+ int curilen, newilen;
+ if (curarg == oparg)
+ return i;
+ curilen = instrsize(curarg);
+ newilen = instrsize(oparg);
+ if (curilen < newilen) {
+ return -1;
+ }
+
+ write_op_arg(codestr + i + 2 - curilen, codestr[i], oparg, newilen);
+ memset(codestr + i + 2 - curilen + newilen, NOP, curilen - newilen);
+ return i-curilen+newilen;
+}
+
+/* Attempt to write op/arg at end of specified region of memory.
+ Preceding memory in the region is overwritten with NOPs.
+ Returns -1 on failure, op index on success */
+static Py_ssize_t
+copy_op_arg(unsigned char *codestr, Py_ssize_t i, unsigned char op,
+ unsigned int oparg, Py_ssize_t maxi)
+{
+ int ilen = instrsize(oparg);
+ assert((i&1) == 0);
+ if (i + ilen > maxi) {
+ return -1;
+ }
+ write_op_arg(codestr + maxi - ilen, op, oparg, ilen);
+ memset(codestr + i, NOP, maxi - i - ilen);
+ return maxi - 2;
+}
+
+/* Replace LOAD_CONST c1, LOAD_CONST c2 ... LOAD_CONST cn, BUILD_TUPLE n
with LOAD_CONST (c1, c2, ... cn).
The consts table must still be in list form so that the
new constant (c1, c2, ... cn) can be appended.
@@ -94,9 +169,10 @@
Also works for BUILD_LIST and BUILT_SET when followed by an "in" or "not in"
test; for BUILD_SET it assembles a frozenset rather than a tuple.
*/
-static int
-tuple_of_constants(unsigned char *codestr, Py_ssize_t n,
- PyObject *consts, PyObject **objs)
+static Py_ssize_t
+fold_tuple_on_constants(unsigned char *codestr, Py_ssize_t c_start,
+ Py_ssize_t opcode_end, unsigned char opcode,
+ PyObject *consts, PyObject **objs, int n)
{
PyObject *newconst, *constant;
Py_ssize_t i, len_consts;
@@ -106,9 +182,9 @@
/* Buildup new tuple of constants */
newconst = PyTuple_New(n);
- if (newconst == NULL)
- return 0;
- len_consts = PyList_GET_SIZE(consts);
+ if (newconst == NULL) {
+ return -1;
+ }
for (i=0 ; i<n ; i++) {
constant = objs[i];
Py_INCREF(constant);
@@ -116,30 +192,26 @@
}
/* If it's a BUILD_SET, use the PyTuple we just built to create a
- PyFrozenSet, and use that as the constant instead: */
- if (codestr[0] == BUILD_SET) {
- PyObject *tuple = newconst;
- newconst = PyFrozenSet_New(tuple);
- Py_DECREF(tuple);
- if (newconst == NULL)
- return 0;
+ PyFrozenSet, and use that as the constant instead: */
+ if (opcode == BUILD_SET) {
+ Py_SETREF(newconst, PyFrozenSet_New(newconst));
+ if (newconst == NULL) {
+ return -1;
+ }
}
/* Append folded constant onto consts */
+ len_consts = PyList_GET_SIZE(consts);
if (PyList_Append(consts, newconst)) {
Py_DECREF(newconst);
- return 0;
+ return -1;
}
Py_DECREF(newconst);
- /* Write NOPs over old LOAD_CONSTS and
- add a new LOAD_CONST newconst on top of the BUILD_TUPLE n */
- codestr[0] = LOAD_CONST;
- SETARG(codestr, 0, len_consts);
- return 1;
+ return copy_op_arg(codestr, c_start, LOAD_CONST, len_consts, opcode_end);
}
-/* Replace LOAD_CONST c1. LOAD_CONST c2 BINOP
+/* Replace LOAD_CONST c1, LOAD_CONST c2, BINOP
with LOAD_CONST binop(c1,c2)
The consts table must still be in list form so that the
new constant can be appended.
@@ -149,20 +221,21 @@
is below a threshold value. That keeps pyc files from
becoming large in the presence of code like: (None,)*1000.
*/
-static int
-fold_binops_on_constants(unsigned char *codestr, PyObject *consts, PyObject **objs)
+static Py_ssize_t
+fold_binops_on_constants(unsigned char *codestr, Py_ssize_t c_start,
+ Py_ssize_t opcode_end, unsigned char opcode,
+ PyObject *consts, PyObject **objs)
{
PyObject *newconst, *v, *w;
Py_ssize_t len_consts, size;
- int opcode;
/* Pre-conditions */
assert(PyList_CheckExact(consts));
+ len_consts = PyList_GET_SIZE(consts);
/* Create new constant */
v = objs[0];
w = objs[1];
- opcode = codestr[0];
switch (opcode) {
case BINARY_POWER:
newconst = PyNumber_Power(v, w, Py_None);
@@ -208,50 +281,48 @@
PyErr_Format(PyExc_SystemError,
"unexpected binary operation %d on a constant",
opcode);
- return 0;
+ return -1;
}
if (newconst == NULL) {
- if(!PyErr_ExceptionMatches(PyExc_KeyboardInterrupt))
+ if(!PyErr_ExceptionMatches(PyExc_KeyboardInterrupt)) {
PyErr_Clear();
- return 0;
+ }
+ return -1;
}
size = PyObject_Size(newconst);
if (size == -1) {
- if (PyErr_ExceptionMatches(PyExc_KeyboardInterrupt))
- return 0;
+ if (PyErr_ExceptionMatches(PyExc_KeyboardInterrupt)) {
+ return -1;
+ }
PyErr_Clear();
} else if (size > 20) {
Py_DECREF(newconst);
- return 0;
+ return -1;
}
/* Append folded constant into consts table */
- len_consts = PyList_GET_SIZE(consts);
if (PyList_Append(consts, newconst)) {
Py_DECREF(newconst);
- return 0;
+ return -1;
}
Py_DECREF(newconst);
- /* Write NOP NOP NOP NOP LOAD_CONST newconst */
- codestr[-2] = LOAD_CONST;
- SETARG(codestr, -2, len_consts);
- return 1;
+ return copy_op_arg(codestr, c_start, LOAD_CONST, len_consts, opcode_end);
}
-static int
-fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts, PyObject *v)
+static Py_ssize_t
+fold_unaryops_on_constants(unsigned char *codestr, Py_ssize_t c_start,
+ Py_ssize_t opcode_end, unsigned char opcode,
+ PyObject *consts, PyObject *v)
{
PyObject *newconst;
Py_ssize_t len_consts;
- int opcode;
/* Pre-conditions */
assert(PyList_CheckExact(consts));
- assert(codestr[0] == LOAD_CONST);
+ len_consts = PyList_GET_SIZE(consts);
/* Create new constant */
- opcode = codestr[3];
switch (opcode) {
case UNARY_NEGATIVE:
newconst = PyNumber_Negative(v);
@@ -267,35 +338,31 @@
PyErr_Format(PyExc_SystemError,
"unexpected unary operation %d on a constant",
opcode);
- return 0;
+ return -1;
}
if (newconst == NULL) {
- if(!PyErr_ExceptionMatches(PyExc_KeyboardInterrupt))
+ if(!PyErr_ExceptionMatches(PyExc_KeyboardInterrupt)) {
PyErr_Clear();
- return 0;
+ }
+ return -1;
}
/* Append folded constant into consts table */
- len_consts = PyList_GET_SIZE(consts);
if (PyList_Append(consts, newconst)) {
Py_DECREF(newconst);
PyErr_Clear();
- return 0;
+ return -1;
}
Py_DECREF(newconst);
- /* Write NOP LOAD_CONST newconst */
- codestr[0] = NOP;
- codestr[1] = LOAD_CONST;
- SETARG(codestr, 1, len_consts);
- return 1;
+ return copy_op_arg(codestr, c_start, LOAD_CONST, len_consts, opcode_end);
}
static unsigned int *
markblocks(unsigned char *code, Py_ssize_t len)
{
unsigned int *blocks = PyMem_New(unsigned int, len);
- int i,j, opcode, blockcnt = 0;
+ int i, j, opcode, blockcnt = 0;
if (blocks == NULL) {
PyErr_NoMemory();
@@ -304,7 +371,7 @@
memset(blocks, 0, len*sizeof(int));
/* Mark labels in the first pass */
- for (i=0 ; i<len ; i+=CODESIZE(opcode)) {
+ for (i=0 ; i<len ; i+=2) {
opcode = code[i];
switch (opcode) {
case FOR_ITER:
@@ -326,7 +393,7 @@
}
}
/* Build block numbers in the second pass */
- for (i=0 ; i<len ; i++) {
+ for (i=0 ; i<len ; i+=2) {
blockcnt += blocks[i]; /* increment blockcnt over labels */
blocks[i] = blockcnt;
}
@@ -337,33 +404,27 @@
The consts object should still be in list form to allow new constants
to be appended.
- To keep the optimizer simple, it bails out (does nothing) for code that
- has a length over 32,700, and does not calculate extended arguments.
- That allows us to avoid overflow and sign issues. Likewise, it bails when
- the lineno table has complex encoding for gaps >= 255. EXTENDED_ARG can
- appear before MAKE_FUNCTION; in this case both opcodes are skipped.
- EXTENDED_ARG preceding any other opcode causes the optimizer to bail.
+ To keep the optimizer simple, it bails when the lineno table has complex
+ encoding for gaps >= 255.
Optimizations are restricted to simple transformations occurring within a
single basic block. All transformations keep the code size the same or
smaller. For those that reduce size, the gaps are initially filled with
NOPs. Later those NOPs are removed and the jump addresses retargeted in
- a single pass. Line numbering is adjusted accordingly. */
+ a single pass. */
PyObject *
PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
- PyObject *lineno_obj)
+ PyObject *lnotab_obj)
{
- Py_ssize_t i, j, codelen;
- int nops, h, adj;
- int tgt, tgttgt, opcode;
+ Py_ssize_t h, i, nexti, op_start, codelen, tgt;
+ unsigned int j, nops;
+ unsigned char opcode, nextop;
unsigned char *codestr = NULL;
- unsigned char *lineno;
- int *addrmap = NULL;
- int new_line, cum_orig_line, last_line;
+ unsigned char *lnotab;
+ unsigned int cum_orig_offset, last_offset;
Py_ssize_t tabsiz;
PyObject **const_stack = NULL;
- Py_ssize_t *load_const_stack = NULL;
Py_ssize_t const_stack_top = -1;
Py_ssize_t const_stack_size = 0;
int in_consts = 0; /* whether we are in a LOAD_CONST sequence */
@@ -373,18 +434,21 @@
if (PyErr_Occurred())
goto exitError;
- /* Bypass optimization when the lineno table is too complex */
- assert(PyBytes_Check(lineno_obj));
- lineno = (unsigned char*)PyBytes_AS_STRING(lineno_obj);
- tabsiz = PyBytes_GET_SIZE(lineno_obj);
- if (memchr(lineno, 255, tabsiz) != NULL)
+ /* Bypass optimization when the lnotab table is too complex */
+ assert(PyBytes_Check(lnotab_obj));
+ lnotab = (unsigned char*)PyBytes_AS_STRING(lnotab_obj);
+ tabsiz = PyBytes_GET_SIZE(lnotab_obj);
+ assert(tabsiz == 0 || Py_REFCNT(lnotab_obj) == 1);
+ if (memchr(lnotab, 255, tabsiz) != NULL) {
+ /* 255 value are used for multibyte bytecode instructions */
goto exitUnchanged;
+ }
+ /* Note: -128 and 127 special values for line number delta are ok,
+ the peephole optimizer doesn't modify line numbers. */
- /* Avoid situations where jump retargeting could overflow */
assert(PyBytes_Check(code));
codelen = PyBytes_GET_SIZE(code);
- if (codelen > 32700)
- goto exitUnchanged;
+ assert(codelen % 2 == 0);
/* Make a modifiable copy of the code string */
codestr = (unsigned char *)PyMem_Malloc(codelen);
@@ -395,21 +459,6 @@
codestr = (unsigned char *)memcpy(codestr,
PyBytes_AS_STRING(code), codelen);
- /* Verify that RETURN_VALUE terminates the codestring. This allows
- the various transformation patterns to look ahead several
- instructions without additional checks to make sure they are not
- looking beyond the end of the code string.
- */
- if (codestr[codelen-1] != RETURN_VALUE)
- goto exitUnchanged;
-
- /* Mapping to new jump targets after NOPs are removed */
- addrmap = PyMem_New(int, codelen);
- if (addrmap == NULL) {
- PyErr_NoMemory();
- goto exitError;
- }
-
blocks = markblocks(codestr, codelen);
if (blocks == NULL)
goto exitError;
@@ -417,9 +466,17 @@
CONST_STACK_CREATE();
- for (i=0 ; i<codelen ; i += CODESIZE(codestr[i])) {
- reoptimize_current:
+ for (i=find_op(codestr, 0) ; i<codelen ; i=nexti) {
opcode = codestr[i];
+ op_start = i;
+ while (op_start >= 2 && codestr[op_start-2] == EXTENDED_ARG) {
+ op_start -= 2;
+ }
+
+ nexti = i + 2;
+ while (nexti < codelen && codestr[nexti] == EXTENDED_ARG)
+ nexti += 2;
+ nextop = nexti < codelen ? codestr[nexti] : 0;
if (!in_consts) {
CONST_STACK_RESET();
@@ -430,14 +487,12 @@
/* Replace UNARY_NOT POP_JUMP_IF_FALSE
with POP_JUMP_IF_TRUE */
case UNARY_NOT:
- if (codestr[i+1] != POP_JUMP_IF_FALSE
- || !ISBASICBLOCK(blocks,i,4))
- continue;
- j = GETARG(codestr, i+1);
- codestr[i] = POP_JUMP_IF_TRUE;
- SETARG(codestr, i, j);
- codestr[i+3] = NOP;
- goto reoptimize_current;
+ if (nextop != POP_JUMP_IF_FALSE
+ || !ISBASICBLOCK(blocks, op_start, i+2))
+ break;
+ memset(codestr + op_start, NOP, i - op_start + 2);
+ codestr[nexti] = POP_JUMP_IF_TRUE;
+ break;
/* not a is b --> a is not b
not a in b --> a not in b
@@ -445,78 +500,79 @@
not a not in b --> a in b
*/
case COMPARE_OP:
- j = GETARG(codestr, i);
- if (j < 6 || j > 9 ||
- codestr[i+3] != UNARY_NOT ||
- !ISBASICBLOCK(blocks,i,4))
- continue;
- SETARG(codestr, i, (j^1));
- codestr[i+3] = NOP;
+ j = get_arg(codestr, i);
+ if (j < 6 || j > 9 ||
+ nextop != UNARY_NOT ||
+ !ISBASICBLOCK(blocks, op_start, i + 2))
+ break;
+ codestr[i+1] = (j^1);
+ memset(codestr + i + 2, NOP, nexti - i);
break;
/* Skip over LOAD_CONST trueconst
- POP_JUMP_IF_FALSE xx. This improves
- "while 1" performance. */
+ POP_JUMP_IF_FALSE xx. This improves
+ "while 1" performance. */
case LOAD_CONST:
CONST_STACK_PUSH_OP(i);
- j = GETARG(codestr, i);
- if (codestr[i+3] != POP_JUMP_IF_FALSE ||
- !ISBASICBLOCK(blocks,i,6) ||
- !PyObject_IsTrue(PyList_GET_ITEM(consts, j)))
- continue;
- memset(codestr+i, NOP, 6);
- CONST_STACK_RESET();
+ if (nextop != POP_JUMP_IF_FALSE ||
+ !ISBASICBLOCK(blocks, op_start, i + 2) ||
+ !PyObject_IsTrue(PyList_GET_ITEM(consts, get_arg(codestr, i))))
+ break;
+ memset(codestr + op_start, NOP, nexti - op_start + 2);
+ CONST_STACK_POP(1);
break;
- /* Try to fold tuples of constants (includes a case for lists and sets
- which are only used for "in" and "not in" tests).
+ /* Try to fold tuples of constants (includes a case for lists
+ and sets which are only used for "in" and "not in" tests).
Skip over BUILD_SEQN 1 UNPACK_SEQN 1.
Replace BUILD_SEQN 2 UNPACK_SEQN 2 with ROT2.
Replace BUILD_SEQN 3 UNPACK_SEQN 3 with ROT3 ROT2. */
case BUILD_TUPLE:
case BUILD_LIST:
case BUILD_SET:
- j = GETARG(codestr, i);
- if (j == 0)
- break;
- h = CONST_STACK_OP_LASTN(j);
- assert((h >= 0 || CONST_STACK_LEN() < j));
- if (h >= 0 && j > 0 && j <= CONST_STACK_LEN() &&
- ((opcode == BUILD_TUPLE &&
- ISBASICBLOCK(blocks, h, i-h+3)) ||
- ((opcode == BUILD_LIST || opcode == BUILD_SET) &&
- codestr[i+3]==COMPARE_OP &&
- ISBASICBLOCK(blocks, h, i-h+6) &&
- (GETARG(codestr,i+3)==6 ||
- GETARG(codestr,i+3)==7))) &&
- tuple_of_constants(&codestr[i], j, consts, CONST_STACK_LASTN(j))) {
- assert(codestr[i] == LOAD_CONST);
- memset(&codestr[h], NOP, i - h);
- CONST_STACK_POP(j);
- CONST_STACK_PUSH_OP(i);
- break;
+ j = get_arg(codestr, i);
+ if (j > 0 && CONST_STACK_LEN() >= j) {
+ h = lastn_const_start(codestr, op_start, j);
+ if ((opcode == BUILD_TUPLE &&
+ ISBASICBLOCK(blocks, h, op_start)) ||
+ ((opcode == BUILD_LIST || opcode == BUILD_SET) &&
+ ((nextop==COMPARE_OP &&
+ (codestr[nexti+1]==6 ||
+ codestr[nexti+1]==7)) ||
+ nextop == GET_ITER) && ISBASICBLOCK(blocks, h, i + 2))) {
+ h = fold_tuple_on_constants(codestr, h, i+2, opcode,
+ consts, CONST_STACK_LASTN(j), j);
+ if (h >= 0) {
+ CONST_STACK_POP(j);
+ CONST_STACK_PUSH_OP(h);
+ }
+ break;
+ }
}
- if (codestr[i+3] != UNPACK_SEQUENCE ||
- !ISBASICBLOCK(blocks,i,6) ||
- j != GETARG(codestr, i+3) ||
+ if (nextop != UNPACK_SEQUENCE ||
+ !ISBASICBLOCK(blocks, op_start, i + 2) ||
+ j != get_arg(codestr, nexti) ||
opcode == BUILD_SET)
- continue;
- if (j == 1) {
- memset(codestr+i, NOP, 6);
+ break;
+ if (j < 2) {
+ memset(codestr+op_start, NOP, nexti - op_start + 2);
} else if (j == 2) {
- codestr[i] = ROT_TWO;
- memset(codestr+i+1, NOP, 5);
+ codestr[op_start] = ROT_TWO;
+ codestr[op_start + 1] = 0;
+ memset(codestr + op_start + 2, NOP, nexti - op_start);
CONST_STACK_RESET();
} else if (j == 3) {
- codestr[i] = ROT_THREE;
- codestr[i+1] = ROT_TWO;
- memset(codestr+i+2, NOP, 4);
+ codestr[op_start] = ROT_THREE;
+ codestr[op_start + 1] = 0;
+ codestr[op_start + 2] = ROT_TWO;
+ codestr[op_start + 3] = 0;
+ memset(codestr + op_start + 4, NOP, nexti - op_start - 2);
CONST_STACK_RESET();
}
break;
/* Fold binary ops on constants.
- LOAD_CONST c1 LOAD_CONST c2 BINOP --> LOAD_CONST binop(c1,c2) */
+ LOAD_CONST c1 LOAD_CONST c2 BINOP --> LOAD_CONST binop(c1,c2) */
case BINARY_POWER:
case BINARY_MULTIPLY:
case BINARY_TRUE_DIVIDE:
@@ -530,35 +586,34 @@
case BINARY_AND:
case BINARY_XOR:
case BINARY_OR:
- /* NOTE: LOAD_CONST is saved at `i-2` since it has an arg
- while BINOP hasn't */
- h = CONST_STACK_OP_LASTN(2);
- assert((h >= 0 || CONST_STACK_LEN() < 2));
- if (h >= 0 &&
- ISBASICBLOCK(blocks, h, i-h+1) &&
- fold_binops_on_constants(&codestr[i], consts, CONST_STACK_LASTN(2))) {
- i -= 2;
- memset(&codestr[h], NOP, i - h);
- assert(codestr[i] == LOAD_CONST);
- CONST_STACK_POP(2);
- CONST_STACK_PUSH_OP(i);
+ if (CONST_STACK_LEN() < 2)
+ break;
+ h = lastn_const_start(codestr, op_start, 2);
+ if (ISBASICBLOCK(blocks, h, op_start)) {
+ h = fold_binops_on_constants(codestr, h, i+2, opcode,
+ consts, CONST_STACK_LASTN(2));
+ if (h >= 0) {
+ CONST_STACK_POP(2);
+ CONST_STACK_PUSH_OP(h);
+ }
}
break;
/* Fold unary ops on constants.
- LOAD_CONST c1 UNARY_OP --> LOAD_CONST unary_op(c) */
+ LOAD_CONST c1 UNARY_OP --> LOAD_CONST unary_op(c) */
case UNARY_NEGATIVE:
case UNARY_INVERT:
case UNARY_POSITIVE:
- h = CONST_STACK_OP_LASTN(1);
- assert((h >= 0 || CONST_STACK_LEN() < 1));
- if (h >= 0 &&
- ISBASICBLOCK(blocks, h, i-h+1) &&
- fold_unaryops_on_constants(&codestr[i-3], consts, CONST_STACK_TOP())) {
- i -= 2;
- assert(codestr[i] == LOAD_CONST);
- CONST_STACK_POP(1);
- CONST_STACK_PUSH_OP(i);
+ if (CONST_STACK_LEN() < 1)
+ break;
+ h = lastn_const_start(codestr, op_start, 1);
+ if (ISBASICBLOCK(blocks, h, op_start)) {
+ h = fold_unaryops_on_constants(codestr, h, i+2, opcode,
+ consts, *CONST_STACK_LASTN(1));
+ if (h >= 0) {
+ CONST_STACK_POP(1);
+ CONST_STACK_PUSH_OP(h);
+ }
}
break;
@@ -573,25 +628,24 @@
x:JUMP_IF_FALSE_OR_POP y y:JUMP_IF_FALSE_OR_POP z
--> x:JUMP_IF_FALSE_OR_POP z
x:JUMP_IF_FALSE_OR_POP y y:JUMP_IF_TRUE_OR_POP z
- --> x:POP_JUMP_IF_FALSE y+3
- where y+3 is the instruction following the second test.
+ --> x:POP_JUMP_IF_FALSE y+2
+ where y+2 is the instruction following the second test.
*/
case JUMP_IF_FALSE_OR_POP:
case JUMP_IF_TRUE_OR_POP:
- tgt = GETJUMPTGT(codestr, i);
+ h = get_arg(codestr, i);
+ tgt = find_op(codestr, h);
+
j = codestr[tgt];
if (CONDITIONAL_JUMP(j)) {
/* NOTE: all possible jumps here are
absolute! */
if (JUMPS_ON_TRUE(j) == JUMPS_ON_TRUE(opcode)) {
/* The second jump will be
- taken iff the first is. */
- tgttgt = GETJUMPTGT(codestr, tgt);
- /* The current opcode inherits
- its target's stack behaviour */
- codestr[i] = j;
- SETARG(codestr, i, tgttgt);
- goto reoptimize_current;
+ taken iff the first is.
+ The current opcode inherits
+ its target's stack effect */
+ h = set_arg(codestr, i, get_arg(codestr, tgt));
} else {
/* The second jump is not taken
if the first is (so jump past
@@ -600,12 +654,15 @@
they're not taken (so change
the first jump to pop its
argument when it's taken). */
- if (JUMPS_ON_TRUE(opcode))
- codestr[i] = POP_JUMP_IF_TRUE;
- else
- codestr[i] = POP_JUMP_IF_FALSE;
- SETARG(codestr, i, (tgt + 3));
- goto reoptimize_current;
+ h = set_arg(codestr, i, tgt + 2);
+ j = opcode == JUMP_IF_TRUE_OR_POP ?
+ POP_JUMP_IF_TRUE : POP_JUMP_IF_FALSE;
+ }
+
+ if (h >= 0) {
+ nexti = h;
+ codestr[nexti] = j;
+ break;
}
}
/* Intentional fallthrough */
@@ -622,73 +679,73 @@
case SETUP_FINALLY:
case SETUP_WITH:
case SETUP_ASYNC_WITH:
- tgt = GETJUMPTGT(codestr, i);
+ h = GETJUMPTGT(codestr, i);
+ tgt = find_op(codestr, h);
/* Replace JUMP_* to a RETURN into just a RETURN */
if (UNCONDITIONAL_JUMP(opcode) &&
codestr[tgt] == RETURN_VALUE) {
- codestr[i] = RETURN_VALUE;
- memset(codestr+i+1, NOP, 2);
- continue;
+ codestr[op_start] = RETURN_VALUE;
+ codestr[op_start + 1] = 0;
+ memset(codestr + op_start + 2, NOP, i - op_start);
+ } else if (UNCONDITIONAL_JUMP(codestr[tgt])) {
+ j = GETJUMPTGT(codestr, tgt);
+ if (opcode == JUMP_FORWARD) { /* JMP_ABS can go backwards */
+ opcode = JUMP_ABSOLUTE;
+ } else if (!ABSOLUTE_JUMP(opcode)) {
+ if ((Py_ssize_t)j < i + 2) {
+ break; /* No backward relative jumps */
+ }
+ j -= i + 2; /* Calc relative jump addr */
+ }
+ copy_op_arg(codestr, op_start, opcode, j, i+2);
}
- if (!UNCONDITIONAL_JUMP(codestr[tgt]))
- continue;
- tgttgt = GETJUMPTGT(codestr, tgt);
- if (opcode == JUMP_FORWARD) /* JMP_ABS can go backwards */
- opcode = JUMP_ABSOLUTE;
- if (!ABSOLUTE_JUMP(opcode))
- tgttgt -= i + 3; /* Calc relative jump addr */
- if (tgttgt < 0) /* No backward relative jumps */
- continue;
- codestr[i] = opcode;
- SETARG(codestr, i, tgttgt);
break;
- case EXTENDED_ARG:
- if (codestr[i+3] != MAKE_FUNCTION)
- goto exitUnchanged;
- /* don't visit MAKE_FUNCTION as GETARG will be wrong */
- i += 3;
- break;
-
- /* Replace RETURN LOAD_CONST None RETURN with just RETURN */
- /* Remove unreachable JUMPs after RETURN */
+ /* Remove unreachable ops after RETURN */
case RETURN_VALUE:
- if (i+4 >= codelen)
- continue;
- if (codestr[i+4] == RETURN_VALUE &&
- ISBASICBLOCK(blocks,i,5))
- memset(codestr+i+1, NOP, 4);
- else if (UNCONDITIONAL_JUMP(codestr[i+1]) &&
- ISBASICBLOCK(blocks,i,4))
- memset(codestr+i+1, NOP, 3);
+ h = i + 2;
+ while (h + 2 < codelen && ISBASICBLOCK(blocks, i, h + 2)) {
+ h += 2;
+ }
+ if (h > i + 2) {
+ memset(codestr + i + 2, NOP, h - i);
+ nexti = find_op(codestr, h);
+ }
break;
}
}
- /* Fixup linenotab */
- for (i=0, nops=0 ; i<codelen ; i += CODESIZE(codestr[i])) {
+ /* Fixup lnotab */
+ for (i=0, nops=0 ; i<codelen ; i += 2) {
assert(i - nops <= INT_MAX);
- addrmap[i] = (int)(i - nops);
+ /* original code offset => new code offset */
+ blocks[i] = i - nops;
if (codestr[i] == NOP)
- nops++;
+ nops += 2;
}
- cum_orig_line = 0;
- last_line = 0;
+ cum_orig_offset = 0;
+ last_offset = 0;
for (i=0 ; i < tabsiz ; i+=2) {
- cum_orig_line += lineno[i];
- new_line = addrmap[cum_orig_line];
- assert (new_line - last_line < 255);
- lineno[i] =((unsigned char)(new_line - last_line));
- last_line = new_line;
+ unsigned int offset_delta, new_offset;
+ cum_orig_offset += lnotab[i];
+ assert((cum_orig_offset & 1) == 0);
+ new_offset = blocks[cum_orig_offset];
+ offset_delta = new_offset - last_offset;
+ assert(offset_delta <= 255);
+ lnotab[i] = (unsigned char)offset_delta;
+ last_offset = new_offset;
}
/* Remove NOPs and fixup jump targets */
- for (i=0, h=0 ; i<codelen ; ) {
+ for (op_start=0, i=0, h=0 ; i<codelen ; i+=2, op_start=i) {
+ j = codestr[i+1];
+ while (codestr[i] == EXTENDED_ARG) {
+ i += 2;
+ j = j<<8 | codestr[i+1];
+ }
opcode = codestr[i];
switch (opcode) {
- case NOP:
- i++;
- continue;
+ case NOP:continue;
case JUMP_ABSOLUTE:
case CONTINUE_LOOP:
@@ -696,8 +753,7 @@
case POP_JUMP_IF_TRUE:
case JUMP_IF_FALSE_OR_POP:
case JUMP_IF_TRUE_OR_POP:
- j = addrmap[GETARG(codestr, i)];
- SETARG(codestr, i, j);
+ j = blocks[j];
break;
case FOR_ITER:
@@ -707,34 +763,31 @@
case SETUP_FINALLY:
case SETUP_WITH:
case SETUP_ASYNC_WITH:
- j = addrmap[GETARG(codestr, i) + i + 3] - addrmap[i] - 3;
- SETARG(codestr, i, j);
+ j = blocks[j + i + 2] - blocks[i] - 2;
break;
}
- adj = CODESIZE(opcode);
- while (adj--)
- codestr[h++] = codestr[i++];
+ nexti = i - op_start + 2;
+ if (instrsize(j) > nexti)
+ goto exitUnchanged;
+ /* If instrsize(j) < nexti, we'll emit EXTENDED_ARG 0 */
+ write_op_arg(codestr + h, opcode, j, nexti);
+ h += nexti;
}
- assert(h + nops == codelen);
+ assert(h + (Py_ssize_t)nops == codelen);
- code = PyBytes_FromStringAndSize((char *)codestr, h);
CONST_STACK_DELETE();
- PyMem_Free(addrmap);
- PyMem_Free(codestr);
PyMem_Free(blocks);
+ code = PyBytes_FromStringAndSize((char *)codestr, h);
+ PyMem_Free(codestr);
return code;
exitError:
code = NULL;
exitUnchanged:
- CONST_STACK_DELETE();
- if (blocks != NULL)
- PyMem_Free(blocks);
- if (addrmap != NULL)
- PyMem_Free(addrmap);
- if (codestr != NULL)
- PyMem_Free(codestr);
Py_XINCREF(code);
+ CONST_STACK_DELETE();
+ PyMem_Free(blocks);
+ PyMem_Free(codestr);
return code;
}
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index ce52990..72a00e6 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -154,8 +154,8 @@
return 0;
}
-/* Global initializations. Can be undone by Py_Finalize(). Don't
- call this twice without an intervening Py_Finalize() call. When
+/* Global initializations. Can be undone by Py_FinalizeEx(). Don't
+ call this twice without an intervening Py_FinalizeEx() call. When
initializations fail, a fatal error is issued and the function does
not return. On return, the first thread and interpreter state have
been created.
@@ -223,6 +223,8 @@
return NULL;
}
return get_codec_name(codeset);
+#elif defined(__ANDROID__)
+ return get_codec_name("UTF-8");
#else
PyErr_SetNone(PyExc_NotImplementedError);
return NULL;
@@ -327,11 +329,11 @@
(void) PyThreadState_Swap(tstate);
#ifdef WITH_THREAD
- /* We can't call _PyEval_FiniThreads() in Py_Finalize because
+ /* We can't call _PyEval_FiniThreads() in Py_FinalizeEx because
destroying the GIL might fail when it is being referenced from
another running thread (see issue #9901).
Instead we destroy the previously created GIL here, which ensures
- that we can call Py_Initialize / Py_Finalize multiple times. */
+ that we can call Py_Initialize / Py_FinalizeEx multiple times. */
_PyEval_FiniThreads();
/* Auto-thread-state API */
@@ -477,28 +479,35 @@
return r > 0;
}
-static void
+static int
flush_std_files(void)
{
PyObject *fout = _PySys_GetObjectId(&PyId_stdout);
PyObject *ferr = _PySys_GetObjectId(&PyId_stderr);
PyObject *tmp;
+ int status = 0;
if (fout != NULL && fout != Py_None && !file_is_closed(fout)) {
tmp = _PyObject_CallMethodId(fout, &PyId_flush, "");
- if (tmp == NULL)
+ if (tmp == NULL) {
PyErr_WriteUnraisable(fout);
+ status = -1;
+ }
else
Py_DECREF(tmp);
}
if (ferr != NULL && ferr != Py_None && !file_is_closed(ferr)) {
tmp = _PyObject_CallMethodId(ferr, &PyId_flush, "");
- if (tmp == NULL)
+ if (tmp == NULL) {
PyErr_Clear();
+ status = -1;
+ }
else
Py_DECREF(tmp);
}
+
+ return status;
}
/* Undo the effect of Py_Initialize().
@@ -515,14 +524,15 @@
*/
-void
-Py_Finalize(void)
+int
+Py_FinalizeEx(void)
{
PyInterpreterState *interp;
PyThreadState *tstate;
+ int status = 0;
if (!initialized)
- return;
+ return status;
wait_for_thread_shutdown();
@@ -547,7 +557,9 @@
initialized = 0;
/* Flush sys.stdout and sys.stderr */
- flush_std_files();
+ if (flush_std_files() < 0) {
+ status = -1;
+ }
/* Disable signal handling */
PyOS_FiniInterrupts();
@@ -576,7 +588,9 @@
PyImport_Cleanup();
/* Flush sys.stdout and sys.stderr (again, in case more was printed) */
- flush_std_files();
+ if (flush_std_files() < 0) {
+ status = -1;
+ }
/* Collect final garbage. This disposes of cycles created by
* class definitions, for example.
@@ -680,6 +694,7 @@
/* Delete current thread. After this, many C API calls become crashy. */
PyThreadState_Swap(NULL);
+
PyInterpreterState_Delete(interp);
#ifdef Py_TRACE_REFS
@@ -690,12 +705,22 @@
if (Py_GETENV("PYTHONDUMPREFS"))
_Py_PrintReferenceAddresses(stderr);
#endif /* Py_TRACE_REFS */
-#ifdef PYMALLOC_DEBUG
- if (Py_GETENV("PYTHONMALLOCSTATS"))
- _PyObject_DebugMallocStats(stderr);
+#ifdef WITH_PYMALLOC
+ if (_PyMem_PymallocEnabled()) {
+ char *opt = Py_GETENV("PYTHONMALLOCSTATS");
+ if (opt != NULL && *opt != '\0')
+ _PyObject_DebugMallocStats(stderr);
+ }
#endif
call_ll_exitfuncs();
+ return status;
+}
+
+void
+Py_Finalize(void)
+{
+ Py_FinalizeEx();
}
/* Create and initialize a new interpreter and thread, and return the
@@ -721,6 +746,12 @@
if (!initialized)
Py_FatalError("Py_NewInterpreter: call Py_Initialize first");
+#ifdef WITH_THREAD
+ /* Issue #10915, #15751: The GIL API doesn't work with multiple
+ interpreters: disable PyGILState_Check(). */
+ _PyGILState_check_enabled = 0;
+#endif
+
interp = PyInterpreterState_New();
if (interp == NULL)
return NULL;
@@ -777,7 +808,7 @@
if (initstdio() < 0)
Py_FatalError(
- "Py_Initialize: can't initialize sys standard streams");
+ "Py_Initialize: can't initialize sys standard streams");
initmain(interp);
if (!Py_NoSiteFlag)
initsite();
@@ -803,7 +834,7 @@
frames, and that it is its interpreter's only remaining thread.
It is a fatal error to violate these constraints.
- (Py_Finalize() doesn't have these constraints -- it zaps
+ (Py_FinalizeEx() doesn't have these constraints -- it zaps
everything, regardless.)
Locking: as above.
@@ -972,6 +1003,9 @@
if (fd < 0 || !_PyVerify_fd(fd))
return 0;
_Py_BEGIN_SUPPRESS_IPH
+ /* Prefer dup() over fstat(). fstat() can require input/output whereas
+ dup() doesn't, there is a low risk of EMFILE/ENFILE at Python
+ startup. */
fd2 = dup(fd);
if (fd2 >= 0)
close(fd2);
@@ -982,8 +1016,8 @@
/* returns Py_None if the fd is not valid */
static PyObject*
create_stdio(PyObject* io,
- int fd, int write_mode, char* name,
- char* encoding, char* errors)
+ int fd, int write_mode, const char* name,
+ const char* encoding, const char* errors)
{
PyObject *buf = NULL, *stream = NULL, *text = NULL, *raw = NULL, *res;
const char* mode;
@@ -1013,7 +1047,8 @@
mode = "rb";
buf = _PyObject_CallMethodId(io, &PyId_open, "isiOOOi",
fd, mode, buffering,
- Py_None, Py_None, Py_None, 0);
+ Py_None, Py_None, /* encoding, errors */
+ Py_None, 0); /* newline, closefd */
if (buf == NULL)
goto error;
@@ -1243,25 +1278,11 @@
static void
_Py_FatalError_DumpTracebacks(int fd)
{
- PyThreadState *tstate;
-
-#ifdef WITH_THREAD
- /* PyGILState_GetThisThreadState() works even if the GIL was released */
- tstate = PyGILState_GetThisThreadState();
-#else
- tstate = PyThreadState_GET();
-#endif
- if (tstate == NULL) {
- /* _Py_DumpTracebackThreads() requires the thread state to display
- * frames */
- return;
- }
-
fputc('\n', stderr);
fflush(stderr);
/* display the current Python stack */
- _Py_DumpTracebackThreads(fd, tstate->interp, tstate);
+ _Py_DumpTracebackThreads(fd, NULL, NULL);
}
/* Print the current exception (if an exception is set) with its traceback,
@@ -1388,7 +1409,7 @@
/* Clean up and exit */
#ifdef WITH_THREAD
-#include "pythread.h"
+# include "pythread.h"
#endif
static void (*pyexitfunc)(void) = NULL;
@@ -1462,7 +1483,9 @@
void
Py_Exit(int sts)
{
- Py_Finalize();
+ if (Py_FinalizeEx() < 0) {
+ sts = 120;
+ }
exit(sts);
}
diff --git a/Python/pystate.c b/Python/pystate.c
index 6d1c6d0..ba4dd4c 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -25,7 +25,7 @@
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif
-#ifndef RTLD_LAZY
+#if !HAVE_DECL_RTLD_LAZY
#define RTLD_LAZY 1
#endif
#endif
@@ -34,6 +34,8 @@
extern "C" {
#endif
+int _PyGILState_check_enabled = 1;
+
#ifdef WITH_THREAD
#include "pythread.h"
static PyThread_type_lock head_mutex = NULL; /* Protects interp->tstate_head */
@@ -45,7 +47,7 @@
GILState implementation
*/
static PyInterpreterState *autoInterpreterState = NULL;
-static int autoTLSkey = 0;
+static int autoTLSkey = -1;
#else
#define HEAD_INIT() /* Nothing */
#define HEAD_LOCK() /* Nothing */
@@ -89,7 +91,7 @@
interp->fscodec_initialized = 0;
interp->importlib = NULL;
#ifdef HAVE_DLOPEN
-#ifdef RTLD_NOW
+#if HAVE_DECL_RTLD_NOW
interp->dlopenflags = RTLD_NOW;
#else
interp->dlopenflags = RTLD_LAZY;
@@ -449,10 +451,10 @@
if (tstate == NULL)
Py_FatalError(
"PyThreadState_DeleteCurrent: no current tstate");
- SET_TSTATE(NULL);
+ tstate_delete_common(tstate);
if (autoInterpreterState && PyThread_get_key_value(autoTLSkey) == tstate)
PyThread_delete_key_value(autoTLSkey);
- tstate_delete_common(tstate);
+ SET_TSTATE(NULL);
PyEval_ReleaseLock();
}
#endif /* WITH_THREAD */
@@ -696,7 +698,7 @@
}
/* Internal initialization/finalization functions called by
- Py_Initialize/Py_Finalize
+ Py_Initialize/Py_FinalizeEx
*/
void
_PyGILState_Init(PyInterpreterState *i, PyThreadState *t)
@@ -712,10 +714,17 @@
_PyGILState_NoteThreadState(t);
}
+PyInterpreterState *
+_PyGILState_GetInterpreterStateUnsafe(void)
+{
+ return autoInterpreterState;
+}
+
void
_PyGILState_Fini(void)
{
PyThread_delete_key(autoTLSkey);
+ autoTLSkey = -1;
autoInterpreterState = NULL;
}
@@ -784,8 +793,19 @@
int
PyGILState_Check(void)
{
- PyThreadState *tstate = GET_TSTATE();
- return tstate && (tstate == PyGILState_GetThisThreadState());
+ PyThreadState *tstate;
+
+ if (!_PyGILState_check_enabled)
+ return 1;
+
+ if (autoTLSkey == -1)
+ return 1;
+
+ tstate = GET_TSTATE();
+ if (tstate == NULL)
+ return 0;
+
+ return (tstate == PyGILState_GetThisThreadState());
}
PyGILState_STATE
diff --git a/Python/pystrtod.c b/Python/pystrtod.c
index 209c908..5f3af92 100644
--- a/Python/pystrtod.c
+++ b/Python/pystrtod.c
@@ -881,12 +881,12 @@
#define OFS_E 2
/* The lengths of these are known to the code below, so don't change them */
-static char *lc_float_strings[] = {
+static const char * const lc_float_strings[] = {
"inf",
"nan",
"e",
};
-static char *uc_float_strings[] = {
+static const char * const uc_float_strings[] = {
"INF",
"NAN",
"E",
@@ -925,7 +925,8 @@
format_float_short(double d, char format_code,
int mode, int precision,
int always_add_sign, int add_dot_0_if_integer,
- int use_alt_formatting, char **float_strings, int *type)
+ int use_alt_formatting, const char * const *float_strings,
+ int *type)
{
char *buf = NULL;
char *p = NULL;
@@ -1176,7 +1177,7 @@
int flags,
int *type)
{
- char **float_strings = lc_float_strings;
+ const char * const *float_strings = lc_float_strings;
int mode;
/* Validate format_code, and map upper and lower case. Compute the
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 7fbf06e..678ebfe 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -431,7 +431,7 @@
parse_syntax_error(PyObject *err, PyObject **message, PyObject **filename,
int *lineno, int *offset, PyObject **text)
{
- long hold;
+ int hold;
PyObject *v;
_Py_IDENTIFIER(msg);
_Py_IDENTIFIER(filename);
@@ -464,11 +464,11 @@
v = _PyObject_GetAttrId(err, &PyId_lineno);
if (!v)
goto finally;
- hold = PyLong_AsLong(v);
+ hold = _PyLong_AsInt(v);
Py_DECREF(v);
if (hold < 0 && PyErr_Occurred())
goto finally;
- *lineno = (int)hold;
+ *lineno = hold;
v = _PyObject_GetAttrId(err, &PyId_offset);
if (!v)
@@ -477,11 +477,11 @@
*offset = -1;
Py_DECREF(v);
} else {
- hold = PyLong_AsLong(v);
+ hold = _PyLong_AsInt(v);
Py_DECREF(v);
if (hold < 0 && PyErr_Occurred())
goto finally;
- *offset = (int)hold;
+ *offset = hold;
}
v = _PyObject_GetAttrId(err, &PyId_text);
@@ -791,11 +791,11 @@
PyErr_Clear();
}
-static const char *cause_message =
+static const char cause_message[] =
"\nThe above exception was the direct cause "
"of the following exception:\n\n";
-static const char *context_message =
+static const char context_message[] =
"\nDuring handling of the above exception, "
"another exception occurred:\n\n";
@@ -1144,8 +1144,8 @@
mod_ty
PyParser_ASTFromFileObject(FILE *fp, PyObject *filename, const char* enc,
- int start, char *ps1,
- char *ps2, PyCompilerFlags *flags, int *errcode,
+ int start, const char *ps1,
+ const char *ps2, PyCompilerFlags *flags, int *errcode,
PyArena *arena)
{
mod_ty mod;
@@ -1177,8 +1177,8 @@
mod_ty
PyParser_ASTFromFile(FILE *fp, const char *filename_str, const char* enc,
- int start, char *ps1,
- char *ps2, PyCompilerFlags *flags, int *errcode,
+ int start, const char *ps1,
+ const char *ps2, PyCompilerFlags *flags, int *errcode,
PyArena *arena)
{
mod_ty mod;
diff --git a/Python/pytime.c b/Python/pytime.c
index 7f65824..81682ca 100644
--- a/Python/pytime.c
+++ b/Python/pytime.c
@@ -7,6 +7,11 @@
#include <mach/mach_time.h> /* mach_absolute_time(), mach_timebase_info() */
#endif
+#define _PyTime_check_mul_overflow(a, b) \
+ (assert(b > 0), \
+ (_PyTime_t)(a) < _PyTime_MIN / (_PyTime_t)(b) \
+ || _PyTime_MAX / (_PyTime_t)(b) < (_PyTime_t)(a))
+
/* To millisecond (10^-3) */
#define SEC_TO_MS 1000
@@ -38,7 +43,7 @@
val = PyLong_AsLongLong(obj);
#else
long val;
- assert(sizeof(time_t) <= sizeof(long));
+ Py_BUILD_ASSERT(sizeof(time_t) <= sizeof(long));
val = PyLong_AsLong(obj);
#endif
if (val == -1 && PyErr_Occurred()) {
@@ -55,55 +60,88 @@
#if defined(HAVE_LONG_LONG) && SIZEOF_TIME_T == SIZEOF_LONG_LONG
return PyLong_FromLongLong((PY_LONG_LONG)t);
#else
- assert(sizeof(time_t) <= sizeof(long));
+ Py_BUILD_ASSERT(sizeof(time_t) <= sizeof(long));
return PyLong_FromLong((long)t);
#endif
}
+/* Round to nearest with ties going to nearest even integer
+ (_PyTime_ROUND_HALF_EVEN) */
+static double
+_PyTime_RoundHalfEven(double x)
+{
+ double rounded = round(x);
+ if (fabs(x-rounded) == 0.5)
+ /* halfway case: round to even */
+ rounded = 2.0*round(x/2.0);
+ return rounded;
+}
+
+static double
+_PyTime_Round(double x, _PyTime_round_t round)
+{
+ /* volatile avoids optimization changing how numbers are rounded */
+ volatile double d;
+
+ d = x;
+ if (round == _PyTime_ROUND_HALF_EVEN)
+ d = _PyTime_RoundHalfEven(d);
+ else if (round == _PyTime_ROUND_CEILING)
+ d = ceil(d);
+ else
+ d = floor(d);
+ return d;
+}
+
+static int
+_PyTime_DoubleToDenominator(double d, time_t *sec, long *numerator,
+ double denominator, _PyTime_round_t round)
+{
+ double intpart, err;
+ /* volatile avoids optimization changing how numbers are rounded */
+ volatile double floatpart;
+
+ floatpart = modf(d, &intpart);
+
+ floatpart *= denominator;
+ floatpart = _PyTime_Round(floatpart, round);
+ if (floatpart >= denominator) {
+ floatpart -= denominator;
+ intpart += 1.0;
+ }
+ else if (floatpart < 0) {
+ floatpart += denominator;
+ intpart -= 1.0;
+ }
+ assert(0.0 <= floatpart && floatpart < denominator);
+
+ *sec = (time_t)intpart;
+ *numerator = (long)floatpart;
+
+ err = intpart - (double)*sec;
+ if (err <= -1.0 || err >= 1.0) {
+ error_time_t_overflow();
+ return -1;
+ }
+ return 0;
+}
+
static int
_PyTime_ObjectToDenominator(PyObject *obj, time_t *sec, long *numerator,
double denominator, _PyTime_round_t round)
{
- assert(denominator <= LONG_MAX);
+ assert(denominator <= (double)LONG_MAX);
+
if (PyFloat_Check(obj)) {
- double d, intpart, err;
- /* volatile avoids unsafe optimization on float enabled by gcc -O3 */
- volatile double floatpart;
-
- d = PyFloat_AsDouble(obj);
- floatpart = modf(d, &intpart);
- if (floatpart < 0) {
- floatpart = 1.0 + floatpart;
- intpart -= 1.0;
- }
-
- floatpart *= denominator;
- if (round == _PyTime_ROUND_CEILING) {
- floatpart = ceil(floatpart);
- if (floatpart >= denominator) {
- floatpart = 0.0;
- intpart += 1.0;
- }
- }
- else {
- floatpart = floor(floatpart);
- }
-
- *sec = (time_t)intpart;
- err = intpart - (double)*sec;
- if (err <= -1.0 || err >= 1.0) {
- error_time_t_overflow();
- return -1;
- }
-
- *numerator = (long)floatpart;
- return 0;
+ double d = PyFloat_AsDouble(obj);
+ return _PyTime_DoubleToDenominator(d, sec, numerator,
+ denominator, round);
}
else {
*sec = _PyLong_AsTime_t(obj);
+ *numerator = 0;
if (*sec == (time_t)-1 && PyErr_Occurred())
return -1;
- *numerator = 0;
return 0;
}
}
@@ -112,13 +150,12 @@
_PyTime_ObjectToTime_t(PyObject *obj, time_t *sec, _PyTime_round_t round)
{
if (PyFloat_Check(obj)) {
- double d, intpart, err;
+ double intpart, err;
+ /* volatile avoids optimization changing how numbers are rounded */
+ volatile double d;
d = PyFloat_AsDouble(obj);
- if (round == _PyTime_ROUND_CEILING)
- d = ceil(d);
- else
- d = floor(d);
+ d = _PyTime_Round(d, round);
(void)modf(d, &intpart);
*sec = (time_t)intpart;
@@ -141,14 +178,20 @@
_PyTime_ObjectToTimespec(PyObject *obj, time_t *sec, long *nsec,
_PyTime_round_t round)
{
- return _PyTime_ObjectToDenominator(obj, sec, nsec, 1e9, round);
+ int res;
+ res = _PyTime_ObjectToDenominator(obj, sec, nsec, 1e9, round);
+ assert(0 <= *nsec && *nsec < SEC_TO_NS);
+ return res;
}
int
_PyTime_ObjectToTimeval(PyObject *obj, time_t *sec, long *usec,
_PyTime_round_t round)
{
- return _PyTime_ObjectToDenominator(obj, sec, usec, 1e6, round);
+ int res;
+ res = _PyTime_ObjectToDenominator(obj, sec, usec, 1e6, round);
+ assert(0 <= *usec && *usec < SEC_TO_US);
+ return res;
}
static void
@@ -162,12 +205,15 @@
_PyTime_FromSeconds(int seconds)
{
_PyTime_t t;
+ t = (_PyTime_t)seconds;
/* ensure that integer overflow cannot happen, int type should have 32
bits, whereas _PyTime_t type has at least 64 bits (SEC_TO_MS takes 30
bits). */
- assert((seconds >= 0 && seconds <= _PyTime_MAX / SEC_TO_NS)
- || (seconds < 0 && seconds >= _PyTime_MIN / SEC_TO_NS));
- t = (_PyTime_t)seconds * SEC_TO_NS;
+ Py_BUILD_ASSERT(INT_MAX <= _PyTime_MAX / SEC_TO_NS);
+ Py_BUILD_ASSERT(INT_MIN >= _PyTime_MIN / SEC_TO_NS);
+ assert((t >= 0 && t <= _PyTime_MAX / SEC_TO_NS)
+ || (t < 0 && t >= _PyTime_MIN / SEC_TO_NS));
+ t *= SEC_TO_NS;
return t;
}
@@ -175,7 +221,7 @@
_PyTime_FromNanoseconds(PY_LONG_LONG ns)
{
_PyTime_t t;
- assert(sizeof(PY_LONG_LONG) <= sizeof(_PyTime_t));
+ Py_BUILD_ASSERT(sizeof(PY_LONG_LONG) <= sizeof(_PyTime_t));
t = Py_SAFE_DOWNCAST(ns, PY_LONG_LONG, _PyTime_t);
return t;
}
@@ -187,12 +233,15 @@
_PyTime_t t;
int res = 0;
- t = (_PyTime_t)ts->tv_sec * SEC_TO_NS;
- if (t / SEC_TO_NS != ts->tv_sec) {
+ Py_BUILD_ASSERT(sizeof(ts->tv_sec) <= sizeof(_PyTime_t));
+ t = (_PyTime_t)ts->tv_sec;
+
+ if (_PyTime_check_mul_overflow(t, SEC_TO_NS)) {
if (raise)
_PyTime_overflow();
res = -1;
}
+ t = t * SEC_TO_NS;
t += ts->tv_nsec;
@@ -206,12 +255,15 @@
_PyTime_t t;
int res = 0;
- t = (_PyTime_t)tv->tv_sec * SEC_TO_NS;
- if (t / SEC_TO_NS != tv->tv_sec) {
+ Py_BUILD_ASSERT(sizeof(tv->tv_sec) <= sizeof(_PyTime_t));
+ t = (_PyTime_t)tv->tv_sec;
+
+ if (_PyTime_check_mul_overflow(t, SEC_TO_NS)) {
if (raise)
_PyTime_overflow();
res = -1;
}
+ t = t * SEC_TO_NS;
t += (_PyTime_t)tv->tv_usec * US_TO_NS;
@@ -221,50 +273,59 @@
#endif
static int
+_PyTime_FromFloatObject(_PyTime_t *t, double value, _PyTime_round_t round,
+ long unit_to_ns)
+{
+ double err;
+ /* volatile avoids optimization changing how numbers are rounded */
+ volatile double d;
+
+ /* convert to a number of nanoseconds */
+ d = value;
+ d *= (double)unit_to_ns;
+ d = _PyTime_Round(d, round);
+
+ *t = (_PyTime_t)d;
+ err = d - (double)*t;
+ if (fabs(err) >= 1.0) {
+ _PyTime_overflow();
+ return -1;
+ }
+ return 0;
+}
+
+static int
_PyTime_FromObject(_PyTime_t *t, PyObject *obj, _PyTime_round_t round,
- long to_nanoseconds)
+ long unit_to_ns)
{
if (PyFloat_Check(obj)) {
- /* volatile avoids unsafe optimization on float enabled by gcc -O3 */
- volatile double d, err;
-
- /* convert to a number of nanoseconds */
+ double d;
d = PyFloat_AsDouble(obj);
- d *= to_nanoseconds;
-
- if (round == _PyTime_ROUND_CEILING)
- d = ceil(d);
- else
- d = floor(d);
-
- *t = (_PyTime_t)d;
- err = d - (double)*t;
- if (fabs(err) >= 1.0) {
- _PyTime_overflow();
- return -1;
- }
- return 0;
+ return _PyTime_FromFloatObject(t, d, round, unit_to_ns);
}
else {
#ifdef HAVE_LONG_LONG
PY_LONG_LONG sec;
+ Py_BUILD_ASSERT(sizeof(PY_LONG_LONG) <= sizeof(_PyTime_t));
+
sec = PyLong_AsLongLong(obj);
- assert(sizeof(PY_LONG_LONG) <= sizeof(_PyTime_t));
#else
long sec;
+ Py_BUILD_ASSERT(sizeof(PY_LONG_LONG) <= sizeof(_PyTime_t));
+
sec = PyLong_AsLong(obj);
- assert(sizeof(PY_LONG_LONG) <= sizeof(_PyTime_t));
#endif
if (sec == -1 && PyErr_Occurred()) {
if (PyErr_ExceptionMatches(PyExc_OverflowError))
_PyTime_overflow();
return -1;
}
- *t = sec * to_nanoseconds;
- if (*t / to_nanoseconds != sec) {
+
+ if (_PyTime_check_mul_overflow(sec, unit_to_ns)) {
_PyTime_overflow();
return -1;
}
+ *t = sec * unit_to_ns;
return 0;
}
}
@@ -284,22 +345,31 @@
double
_PyTime_AsSecondsDouble(_PyTime_t t)
{
- _PyTime_t sec, ns;
- /* Divide using integers to avoid rounding issues on the integer part.
- 1e-9 cannot be stored exactly in IEEE 64-bit. */
- sec = t / SEC_TO_NS;
- ns = t % SEC_TO_NS;
- return (double)sec + (double)ns * 1e-9;
+ /* volatile avoids optimization changing how numbers are rounded */
+ volatile double d;
+
+ if (t % SEC_TO_NS == 0) {
+ _PyTime_t secs;
+ /* Divide using integers to avoid rounding issues on the integer part.
+ 1e-9 cannot be stored exactly in IEEE 64-bit. */
+ secs = t / SEC_TO_NS;
+ d = (double)secs;
+ }
+ else {
+ d = (double)t;
+ d /= 1e9;
+ }
+ return d;
}
PyObject *
_PyTime_AsNanosecondsObject(_PyTime_t t)
{
#ifdef HAVE_LONG_LONG
- assert(sizeof(PY_LONG_LONG) >= sizeof(_PyTime_t));
+ Py_BUILD_ASSERT(sizeof(PY_LONG_LONG) >= sizeof(_PyTime_t));
return PyLong_FromLongLong((PY_LONG_LONG)t);
#else
- assert(sizeof(long) >= sizeof(_PyTime_t));
+ Py_BUILD_ASSERT(sizeof(long) >= sizeof(_PyTime_t));
return PyLong_FromLong((long)t);
#endif
}
@@ -309,7 +379,20 @@
const _PyTime_round_t round)
{
assert(k > 1);
- if (round == _PyTime_ROUND_CEILING) {
+ if (round == _PyTime_ROUND_HALF_EVEN) {
+ _PyTime_t x, r, abs_r;
+ x = t / k;
+ r = t % k;
+ abs_r = Py_ABS(r);
+ if (abs_r > k / 2 || (abs_r == k / 2 && (Py_ABS(x) & 1))) {
+ if (t >= 0)
+ x++;
+ else
+ x--;
+ }
+ return x;
+ }
+ else if (round == _PyTime_ROUND_CEILING) {
if (t >= 0)
return (t + k - 1) / k;
else
@@ -373,7 +456,7 @@
_PyTime_AsTimevalStruct_impl(_PyTime_t t, struct timeval *tv,
_PyTime_round_t round, int raise)
{
- _PyTime_t secs;
+ _PyTime_t secs, secs2;
int us;
int res;
@@ -386,7 +469,8 @@
#endif
tv->tv_usec = us;
- if (res < 0 || (_PyTime_t)tv->tv_sec != secs) {
+ secs2 = (_PyTime_t)tv->tv_sec;
+ if (res < 0 || secs2 != secs) {
if (raise)
error_time_t_overflow();
return -1;
@@ -424,6 +508,7 @@
return 0;
}
+
#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_KQUEUE)
int
_PyTime_AsTimespec(_PyTime_t t, struct timespec *ts)
@@ -437,13 +522,13 @@
secs -= 1;
}
ts->tv_sec = (time_t)secs;
- if ((_PyTime_t)ts->tv_sec != secs) {
- _PyTime_overflow();
- return -1;
- }
+ assert(0 <= nsec && nsec < SEC_TO_NS);
ts->tv_nsec = nsec;
- assert(0 <= ts->tv_nsec && ts->tv_nsec <= 999999999);
+ if ((_PyTime_t)ts->tv_sec != secs) {
+ error_time_t_overflow();
+ return -1;
+ }
return 0;
}
#endif
@@ -557,19 +642,20 @@
return pygettimeofday(t, info, 1);
}
-
static int
pymonotonic(_PyTime_t *tp, _Py_clock_info_t *info, int raise)
{
#if defined(MS_WINDOWS)
- ULONGLONG result;
+ ULONGLONG ticks;
+ _PyTime_t t;
assert(info == NULL || raise);
- result = GetTickCount64();
+ ticks = GetTickCount64();
+ Py_BUILD_ASSERT(sizeof(ticks) <= sizeof(_PyTime_t));
+ t = (_PyTime_t)ticks;
- *tp = result * MS_TO_NS;
- if (*tp / MS_TO_NS != result) {
+ if (_PyTime_check_mul_overflow(t, MS_TO_NS)) {
if (raise) {
_PyTime_overflow();
return -1;
@@ -577,6 +663,7 @@
/* Hello, time traveler! */
assert(0);
}
+ *tp = t * MS_TO_NS;
if (info) {
DWORD timeAdjustment, timeIncrement;
@@ -689,8 +776,5 @@
if (_PyTime_GetMonotonicClockWithInfo(&t, NULL) < 0)
return -1;
- /* check that _PyTime_FromSeconds() cannot overflow */
- assert(INT_MAX <= _PyTime_MAX / SEC_TO_NS);
- assert(INT_MIN >= _PyTime_MIN / SEC_TO_NS);
return 0;
}
diff --git a/Python/random.c b/Python/random.c
index 3119872..c8e844e 100644
--- a/Python/random.c
+++ b/Python/random.c
@@ -132,11 +132,14 @@
* see https://bugs.python.org/issue26839. To avoid this, use the
* GRND_NONBLOCK flag. */
const int flags = GRND_NONBLOCK;
+
+ char *dest;
long n;
if (!getrandom_works)
return 0;
+ dest = buffer;
while (0 < size) {
#ifdef sun
/* Issue #26735: On Solaris, getrandom() is limited to returning up
@@ -150,11 +153,11 @@
#ifdef HAVE_GETRANDOM
if (raise) {
Py_BEGIN_ALLOW_THREADS
- n = getrandom(buffer, n, flags);
+ n = getrandom(dest, n, flags);
Py_END_ALLOW_THREADS
}
else {
- n = getrandom(buffer, n, flags);
+ n = getrandom(dest, n, flags);
}
#else
/* On Linux, use the syscall() function because the GNU libc doesn't
@@ -162,11 +165,11 @@
* https://sourceware.org/bugzilla/show_bug.cgi?id=17252 */
if (raise) {
Py_BEGIN_ALLOW_THREADS
- n = syscall(SYS_getrandom, buffer, n, flags);
+ n = syscall(SYS_getrandom, dest, n, flags);
Py_END_ALLOW_THREADS
}
else {
- n = syscall(SYS_getrandom, buffer, n, flags);
+ n = syscall(SYS_getrandom, dest, n, flags);
}
#endif
@@ -204,7 +207,7 @@
return -1;
}
- buffer += n;
+ dest += n;
size -= n;
}
return 1;
@@ -404,7 +407,7 @@
char *env;
unsigned char *secret = (unsigned char *)&_Py_HashSecret.uc;
Py_ssize_t secret_size = sizeof(_Py_HashSecret_t);
- assert(secret_size == sizeof(_Py_HashSecret.uc));
+ Py_BUILD_ASSERT(sizeof(_Py_HashSecret_t) == sizeof(_Py_HashSecret.uc));
if (_Py_HashSecret_Initialized)
return;
diff --git a/Python/symtable.c b/Python/symtable.c
index 1591a20..3f03184 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -160,7 +160,7 @@
};
static int symtable_analyze(struct symtable *st);
-static int symtable_warn(struct symtable *st, char *msg, int lineno);
+static int symtable_warn(struct symtable *st, const char *msg, int lineno);
static int symtable_enter_block(struct symtable *st, identifier name,
_Py_block_ty block, void *ast, int lineno,
int col_offset);
@@ -908,7 +908,7 @@
static int
-symtable_warn(struct symtable *st, char *msg, int lineno)
+symtable_warn(struct symtable *st, const char *msg, int lineno)
{
PyObject *message = PyUnicode_FromString(msg);
if (message == NULL)
@@ -1447,6 +1447,15 @@
VISIT_SEQ(st, expr, e->v.Call.args);
VISIT_SEQ_WITH_NULL(st, keyword, e->v.Call.keywords);
break;
+ case FormattedValue_kind:
+ VISIT(st, expr, e->v.FormattedValue.value);
+ if (e->v.FormattedValue.format_spec)
+ VISIT(st, expr, e->v.FormattedValue.format_spec);
+ break;
+ case JoinedStr_kind:
+ VISIT_SEQ(st, expr, e->v.JoinedStr.values);
+ break;
+ case Constant_kind:
case Num_kind:
case Str_kind:
case Bytes_kind:
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 8d7e05a..56175d9 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -20,6 +20,7 @@
#include "pythread.h"
#include "osdefs.h"
+#include <locale.h>
#ifdef MS_WINDOWS
#define WIN32_LEAN_AND_MEAN
@@ -33,7 +34,6 @@
#endif
#ifdef HAVE_LANGINFO_H
-#include <locale.h>
#include <langinfo.h>
#endif
@@ -346,8 +346,10 @@
static int
trace_init(void)
{
- static char *whatnames[7] = {"call", "exception", "line", "return",
- "c_call", "c_exception", "c_return"};
+ static const char * const whatnames[7] = {
+ "call", "exception", "line", "return",
+ "c_call", "c_exception", "c_return"
+ };
PyObject *name;
int i;
for (i = 0; i < 7; ++i) {
@@ -434,10 +436,7 @@
return -1;
}
if (result != Py_None) {
- PyObject *temp = frame->f_trace;
- frame->f_trace = NULL;
- Py_XDECREF(temp);
- frame->f_trace = result;
+ Py_XSETREF(frame->f_trace, result);
}
else {
Py_DECREF(result);
@@ -1152,8 +1151,10 @@
sys_debugmallocstats(PyObject *self, PyObject *args)
{
#ifdef WITH_PYMALLOC
- _PyObject_DebugMallocStats(stderr);
- fputc('\n', stderr);
+ if (_PyMem_PymallocEnabled()) {
+ _PyObject_DebugMallocStats(stderr);
+ fputc('\n', stderr);
+ }
#endif
_PyObject_DebugTypeStats(stderr);
@@ -1643,15 +1644,11 @@
/* sys.implementation values */
#define NAME "cpython"
const char *_PySys_ImplName = NAME;
-#define QUOTE(arg) #arg
-#define STRIFY(name) QUOTE(name)
-#define MAJOR STRIFY(PY_MAJOR_VERSION)
-#define MINOR STRIFY(PY_MINOR_VERSION)
+#define MAJOR Py_STRINGIFY(PY_MAJOR_VERSION)
+#define MINOR Py_STRINGIFY(PY_MINOR_VERSION)
#define TAG NAME "-" MAJOR MINOR
const char *_PySys_ImplCacheTag = TAG;
#undef NAME
-#undef QUOTE
-#undef STRIFY
#undef MAJOR
#undef MINOR
#undef TAG
@@ -1696,6 +1693,16 @@
if (res < 0)
goto error;
+#ifdef MULTIARCH
+ value = PyUnicode_FromString(MULTIARCH);
+ if (value == NULL)
+ goto error;
+ res = PyDict_SetItemString(impl_info, "_multiarch", value);
+ Py_DECREF(value);
+ if (res < 0)
+ goto error;
+#endif
+
/* dict ready */
ns = _PyNamespace_New(impl_info);
diff --git a/Python/traceback.c b/Python/traceback.c
index 941d1cb..59552ca 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -479,40 +479,26 @@
This function is signal safe. */
-static void
-reverse_string(char *text, const size_t len)
+void
+_Py_DumpDecimal(int fd, unsigned long value)
{
- char tmp;
- size_t i, j;
- if (len == 0)
- return;
- for (i=0, j=len-1; i < j; i++, j--) {
- tmp = text[i];
- text[i] = text[j];
- text[j] = tmp;
- }
-}
+ /* maximum number of characters required for output of %lld or %p.
+ We need at most ceil(log10(256)*SIZEOF_LONG_LONG) digits,
+ plus 1 for the null byte. 53/22 is an upper bound for log10(256). */
+ char buffer[1 + (sizeof(unsigned long)*53-1) / 22 + 1];
+ char *ptr, *end;
-/* Format an integer in range [0; 999999] to decimal,
- and write it into the file fd.
-
- This function is signal safe. */
-
-static void
-dump_decimal(int fd, int value)
-{
- char buffer[7];
- int len;
- if (value < 0 || 999999 < value)
- return;
- len = 0;
+ end = &buffer[Py_ARRAY_LENGTH(buffer) - 1];
+ ptr = end;
+ *ptr = '\0';
do {
- buffer[len] = '0' + (value % 10);
+ --ptr;
+ assert(ptr >= buffer);
+ *ptr = '0' + (value % 10);
value /= 10;
- len++;
} while (value);
- reverse_string(buffer, len);
- _Py_write_noraise(fd, buffer, len);
+
+ _Py_write_noraise(fd, ptr, end - ptr);
}
/* Format an integer in range [0; 0xffffffff] to hexadecimal of 'width' digits,
@@ -520,27 +506,31 @@
This function is signal safe. */
-static void
-dump_hexadecimal(int fd, unsigned long value, int width)
+void
+_Py_DumpHexadecimal(int fd, unsigned long value, Py_ssize_t width)
{
- int len;
- char buffer[sizeof(unsigned long) * 2 + 1];
- len = 0;
+ char buffer[sizeof(unsigned long) * 2 + 1], *ptr, *end;
+ const Py_ssize_t size = Py_ARRAY_LENGTH(buffer) - 1;
+
+ if (width > size)
+ width = size;
+ /* it's ok if width is negative */
+
+ end = &buffer[size];
+ ptr = end;
+ *ptr = '\0';
do {
- buffer[len] = Py_hexdigits[value & 15];
+ --ptr;
+ assert(ptr >= buffer);
+ *ptr = Py_hexdigits[value & 15];
value >>= 4;
- len++;
- } while (len < width || value);
- reverse_string(buffer, len);
- _Py_write_noraise(fd, buffer, len);
+ } while ((end - ptr) < width || value);
+
+ _Py_write_noraise(fd, ptr, end - ptr);
}
-/* Write an unicode object into the file fd using ascii+backslashreplace.
-
- This function is signal safe. */
-
-static void
-dump_ascii(int fd, PyObject *text)
+void
+_Py_DumpASCII(int fd, PyObject *text)
{
PyASCIIObject *ascii = (PyASCIIObject *)text;
Py_ssize_t i, size;
@@ -550,32 +540,36 @@
wchar_t *wstr = NULL;
Py_UCS4 ch;
+ if (!PyUnicode_Check(text))
+ return;
+
size = ascii->length;
kind = ascii->state.kind;
- if (ascii->state.compact) {
+ if (kind == PyUnicode_WCHAR_KIND) {
+ wstr = ((PyASCIIObject *)text)->wstr;
+ if (wstr == NULL)
+ return;
+ size = ((PyCompactUnicodeObject *)text)->wstr_length;
+ }
+ else if (ascii->state.compact) {
if (ascii->state.ascii)
data = ((PyASCIIObject*)text) + 1;
else
data = ((PyCompactUnicodeObject*)text) + 1;
}
- else if (kind != PyUnicode_WCHAR_KIND) {
+ else {
data = ((PyUnicodeObject *)text)->data.any;
if (data == NULL)
return;
}
- else {
- wstr = ((PyASCIIObject *)text)->wstr;
- if (wstr == NULL)
- return;
- size = ((PyCompactUnicodeObject *)text)->wstr_length;
- }
if (MAX_STRING_LENGTH < size) {
size = MAX_STRING_LENGTH;
truncated = 1;
}
- else
+ else {
truncated = 0;
+ }
for (i=0; i < size; i++) {
if (kind != PyUnicode_WCHAR_KIND)
@@ -589,19 +583,20 @@
}
else if (ch <= 0xff) {
PUTS(fd, "\\x");
- dump_hexadecimal(fd, ch, 2);
+ _Py_DumpHexadecimal(fd, ch, 2);
}
else if (ch <= 0xffff) {
PUTS(fd, "\\u");
- dump_hexadecimal(fd, ch, 4);
+ _Py_DumpHexadecimal(fd, ch, 4);
}
else {
PUTS(fd, "\\U");
- dump_hexadecimal(fd, ch, 8);
+ _Py_DumpHexadecimal(fd, ch, 8);
}
}
- if (truncated)
+ if (truncated) {
PUTS(fd, "...");
+ }
}
/* Write a frame into the file fd: "File "xxx", line xxx in xxx".
@@ -620,7 +615,7 @@
&& PyUnicode_Check(code->co_filename))
{
PUTS(fd, "\"");
- dump_ascii(fd, code->co_filename);
+ _Py_DumpASCII(fd, code->co_filename);
PUTS(fd, "\"");
} else {
PUTS(fd, "???");
@@ -629,14 +624,21 @@
/* PyFrame_GetLineNumber() was introduced in Python 2.7.0 and 3.2.0 */
lineno = PyCode_Addr2Line(code, frame->f_lasti);
PUTS(fd, ", line ");
- dump_decimal(fd, lineno);
+ if (lineno >= 0) {
+ _Py_DumpDecimal(fd, (unsigned long)lineno);
+ }
+ else {
+ PUTS(fd, "???");
+ }
PUTS(fd, " in ");
if (code != NULL && code->co_name != NULL
- && PyUnicode_Check(code->co_name))
- dump_ascii(fd, code->co_name);
- else
+ && PyUnicode_Check(code->co_name)) {
+ _Py_DumpASCII(fd, code->co_name);
+ }
+ else {
PUTS(fd, "???");
+ }
PUTS(fd, "\n");
}
@@ -692,7 +694,9 @@
PUTS(fd, "Current thread 0x");
else
PUTS(fd, "Thread 0x");
- dump_hexadecimal(fd, (unsigned long)tstate->thread_id, sizeof(unsigned long)*2);
+ _Py_DumpHexadecimal(fd,
+ (unsigned long)tstate->thread_id,
+ sizeof(unsigned long) * 2);
PUTS(fd, " (most recent call first):\n");
}
@@ -704,11 +708,56 @@
handlers if signals were received. */
const char*
_Py_DumpTracebackThreads(int fd, PyInterpreterState *interp,
- PyThreadState *current_thread)
+ PyThreadState *current_tstate)
{
PyThreadState *tstate;
unsigned int nthreads;
+#ifdef WITH_THREAD
+ if (current_tstate == NULL) {
+ /* _Py_DumpTracebackThreads() is called from signal handlers by
+ faulthandler.
+
+ SIGSEGV, SIGFPE, SIGABRT, SIGBUS and SIGILL are synchronous signals
+ and are thus delivered to the thread that caused the fault. Get the
+ Python thread state of the current thread.
+
+ PyThreadState_Get() doesn't give the state of the thread that caused
+ the fault if the thread released the GIL, and so this function
+ cannot be used. Read the thread local storage (TLS) instead: call
+ PyGILState_GetThisThreadState(). */
+ current_tstate = PyGILState_GetThisThreadState();
+ }
+
+ if (interp == NULL) {
+ if (current_tstate == NULL) {
+ interp = _PyGILState_GetInterpreterStateUnsafe();
+ if (interp == NULL) {
+ /* We need the interpreter state to get Python threads */
+ return "unable to get the interpreter state";
+ }
+ }
+ else {
+ interp = current_tstate->interp;
+ }
+ }
+#else
+ if (current_tstate == NULL) {
+ /* Call _PyThreadState_UncheckedGet() instead of PyThreadState_Get()
+ to not fail with a fatal error if the thread state is NULL. */
+ current_tstate = _PyThreadState_UncheckedGet();
+ }
+
+ if (interp == NULL) {
+ if (current_tstate == NULL) {
+ /* We need the interpreter state to get Python threads */
+ return "unable to get the interpreter state";
+ }
+ interp = current_tstate->interp;
+ }
+#endif
+ assert(interp != NULL);
+
/* Get the current interpreter from the current thread */
tstate = PyInterpreterState_ThreadHead(interp);
if (tstate == NULL)
@@ -726,7 +775,7 @@
PUTS(fd, "...\n");
break;
}
- write_thread_id(fd, tstate, tstate == current_thread);
+ write_thread_id(fd, tstate, tstate == current_tstate);
dump_traceback(fd, tstate, 0);
tstate = PyThreadState_Next(tstate);
nthreads++;
diff --git a/Python/wordcode_helpers.h b/Python/wordcode_helpers.h
new file mode 100644
index 0000000..b61ba33
--- /dev/null
+++ b/Python/wordcode_helpers.h
@@ -0,0 +1,38 @@
+/* This file contains code shared by the compiler and the peephole
+ optimizer.
+ */
+
+/* Minimum number of bytes necessary to encode instruction with EXTENDED_ARGs */
+static int
+instrsize(unsigned int oparg)
+{
+ return oparg <= 0xff ? 2 :
+ oparg <= 0xffff ? 4 :
+ oparg <= 0xffffff ? 6 :
+ 8;
+}
+
+/* Spits out op/oparg pair using ilen bytes. codestr should be pointed at the
+ desired location of the first EXTENDED_ARG */
+static void
+write_op_arg(unsigned char *codestr, unsigned char opcode,
+ unsigned int oparg, int ilen)
+{
+ switch (ilen) {
+ case 8:
+ *codestr++ = EXTENDED_ARG;
+ *codestr++ = (oparg >> 24) & 0xff;
+ case 6:
+ *codestr++ = EXTENDED_ARG;
+ *codestr++ = (oparg >> 16) & 0xff;
+ case 4:
+ *codestr++ = EXTENDED_ARG;
+ *codestr++ = (oparg >> 8) & 0xff;
+ case 2:
+ *codestr++ = opcode;
+ *codestr++ = oparg & 0xff;
+ break;
+ default:
+ assert(0);
+ }
+}
diff --git a/README b/README
index 483134d..1b15b7c 100644
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
-This is Python version 3.5.3 release candidate 1
-================================================
+This is Python version 3.6.0 alpha 2
+====================================
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
2012, 2013, 2014, 2015, 2016 Python Software Foundation. All rights reserved.
@@ -28,9 +28,9 @@
elsewhere it's just python.
On Mac OS X, if you have configured Python with --enable-framework, you should
-use "make frameworkinstall" to do the installation. Note that this installs
-the Python executable in a place that is not normally on your PATH, you may
-want to set up a symlink in /usr/local/bin.
+use "make frameworkinstall" to do the installation. Note that this installs the
+Python executable in a place that is not normally on your PATH, you may want to
+set up a symlink in /usr/local/bin.
On Windows, see PCbuild/readme.txt.
@@ -79,9 +79,9 @@
----------
We have a comprehensive overview of the changes in the "What's New in
-Python 3.5" document, found at
+Python 3.6" document, found at
- http://docs.python.org/3.5/whatsnew/3.5.html
+ https://docs.python.org/3.6/whatsnew/3.6.html
For a more detailed change log, read Misc/NEWS (though this file, too,
is incomplete, and also doesn't list anything merged in from the 2.7
@@ -94,9 +94,9 @@
Documentation
-------------
-Documentation for Python 3.5 is online, updated daily:
+Documentation for Python 3.6 is online, updated daily:
- http://docs.python.org/3.5/
+ https://docs.python.org/3.6/
It can also be downloaded in many formats for faster access. The documentation
is downloadable in HTML, PDF, and reStructuredText formats; the latter version
@@ -106,7 +106,7 @@
If you would like to contribute to the development of Python, relevant
documentation is available at:
- http://docs.python.org/devguide/
+ https://docs.python.org/devguide/
For information about building Python's documentation, refer to Doc/README.txt.
@@ -121,7 +121,7 @@
A source-to-source translation tool, "2to3", can take care of the mundane task
of converting large amounts of source code. It is not a complete solution but
is complemented by the deprecation warnings in 2.6. See
-http://docs.python.org/3.5/library/2to3.html for more information.
+https://docs.python.org/3.6/library/2to3.html for more information.
Testing
@@ -151,16 +151,16 @@
On Unix and Mac systems if you intend to install multiple versions of Python
using the same installation prefix (--prefix argument to the configure script)
-you must take care that your primary python executable is not overwritten by
-the installation of a different version. All files and directories installed
-using "make altinstall" contain the major and minor version and can thus live
-side-by-side. "make install" also creates ${prefix}/bin/python3 which refers
-to ${prefix}/bin/pythonX.Y. If you intend to install multiple versions using
-the same prefix you must decide which version (if any) is your "primary"
-version. Install that version using "make install". Install all other
-versions using "make altinstall".
+you must take care that your primary python executable is not overwritten by the
+installation of a different version. All files and directories installed using
+"make altinstall" contain the major and minor version and can thus live
+side-by-side. "make install" also creates ${prefix}/bin/python3 which refers to
+${prefix}/bin/pythonX.Y. If you intend to install multiple versions using the
+same prefix you must decide which version (if any) is your "primary" version.
+Install that version using "make install". Install all other versions using
+"make altinstall".
-For example, if you want to install Python 2.6, 2.7 and 3.5 with 2.7 being the
+For example, if you want to install Python 2.6, 2.7 and 3.6 with 2.7 being the
primary version, you would execute "make install" in your 2.7 build directory
and "make altinstall" in the others.
@@ -171,7 +171,7 @@
We're soliciting bug reports about all aspects of the language. Fixes are also
welcome, preferably in unified diff format. Please use the issue tracker:
- http://bugs.python.org/
+ https://bugs.python.org/
If you're not sure whether you're dealing with a bug or a feature, use the
mailing list:
@@ -180,23 +180,23 @@
To subscribe to the list, use the mailman form:
- http://mail.python.org/mailman/listinfo/python-dev/
+ https://mail.python.org/mailman/listinfo/python-dev/
Proposals for enhancement
-------------------------
If you have a proposal to change Python, you may want to send an email to the
-comp.lang.python or python-ideas mailing lists for inital feedback. A Python
+comp.lang.python or python-ideas mailing lists for initial feedback. A Python
Enhancement Proposal (PEP) may be submitted if your idea gains ground. All
current PEPs, as well as guidelines for submitting a new PEP, are listed at
-http://www.python.org/dev/peps/.
+https://www.python.org/dev/peps/.
Release Schedule
----------------
-See PEP 478 for release details: http://www.python.org/dev/peps/pep-0478/
+See PEP 494 for release details: https://www.python.org/dev/peps/pep-0494/
Copyright and License Information
diff --git a/Tools/buildbot/test.bat b/Tools/buildbot/test.bat
index ff7d167..5972d5e 100644
--- a/Tools/buildbot/test.bat
+++ b/Tools/buildbot/test.bat
@@ -4,7 +4,7 @@
set here=%~dp0
set rt_opts=-q -d
-set regrtest_args=
+set regrtest_args=-j1
:CheckOpts
if "%1"=="-x64" (set rt_opts=%rt_opts% %1) & shift & goto CheckOpts
@@ -16,4 +16,4 @@
if NOT "%1"=="" (set regrtest_args=%regrtest_args% %1) & shift & goto CheckOpts
echo on
-call "%here%..\..\PCbuild\rt.bat" %rt_opts% -uall -rwW --timeout=3600 %regrtest_args%
+call "%here%..\..\PCbuild\rt.bat" %rt_opts% -uall -rwW --timeout=900 %regrtest_args%
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 1d851da..c964093 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -644,7 +644,7 @@
default_return_converter = (not f.return_converter or
f.return_converter.type == 'PyObject *')
- positional = parameters and (parameters[-1].kind == inspect.Parameter.POSITIONAL_ONLY)
+ positional = parameters and parameters[-1].is_positional_only()
all_boring_objects = False # yes, this will be false if there are 0 parameters, it's fine
first_optional = len(parameters)
for i, p in enumerate(parameters):
@@ -661,7 +661,7 @@
new_or_init = f.kind in (METHOD_NEW, METHOD_INIT)
meth_o = (len(parameters) == 1 and
- parameters[0].kind == inspect.Parameter.POSITIONAL_ONLY and
+ parameters[0].is_positional_only() and
not converters[0].is_optional() and
not new_or_init)
@@ -797,8 +797,9 @@
""" % argname)
parser_definition = parser_body(parser_prototype, normalize_snippet("""
- if (!PyArg_Parse(%s, "{format_units}:{name}", {parse_arguments}))
+ if (!PyArg_Parse(%s, "{format_units}:{name}", {parse_arguments})) {{
goto exit;
+ }}
""" % argname, indent=4))
elif has_option_groups:
@@ -822,8 +823,9 @@
parser_definition = parser_body(parser_prototype, normalize_snippet("""
if (!PyArg_UnpackTuple(args, "{name}",
{unpack_min}, {unpack_max},
- {parse_arguments}))
+ {parse_arguments})) {{
goto exit;
+ }}
""", indent=4))
elif positional:
@@ -835,8 +837,9 @@
parser_definition = parser_body(parser_prototype, normalize_snippet("""
if (!PyArg_ParseTuple(args, "{format_units}:{name}",
- {parse_arguments}))
+ {parse_arguments})) {{
goto exit;
+ }}
""", indent=4))
else:
@@ -847,13 +850,15 @@
body = normalize_snippet("""
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "{format_units}:{name}", _keywords,
- {parse_arguments}))
+ {parse_arguments})) {{
goto exit;
- """, indent=4)
+ }}
+ """, indent=4)
parser_definition = parser_body(parser_prototype, normalize_snippet("""
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "{format_units}:{name}", _keywords,
- {parse_arguments}))
+ {parse_arguments})) {{
goto exit;
+ }}
""", indent=4))
parser_definition = insert_keywords(parser_definition)
@@ -878,13 +883,15 @@
if not parses_keywords:
fields.insert(0, normalize_snippet("""
- if ({self_type_check}!_PyArg_NoKeywords("{name}", kwargs))
+ if ({self_type_check}!_PyArg_NoKeywords("{name}", kwargs)) {{
goto exit;
+ }}
""", indent=4))
if not parses_positional:
fields.insert(0, normalize_snippet("""
- if ({self_type_check}!_PyArg_NoPositional("{name}", args))
+ if ({self_type_check}!_PyArg_NoPositional("{name}", args)) {{
goto exit;
+ }}
""", indent=4))
parser_definition = parser_body(parser_prototype, *fields)
@@ -1032,8 +1039,9 @@
s = """
case {count}:
- if (!PyArg_ParseTuple(args, "{format_units}:{name}", {parse_arguments}))
+ if (!PyArg_ParseTuple(args, "{format_units}:{name}", {parse_arguments})) {{
goto exit;
+ }}
{group_booleans}
break;
"""[1:]
@@ -1067,7 +1075,7 @@
last_group = 0
first_optional = len(selfless)
- positional = selfless and selfless[-1].kind == inspect.Parameter.POSITIONAL_ONLY
+ positional = selfless and selfless[-1].is_positional_only()
new_or_init = f.kind in (METHOD_NEW, METHOD_INIT)
default_return_converter = (not f.return_converter or
f.return_converter.type == 'PyObject *')
@@ -2359,7 +2367,10 @@
data.modifications.append('/* modifications for ' + name + ' */\n' + modifications.rstrip())
# keywords
- data.keywords.append(parameter.name)
+ if parameter.is_positional_only():
+ data.keywords.append('')
+ else:
+ data.keywords.append(parameter.name)
# format_units
if self.is_optional() and '|' not in data.format_units:
@@ -2676,7 +2687,7 @@
def cleanup(self):
if self.encoding:
name = ensure_legal_c_identifier(self.name)
- return "".join(["if (", name, ")\n PyMem_FREE(", name, ");\n"])
+ return "".join(["if (", name, ") {\n PyMem_FREE(", name, ");\n}\n"])
#
# This is the fourth or fifth rewrite of registering all the
@@ -2786,7 +2797,7 @@
def cleanup(self):
name = ensure_legal_c_identifier(self.name)
- return "".join(["if (", name, ".obj)\n PyBuffer_Release(&", name, ");\n"])
+ return "".join(["if (", name, ".obj) {\n PyBuffer_Release(&", name, ");\n}\n"])
def correct_name_for_self(f):
@@ -2959,10 +2970,10 @@
data.return_value = name
def err_occurred_if(self, expr, data):
- data.return_conversion.append('if (({}) && PyErr_Occurred())\n goto exit;\n'.format(expr))
+ data.return_conversion.append('if (({}) && PyErr_Occurred()) {{\n goto exit;\n}}\n'.format(expr))
def err_occurred_if_null_pointer(self, variable, data):
- data.return_conversion.append('if ({} == NULL)\n goto exit;\n'.format(variable))
+ data.return_conversion.append('if ({} == NULL) {{\n goto exit;\n}}\n'.format(variable))
def render(self, function, data):
"""
@@ -2977,8 +2988,9 @@
def render(self, function, data):
self.declare(data)
data.return_conversion.append('''
-if (_return_value != Py_None)
+if (_return_value != Py_None) {
goto exit;
+}
return_value = Py_None;
Py_INCREF(Py_None);
'''.strip())
@@ -3183,6 +3195,7 @@
self.state = self.state_dsl_start
self.parameter_indent = None
self.keyword_only = False
+ self.positional_only = False
self.group = 0
self.parameter_state = self.ps_start
self.seen_positional_with_default = False
@@ -3561,8 +3574,8 @@
# "parameter_state". (Previously the code was a miasma of ifs and
# separate boolean state variables.) The states are:
#
- # [ [ a, b, ] c, ] d, e, f=3, [ g, h, [ i ] ] / <- line
- # 01 2 3 4 5 6 7 <- state transitions
+ # [ [ a, b, ] c, ] d, e, f=3, [ g, h, [ i ] ] <- line
+ # 01 2 3 4 5 6 <- state transitions
#
# 0: ps_start. before we've seen anything. legal transitions are to 1 or 3.
# 1: ps_left_square_before. left square brackets before required parameters.
@@ -3573,9 +3586,8 @@
# now must have default values.
# 5: ps_group_after. in a group, after required parameters.
# 6: ps_right_square_after. right square brackets after required parameters.
- # 7: ps_seen_slash. seen slash.
ps_start, ps_left_square_before, ps_group_before, ps_required, \
- ps_optional, ps_group_after, ps_right_square_after, ps_seen_slash = range(8)
+ ps_optional, ps_group_after, ps_right_square_after = range(7)
def state_parameters_start(self, line):
if self.ignore_line(line):
@@ -3854,9 +3866,6 @@
return name, False, kwargs
def parse_special_symbol(self, symbol):
- if self.parameter_state == self.ps_seen_slash:
- fail("Function " + self.function.name + " specifies " + symbol + " after /, which is unsupported.")
-
if symbol == '*':
if self.keyword_only:
fail("Function " + self.function.name + " uses '*' more than once.")
@@ -3883,13 +3892,15 @@
else:
fail("Function " + self.function.name + " has an unsupported group configuration. (Unexpected state " + str(self.parameter_state) + ".c)")
elif symbol == '/':
+ if self.positional_only:
+ fail("Function " + self.function.name + " uses '/' more than once.")
+ self.positional_only = True
# ps_required and ps_optional are allowed here, that allows positional-only without option groups
# to work (and have default values!)
if (self.parameter_state not in (self.ps_required, self.ps_optional, self.ps_right_square_after, self.ps_group_before)) or self.group:
fail("Function " + self.function.name + " has an unsupported group configuration. (Unexpected state " + str(self.parameter_state) + ".d)")
if self.keyword_only:
fail("Function " + self.function.name + " mixes keyword-only and positional-only parameters, which is unsupported.")
- self.parameter_state = self.ps_seen_slash
# fixup preceding parameters
for p in self.function.parameters.values():
if (p.kind != inspect.Parameter.POSITIONAL_OR_KEYWORD and not isinstance(p.converter, self_converter)):
@@ -3977,23 +3988,20 @@
# populate "right_bracket_count" field for every parameter
assert parameters, "We should always have a self parameter. " + repr(f)
assert isinstance(parameters[0].converter, self_converter)
+ # self is always positional-only.
+ assert parameters[0].is_positional_only()
parameters[0].right_bracket_count = 0
- parameters_after_self = parameters[1:]
- if parameters_after_self:
- # for now, the only way Clinic supports positional-only parameters
- # is if all of them are positional-only...
- #
- # ... except for self! self is always positional-only.
-
- positional_only_parameters = [p.kind == inspect.Parameter.POSITIONAL_ONLY for p in parameters_after_self]
- if parameters_after_self[0].kind == inspect.Parameter.POSITIONAL_ONLY:
- assert all(positional_only_parameters)
- for p in parameters:
- p.right_bracket_count = abs(p.group)
+ positional_only = True
+ for p in parameters[1:]:
+ if not p.is_positional_only():
+ positional_only = False
+ else:
+ assert positional_only
+ if positional_only:
+ p.right_bracket_count = abs(p.group)
else:
# don't put any right brackets around non-positional-only parameters, ever.
- for p in parameters_after_self:
- p.right_bracket_count = 0
+ p.right_bracket_count = 0
right_bracket_count = 0
diff --git a/Tools/freeze/freeze.py b/Tools/freeze/freeze.py
index c075807..389fffd 100755
--- a/Tools/freeze/freeze.py
+++ b/Tools/freeze/freeze.py
@@ -218,7 +218,7 @@
ishome = os.path.exists(os.path.join(prefix, 'Python', 'ceval.c'))
# locations derived from options
- version = sys.version[:3]
+ version = '%d.%d' % sys.version_info[:2]
flagged_version = version + sys.abiflags
if win:
extensions_c = 'frozen_extensions.c'
diff --git a/Tools/i18n/pygettext.py b/Tools/i18n/pygettext.py
index 3c6c14c..be941c7 100755
--- a/Tools/i18n/pygettext.py
+++ b/Tools/i18n/pygettext.py
@@ -156,7 +156,8 @@
""")
import os
-import imp
+import importlib.machinery
+import importlib.util
import sys
import glob
import time
@@ -263,8 +264,7 @@
# get extension for python source files
if '_py_ext' not in globals():
global _py_ext
- _py_ext = [triple[0] for triple in imp.get_suffixes()
- if triple[2] == imp.PY_SOURCE][0]
+ _py_ext = importlib.machinery.SOURCE_SUFFIXES[0]
# don't recurse into CVS directories
if 'CVS' in names:
@@ -277,45 +277,6 @@
)
-def _get_modpkg_path(dotted_name, pathlist=None):
- """Get the filesystem path for a module or a package.
-
- Return the file system path to a file for a module, and to a directory for
- a package. Return None if the name is not found, or is a builtin or
- extension module.
- """
- # split off top-most name
- parts = dotted_name.split('.', 1)
-
- if len(parts) > 1:
- # we have a dotted path, import top-level package
- try:
- file, pathname, description = imp.find_module(parts[0], pathlist)
- if file: file.close()
- except ImportError:
- return None
-
- # check if it's indeed a package
- if description[2] == imp.PKG_DIRECTORY:
- # recursively handle the remaining name parts
- pathname = _get_modpkg_path(parts[1], [pathname])
- else:
- pathname = None
- else:
- # plain name
- try:
- file, pathname, description = imp.find_module(
- dotted_name, pathlist)
- if file:
- file.close()
- if description[2] not in [imp.PY_SOURCE, imp.PKG_DIRECTORY]:
- pathname = None
- except ImportError:
- pathname = None
-
- return pathname
-
-
def getFilesForName(name):
"""Get a list of module files for a filename, a module or package name,
or a directory.
@@ -330,7 +291,11 @@
return list
# try to find module or package
- name = _get_modpkg_path(name)
+ try:
+ spec = importlib.util.find_spec(name)
+ name = spec.origin
+ except ImportError:
+ name = None
if not name:
return []
diff --git a/Tools/msi/lib/lib_files.wxs b/Tools/msi/lib/lib_files.wxs
index fa79a8d..804ab01 100644
--- a/Tools/msi/lib/lib_files.wxs
+++ b/Tools/msi/lib/lib_files.wxs
@@ -64,16 +64,10 @@
<RegistryValue Key="PythonPath" Type="string" Value="[Lib];[DLLs]" />
</RegistryKey>
</Component>
- <Component Id="Lib_site_packages_README" Directory="Lib_site_packages" Guid="*">
- <File Id="Lib_site_packages_README" Name="README.txt" Source="!(bindpath.src)Lib\site-packages\README" KeyPath="yes" />
- </Component>
<Component Id="Lib2to3_pickle_remove" Directory="Lib_lib2to3" Guid="$(var.RemoveLib2to3PickleComponentGuid)">
<RemoveFile Id="Lib2to3_pickle_remove_files" Name="*.pickle" On="uninstall" />
<RemoveFolder Id="Lib2to3_pickle_remove_folder" On="uninstall" />
</Component>
</ComponentGroup>
- <DirectoryRef Id="Lib">
- <Directory Id="Lib_site_packages" Name="site-packages" />
- </DirectoryRef>
</Fragment>
</Wix>
diff --git a/Tools/parser/unparse.py b/Tools/parser/unparse.py
index 285030e..7203057 100644
--- a/Tools/parser/unparse.py
+++ b/Tools/parser/unparse.py
@@ -322,9 +322,72 @@
def _Str(self, tree):
self.write(repr(tree.s))
+ def _JoinedStr(self, t):
+ self.write("f")
+ string = io.StringIO()
+ self._fstring_JoinedStr(t, string.write)
+ self.write(repr(string.getvalue()))
+
+ def _FormattedValue(self, t):
+ self.write("f")
+ string = io.StringIO()
+ self._fstring_FormattedValue(t, string.write)
+ self.write(repr(string.getvalue()))
+
+ def _fstring_JoinedStr(self, t, write):
+ for value in t.values:
+ meth = getattr(self, "_fstring_" + type(value).__name__)
+ meth(value, write)
+
+ def _fstring_Str(self, t, write):
+ value = t.s.replace("{", "{{").replace("}", "}}")
+ write(value)
+
+ def _fstring_Constant(self, t, write):
+ assert isinstance(t.value, str)
+ value = t.value.replace("{", "{{").replace("}", "}}")
+ write(value)
+
+ def _fstring_FormattedValue(self, t, write):
+ write("{")
+ expr = io.StringIO()
+ Unparser(t.value, expr)
+ expr = expr.getvalue().rstrip("\n")
+ if expr.startswith("{"):
+ write(" ") # Separate pair of opening brackets as "{ {"
+ write(expr)
+ if t.conversion != -1:
+ conversion = chr(t.conversion)
+ assert conversion in "sra"
+ write(f"!{conversion}")
+ if t.format_spec:
+ write(":")
+ meth = getattr(self, "_fstring_" + type(t.format_spec).__name__)
+ meth(t.format_spec, write)
+ write("}")
+
def _Name(self, t):
self.write(t.id)
+ def _write_constant(self, value):
+ if isinstance(value, (float, complex)):
+ self.write(repr(value).replace("inf", INFSTR))
+ else:
+ self.write(repr(value))
+
+ def _Constant(self, t):
+ value = t.value
+ if isinstance(value, tuple):
+ self.write("(")
+ if len(value) == 1:
+ self._write_constant(value[0])
+ self.write(",")
+ else:
+ interleave(lambda: self.write(", "), self._write_constant, value)
+ self.write(")")
+ else:
+ self._write_constant(t.value)
+
def _NameConstant(self, t):
self.write(repr(t.value))
@@ -413,7 +476,7 @@
def _Tuple(self, t):
self.write("(")
if len(t.elts) == 1:
- (elt,) = t.elts
+ elt = t.elts[0]
self.dispatch(elt)
self.write(",")
else:
@@ -460,7 +523,8 @@
# Special case: 3.__abs__() is a syntax error, so if t.value
# is an integer literal then we need to either parenthesize
# it or add an extra space to get 3 .__abs__().
- if isinstance(t.value, ast.Num) and isinstance(t.value.n, int):
+ if ((isinstance(t.value, ast.Num) and isinstance(t.value.n, int))
+ or (isinstance(t.value, ast.Constant) and isinstance(t.value.value, int))):
self.write(" ")
self.write(".")
self.write(t.attr)
diff --git a/Tools/scripts/combinerefs.py b/Tools/scripts/combinerefs.py
index e10e49a..7ca9526 100755
--- a/Tools/scripts/combinerefs.py
+++ b/Tools/scripts/combinerefs.py
@@ -6,7 +6,7 @@
A helper for analyzing PYTHONDUMPREFS output.
When the PYTHONDUMPREFS envar is set in a debug build, at Python shutdown
-time Py_Finalize() prints the list of all live objects twice: first it
+time Py_FinalizeEx() prints the list of all live objects twice: first it
prints the repr() of each object while the interpreter is still fully intact.
After cleaning up everything it can, it prints all remaining live objects
again, but the second time just prints their addresses, refcounts, and type
@@ -41,7 +41,7 @@
objects shown in the repr: the repr was captured from the first output block,
and some of the containees may have been released since then. For example,
it's common for the line showing the dict of interned strings to display
-strings that no longer exist at the end of Py_Finalize; this can be recognized
+strings that no longer exist at the end of Py_FinalizeEx; this can be recognized
(albeit painfully) because such containees don't have a line of their own.
The objects are listed in allocation order, with most-recently allocated
diff --git a/Tools/scripts/diff.py b/Tools/scripts/diff.py
index 9720a43..96199b8 100755
--- a/Tools/scripts/diff.py
+++ b/Tools/scripts/diff.py
@@ -8,7 +8,7 @@
"""
-import sys, os, time, difflib, argparse
+import sys, os, difflib, argparse
from datetime import datetime, timezone
def file_mtime(path):
diff --git a/Tools/scripts/idle3 b/Tools/scripts/idle3
index 8ee92c2..d7332bc 100755
--- a/Tools/scripts/idle3
+++ b/Tools/scripts/idle3
@@ -1,5 +1,5 @@
#! /usr/bin/env python3
-from idlelib.PyShell import main
+from idlelib.pyshell import main
if __name__ == '__main__':
main()
diff --git a/Tools/scripts/nm2def.py b/Tools/scripts/nm2def.py
index 8f07559..83bbcd7 100755
--- a/Tools/scripts/nm2def.py
+++ b/Tools/scripts/nm2def.py
@@ -36,8 +36,8 @@
"""
import os, sys
-PYTHONLIB = 'libpython'+sys.version[:3]+'.a'
-PC_PYTHONLIB = 'Python'+sys.version[0]+sys.version[2]+'.dll'
+PYTHONLIB = 'libpython%d.%d.a' % sys.version_info[:2]
+PC_PYTHONLIB = 'Python%d%d.dll' % sys.version_info[:2]
NM = 'nm -p -g %s' # For Linux, use "nm -g %s"
def symbols(lib=PYTHONLIB,types=('T','C','D')):
diff --git a/Tools/scripts/pyvenv b/Tools/scripts/pyvenv
index 978d691..1fb42c6 100755
--- a/Tools/scripts/pyvenv
+++ b/Tools/scripts/pyvenv
@@ -1,6 +1,12 @@
#!/usr/bin/env python3
if __name__ == '__main__':
import sys
+ import pathlib
+
+ executable = pathlib.Path(sys.executable or 'python3').name
+ print('WARNING: the pyenv script is deprecated in favour of '
+ f'`{executable} -m venv`', file=sys.stderr)
+
rc = 1
try:
import venv
diff --git a/configure b/configure
index c892a99..7b02530 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for python 3.5.
+# Generated by GNU Autoconf 2.69 for python 3.6.
#
# Report bugs to <http://bugs.python.org/>.
#
@@ -580,8 +580,8 @@
# Identity of this package.
PACKAGE_NAME='python'
PACKAGE_TARNAME='python'
-PACKAGE_VERSION='3.5'
-PACKAGE_STRING='python 3.5'
+PACKAGE_VERSION='3.6'
+PACKAGE_STRING='python 3.6'
PACKAGE_BUGREPORT='http://bugs.python.org/'
PACKAGE_URL=''
@@ -704,6 +704,7 @@
BUILDEXEEXT
EGREP
NO_AS_NEEDED
+MULTIARCH_CPPFLAGS
PLATFORM_TRIPLET
PLATDIR
MULTIARCH
@@ -776,6 +777,7 @@
docdir
oldincludedir
includedir
+runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -886,6 +888,7 @@
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1138,6 +1141,15 @@
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
+ -runstatedir | --runstatedir | --runstatedi | --runstated \
+ | --runstate | --runstat | --runsta | --runst | --runs \
+ | --run | --ru | --r)
+ ac_prev=runstatedir ;;
+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+ | --run=* | --ru=* | --r=*)
+ runstatedir=$ac_optarg ;;
+
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1275,7 +1287,7 @@
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir
+ libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1388,7 +1400,7 @@
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures python 3.5 to adapt to many kinds of systems.
+\`configure' configures python 3.6 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1428,6 +1440,7 @@
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -1453,7 +1466,7 @@
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of python 3.5:";;
+ short | recursive ) echo "Configuration of python 3.6:";;
esac
cat <<\_ACEOF
@@ -1610,7 +1623,7 @@
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-python configure 3.5
+python configure 3.6
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2449,7 +2462,7 @@
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by python $as_me 3.5, which was
+It was created by python $as_me 3.6, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -3023,7 +3036,7 @@
mv confdefs.h.new confdefs.h
-VERSION=3.5
+VERSION=3.6
# Version number of Python's own shared library file.
@@ -5332,9 +5345,16 @@
as_fn_error $? "internal configure error for the platform triplet, please file a bug report" "$LINENO" 5
fi
fi
-PLATDIR=plat-$MACHDEP
+if test x$PLATFORM_TRIPLET = x; then
+ PLATDIR=plat-$MACHDEP
+else
+ PLATDIR=plat-$PLATFORM_TRIPLET
+fi
+if test x$MULTIARCH != x; then
+ MULTIARCH_CPPFLAGS="-DMULTIARCH=\\\"$MULTIARCH\\\""
+fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -Wl,--no-as-needed" >&5
@@ -7997,6 +8017,11 @@
use_lfs=no
fi
+# Don't use largefile support for GNU/Hurd
+case $ac_sys_system in GNU*)
+ use_lfs=no
+esac
+
if test "$use_lfs" = "yes"; then
# Two defines needed to enable largefile support on various platforms
# These may affect some typedefs
@@ -12919,6 +12944,33 @@
fi
+ac_fn_c_check_member "$LINENO" "struct passwd" "pw_gecos" "ac_cv_member_struct_passwd_pw_gecos" "
+ #include <sys/types.h>
+ #include <pwd.h>
+
+"
+if test "x$ac_cv_member_struct_passwd_pw_gecos" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_PASSWD_PW_GECOS 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_member "$LINENO" "struct passwd" "pw_passwd" "ac_cv_member_struct_passwd_pw_passwd" "
+ #include <sys/types.h>
+ #include <pwd.h>
+
+"
+if test "x$ac_cv_member_struct_passwd_pw_passwd" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_PASSWD_PW_PASSWD 1
+_ACEOF
+
+
+fi
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for time.h that defines altzone" >&5
$as_echo_n "checking for time.h that defines altzone... " >&6; }
@@ -14229,6 +14281,85 @@
fi
+ac_fn_c_check_decl "$LINENO" "RTLD_LAZY" "ac_cv_have_decl_RTLD_LAZY" "#include <dlfcn.h>
+"
+if test "x$ac_cv_have_decl_RTLD_LAZY" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_RTLD_LAZY $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "RTLD_NOW" "ac_cv_have_decl_RTLD_NOW" "#include <dlfcn.h>
+"
+if test "x$ac_cv_have_decl_RTLD_NOW" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_RTLD_NOW $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "RTLD_GLOBAL" "ac_cv_have_decl_RTLD_GLOBAL" "#include <dlfcn.h>
+"
+if test "x$ac_cv_have_decl_RTLD_GLOBAL" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_RTLD_GLOBAL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "RTLD_LOCAL" "ac_cv_have_decl_RTLD_LOCAL" "#include <dlfcn.h>
+"
+if test "x$ac_cv_have_decl_RTLD_LOCAL" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_RTLD_LOCAL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "RTLD_NODELETE" "ac_cv_have_decl_RTLD_NODELETE" "#include <dlfcn.h>
+"
+if test "x$ac_cv_have_decl_RTLD_NODELETE" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_RTLD_NODELETE $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "RTLD_NOLOAD" "ac_cv_have_decl_RTLD_NOLOAD" "#include <dlfcn.h>
+"
+if test "x$ac_cv_have_decl_RTLD_NOLOAD" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_RTLD_NOLOAD $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "RTLD_DEEPBIND" "ac_cv_have_decl_RTLD_DEEPBIND" "#include <dlfcn.h>
+"
+if test "x$ac_cv_have_decl_RTLD_DEEPBIND" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_RTLD_DEEPBIND $ac_have_decl
+_ACEOF
+
+
# determine what size digit to use for Python's longs
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking digit size for Python's longs" >&5
$as_echo_n "checking digit size for Python's longs... " >&6; }
@@ -14662,7 +14793,11 @@
$as_echo "$LDVERSION" >&6; }
-LIBPL='$(prefix)'"/lib/python${VERSION}/config-${LDVERSION}"
+if test x$PLATFORM_TRIPLET = x; then
+ LIBPL='$(prefix)'"/lib/python${VERSION}/config-${LDVERSION}"
+else
+ LIBPL='$(prefix)'"/lib/python${VERSION}/config-${LDVERSION}-${PLATFORM_TRIPLET}"
+fi
# Check whether right shifting a negative integer extends the sign bit
@@ -16904,7 +17039,7 @@
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by python $as_me 3.5, which was
+This file was extended by python $as_me 3.6, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -16966,7 +17101,7 @@
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-python config.status 3.5
+python config.status 3.6
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/configure.ac b/configure.ac
index 1c07c05..39d12e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@
dnl ***********************************************
# Set VERSION so we only need to edit in one place (i.e., here)
-m4_define(PYTHON_VERSION, 3.5)
+m4_define(PYTHON_VERSION, 3.6)
AC_PREREQ(2.65)
@@ -872,10 +872,17 @@
AC_MSG_ERROR([internal configure error for the platform triplet, please file a bug report])
fi
fi
-PLATDIR=plat-$MACHDEP
+if test x$PLATFORM_TRIPLET = x; then
+ PLATDIR=plat-$MACHDEP
+else
+ PLATDIR=plat-$PLATFORM_TRIPLET
+fi
AC_SUBST(PLATDIR)
AC_SUBST(PLATFORM_TRIPLET)
-
+if test x$MULTIARCH != x; then
+ MULTIARCH_CPPFLAGS="-DMULTIARCH=\\\"$MULTIARCH\\\""
+fi
+AC_SUBST(MULTIARCH_CPPFLAGS)
AC_MSG_CHECKING([for -Wl,--no-as-needed])
save_LDFLAGS="$LDFLAGS"
@@ -1979,6 +1986,11 @@
use_lfs=no
fi
+# Don't use largefile support for GNU/Hurd
+case $ac_sys_system in GNU*)
+ use_lfs=no
+esac
+
if test "$use_lfs" = "yes"; then
# Two defines needed to enable largefile support on various platforms
# These may affect some typedefs
@@ -3762,6 +3774,10 @@
AC_CHECK_MEMBERS([struct stat.st_gen])
AC_CHECK_MEMBERS([struct stat.st_birthtime])
AC_CHECK_MEMBERS([struct stat.st_blocks])
+AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_passwd], [], [], [[
+ #include <sys/types.h>
+ #include <pwd.h>
+]])
AC_MSG_CHECKING(for time.h that defines altzone)
AC_CACHE_VAL(ac_cv_header_time_altzone,[
@@ -4338,6 +4354,8 @@
[define to 1 if your sem_getvalue is broken.])
fi
+AC_CHECK_DECLS([RTLD_LAZY, RTLD_NOW, RTLD_GLOBAL, RTLD_LOCAL, RTLD_NODELETE, RTLD_NOLOAD, RTLD_DEEPBIND], [], [], [[#include <dlfcn.h>]])
+
# determine what size digit to use for Python's longs
AC_MSG_CHECKING([digit size for Python's longs])
AC_ARG_ENABLE(big-digits,
@@ -4456,7 +4474,11 @@
dnl define LIBPL after ABIFLAGS and LDVERSION is defined.
AC_SUBST(PY_ENABLE_SHARED)
-LIBPL='$(prefix)'"/lib/python${VERSION}/config-${LDVERSION}"
+if test x$PLATFORM_TRIPLET = x; then
+ LIBPL='$(prefix)'"/lib/python${VERSION}/config-${LDVERSION}"
+else
+ LIBPL='$(prefix)'"/lib/python${VERSION}/config-${LDVERSION}-${PLATFORM_TRIPLET}"
+fi
AC_SUBST(LIBPL)
# Check whether right shifting a negative integer extends the sign bit
diff --git a/pyconfig.h.in b/pyconfig.h.in
index 7895535..eaee16f 100644
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -167,6 +167,34 @@
*/
#undef HAVE_DECL_ISNAN
+/* Define to 1 if you have the declaration of `RTLD_DEEPBIND', and to 0 if you
+ don't. */
+#undef HAVE_DECL_RTLD_DEEPBIND
+
+/* Define to 1 if you have the declaration of `RTLD_GLOBAL', and to 0 if you
+ don't. */
+#undef HAVE_DECL_RTLD_GLOBAL
+
+/* Define to 1 if you have the declaration of `RTLD_LAZY', and to 0 if you
+ don't. */
+#undef HAVE_DECL_RTLD_LAZY
+
+/* Define to 1 if you have the declaration of `RTLD_LOCAL', and to 0 if you
+ don't. */
+#undef HAVE_DECL_RTLD_LOCAL
+
+/* Define to 1 if you have the declaration of `RTLD_NODELETE', and to 0 if you
+ don't. */
+#undef HAVE_DECL_RTLD_NODELETE
+
+/* Define to 1 if you have the declaration of `RTLD_NOLOAD', and to 0 if you
+ don't. */
+#undef HAVE_DECL_RTLD_NOLOAD
+
+/* Define to 1 if you have the declaration of `RTLD_NOW', and to 0 if you
+ don't. */
+#undef HAVE_DECL_RTLD_NOW
+
/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
*/
#undef HAVE_DECL_TZNAME
@@ -919,6 +947,12 @@
/* Define to 1 if you have the <stropts.h> header file. */
#undef HAVE_STROPTS_H
+/* Define to 1 if `pw_gecos' is a member of `struct passwd'. */
+#undef HAVE_STRUCT_PASSWD_PW_GECOS
+
+/* Define to 1 if `pw_passwd' is a member of `struct passwd'. */
+#undef HAVE_STRUCT_PASSWD_PW_PASSWD
+
/* Define to 1 if `st_birthtime' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_BIRTHTIME
diff --git a/setup.py b/setup.py
index 174ce72..006ecdd 100644
--- a/setup.py
+++ b/setup.py
@@ -2007,7 +2007,7 @@
break
ffi_lib = None
if ffi_inc is not None:
- for lib_name in ('ffi_convenience', 'ffi_pic', 'ffi'):
+ for lib_name in ('ffi', 'ffi_pic'):
if (self.compiler.find_library_file(lib_dirs, lib_name)):
ffi_lib = lib_name
break
@@ -2060,7 +2060,7 @@
'_decimal/libmpdec/fnt.h',
'_decimal/libmpdec/fourstep.h',
'_decimal/libmpdec/io.h',
- '_decimal/libmpdec/memory.h',
+ '_decimal/libmpdec/mpalloc.h',
'_decimal/libmpdec/mpdecimal.h',
'_decimal/libmpdec/numbertheory.h',
'_decimal/libmpdec/sixstep.h',
@@ -2255,7 +2255,7 @@
setup(# PyPI Metadata (PEP 301)
name = "Python",
version = sys.version.split()[0],
- url = "http://www.python.org/%s" % sys.version[:3],
+ url = "http://www.python.org/%d.%d" % sys.version_info[:2],
maintainer = "Guido van Rossum and the Python community",
maintainer_email = "python-dev@python.org",
description = "A high-level object-oriented programming language",