summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-03-14 22:23:00 (GMT)
committerGitHub <noreply@github.com>2024-03-14 22:23:00 (GMT)
commit7bbb9b57e67057d5ca3b7e3a434527fb3fcf5a2b (patch)
tree5f09547613d22804329cac09199b629f3182b4db /Doc
parent5f52d20a93908196f74271db8437cc1ba7e1e262 (diff)
downloadcpython-7bbb9b57e67057d5ca3b7e3a434527fb3fcf5a2b.zip
cpython-7bbb9b57e67057d5ca3b7e3a434527fb3fcf5a2b.tar.gz
cpython-7bbb9b57e67057d5ca3b7e3a434527fb3fcf5a2b.tar.bz2
gh-111696, PEP 737: Add %T and %N to PyUnicode_FromFormat() (#116839)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/c-api/unicode.rst23
-rw-r--r--Doc/whatsnew/3.13.rst6
2 files changed, 29 insertions, 0 deletions
diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst
index 666ffe8..78eec14 100644
--- a/Doc/c-api/unicode.rst
+++ b/Doc/c-api/unicode.rst
@@ -518,6 +518,26 @@ APIs:
- :c:expr:`PyObject*`
- The result of calling :c:func:`PyObject_Repr`.
+ * - ``T``
+ - :c:expr:`PyObject*`
+ - Get the fully qualified name of an object type;
+ call :c:func:`PyType_GetFullyQualifiedName`.
+
+ * - ``T#``
+ - :c:expr:`PyObject*`
+ - Similar to ``T`` format, but use a colon (``:``) as separator between
+ the module name and the qualified name.
+
+ * - ``N``
+ - :c:expr:`PyTypeObject*`
+ - Get the fully qualified name of a type;
+ call :c:func:`PyType_GetFullyQualifiedName`.
+
+ * - ``N#``
+ - :c:expr:`PyTypeObject*`
+ - Similar to ``N`` format, but use a colon (``:``) as separator between
+ the module name and the qualified name.
+
.. note::
The width formatter unit is number of characters rather than bytes.
The precision formatter unit is number of bytes or :c:type:`wchar_t`
@@ -553,6 +573,9 @@ APIs:
In previous versions it caused all the rest of the format string to be
copied as-is to the result string, and any extra arguments discarded.
+ .. versionchanged:: 3.13
+ Support for ``%T``, ``%T#``, ``%N`` and ``%N#`` formats added.
+
.. c:function:: PyObject* PyUnicode_FromFormatV(const char *format, va_list vargs)
diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst
index f42197c..856c6ee 100644
--- a/Doc/whatsnew/3.13.rst
+++ b/Doc/whatsnew/3.13.rst
@@ -1668,6 +1668,12 @@ New Features
Equivalent to getting the ``type.__module__`` attribute.
(Contributed by Eric Snow and Victor Stinner in :gh:`111696`.)
+* Add support for ``%T``, ``%T#``, ``%N`` and ``%N#`` formats to
+ :c:func:`PyUnicode_FromFormat`: format the fully qualified name of an object
+ type and of a type: call :c:func:`PyType_GetModuleName`. See :pep:`737` for
+ more information.
+ (Contributed by Victor Stinner in :gh:`111696`.)
+
Porting to Python 3.13
----------------------