Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Doc/c-api/module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <the module in question>
PyObject *module = <the module in question>;

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:

Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/typeobj.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 10 additions & 9 deletions Doc/extending/embedding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Doc/extending/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down
2 changes: 1 addition & 1 deletion Doc/howto/descriptor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Doc/howto/instrumentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions Doc/howto/isolating-extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Doc/howto/logging-cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/annotationlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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'}


Expand Down
6 changes: 3 additions & 3 deletions Doc/library/argparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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::

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/asyncio-eventloop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions Doc/library/binascii.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions Doc/library/calendar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.


Expand Down
4 changes: 2 additions & 2 deletions Doc/library/cgi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ It was :ref:`removed in Python 3.13 <whatsnew313-pep594>` 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 <https://docs.python.org/3.12/library/cgi.html>`_.
4 changes: 2 additions & 2 deletions Doc/library/cgitb.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ It was :ref:`removed in Python 3.13 <whatsnew313-pep594>` 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 <https://docs.python.org/3.12/library/cgitb.html>`_.
2 changes: 1 addition & 1 deletion Doc/library/codecs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/doctest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions Doc/library/ftplib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/http.client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/http.cookies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)`_
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Doc/library/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/multiprocessing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions Doc/library/optparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/pdb.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <number>`` to switch to that exception.
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/profile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Loading
Loading