Skip to content
Merged
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
10 changes: 10 additions & 0 deletions Doc/c-api/codec.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,13 @@ Registry API for Unicode encoding error handlers
Replace the unicode encode error with ``\N{...}`` escapes.

.. versionadded:: 3.5


Codec utility variables
-----------------------

.. c:var:: const char *Py_hexdigits

A string constant containing the lowercase hexadecimal digits: ``"0123456789abcdef"``.

.. versionadded:: 3.3
21 changes: 21 additions & 0 deletions Doc/c-api/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,27 @@ these are the C equivalent to :func:`reprlib.recursive_repr`.
Ends a :c:func:`Py_ReprEnter`. Must be called once for each
invocation of :c:func:`Py_ReprEnter` that returns zero.

.. c:function:: int Py_GetRecursionLimit(void)

Get the recursion limit for the current interpreter. It can be set with
:c:func:`Py_SetRecursionLimit`. The recursion limit prevents the
Python interpreter stack from growing infinitely.

This function cannot fail, and the caller must hold an
:term:`attached thread state`.

.. seealso::
:py:func:`sys.getrecursionlimit`

.. c:function:: void Py_SetRecursionLimit(int new_limit)

Set the recursion limit for the current interpreter.

This function cannot fail, and the caller must hold an
:term:`attached thread state`.

.. seealso::
:py:func:`sys.setrecursionlimit`

.. _standardexceptions:

Expand Down
39 changes: 39 additions & 0 deletions Doc/c-api/iterator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,45 @@ sentinel value is returned.
*sentinel*, the iteration will be terminated.


Range Objects
^^^^^^^^^^^^^

.. c:var:: PyTypeObject PyRange_Type

The type object for :class:`range` objects.


.. c:function:: int PyRange_Check(PyObject *o)

Return true if the object *o* is an instance of a :class:`range` object.
This function always succeeds.


Builtin Iterator Types
^^^^^^^^^^^^^^^^^^^^^^

These are built-in iteration types that are included in Python's C API, but
provide no additional functions. They are here for completeness.


.. list-table::
:widths: auto
:header-rows: 1

* * C type
* Python type
* * .. c:var:: PyTypeObject PyEnum_Type
* :py:class:`enumerate`
* * .. c:var:: PyTypeObject PyFilter_Type
* :py:class:`filter`
* * .. c:var:: PyTypeObject PyMap_Type
* :py:class:`map`
* * .. c:var:: PyTypeObject PyReversed_Type
* :py:class:`reversed`
* * .. c:var:: PyTypeObject PyZip_Type
* :py:class:`zip`


Other Iterator Objects
^^^^^^^^^^^^^^^^^^^^^^

Expand Down
22 changes: 22 additions & 0 deletions Doc/c-api/long.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
.. versionadded:: 3.13


.. c:macro:: PyLong_FromPid(pid)

Macro for creating a Python integer from a process identifier.

This can be defined as an alias to :c:func:`PyLong_FromLong` or
:c:func:`PyLong_FromLongLong`, depending on the size of the system's
PID type.

.. versionadded:: 3.2


.. c:function:: long PyLong_AsLong(PyObject *obj)

.. index::
Expand Down Expand Up @@ -575,6 +586,17 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
.. versionadded:: 3.13


.. c:macro:: PyLong_AsPid(pid)

Macro for converting a Python integer into a process identifier.

This can be defined as an alias to :c:func:`PyLong_AsLong`,
:c:func:`PyLong_FromLongLong`, or :c:func:`PyLong_AsInt`, depending on the
size of the system's PID type.

.. versionadded:: 3.2


.. c:function:: int PyLong_GetSign(PyObject *obj, int *sign)

Get the sign of the integer object *obj*.
Expand Down
6 changes: 3 additions & 3 deletions Doc/library/concurrent.interpreters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ Actual concurrency is available separately through
.. seealso::

