diff options
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/dis.rst | 22 | ||||
-rw-r--r-- | Doc/library/http.cookies.rst | 18 | ||||
-rw-r--r-- | Doc/library/io.rst | 21 | ||||
-rw-r--r-- | Doc/library/logging.rst | 10 | ||||
-rw-r--r-- | Doc/library/os.path.rst | 13 | ||||
-rw-r--r-- | Doc/library/re.rst | 6 | ||||
-rw-r--r-- | Doc/library/socket.rst | 12 | ||||
-rw-r--r-- | Doc/library/stdtypes.rst | 12 | ||||
-rw-r--r-- | Doc/library/string.rst | 6 | ||||
-rw-r--r-- | Doc/library/subprocess.rst | 6 | ||||
-rw-r--r-- | Doc/library/sys.rst | 9 | ||||
-rw-r--r-- | Doc/library/tarfile.rst | 11 | ||||
-rw-r--r-- | Doc/library/time.rst | 9 | ||||
-rw-r--r-- | Doc/library/timeit.rst | 35 | ||||
-rw-r--r-- | Doc/library/unittest.mock.rst | 5 | ||||
-rw-r--r-- | Doc/library/zipfile.rst | 4 |
16 files changed, 117 insertions, 82 deletions
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index a15690ba48..694d5642fb 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -957,6 +957,28 @@ All of the following opcodes use their arguments. value. +.. opcode:: LOAD_METHOD (namei) + + Loads a method named ``co_names[namei]`` from TOS object. TOS is popped and + method and TOS are pushed when interpreter can call unbound method directly. + TOS will be uesd as the first argument (``self``) by :opcode:`CALL_METHOD`. + Otherwise, ``NULL`` and method is pushed (method is bound method or + something else). + + .. versionadded:: 3.7 + + +.. opcode:: CALL_METHOD (argc) + + Calls a method. *argc* is number of positional arguments. + Keyword arguments are not supported. This opcode is designed to be used + with :opcode:`LOAD_METHOD`. Positional arguments are on top of the stack. + Below them, two items described in :opcode:`LOAD_METHOD` on the stack. + All of them are popped and return value is pushed. + + .. versionadded:: 3.7 + + .. opcode:: MAKE_FUNCTION (argc) Pushes a new function object on the stack. From bottom to top, the consumed diff --git a/Doc/library/http.cookies.rst b/Doc/library/http.cookies.rst index 4b45d4bc38..fb8317ad59 100644 --- a/Doc/library/http.cookies.rst +++ b/Doc/library/http.cookies.rst @@ -148,39 +148,31 @@ Morsel Objects :meth:`~Morsel.__eq__` now takes :attr:`~Morsel.key` and :attr:`~Morsel.value` into account. + .. versionchanged:: 3.7 + Attributes :attr:`~Morsel.key`, :attr:`~Morsel.value` and + :attr:`~Morsel.coded_value` are read-only. Use :meth:`~Morsel.set` for + setting them. + .. attribute:: Morsel.value The value of the cookie. - .. deprecated:: 3.5 - assigning to ``value``; use :meth:`~Morsel.set` instead. - .. attribute:: Morsel.coded_value The encoded value of the cookie --- this is what should be sent. - .. deprecated:: 3.5 - assigning to ``coded_value``; use :meth:`~Morsel.set` instead. - .. attribute:: Morsel.key The name of the cookie. - .. deprecated:: 3.5 - assigning to ``key``; use :meth:`~Morsel.set` instead. - .. method:: Morsel.set(key, value, coded_value) Set the *key*, *value* and *coded_value* attributes. - .. deprecated:: 3.5 - The undocumented *LegalChars* parameter is ignored and will be removed in - a future version. - .. method:: Morsel.isReservedKey(K) diff --git a/Doc/library/io.rst b/Doc/library/io.rst index 4da6e095d1..c8ff5b826d 100644 --- a/Doc/library/io.rst +++ b/Doc/library/io.rst @@ -477,7 +477,7 @@ I/O Base Classes A :exc:`BlockingIOError` is raised if the underlying raw stream is in non blocking-mode, and has no data available at the moment. - .. method:: read1(size=-1) + .. method:: read1([size]) Read and return up to *size* bytes, with at most one call to the underlying raw stream's :meth:`~RawIOBase.read` (or @@ -485,6 +485,9 @@ I/O Base Classes implementing your own buffering on top of a :class:`BufferedIOBase` object. + If *size* is ``-1`` (the default), an arbitrary number of bytes are + returned (more than zero unless EOF is reached). + .. method:: readinto(b) Read bytes into a pre-allocated, writable @@ -628,13 +631,16 @@ than raw I/O does. Return :class:`bytes` containing the entire contents of the buffer. - .. method:: read1() + .. method:: read1([size]) + + In :class:`BytesIO`, this is the same as :meth:`~BufferedIOBase.read`. - In :class:`BytesIO`, this is the same as :meth:`read`. + .. versionchanged:: 3.7 + The *size* argument is now optional. - .. method:: readinto1() + .. method:: readinto1(b) - In :class:`BytesIO`, this is the same as :meth:`readinto`. + In :class:`BytesIO`, this is the same as :meth:`~BufferedIOBase.readinto`. .. versionadded:: 3.5 @@ -664,12 +670,15 @@ than raw I/O does. Read and return *size* bytes, or if *size* is not given or negative, until EOF or if the read call would block in non-blocking mode. - .. method:: read1(size) + .. method:: read1([size]) Read and return up to *size* bytes with only one call on the raw stream. If at least one byte is buffered, only buffered bytes are returned. Otherwise, one raw stream read call is made. + .. versionchanged:: 3.7 + The *size* argument is now optional. + .. class:: BufferedWriter(raw, buffer_size=DEFAULT_BUFFER_SIZE) diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst index 6098878c1a..d03cc50d87 100644 --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -1023,7 +1023,7 @@ functions. handlers being added multiple times to the root logger, which can in turn lead to multiple messages for the same event. -.. function:: disable(lvl) +.. function:: disable(lvl=CRITICAL) Provides an overriding level *lvl* for all loggers which takes precedence over the logger's own level. When the need arises to temporarily throttle logging @@ -1036,6 +1036,14 @@ functions. overriding level, so that logging output again depends on the effective levels of individual loggers. + Note that if you have defined any custom logging level higher than + ``CRITICAL`` (this is not recommended), you won't be able to rely on the + default value for the *lvl* parameter, but will have to explicitly supply a + suitable value. + + .. versionchanged:: 3.7 + The *lvl* parameter was defaulted to level ``CRITICAL``. See Issue + #28524 for more information about this change. .. function:: addLevelName(lvl, levelName) diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst index 406054e5d7..38a9331577 100644 --- a/Doc/library/os.path.rst +++ b/Doc/library/os.path.rst @@ -453,19 +453,6 @@ the :mod:`glob` module.) Accepts a :term:`path-like object`. -.. function:: splitunc(path) - - .. deprecated:: 3.1 - Use *splitdrive* instead. - - Split the pathname *path* into a pair ``(unc, rest)`` so that *unc* is the UNC - mount point (such as ``r'\\host\mount'``), if present, and *rest* the rest of - the path (such as ``r'\path\file.ext'``). For paths containing drive letters, - *unc* will always be the empty string. - - Availability: Windows. - - .. data:: supports_unicode_filenames ``True`` if arbitrary Unicode strings can be used as file names (within limitations diff --git a/Doc/library/re.rst b/Doc/library/re.rst index 7ef4cbeee7..adf3ddde23 100644 --- a/Doc/library/re.rst +++ b/Doc/library/re.rst @@ -761,9 +761,9 @@ form. Unknown escapes in *pattern* consisting of ``'\'`` and an ASCII letter now are errors. - .. deprecated-removed:: 3.5 3.7 - Unknown escapes in *repl* consisting of ``'\'`` and an ASCII letter now raise - a deprecation warning and will be forbidden in Python 3.7. + .. versionchanged:: 3.7 + Unknown escapes in *repl* consisting of ``'\'`` and an ASCII letter + now are errors. .. function:: subn(pattern, repl, string, count=0, flags=0) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index 678e32ce57..d56caf0a58 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -664,6 +664,12 @@ The :mod:`socket` module also offers various network-related services: where the host byte order is the same as network byte order, this is a no-op; otherwise, it performs a 2-byte swap operation. + .. deprecated:: 3.7 + In case *x* does not fit in 16-bit unsigned integer, but does fit in a + positive C int, it is silently truncated to 16-bit unsigned integer. + This silent truncation feature is deprecated, and will raise an + exception in future versions of Python. + .. function:: htonl(x) @@ -678,6 +684,12 @@ The :mod:`socket` module also offers various network-related services: where the host byte order is the same as network byte order, this is a no-op; otherwise, it performs a 2-byte swap operation. + .. deprecated:: 3.7 + In case *x* does not fit in 16-bit unsigned integer, but does fit in a + positive C int, it is silently truncated to 16-bit unsigned integer. + This silent truncation feature is deprecated, and will raise an + exception in future versions of Python. + .. function:: inet_aton(ip_string) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 9a4f42caa4..d13fc3d920 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2316,11 +2316,15 @@ the bytes type has an additional class method to read data in that format: This :class:`bytes` class method returns a bytes object, decoding the given string object. The string must contain two hexadecimal digits per - byte, with ASCII spaces being ignored. + byte, with ASCII whitespace being ignored. >>> bytes.fromhex('2Ef0 F1f2 ') b'.\xf0\xf1\xf2' + .. versionchanged:: 3.7 + :meth:`bytes.fromhex` now skips all ASCII whitespace in the string, + not just spaces. + A reverse conversion function exists to transform a bytes object into its hexadecimal representation. @@ -2384,11 +2388,15 @@ the bytearray type has an additional class method to read data in that format: This :class:`bytearray` class method returns bytearray object, decoding the given string object. The string must contain two hexadecimal digits - per byte, with ASCII spaces being ignored. + per byte, with ASCII whitespace being ignored. >>> bytearray.fromhex('2Ef0 F1f2 ') bytearray(b'.\xf0\xf1\xf2') + .. versionchanged:: 3.7 + :meth:`bytearray.fromhex` now skips all ASCII whitespace in the string, + not just spaces. + A reverse conversion function exists to transform a bytearray object into its hexadecimal representation. diff --git a/Doc/library/string.rst b/Doc/library/string.rst index a0977b6461..03eaf3b9cd 100644 --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -95,9 +95,9 @@ implementation as the built-in :meth:`~str.format` method. an arbitrary set of positional and keyword arguments. It is just a wrapper that calls :meth:`vformat`. - .. deprecated:: 3.5 - Passing a format string as keyword argument *format_string* has been - deprecated. + .. versionchanged:: 3.7 + A format string argument is now :ref:`positional-only + <positional-only_parameter>`. .. method:: vformat(format_string, args, kwargs) diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst index ad2abe8245..ea065b897e 100644 --- a/Doc/library/subprocess.rst +++ b/Doc/library/subprocess.rst @@ -608,12 +608,6 @@ Instances of the :class:`Popen` class have the following methods: .. versionchanged:: 3.3 *timeout* was added. - .. deprecated:: 3.4 - - Do not use the *endtime* parameter. It is was unintentionally - exposed in 3.3 but was left undocumented as it was intended to be - private for internal use. Use *timeout* instead. - .. method:: Popen.communicate(input=None, timeout=None) Interact with process: Send data to stdin. Read data from stdout and stderr, diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index dd51ffd56c..54b99e0fd9 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -404,6 +404,15 @@ always available. .. versionadded:: 3.4 +.. function:: getandroidapilevel() + + Return the build time API version of Android as an integer. + + Availability: Android. + + .. versionadded:: 3.7 + + .. function:: getcheckinterval() Return the interpreter's "check interval"; see :func:`setcheckinterval`. diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst index d8f809753d..2167f32f6a 100644 --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -429,16 +429,13 @@ be finalized; only the internally used file object will be closed. See the Return an :class:`io.BufferedReader` object. -.. method:: TarFile.add(name, arcname=None, recursive=True, exclude=None, *, filter=None) +.. method:: TarFile.add(name, arcname=None, recursive=True, *, filter=None) Add the file *name* to the archive. *name* may be any type of file (directory, fifo, symbolic link, etc.). If given, *arcname* specifies an alternative name for the file in the archive. Directories are added recursively by default. This can be avoided by setting *recursive* to - :const:`False`. If *exclude* is given, it must be a function that takes one - filename argument and returns a boolean value. Depending on this value the - respective file is either excluded (:const:`True`) or added - (:const:`False`). If *filter* is specified it must be a keyword argument. It + :const:`False`. If *filter* is given, it should be a function that takes a :class:`TarInfo` object argument and returns the changed :class:`TarInfo` object. If it instead returns :const:`None` the :class:`TarInfo` object will be excluded from the @@ -447,10 +444,6 @@ be finalized; only the internally used file object will be closed. See the .. versionchanged:: 3.2 Added the *filter* parameter. - .. deprecated:: 3.2 - The *exclude* parameter is deprecated, please use the *filter* parameter - instead. - .. method:: TarFile.addfile(tarinfo, fileobj=None) diff --git a/Doc/library/time.rst b/Doc/library/time.rst index ae17f6f4f0..6ef02b7403 100644 --- a/Doc/library/time.rst +++ b/Doc/library/time.rst @@ -594,8 +594,13 @@ The module defines the following functions and data items: .. function:: tzset() - Resets the time conversion rules used by the library routines. The environment - variable :envvar:`TZ` specifies how this is done. + Reset the time conversion rules used by the library routines. The environment + variable :envvar:`TZ` specifies how this is done. It will also set the variables + ``tzname`` (from the :envvar:`TZ` environment variable), ``timezone`` (non-DST + seconds West of UTC), ``altzone`` (DST seconds west of UTC) and ``daylight`` + (to 0 if this timezone does not have any daylight saving time rules, or to + nonzero if there is a time, past, present or future when daylight saving time + applies). Availability: Unix. diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst index 3b772765ac..4065808854 100644 --- a/Doc/library/timeit.rst +++ b/Doc/library/timeit.rst @@ -28,11 +28,11 @@ can be used to compare three different expressions: .. code-block:: sh $ python3 -m timeit '"-".join(str(n) for n in range(100))' - 10000 loops, best of 3: 30.2 usec per loop + 10000 loops, best of 5: 30.2 usec per loop $ python3 -m timeit '"-".join([str(n) for n in range(100)])' - 10000 loops, best of 3: 27.5 usec per loop + 10000 loops, best of 5: 27.5 usec per loop $ python3 -m timeit '"-".join(map(str, range(100)))' - 10000 loops, best of 3: 23.2 usec per loop + 10000 loops, best of 5: 23.2 usec per loop This can be achieved from the :ref:`python-interface` with:: @@ -141,9 +141,8 @@ The module defines three convenience functions and a public class: This is a convenience function that calls :meth:`.timeit` repeatedly so that the total time >= 0.2 second, returning the eventual (number of loops, time taken for that number of loops). It calls - :meth:`.timeit` with *number* set to successive powers of ten (10, - 100, 1000, ...) up to a maximum of one billion, until the time taken - is at least 0.2 second, or the maximum is reached. + :meth:`.timeit` with increasing numbers from the sequence 1, 2, 5, + 10, 20, 50, ... until the time taken is at least 0.2 second. If *callback* is given and is not ``None``, it will be called after each trial with two arguments: ``callback(number, time_taken)``. @@ -197,7 +196,7 @@ Command-Line Interface When called as a program from the command line, the following form is used:: - python -m timeit [-n N] [-r N] [-u U] [-s S] [-t] [-c] [-h] [statement ...] + python -m timeit [-n N] [-r N] [-u U] [-s S] [-h] [statement ...] Where the following options are understood: @@ -222,20 +221,12 @@ Where the following options are understood: .. versionadded:: 3.3 -.. cmdoption:: -t, --time - - use :func:`time.time` (deprecated) - .. cmdoption:: -u, --unit=U - specify a time unit for timer output; can select usec, msec, or sec + specify a time unit for timer output; can select nsec, usec, msec, or sec .. versionadded:: 3.5 -.. cmdoption:: -c, --clock - - use :func:`time.clock` (deprecated) - .. cmdoption:: -v, --verbose print raw timing results; repeat for more digits precision @@ -276,9 +267,9 @@ It is possible to provide a setup statement that is executed only once at the be .. code-block:: sh $ python -m timeit -s 'text = "sample string"; char = "g"' 'char in text' - 10000000 loops, best of 3: 0.0877 usec per loop + 5000000 loops, best of 5: 0.0877 usec per loop $ python -m timeit -s 'text = "sample string"; char = "g"' 'text.find(char)' - 1000000 loops, best of 3: 0.342 usec per loop + 1000000 loops, best of 5: 0.342 usec per loop :: @@ -305,14 +296,14 @@ to test for missing and present object attributes: .. code-block:: sh $ python -m timeit 'try:' ' str.__bool__' 'except AttributeError:' ' pass' - 100000 loops, best of 3: 15.7 usec per loop + 20000 loops, best of 5: 15.7 usec per loop $ python -m timeit 'if hasattr(str, "__bool__"): pass' - 100000 loops, best of 3: 4.26 usec per loop + 50000 loops, best of 5: 4.26 usec per loop $ python -m timeit 'try:' ' int.__bool__' 'except AttributeError:' ' pass' - 1000000 loops, best of 3: 1.43 usec per loop + 200000 loops, best of 5: 1.43 usec per loop $ python -m timeit 'if hasattr(int, "__bool__"): pass' - 100000 loops, best of 3: 2.23 usec per loop + 100000 loops, best of 5: 2.23 usec per loop :: diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index c6d0ec92b6..ca5c2bc787 100644 --- a/Doc/library/unittest.mock.rst +++ b/Doc/library/unittest.mock.rst @@ -1831,8 +1831,9 @@ sentinel the same attribute will always return the same object. The objects returned have a sensible repr so that test failure messages are readable. - The ``sentinel`` attributes don't preserve their identity when they are - :mod:`copied <copy>` or :mod:`pickled <pickle>`. + .. versionchanged:: 3.7 + The ``sentinel`` attributes now preserve their identity when they are + :mod:`copied <copy>` or :mod:`pickled <pickle>`. Sometimes when testing you need to test that a specific object is passed as an argument to another method, or returned. It can be common to create named diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst index 5eb6f10338..a0de10cae3 100644 --- a/Doc/library/zipfile.rst +++ b/Doc/library/zipfile.rst @@ -672,18 +672,22 @@ Command-line options ~~~~~~~~~~~~~~~~~~~~ .. cmdoption:: -l <zipfile> + --list <zipfile> List files in a zipfile. .. cmdoption:: -c <zipfile> <source1> ... <sourceN> + --create <zipfile> <source1> ... <sourceN> Create zipfile from source files. .. cmdoption:: -e <zipfile> <output_dir> + --extract <zipfile> <output_dir> Extract zipfile into target directory. .. cmdoption:: -t <zipfile> + --test <zipfile> Test whether the zipfile is valid or not. |