Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 16c8976

Browse files
committed
Merge remote-tracking branch 'upstream/master' into bpo-36594-p-format-strings
2 parents 2b41f00 + 1e82954 commit 16c8976

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+814
-392
lines changed

Doc/c-api/memory.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,9 @@ Customize Memory Allocators
440440
441441
Setup hooks to detect bugs in the Python memory allocator functions.
442442
443-
Newly allocated memory is filled with the byte ``0xCB``, freed memory is
444-
filled with the byte ``0xDB``.
443+
Newly allocated memory is filled with the byte ``0xCD`` (``CLEANBYTE``),
444+
freed memory is filled with the byte ``0xDD`` (``DEADBYTE``). Memory blocks
445+
are surrounded by "forbidden bytes" (``FORBIDDENBYTE``: byte ``0xFD``).
445446
446447
Runtime checks:
447448
@@ -471,6 +472,12 @@ Customize Memory Allocators
471472
if the GIL is held when functions of :c:data:`PYMEM_DOMAIN_OBJ` and
472473
:c:data:`PYMEM_DOMAIN_MEM` domains are called.
473474
475+
.. versionchanged:: 3.8.0
476+
Byte patterns ``0xCB`` (``CLEANBYTE``), ``0xDB`` (``DEADBYTE``) and
477+
``0xFB`` (``FORBIDDENBYTE``) have been replaced with ``0xCD``, ``0xDD``
478+
and ``0xFD`` to use the same values than Windows CRT debug ``malloc()``
479+
and ``free()``.
480+
474481
475482
.. _pymalloc:
476483

Doc/library/codecs.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ define in order to be compatible with the Python codec registry.
638638

639639
.. method:: setstate(state)
640640

641-
Set the state of the encoder to *state*. *state* must be a decoder state
641+
Set the state of the decoder to *state*. *state* must be a decoder state
642642
returned by :meth:`getstate`.
643643

644644

Doc/library/io.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -719,15 +719,15 @@ than raw I/O does.
719719
.. class:: BufferedRandom(raw, buffer_size=DEFAULT_BUFFER_SIZE)
720720

721721
A buffered interface to random access streams. It inherits
722-
:class:`BufferedReader` and :class:`BufferedWriter`, and further supports
723-
:meth:`seek` and :meth:`tell` functionality.
722+
:class:`BufferedReader` and :class:`BufferedWriter`.
724723

725724
The constructor creates a reader and writer for a seekable raw stream, given
726725
in the first argument. If the *buffer_size* is omitted it defaults to
727726
:data:`DEFAULT_BUFFER_SIZE`.
728727

729728
:class:`BufferedRandom` is capable of anything :class:`BufferedReader` or
730-
:class:`BufferedWriter` can do.
729+
:class:`BufferedWriter` can do. In addition, :meth:`seek` and :meth:`tell`
730+
are guaranteed to be implemented.
731731

732732

733733
.. class:: BufferedRWPair(reader, writer, buffer_size=DEFAULT_BUFFER_SIZE)

Doc/library/socket.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,8 @@ The :mod:`socket` module also offers various network-related services:
796796
For IPv6 addresses, ``%scope`` is appended to the host part if *sockaddr*
797797
contains meaningful *scopeid*. Usually this happens for multicast addresses.
798798

799+
For more information about *flags* you can consult :manpage:`getnameinfo(3)`.
800+
799801
.. function:: getprotobyname(protocolname)
800802

801803
Translate an Internet protocol name (for example, ``'icmp'``) to a constant

Doc/library/stdtypes.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,10 @@ expression support in the :mod:`re` module).
15091509
Return a copy of the string with its first character capitalized and the
15101510
rest lowercased.
15111511

1512+
.. versionchanged:: 3.8
1513+
The first character is now put into titlecase rather than uppercase.
1514+
This means that characters like digraphs will only have their first
1515+
letter capitalized, instead of the full character.
15121516

15131517
.. method:: str.casefold()
15141518

@@ -2052,8 +2056,7 @@ expression support in the :mod:`re` module).
20522056
>>> import re
20532057
>>> def titlecase(s):
20542058
... return re.sub(r"[A-Za-z]+('[A-Za-z]+)?",
2055-
... lambda mo: mo.group(0)[0].upper() +
2056-
... mo.group(0)[1:].lower(),
2059+
... lambda mo: mo.group(0).capitalize(),
20572060
... s)
20582061
...
20592062
>>> titlecase("they're bill's friends.")
@@ -2696,8 +2699,8 @@ arbitrary binary data.
26962699
containing the part before the separator, the separator itself or its
26972700
bytearray copy, and the part after the separator.
26982701
If the separator is not found, return a 3-tuple
2699-
containing a copy of the original sequence, followed by two empty bytes or
2700-
bytearray objects.
2702+
containing two empty bytes or bytearray objects, followed by a copy of the
2703+
original sequence.
27012704

27022705
The separator to search for may be any :term:`bytes-like object`.
27032706

Doc/library/sys.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ always available.
10141014
This string contains a platform identifier that can be used to append
10151015
platform-specific components to :data:`sys.path`, for instance.
10161016

