https://github.com/python/cpython/commit/f336df05751a83d58237f38c25530bba92fed5ea commit: f336df05751a83d58237f38c25530bba92fed5ea branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: methane <[email protected]> date: 2026-10-27T11:02:44Z summary:
Doc: Fix errors in documentation examples (GH-160742) (cherry picked from commit 085d3665b10b8b4a86504a7e6c05c933bbde12bc) Co-authored-by: Inada Naoki <[email protected]> Co-authored-by: Stan Ulbrych <[email protected]> files: M Doc/deprecations/c-api-pending-removal-in-3.18.rst M Doc/library/decimal.rst M Doc/library/ftplib.rst M Doc/library/zipapp.rst M Doc/tutorial/errors.rst M Doc/whatsnew/2.6.rst M Doc/whatsnew/3.10.rst M Doc/whatsnew/3.11.rst M Doc/whatsnew/3.13.rst M Doc/whatsnew/3.14.rst M Doc/whatsnew/3.2.rst M Doc/whatsnew/3.8.rst M Misc/NEWS.d/3.14.0a6.rst diff --git a/Doc/deprecations/c-api-pending-removal-in-3.18.rst b/Doc/deprecations/c-api-pending-removal-in-3.18.rst index 022aee93aa70c47..95441cfbbe8738d 100644 --- a/Doc/deprecations/c-api-pending-removal-in-3.18.rst +++ b/Doc/deprecations/c-api-pending-removal-in-3.18.rst @@ -31,11 +31,13 @@ Pending removal in Python 3.18 replace ``_PyUnicodeWriter_WriteSubstring(&writer, str, start, end)`` with :c:func:`PyUnicodeWriter_WriteSubstring(writer, str, start, end) <PyUnicodeWriter_WriteSubstring>`. * :c:func:`!_PyUnicodeWriter_WriteASCIIString`: - replace ``_PyUnicodeWriter_WriteASCIIString(&writer, str)`` with - :c:func:`PyUnicodeWriter_WriteASCII(writer, str) <PyUnicodeWriter_WriteASCII>`. + replace ``_PyUnicodeWriter_WriteASCIIString(&writer, str, size)`` with + :c:func:`PyUnicodeWriter_WriteASCII(writer, str, size) <PyUnicodeWriter_WriteASCII>`. * :c:func:`!_PyUnicodeWriter_WriteLatin1String`: - replace ``_PyUnicodeWriter_WriteLatin1String(&writer, str)`` with - :c:func:`PyUnicodeWriter_WriteUTF8(writer, str) <PyUnicodeWriter_WriteUTF8>`. + replace ``_PyUnicodeWriter_WriteLatin1String(&writer, str, size)`` by + decoding the string with :c:func:`PyUnicode_DecodeLatin1`, writing the + result with :c:func:`PyUnicodeWriter_WriteStr`, and releasing the result + with :c:func:`Py_DECREF`. * :c:func:`!_PyUnicodeWriter_Prepare`: (no replacement). * :c:func:`!_PyUnicodeWriter_PrepareKind`: (no replacement). * :c:func:`!_Py_HashPointer`: use :c:func:`Py_HashPointer`. diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst index d4c089f5a144145..a24f2ff52af7c45 100644 --- a/Doc/library/decimal.rst +++ b/Doc/library/decimal.rst @@ -2217,7 +2217,7 @@ applied to the *result* of the computation:: Decimal('3.1416') >>> pi - Decimal('0.00005') # Subtract unrounded numbers, then round Decimal('3.1415') - >>> pi + 0 - Decimal('0.00005'). # Intermediate values are rounded + >>> pi + 0 - Decimal('0.00005') # Intermediate values are rounded Decimal('3.1416') Q: Some decimal values always print with exponential notation. Is there a way diff --git a/Doc/library/ftplib.rst b/Doc/library/ftplib.rst index 9cbb387f40fb4c3..b359e49be6946a4 100644 --- a/Doc/library/ftplib.rst +++ b/Doc/library/ftplib.rst @@ -39,7 +39,7 @@ Here's a sample session using the :mod:`!ftplib` module:: drwxr-xr-x 3 1176 1176 4096 Oct 10 2012 tools '226 Directory send OK.' >>> with open('README', 'wb') as fp: - >>> ftp.retrbinary('RETR README', fp.write) + ... ftp.retrbinary('RETR README', fp.write) '226 Transfer complete.' >>> ftp.quit() '221 Goodbye.' diff --git a/Doc/library/zipapp.rst b/Doc/library/zipapp.rst index 2083857312f5e1a..1148ebec44c7872 100644 --- a/Doc/library/zipapp.rst +++ b/Doc/library/zipapp.rst @@ -227,7 +227,7 @@ fits in memory:: >>> temp = io.BytesIO() >>> zipapp.create_archive('myapp.pyz', temp, '/usr/bin/python2') >>> with open('myapp.pyz', 'wb') as f: - >>> f.write(temp.getvalue()) + ... f.write(temp.getvalue()) .. _zipapp-specifying-the-interpreter: diff --git a/Doc/tutorial/errors.rst b/Doc/tutorial/errors.rst index 3c6edf2c4793abd..40b7dacd202deca 100644 --- a/Doc/tutorial/errors.rst +++ b/Doc/tutorial/errors.rst @@ -608,7 +608,7 @@ be ones that have already been raised and caught by the program, along the following pattern:: >>> excs = [] - ... for test in tests: + >>> for test in tests: ... try: ... test.run() ... except Exception as e: diff --git a/Doc/whatsnew/2.6.rst b/Doc/whatsnew/2.6.rst index db5b41b40fecaba..3c430a9edd9d4dc 100644 --- a/Doc/whatsnew/2.6.rst +++ b/Doc/whatsnew/2.6.rst @@ -2600,7 +2600,7 @@ changes, or look through the Subversion logs for all the details. measured in seconds. For example:: >>> u = urllib2.urlopen("http://slow.example.com", - timeout=3) + ... timeout=3) Traceback (most recent call last): ... urllib2.URLError: <urlopen error timed out> diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index 5422b9d99b49378..0e3ffb064613856 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -1964,7 +1964,7 @@ Changes in the C API :c:func:`PyBytes_AsString` and :c:func:`Py_CompileString`, as sketched below. (Declarations and error handling are omitted.) :: - io_module = Import_ImportModule("io"); + io_module = PyImport_ImportModule("io"); fileobject = PyObject_CallMethod(io_module, "open", "ss", filename, "rb"); source_bytes_object = PyObject_CallMethod(fileobject, "read", ""); result = PyObject_CallMethod(fileobject, "close", ""); diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 3dbf806fe754f57..545b2690b40ce06 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -361,7 +361,7 @@ providing protection against injection attacks. For example, a SQL query function could be annotated as follows:: - def run_query(sql: LiteralString) -> ... + def run_query(sql: LiteralString) -> ...: ... def caller( @@ -2335,7 +2335,7 @@ Porting to Python 3.11 PyObject_GC_UnTrack(p); Py_TRASHCAN_SAFE_BEGIN(p); ... - Py_TRASHCAN_SAFE_END + Py_TRASHCAN_SAFE_END(p) } should migrate to the new macros as follows:: diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index 6544aad01b7cec5..d5af11040a4ce1c 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -2730,7 +2730,7 @@ Changes in the C API PyObject_GC_UnTrack(p); Py_TRASHCAN_SAFE_BEGIN(p); ... - Py_TRASHCAN_SAFE_END + Py_TRASHCAN_SAFE_END(p) } should migrate to the new macros as follows:: diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index dc8da16645686ca..4a21b25c9bf6a51 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -403,7 +403,7 @@ function. For example: .. code-block:: python - import sys + import os, sys from tempfile import NamedTemporaryFile with NamedTemporaryFile(mode='w', suffix='.py', delete=False) as f: diff --git a/Doc/whatsnew/3.2.rst b/Doc/whatsnew/3.2.rst index bb260c419c588b0..f72b78e32148738 100644 --- a/Doc/whatsnew/3.2.rst +++ b/Doc/whatsnew/3.2.rst @@ -1351,9 +1351,9 @@ connection when done:: >>> from ftplib import FTP >>> with FTP("ftp1.at.proftpd.org") as ftp: - ftp.login() - ftp.dir() - + ... ftp.login() + ... ftp.dir() + ... '230 Anonymous login ok, restrictions apply.' dr-xr-xr-x 9 ftp ftp 154 May 6 10:43 . dr-xr-xr-x 9 ftp ftp 154 May 6 10:43 .. diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index 663d4c9af2e6c1e..650b75d0acebd1d 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -160,7 +160,7 @@ breaking client code. For example, in the :mod:`statistics` module, the parameter name *dist* may be changed in the future. This was made possible with the following function specification:: - def quantiles(dist, /, *, n=4, method='exclusive') + def quantiles(dist, /, *, n=4, method='exclusive'): ... Since the parameters to the left of ``/`` are not exposed as possible diff --git a/Misc/NEWS.d/3.14.0a6.rst b/Misc/NEWS.d/3.14.0a6.rst index 6ffd0c9d31a45de..f8db5a8ce0a94ad 100644 --- a/Misc/NEWS.d/3.14.0a6.rst +++ b/Misc/NEWS.d/3.14.0a6.rst @@ -1398,11 +1398,13 @@ Python 3.18: replace ``_PyUnicodeWriter_WriteSubstring(&writer, str, start, end)`` with :c:func:`PyUnicodeWriter_WriteSubstring(writer, str, start, end) <PyUnicodeWriter_WriteSubstring>`. * :c:func:`!_PyUnicodeWriter_WriteASCIIString`: - replace ``_PyUnicodeWriter_WriteASCIIString(&writer, str)`` with - :c:func:`PyUnicodeWriter_WriteUTF8(writer, str) <PyUnicodeWriter_WriteUTF8>`. + replace ``_PyUnicodeWriter_WriteASCIIString(&writer, str, size)`` with + :c:func:`PyUnicodeWriter_WriteUTF8(writer, str, size) <PyUnicodeWriter_WriteUTF8>`. * :c:func:`!_PyUnicodeWriter_WriteLatin1String`: - replace ``_PyUnicodeWriter_WriteLatin1String(&writer, str)`` with - :c:func:`PyUnicodeWriter_WriteUTF8(writer, str) <PyUnicodeWriter_WriteUTF8>`. + replace ``_PyUnicodeWriter_WriteLatin1String(&writer, str, size)`` by + decoding the string with :c:func:`PyUnicode_DecodeLatin1`, writing the + result with :c:func:`PyUnicodeWriter_WriteStr`, and releasing the result + with :c:func:`Py_DECREF`. * :c:func:`!_PyUnicodeWriter_Prepare`: (no replacement). * :c:func:`!_PyUnicodeWriter_PrepareKind`: (no replacement). _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