:class:`~concurrent.futures.InterpreterPoolExecutor`
combines threads with interpreters in a familiar interface.
Combines threads with interpreters in a familiar interface.

.. XXX Add references to the upcoming HOWTO docs in the seealso block.
.. XXX Add references to the upcoming HOWTO docs in the seealso block.

:ref:`isolating-extensions-howto`
how to update an extension module to support multiple interpreters
How to update an extension module to support multiple interpreters.

:pep:`554`

Expand Down
10 changes: 5 additions & 5 deletions Doc/library/heapq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ functions, respectively.
The following functions are provided for min-heaps:


.. function:: heapify(x)

Transform list *x* into a min-heap, in-place, in linear time.


.. function:: heappush(heap, item)

Push the value *item* onto the *heap*, maintaining the min-heap invariant.
Expand All @@ -77,11 +82,6 @@ The following functions are provided for min-heaps:
followed by a separate call to :func:`heappop`.


.. function:: heapify(x)

Transform list *x* into a min-heap, in-place, in linear time.


.. function:: heapreplace(heap, item)

Pop and return the smallest item from the *heap*, and also push the new *item*.
Expand Down
2 changes: 1 addition & 1 deletion Include/internal/pycore_moduleobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static inline PyModuleDef *_PyModule_GetDefOrNull(PyObject *arg) {

static inline PyModuleDef *_PyModule_GetToken(PyObject *arg) {
PyModuleObject *mod = _PyModule_CAST(arg);
return mod->md_token;
return (PyModuleDef *)mod->md_token;
}

static inline void* _PyModule_GetState(PyObject* mod) {
Expand Down
4 changes: 0 additions & 4 deletions Lib/test/test_base64.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,6 @@ def test_b32decode_casefold(self):
self.assertRaises(binascii.Error, base64.b32decode, b'me======')
self.assertRaises(binascii.Error, base64.b32decode, 'me======')

# Mapping zero and one
eq(base64.b32decode(b'MLO23456'), b'b\xdd\xad\xf3\xbe')
eq(base64.b32decode('MLO23456'), b'b\xdd\xad\xf3\xbe')

def test_b32decode_map01(self):
# Mapping zero and one
eq = self.assertEqual
Expand Down
5 changes: 4 additions & 1 deletion PC/winreg.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ PyDoc_STRVAR(module_doc,
"DeleteKey() - Deletes the specified key.\n"
"DeleteKeyEx() - Deletes the specified key.\n"
"DeleteValue() - Removes a named value from the specified registry key.\n"
"DeleteTree() - Deletes the specified key and all its subkeys and values recursively.\n"
"EnumKey() - Enumerates subkeys of the specified open registry key.\n"
"EnumValue() - Enumerates values of the specified open registry key.\n"
"ExpandEnvironmentStrings() - Expand the env strings in a REG_EXPAND_SZ\n"
Expand Down Expand Up @@ -107,7 +108,9 @@ PyDoc_STRVAR(PyHKEY_doc,
"Operations:\n"
"__bool__ - Handles with an open object return true, otherwise false.\n"
"__int__ - Converting a handle to an integer returns the Win32 handle.\n"
"rich comparison - Handle objects are compared using the handle value.");
"__enter__, __exit__ - Context manager support for 'with' statement,\n"
"automatically closes handle.\n"
"__eq__, __ne__ - Equality comparison based on Windows handle value.");



Expand Down
4 changes: 1 addition & 3 deletions Python/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,12 @@ PyThread_GetInfo(void)

#ifdef HAVE_PTHREAD_STUBS
value = Py_NewRef(Py_None);
#elif defined(_POSIX_THREADS)
#else
value = PyUnicode_FromString("pymutex");
if (value == NULL) {
Py_DECREF(threadinfo);
return NULL;
}
#else
value = Py_NewRef(Py_None);
#endif
PyStructSequence_SET_ITEM(threadinfo, pos++, value);

Expand Down
Loading