1017-
For Unix systems, except on Linux, this is the lowercased OS name as
1017+
For Unix systems, except on Linux and AIX, this is the lowercased OS name as
10181018
returned by ``uname -s`` with the first part of the version as returned by
10191019
``uname -r`` appended, e.g. ``'sunos5'`` or ``'freebsd8'``, *at the time
10201020
when Python was built*. Unless you want to test for a specific system
@@ -1024,12 +1024,15 @@ always available.
10241024
# FreeBSD-specific code here...
10251025
elif sys.platform.startswith('linux'):
10261026
# Linux-specific code here...
1027+
elif sys.platform.startswith('aix'):
1028+
# AIX-specific code here...
10271029

10281030
For other systems, the values are:
10291031

10301032
================ ===========================
10311033
System ``platform`` value
10321034
================ ===========================
1035+
AIX ``'aix'``
10331036
Linux ``'linux'``
10341037
Windows ``'win32'``
10351038
Windows/Cygwin ``'cygwin'``
@@ -1042,6 +1045,12 @@ always available.
10421045
older Python versions include the version number, it is recommended to
10431046
always use the ``startswith`` idiom presented above.
10441047

1048+
.. versionchanged:: 3.8
1049+
On AIX, :attr:`sys.platform` doesn't contain the major version anymore.
1050+
It is always ``'aix'``, instead of ``'aix5'`` or ``'aix7'``. Since
1051+
older Python versions include the version number, it is recommended to
1052+
always use the ``startswith`` idiom presented above.
1053+
10451054
.. seealso::
10461055

10471056
:attr:`os.name` has a coarser granularity. :func:`os.uname` gives

Doc/library/typing.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,24 @@ The module defines the following classes, functions and decorators:
951951
This wraps the decorator with something that wraps the decorated
952952
function in :func:`no_type_check`.
953953

954+
.. decorator:: type_check_only
955+
956+
Decorator to mark a class or function to be unavailable at runtime.
957+
958+
This decorator is itself not available at runtime. It is mainly
959+
intended to mark classes that are defined in type stub files if
960+
an implementation returns an instance of a private class::
961+
962+
@type_check_only
963+
class Response: # private or not available at runtime
964+
code: int
965+
def get_header(self, name: str) -> str: ...
966+
967+
def fetch_response() -> Response: ...
968+
969+
Note that returning instances of private classes is not recommended.
970+
It is usually preferable to make such classes public.
971+
954972
.. data:: Any
955973

956974
Special type indicating an unconstrained type.

Doc/library/weakref.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -489,11 +489,14 @@ Unless you set the :attr:`~finalize.atexit` attribute to
489489
:const:`False`, a finalizer will be called when the program exits if it
490490
is still alive. For instance
491491

492-
>>> obj = Object()
493-
>>> weakref.finalize(obj, print, "obj dead or exiting") #doctest:+ELLIPSIS
494-
<finalize object at ...; for 'Object' at ...>
495-
>>> exit() #doctest:+SKIP
496-
obj dead or exiting
492+
.. doctest::
493+
:options: +SKIP
494+
495+
>>> obj = Object()
496+
>>> weakref.finalize(obj, print, "obj dead or exiting")
497+
<finalize object at ...; for 'Object' at ...>
498+
>>> exit()
499+
obj dead or exiting
497500

498501

499502
Comparing finalizers with :meth:`__del__` methods

Doc/tutorial/modules.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,9 @@ your package (expressed in terms of a hierarchical filesystem):
425425
When importing the package, Python searches through the directories on
426426
``sys.path`` looking for the package subdirectory.
427427

428-
The :file:`__init__.py` files are required to make Python treat the directories
429-
as containing packages; this is done to prevent directories with a common name,
430-
such as ``string``, from unintentionally hiding valid modules that occur later
428+
The :file:`__init__.py` files are required to make Python treat directories
429+
containing the file as packages. This prevents directories with a common name,
430+
such as ``string``, unintentionally hiding valid modules that occur later
431431
on the module search path. In the simplest case, :file:`__init__.py` can just be
432432
an empty file, but it can also execute initialization code for the package or
433433
set the ``__all__`` variable, described later.

Doc/using/cmdline.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ Miscellaneous options
437437
* Enable :ref:`asyncio debug mode <asyncio-debug-mode>`.
438438
* Set the :attr:`~sys.flags.dev_mode` attribute of :attr:`sys.flags` to
439439
``True``
440+
* :class:`io.IOBase` destructor logs ``close()`` exceptions.
440441

441442
* ``-X utf8`` enables UTF-8 mode for operating system interfaces, overriding
442443
the default locale-aware mode. ``-X utf8=0`` explicitly disables UTF-8
@@ -465,7 +466,8 @@ Miscellaneous options
465466
The ``-X importtime``, ``-X dev`` and ``-X utf8`` options.
466467

467468
.. versionadded:: 3.8
468-
The ``-X pycache_prefix`` option.
469+
The ``-X pycache_prefix`` option. The ``-X dev`` option now logs
470+
``close()`` exceptions in :class:`io.IOBase` destructor.
469471

470472

471473
Options you shouldn't use

0 commit comments

Comments
 (0)