diff --git a/Doc/c-api/module.rst b/Doc/c-api/module.rst index 6e4e3c48c084295..9ec1407c88d01be 100644 --- a/Doc/c-api/module.rst +++ b/Doc/c-api/module.rst @@ -552,19 +552,19 @@ This means that if you have a module object, but you are not sure if it .. code-block:: c - PyObject *module = + PyObject *module = ; void *module_token; if (PyModule_GetToken(module, &module_token) < 0) { return NULL; } if (module_token != your_token) { - PyErr_SetString(PyExc_ValueError, "unexpected module") + PyErr_SetString(PyExc_ValueError, "unexpected module"); return NULL; } // This module's state has the expected memory layout; it's safe to cast - struct my_state state = (struct my_state*)PyModule_GetState(module) + struct my_state *state = (struct my_state*)PyModule_GetState(module); A module's token -- and the *your_token* value to use in the above code -- is: diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst index ee6df73a105d85e..382b92eecdce8ed 100644 --- a/Doc/c-api/typeobj.rst +++ b/Doc/c-api/typeobj.rst @@ -3343,7 +3343,7 @@ A type that supports weakrefs, instance dicts, and hashing:: .tp_new = myobj_new, .tp_traverse = (traverseproc)myobj_traverse, .tp_clear = (inquiry)myobj_clear, - .tp_alloc = PyType_GenericNew, + .tp_alloc = PyType_GenericAlloc, .tp_dealloc = (destructor)myobj_dealloc, .tp_repr = (reprfunc)myobj_repr, .tp_hash = (hashfunc)myobj_hash, diff --git a/Doc/extending/embedding.rst b/Doc/extending/embedding.rst index cb41889437c8b0d..8a87d7cb1c3b4ca 100644 --- a/Doc/extending/embedding.rst +++ b/Doc/extending/embedding.rst @@ -95,15 +95,16 @@ perform some operation on a file. :: See :ref:`arg-parsing-string-and-buffers` for a description of this macro. Setting :c:member:`PyConfig.program_name` should be called before -:c:func:`Py_InitializeFromConfig` 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_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 -be done by using the :c:func:`PyRun_SimpleFile` function, which saves you the -trouble of allocating memory space and loading the file contents. +:c:func:`Py_InitializeFromConfig` to inform the interpreter about paths to +Python run-time libraries. Next, the Python interpreter is initialized with +:c:func:`Py_InitializeFromConfig`, followed by the execution of a hard-coded +Python script 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 be done by using the +:c:func:`PyRun_SimpleFile` function, which saves you the trouble of allocating +memory space and loading the file contents. .. _lower-level-embedding: diff --git a/Doc/extending/extending.rst b/Doc/extending/extending.rst index 6bf27ce33c31826..98ec3f7f993efba 100644 --- a/Doc/extending/extending.rst +++ b/Doc/extending/extending.rst @@ -1040,7 +1040,7 @@ exporting module, not a client module. Finally, the module's :c:data:`mod_exec } Note that ``PySpam_API`` is declared ``static``; otherwise the pointer -array would disappear when :c:func:`!PyInit_spam` terminates! +array would disappear when :c:func:`!spam_module_exec` terminates! The bulk of the work is in the header file :file:`spammodule.h`, which looks like this:: diff --git a/Doc/howto/descriptor.rst b/Doc/howto/descriptor.rst index 7233898860ada14..93d64451e6b6dc2 100644 --- a/Doc/howto/descriptor.rst +++ b/Doc/howto/descriptor.rst @@ -1678,7 +1678,7 @@ variables: def __new__(mcls, clsname, bases, mapping, **kwargs): 'Emulate type_new() in Objects/typeobject.c' - # type_new() calls PyTypeReady() which calls add_methods() + # type_new() calls PyType_Ready() which calls add_methods() slot_names = mapping.get('slot_names', []) for offset, name in enumerate(slot_names): mapping[name] = Member(name, clsname, offset) diff --git a/Doc/howto/instrumentation.rst b/Doc/howto/instrumentation.rst index c7ce5785047a6d5..e0d08b19db7a88f 100644 --- a/Doc/howto/instrumentation.rst +++ b/Doc/howto/instrumentation.rst @@ -430,7 +430,7 @@ Here is a tapset file, based on a non-shared build of CPython: /* Provide a higher-level wrapping around the function__entry and function__return markers: - \*/ + */ probe python.function.entry = process("python").mark("function__entry") { filename = user_string($arg1); @@ -498,7 +498,7 @@ frames, each second, across the whole system: } probe timer.ms(1000) { - printf("\033[2J\033[1;1H") /* clear screen \*/ + printf("\033[2J\033[1;1H") /* clear screen */ printf("%6s %80s %6s %30s %6s\n", "PID", "FILENAME", "LINE", "FUNCTION", "CALLS") foreach ([pid, filename, funcname, lineno] in fn_calls- limit 20) { diff --git a/Doc/howto/isolating-extensions.rst b/Doc/howto/isolating-extensions.rst index 6092c75f48fdef0..e1daf559f6437d0 100644 --- a/Doc/howto/isolating-extensions.rst +++ b/Doc/howto/isolating-extensions.rst @@ -557,9 +557,9 @@ For example:: {"example_method", (PyCFunction)(void(*)(void))example_method, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, - example_method_doc} + example_method_doc}, {NULL}, - } + }; Module State Access from Slot Methods, Getters and Setters diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst index 687a0c516f67173..c105620fc3c04aa 100644 --- a/Doc/howto/logging-cookbook.rst +++ b/Doc/howto/logging-cookbook.rst @@ -1085,7 +1085,7 @@ each request is handled by a thread: # A dummy set of requests which will be used in the simulation - we'll just pick # from this list randomly. Note that all GET requests are from 192.168.2.XXX - # addresses, whereas POST requests are from 192.16.3.XXX addresses. Three users + # addresses, whereas POST requests are from 192.168.3.XXX addresses. Three users # are represented in the sample requests. REQUESTS = [ diff --git a/Doc/library/annotationlib.rst b/Doc/library/annotationlib.rst index 5b22353ea08e647..1755a6582bf9573 100644 --- a/Doc/library/annotationlib.rst +++ b/Doc/library/annotationlib.rst @@ -581,7 +581,7 @@ Or used as the annotate function for an object: >>> class C: ... pass >>> C.__annotate__ = Annotate() - >>> get_annotations(Annotate(), format=Format.STRING) + >>> get_annotations(C, format=Format.STRING) {'x': 'MyType'} diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 02d6940ad06d2c0..ac4f12de6fb663a 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -746,11 +746,11 @@ the upper-cased name. For example:: >>> parser.parse_args(['--foo-bar', 'FOO-BAR']) Namespace(foo_bar='FOO-BAR') >>> parser.print_help() - usage: [-h] [--foo-bar FOO-BAR] + usage: [-h] [--foo-bar FOO_BAR] optional arguments: -h, --help show this help message and exit - --foo-bar FOO-BAR + --foo-bar FOO_BAR .. _action: @@ -1375,7 +1375,7 @@ behavior:: >>> parser.parse_args('-f 1 -q 2 -x 3'.split()) Namespace(foo_bar='1', quz='2', x='3') >>> parser.parse_args('--foo 1 -quz 2 -y 3'.split()) - Namespace(foo_bar='1', quz='2', x='2') + Namespace(foo_bar='1', quz='2', x='3') ``dest`` allows a custom attribute name to be provided:: diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst index b847d73ae09b4dc..10feca3203aec55 100644 --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -2029,7 +2029,7 @@ Display the current date with call_later() An example of a callback displaying the current date every second. The callback uses the :meth:`loop.call_later` method to reschedule itself -after 5 seconds, and then stops the event loop:: +after 1 second, and eventually stops the event loop:: import asyncio import datetime as dt diff --git a/Doc/library/binascii.rst b/Doc/library/binascii.rst index be9ad897bcf2ee3..60d2b878aa455af 100644 --- a/Doc/library/binascii.rst +++ b/Doc/library/binascii.rst @@ -301,11 +301,11 @@ The :mod:`!binascii` module defines the following functions: encoding. The return value is the converted line(s). If the optional argument *quotetabs* is present and true, all tabs and spaces will be encoded. If the optional argument *istext* is present and true, newlines are not encoded but - trailing whitespace will be encoded. If the optional argument *header* is - present and true, spaces will be encoded as underscores per :rfc:`1522`. If the - optional argument *header* is present and false, newline characters will be - encoded as well; otherwise linefeed conversion might corrupt the binary data - stream. + trailing whitespace will be encoded. If the optional argument *istext* is + present and false, newline characters will be encoded as well; otherwise + linefeed conversion might corrupt the binary data stream. If the optional + argument *header* is present and true, spaces will be encoded as underscores + per :rfc:`1522`. .. function:: crc_hqx(data, value) diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst index 18e0319d91fad95..69578e4a4846ced 100644 --- a/Doc/library/calendar.rst +++ b/Doc/library/calendar.rst @@ -162,10 +162,10 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is final newline. - .. method:: formatday(theday, weekday, width) + .. method:: formatday(day, weekday, width) Return a string representing a single day formatted with the given *width*. - If *theday* is ``0``, return a string of spaces of + If *day* is ``0``, return a string of spaces of the specified width, representing an empty day. The *weekday* parameter is unused. @@ -177,10 +177,10 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is :meth:`setfirstweekday` method. - .. method:: formatweekday(weekday, width) + .. method:: formatweekday(day, width) Return a string representing the name of a single weekday formatted to - the specified *width*. The *weekday* parameter is an integer representing + the specified *width*. The *day* parameter is an integer representing the day of the week, where ``0`` is Monday and ``6`` is Sunday. diff --git a/Doc/library/cgi.rst b/Doc/library/cgi.rst index f9108fa954a906f..6e4d277fcefe754 100644 --- a/Doc/library/cgi.rst +++ b/Doc/library/cgi.rst @@ -12,8 +12,8 @@ It was :ref:`removed in Python 3.13 ` after being deprecated in Python 3.11. The removal was decided in :pep:`594`. A fork of the module on PyPI can be used instead: :pypi:`legacy-cgi`. -This is a copy of the cgi module, no longer maintained or supported by the core -Python team. +This package contains copies of the :mod:`!cgi` and :mod:`!cgitb` modules, +which are no longer maintained or supported by the core Python team. The last version of Python that provided the :mod:`!cgi` module was `Python 3.12 `_. diff --git a/Doc/library/cgitb.rst b/Doc/library/cgitb.rst index fc646aa4c48acd0..081a4f561bd3667 100644 --- a/Doc/library/cgitb.rst +++ b/Doc/library/cgitb.rst @@ -12,8 +12,8 @@ It was :ref:`removed in Python 3.13 ` after being deprecated in Python 3.11. The removal was decided in :pep:`594`. A fork of the module on PyPI can now be used instead: :pypi:`legacy-cgi`. -This is a copy of the cgi module, no longer maintained or supported by the core -Python team. +This package contains copies of the :mod:`!cgi` and :mod:`!cgitb` modules, +which are no longer maintained or supported by the core Python team. The last version of Python that provided the :mod:`!cgitb` module was `Python 3.12 `_. diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index ca4f5f6dfea4f4a..f19407818528e20 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -1642,7 +1642,7 @@ This module implements the following exception: :synopsis: Internationalized Domain Names implementation This module implements :rfc:`3490` (Internationalized Domain Names in -Applications) and :rfc:`3492` (Nameprep: A Stringprep Profile for +Applications) and :rfc:`3491` (Nameprep: A Stringprep Profile for Internationalized Domain Names (IDN)). It builds upon the ``punycode`` encoding and :mod:`stringprep`. diff --git a/Doc/library/doctest.rst b/Doc/library/doctest.rst index 894929ac99634a1..de4ac60101a2733 100644 --- a/Doc/library/doctest.rst +++ b/Doc/library/doctest.rst @@ -1642,7 +1642,7 @@ DocTestRunner objects verbosity is not specified, then the :class:`DocTestRunner`'s verbosity is used. - :class:`DocTestParser` has the following attributes: + :class:`DocTestRunner` has the following attributes: .. attribute:: tries diff --git a/Doc/library/ftplib.rst b/Doc/library/ftplib.rst index a0a59868a5ace99..15041a125ba92ad 100644 --- a/Doc/library/ftplib.rst +++ b/Doc/library/ftplib.rst @@ -92,7 +92,7 @@ FTP objects :param str user: |param_doc_user| - If given, :code:`login(host, passwd, acct)` is implicitly called + If given, :code:`login(user, passwd, acct)` is implicitly called by the constructor. :param str passwd: @@ -464,7 +464,7 @@ FTP_TLS objects :param str user: |param_doc_user| - If given, :code:`login(host, passwd, acct)` is implicitly called + If given, :code:`login(user, passwd, acct)` is implicitly called by the constructor. :param str passwd: diff --git a/Doc/library/http.client.rst b/Doc/library/http.client.rst index ab557f1805e1049..055971ec21aee37 100644 --- a/Doc/library/http.client.rst +++ b/Doc/library/http.client.rst @@ -663,7 +663,7 @@ method attribute. Here is an example session that uses the ``PUT`` method:: >>> conn.request("PUT", "/file", BODY) >>> response = conn.getresponse() >>> print(response.status, response.reason) - 200, OK + 200 OK .. _httpmessage-objects: diff --git a/Doc/library/http.cookies.rst b/Doc/library/http.cookies.rst index 4965c5fc3ba1d86..4a8d461213f4e57 100644 --- a/Doc/library/http.cookies.rst +++ b/Doc/library/http.cookies.rst @@ -163,7 +163,7 @@ Morsel Objects that the cookie was first set in. For this to be accepted by the user agent, you **must** also set ``Secure``. - In addition, it is recommended to use the ``__Host`` prefix when setting + In addition, it is recommended to use the ``__Host-`` prefix when setting partitioned cookies to make them bound to the hostname and not the registrable domain. Read `CHIPS (Cookies Having Independent Partitioned State)`_ diff --git a/Doc/library/io.rst b/Doc/library/io.rst index 09e9e42565a99ef..495505ec63f8d13 100644 --- a/Doc/library/io.rst +++ b/Doc/library/io.rst @@ -205,7 +205,7 @@ High-level module interface def read_text(path, encoding=None): encoding = io.text_encoding(encoding) # stacklevel=2 - with open(path, encoding) as f: + with open(path, encoding=encoding) as f: return f.read() In this example, an :class:`EncodingWarning` is emitted for the caller of diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst index a3d117c10702414..123cebf7189041f 100644 --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -747,14 +747,14 @@ Formatter Objects .. versionchanged:: 3.3 Previously, the default format was hard-coded as in this example: ``2010-09-06 22:38:15,292`` where the part before the comma is - handled by a strptime format string (``'%Y-%m-%d %H:%M:%S'``), and the - part after the comma is a millisecond value. Because strptime does not + handled by a strftime format string (``'%Y-%m-%d %H:%M:%S'``), and the + part after the comma is a millisecond value. Because strftime does not have a format placeholder for milliseconds, the millisecond value is appended using another format string, ``'%s,%03d'`` --- and both of these format strings have been hardcoded into this method. With the change, these strings are defined as class-level attributes which can be overridden at the instance level when desired. The names of the - attributes are ``default_time_format`` (for the strptime format string) + attributes are ``default_time_format`` (for the strftime format string) and ``default_msec_format`` (for appending the millisecond value). .. versionchanged:: 3.9 diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst index cd376bd49f43eda..dc45f8401541f45 100644 --- a/Doc/library/multiprocessing.rst +++ b/Doc/library/multiprocessing.rst @@ -2750,7 +2750,7 @@ multiple connections at the same time. assumed to be the fastest available. See :ref:`multiprocessing-address-formats`. Note that if *family* is ``'AF_UNIX'`` and address is ``None`` then the socket will be created in a - private temporary directory created using :func:`tempfile.mkstemp`. + private temporary directory created using :func:`tempfile.mkdtemp`. If the listener object uses a socket then *backlog* (1 by default) is passed to the :meth:`~socket.socket.listen` method of the socket once it has been diff --git a/Doc/library/optparse.rst b/Doc/library/optparse.rst index 4271e65e142cad3..3486c83a6576435 100644 --- a/Doc/library/optparse.rst +++ b/Doc/library/optparse.rst @@ -2003,7 +2003,7 @@ To add new types, you need to define your own subclass of :mod:`!optparse`'s (e.g., ``-f``), and ``value`` is the string from the command line that must be checked and converted to your desired type. ``check_mytype()`` should return an object of the hypothetical type ``mytype``. The value returned by - a type-checking function will wind up in the OptionValues instance returned + a type-checking function will wind up in the Values instance returned by :meth:`OptionParser.parse_args`, or be passed to a callback as the ``value`` parameter. @@ -2070,7 +2070,7 @@ Adding new actions is a bit trickier, because you have to understand that "store" actions actions that result in :mod:`!optparse` storing a value to an attribute of the - current OptionValues instance; these options require a :attr:`~Option.dest` + current Values instance; these options require a :attr:`~Option.dest` attribute to be supplied to the Option constructor. "typed" actions @@ -2152,8 +2152,8 @@ Features of note: control back to :meth:`Option.take_action` for the standard :mod:`!optparse` actions. -* ``values`` is an instance of the optparse_parser.Values class, which provides - the very useful :meth:`ensure_value` method. :meth:`ensure_value` is +* ``values`` is an instance of the optparse.Values class, which provides + the very useful :meth:`!ensure_value` method. :meth:`!ensure_value` is essentially :func:`getattr` with a safety valve; it is called as :: values.ensure_value(attr, value) @@ -2163,9 +2163,9 @@ Features of note: very handy for actions like ``"extend"``, ``"append"``, and ``"count"``, all of which accumulate data in a variable and expect that variable to be of a certain type (a list for the first two, an integer for the latter). Using - :meth:`ensure_value` means that scripts using your action don't have to worry + :meth:`!ensure_value` means that scripts using your action don't have to worry about setting a default value for the option destinations in question; they - can just leave the default as ``None`` and :meth:`ensure_value` will take care of + can just leave the default as ``None`` and :meth:`!ensure_value` will take care of getting it right when it's needed. Exceptions diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 80e119e720574ed..c243b3ebf0b3eab 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -3374,7 +3374,7 @@ features: .. versionchanged:: 3.12 ``st_ctime_ns`` is deprecated on Windows. Use ``st_birthtime_ns`` - for the file creation time. In the future, ``st_ctime`` will contain + for the file creation time. In the future, ``st_ctime_ns`` will contain the time of the most recent metadata change, as for other platforms. .. attribute:: st_birthtime @@ -5456,7 +5456,7 @@ written in Python, such as a mail server's external command delivery program. parent's signal mask. This argument corresponds to the C library :c:macro:`!POSIX_SPAWN_SETSIGMASK` flag. - The *sigdef* argument will reset the disposition of all signals in the set + The *setsigdef* argument will reset the disposition of all signals in the set specified. This argument corresponds to the C library :c:macro:`!POSIX_SPAWN_SETSIGDEF` flag. diff --git a/Doc/library/pdb.rst b/Doc/library/pdb.rst index 995a9756a4ef53b..df5de52a412efac 100644 --- a/Doc/library/pdb.rst +++ b/Doc/library/pdb.rst @@ -812,7 +812,7 @@ can be overridden by the local file. List or jump between chained exceptions. - When using ``pdb.pm()`` or ``Pdb.post_mortem(...)`` with a chained exception + When using ``pdb.pm()`` or ``pdb.post_mortem(...)`` with a chained exception instead of a traceback, it allows the user to move between the chained exceptions using ``exceptions`` command to list exceptions, and ``exceptions `` to switch to that exception. diff --git a/Doc/library/profile.rst b/Doc/library/profile.rst index f7e85d1598727f9..324f69ef9d31c5a 100644 --- a/Doc/library/profile.rst +++ b/Doc/library/profile.rst @@ -92,7 +92,7 @@ following functions: the *timer* argument. This must be a function that returns a single number representing the current time. If the number is an integer, the *timeunit* specifies a multiplier that specifies the duration of each unit of time. For - example, if the timer returns times measured in thousands of seconds, the + example, if the timer returns times measured in thousandths of seconds, the time unit would be ``.001``. Directly using the :class:`Profile` class allows formatting profile results @@ -345,7 +345,7 @@ you are using :class:`profile.Profile` or :class:`profiling.tracing.Profile`, ``your_time_func`` should return a single number. If it returns integers, you can also invoke the class constructor with a second argument specifying the real duration of one unit of time. For example, if - ``your_integer_time_func`` returns times measured in thousands of seconds, + ``your_integer_time_func`` returns times measured in thousandths of seconds, you would construct the :class:`Profile` instance as follows:: pr = profiling.tracing.Profile(your_integer_time_func, 0.001) diff --git a/Doc/library/profiling.sampling.rst b/Doc/library/profiling.sampling.rst index 25d0d098ff84b46..1a0451788b5bfce 100644 --- a/Doc/library/profiling.sampling.rst +++ b/Doc/library/profiling.sampling.rst @@ -1044,7 +1044,7 @@ an interactive flame graph visualization:: `Try the interactive example <../_static/tachyon-example-flamegraph.html>`__! If no output file is specified, the profiler generates a filename based on -the process ID (for example, ``flamegraph.12345.html``). +the process ID (for example, ``flamegraph_12345.html``). The generated HTML file requires no external dependencies and can be opened directly in a web browser. The visualization displays call stacks as nested diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst index 139dc2c24eab764..d177abd48fa9cd4 100644 --- a/Doc/library/ssl.rst +++ b/Doc/library/ssl.rst @@ -2860,7 +2860,7 @@ Visual inspection shows that the certificate does identify the desired service Now the SSL channel is established and the certificate verified, you can proceed to talk with the server:: - >>> conn.sendall(b"HEAD / HTTP/1.0\r\nHost: linuxfr.org\r\n\r\n") + >>> conn.sendall(b"HEAD / HTTP/1.0\r\nHost: www.python.org\r\n\r\n") >>> pprint.pprint(conn.recv(1024).split(b"\r\n")) [b'HTTP/1.1 200 OK', b'Date: Sat, 18 Oct 2014 18:27:20 GMT', @@ -3072,7 +3072,7 @@ provided. When compared to :class:`SSLSocket`, this object lacks the following features: - - Any form of network IO; ``recv()`` and ``send()`` read and write only to + - Any form of network IO; ``read()`` and ``write()`` read and write only to the underlying :class:`MemoryBIO` buffers. - There is no *do_handshake_on_connect* machinery. You must always manually diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst index 98d1ebfd7f603e2..092332812296ccf 100644 --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -781,7 +781,7 @@ call the :meth:`~TarInfo.replace` method to create a modified copy in one step. Several attributes can be set to ``None`` to indicate that a piece of metadata is unused or unknown. -Different :class:`TarInfo` methods handle ``None`` differently: +Different :class:`TarFile` methods handle ``None`` differently: - The :meth:`~TarFile.extract` or :meth:`~TarFile.extractall` methods will ignore the corresponding metadata, leaving it set to a default. @@ -1476,7 +1476,7 @@ The same example using the :keyword:`with` statement:: How to create and write an archive to stdout using :data:`sys.stdout.buffer ` in the *fileobj* parameter -in :meth:`TarFile.add`:: +in :func:`~tarfile.open`:: import sys import tarfile diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst index 5d9a7b6314b1668..5e80c30953955da 100644 --- a/Doc/library/threading.rst +++ b/Doc/library/threading.rst @@ -821,7 +821,7 @@ locks. In the locked state, some thread owns the lock; in the unlocked state, no thread owns it. Threads call a lock's :meth:`~RLock.acquire` method to lock it, -and its :meth:`~Lock.release` method to unlock it. +and its :meth:`~RLock.release` method to unlock it. .. note:: @@ -832,7 +832,7 @@ and its :meth:`~Lock.release` method to unlock it. RLock's :meth:`~RLock.acquire`/:meth:`~RLock.release` call pairs may be nested, unlike Lock's :meth:`~Lock.acquire`/:meth:`~Lock.release`. Only the final -:meth:`~RLock.release` (the :meth:`~Lock.release` of the outermost pair) resets +:meth:`~RLock.release` (the :meth:`~RLock.release` of the outermost pair) resets the lock to an unlocked state and allows another thread blocked in :meth:`~RLock.acquire` to proceed. diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst index dd574fce09f5fc8..09da385bfdf79a1 100644 --- a/Doc/library/timeit.rst +++ b/Doc/library/timeit.rst @@ -148,7 +148,7 @@ The module defines three convenience functions and a public class: Automatically determine how many times to call :meth:`.timeit`. This is a convenience function that calls :meth:`.timeit` repeatedly - so that the total time >= *Timer.target_time* seconds, returning the eventual + so that the total time >= *target_time* seconds, returning the eventual (number of loops, time taken for that number of loops). It calls :meth:`.timeit` with increasing numbers from the sequence 1, 2, 5, 10, 20, 50, ... until the time taken is at least *target_time* seconds. diff --git a/Doc/library/tracemalloc.rst b/Doc/library/tracemalloc.rst index 4a19acb430b0d13..6ce677b15a51b4a 100644 --- a/Doc/library/tracemalloc.rst +++ b/Doc/library/tracemalloc.rst @@ -750,7 +750,7 @@ Traceback Example:: print("Traceback (most recent call first):") - for line in traceback: + for line in traceback.format(most_recent_first=True): print(line) Output:: diff --git a/Doc/library/xml.dom.rst b/Doc/library/xml.dom.rst index e5b5147720802e3..208eb4ad414f706 100644 --- a/Doc/library/xml.dom.rst +++ b/Doc/library/xml.dom.rst @@ -515,7 +515,7 @@ NodeList Objects A :class:`NodeList` represents a sequence of nodes. These objects are used in two ways in the DOM Core recommendation: an :class:`Element` object provides one as its list of child nodes, and the :meth:`~Element.getElementsByTagName` -and :meth:`~Element.getElementsByTagNameNS` methods of :class:`Node` return +and :meth:`~Element.getElementsByTagNameNS` methods of :class:`Element` return objects with this interface to represent query results. :class:`NodeList` does *not* inherit from :class:`Node`. diff --git a/Doc/whatsnew/2.3.rst b/Doc/whatsnew/2.3.rst index f2d372440717517..984f9d363eb7187 100644 --- a/Doc/whatsnew/2.3.rst +++ b/Doc/whatsnew/2.3.rst @@ -1357,7 +1357,7 @@ complete list of changes, or look through the CVS logs for all the details. other than ``e`` and ``10``. (Contributed by Raymond Hettinger.) * Several new POSIX functions (:func:`!getpgid`, :func:`!killpg`, :func:`!lchown`, - :func:`!loadavg`, :func:`!major`, :func:`!makedev`, :func:`!minor`, and + :func:`!getloadavg`, :func:`!major`, :func:`!makedev`, :func:`!minor`, and :func:`!mknod`) were added to the :mod:`posix` module that underlies the :mod:`os` module. (Contributed by Gustavo Niemeyer, Geert Jansen, and Denis S. Otkidach.) @@ -1658,7 +1658,7 @@ complete list of changes, or look through the CVS logs for all the details. has been added. The "idna" encoding can be used to convert between a Unicode domain name and the ASCII-compatible encoding (ACE) of that name. :: - >{}>{}> u"www.Alliancefrançaise.nu".encode("idna") + >>> u"www.Alliancefrançaise.nu".encode("idna") 'www.xn--alliancefranaise-npb.nu' The :mod:`socket` module has also been extended to transparently convert diff --git a/Doc/whatsnew/2.4.rst b/Doc/whatsnew/2.4.rst index ae3e9ed4646eeda..a3c75ec7f8e39ad 100644 --- a/Doc/whatsnew/2.4.rst +++ b/Doc/whatsnew/2.4.rst @@ -1072,7 +1072,7 @@ complete list of changes, or look through the CVS logs for all the details. 3.0 version of the package uses a new incremental parser for MIME messages, available in the :mod:`!email.FeedParser` module. The new parser doesn't require reading the entire message into memory, and doesn't raise exceptions if a - message is malformed; instead it records any problems in the :attr:`!defect` + message is malformed; instead it records any problems in the :attr:`!defects` attribute of the message. (Developed by Anthony Baxter, Barry Warsaw, Thomas Wouters, and others.) @@ -1177,7 +1177,7 @@ complete list of changes, or look through the CVS logs for all the details. import logging logging.basicConfig(filename='/var/log/application.log', level=0, # Log all messages - format='%(levelname):%(process):%(thread):%(message)') + format='%(levelname)s:%(process)d:%(thread)d:%(message)s') Other additions to the :mod:`logging` package include a ``log(level, msg)`` convenience method, as well as a :class:`~logging.handlers.TimedRotatingFileHandler` class that diff --git a/Doc/whatsnew/2.5.rst b/Doc/whatsnew/2.5.rst index 33d8b741ba17668..1e0c2bec9fb98ef 100644 --- a/Doc/whatsnew/2.5.rst +++ b/Doc/whatsnew/2.5.rst @@ -1738,7 +1738,7 @@ constructor that will create a :c:expr:`PyObject *` pointer. A simple usage:: d = {} ctypes.pythonapi.PyObject_SetItem(ctypes.py_object(d), ctypes.py_object("abc"), ctypes.py_object(1)) - # d is now {'abc', 1}. + # d is now {'abc': 1}. Don't forget to use :func:`~ctypes.py_object`; if it's omitted you end up with a segmentation fault. @@ -2182,7 +2182,7 @@ Changes to Python's build process and to the C API include: specified *type* and uses a fast-calling qualifier. :c:macro:`Py_LOCAL_INLINE` does the same thing and also requests the function be inlined. If macro :c:macro:`!PY_LOCAL_AGGRESSIVE` is defined before - :file:`python.h` is included, a set of more aggressive optimizations are enabled + :file:`Python.h` is included, a set of more aggressive optimizations are enabled for the module; you should benchmark the results to find out if these optimizations actually make the code faster. (Contributed by Fredrik Lundh at the NeedForSpeed sprint.) diff --git a/Doc/whatsnew/2.7.rst b/Doc/whatsnew/2.7.rst index de90c37a38d38ff..bc766e37e380e82 100644 --- a/Doc/whatsnew/2.7.rst +++ b/Doc/whatsnew/2.7.rst @@ -2298,7 +2298,7 @@ and getting the pointer requires providing the name: void *vtable; - if (!PyCapsule_IsValid(capsule, "mymodule.CAPI") { + if (!PyCapsule_IsValid(capsule, "mymodule.CAPI")) { PyErr_SetString(PyExc_ValueError, "argument type invalid"); return NULL; } diff --git a/Doc/whatsnew/3.1.rst b/Doc/whatsnew/3.1.rst index 9dc63c7976c5123..6c170abd402b871 100644 --- a/Doc/whatsnew/3.1.rst +++ b/Doc/whatsnew/3.1.rst @@ -310,7 +310,7 @@ New, Improved, and Deprecated Modules CSV header, SQL field list, or user input:: >>> query = input() - SELECT region, dept, count(*) FROM main GROUPBY region, dept + SELECT region, dept, count(*) FROM main GROUP BY region, dept >>> cursor.execute(query) >>> query_fields = [desc[0] for desc in cursor.description] diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 9f30141c10aa4ce..605de1570b2b961 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -1912,8 +1912,8 @@ C APIs pending removal are * :meth:`!importlib.machinery.PathFinder.find_module` * :meth:`!importlib.machinery.WindowsRegistryFinder.find_module` * :func:`!importlib.util.module_for_loader` -* :func:`!importlib.util.set_loader_wrapper` -* :func:`!importlib.util.set_package_wrapper` +* :func:`!importlib.util.set_loader` +* :func:`!importlib.util.set_package` * :class:`!pkgutil.ImpImporter` * :class:`!pkgutil.ImpLoader` * :meth:`!pathlib.Path.link_to` diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index d822d83164db6ff..ddaf07384a6b8c4 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -133,7 +133,7 @@ Security improvements: C API improvements: -* :ref:`PEP 697 `, unstable C API tier +* :ref:`PEP 689 `, unstable C API tier * :ref:`PEP 683 `, immortal objects CPython implementation improvements: @@ -1035,13 +1035,13 @@ unittest Add a ``--durations`` command line option, showing the N slowest test cases:: - python3 -m unittest --durations=3 lib.tests.test_threading + python3 -m unittest --durations=3 test.test_threading ..... Slowest test durations ---------------------------------------------------------------------- - 1.210s test_timeout (Lib.test.test_threading.BarrierTests) - 1.003s test_default_timeout (Lib.test.test_threading.BarrierTests) - 0.518s test_timeout (Lib.test.test_threading.EventTests) + 1.210s test_timeout (test.test_threading.BarrierTests) + 1.003s test_default_timeout (test.test_threading.BarrierTests) + 0.518s test_timeout (test.test_threading.EventTests) (0.000 durations hidden. Use -v to show these durations.) ---------------------------------------------------------------------- @@ -1862,8 +1862,9 @@ New Features ------------ .. _whatsnew312-pep697: +.. _whatsnew312-pep689: -* :pep:`697`: Introduce the :ref:`Unstable C API tier `, +* :pep:`689`: Introduce the :ref:`Unstable C API tier `, intended for low-level tools like debuggers and JIT compilers. This API may change in each minor release of CPython without deprecation warnings. diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 7c4996c5603c6c5..00b2771c6278b8b 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -1548,7 +1548,7 @@ ssl key agreement, extending the previous :meth:`ssl.SSLContext.set_ecdh_curve` method. This new API provides the ability to list multiple groups and - supports fixed-field and post-quantum groups in addition to ECDH + supports finite-field and post-quantum groups in addition to ECDH curves. This method can also be used to control what key shares are sent in the TLS handshake. * :meth:`ssl.SSLSocket.group` returns the group selected for doing key diff --git a/Doc/whatsnew/3.4.rst b/Doc/whatsnew/3.4.rst index 273cbe7ff925a0b..32d1bbe6af7f83f 100644 --- a/Doc/whatsnew/3.4.rst +++ b/Doc/whatsnew/3.4.rst @@ -2281,7 +2281,7 @@ Changes in the Python API * :meth:`!importlib.util.module_for_loader` now sets ``__loader__`` and ``__package__`` unconditionally to properly support reloading. If this is not desired then you will need to set these attributes manually. You can use - :func:`!importlib.util.module_to_load` for module management. + :func:`!importlib.util._module_to_load` for module management. * Import now resets relevant attributes (e.g. ``__name__``, ``__loader__``, ``__package__``, ``__file__``, ``__cached__``) unconditionally when reloading. @@ -2298,7 +2298,7 @@ Changes in the Python API * Frozen modules no longer define a ``__file__`` attribute. It's semantically incorrect for frozen modules to set the attribute as they are not loaded from any explicit location. If you must know that a module comes from frozen code - then you can see if the module's ``__spec__.location`` is set to ``'frozen'``, + then you can see if the module's ``__spec__.origin`` is set to ``'frozen'``, check if the loader is a subclass of :class:`importlib.machinery.FrozenImporter`, or if Python 2 compatibility is necessary you can use :func:`!imp.is_frozen`. diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst index b0382dd8215bc00..d2daf052e43f824 100644 --- a/Doc/whatsnew/3.6.rst +++ b/Doc/whatsnew/3.6.rst @@ -2111,11 +2111,11 @@ API and Feature Removals name for a given path. (Contributed by Yury Selivanov in :issue:`13248`.) -* ``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 +* ``trace.Ignore`` class and ``trace.usage``, ``trace.modname``, + ``trace.fullmodname``, ``trace.find_lines_from_code``, + ``trace.find_lines``, ``trace.find_strings``, + ``trace.find_executable_linenos`` methods were removed from the + :mod:`trace` 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 diff --git a/Doc/whatsnew/3.7.rst b/Doc/whatsnew/3.7.rst index 6900c97e9546c9a..671b83f87d34304 100644 --- a/Doc/whatsnew/3.7.rst +++ b/Doc/whatsnew/3.7.rst @@ -248,7 +248,7 @@ locales are available on the running system, it has the downside of having no effect on extension modules (such as GNU ``readline``), child processes running non-Python applications, and child processes running older versions of Python. To reduce the risk of corrupting text data when communicating with such -components, Python 3.7 also implements :ref:`whatsnew37-pep540`). +components, Python 3.7 also implements :ref:`whatsnew37-pep538`. The UTF-8 mode is enabled by default when the locale is ``C`` or ``POSIX``, and the :pep:`538` locale coercion feature fails to change it to a UTF-8 based @@ -1085,7 +1085,7 @@ itertools :func:`itertools.islice` now accepts :meth:`integer-like objects ` as start, stop, -and slice arguments. +and step arguments. (Contributed by Will Roberts in :issue:`30537`.) diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index 5f3fad1a1a51b50..37dfde666873878 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -2082,7 +2082,7 @@ Changes in the C API return NULL; #if PY_VERSION_HEX < 0x03080000 // Workaround for Python issue 35810; no longer necessary in Python 3.8 - PY_INCREF(type) + Py_INCREF(type); #endif return foo; } diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index 49a52b7504bc951..e2731b6de15a3e0 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -1031,8 +1031,8 @@ Removed :exc:`DeprecationWarning` since Python 3.8. (Contributed by Inada Naoki in :issue:`39377`) -* ``with (await asyncio.lock):`` and ``with (yield from asyncio.lock):`` statements are - not longer supported, use ``async with lock`` instead. The same is correct for +* ``with (await lock):`` and ``with (yield from lock):`` statements are + no longer supported, use ``async with lock`` instead. The same is correct for ``asyncio.Condition`` and ``asyncio.Semaphore``. (Contributed by Andrew Svetlov in :issue:`34793`.)