Skip to content

Commit 1275b18

Browse files
authored
Merge branch 'python:main' into issue-66646
2 parents dabe938 + fd49e22 commit 1275b18

File tree

16 files changed

+177
-53
lines changed

16 files changed

+177
-53
lines changed

Doc/c-api/memory.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,14 @@ The following type-oriented macros are provided for convenience. Note that
267267
.. c:macro:: PyMem_New(TYPE, n)
268268
269269
Same as :c:func:`PyMem_Malloc`, but allocates ``(n * sizeof(TYPE))`` bytes of
270-
memory. Returns a pointer cast to :c:expr:`TYPE*`. The memory will not have
270+
memory. Returns a pointer cast to ``TYPE*``. The memory will not have
271271
been initialized in any way.
272272
273273
274274
.. c:macro:: PyMem_Resize(p, TYPE, n)
275275
276276
Same as :c:func:`PyMem_Realloc`, but the memory block is resized to ``(n *
277-
sizeof(TYPE))`` bytes. Returns a pointer cast to :c:expr:`TYPE*`. On return,
277+
sizeof(TYPE))`` bytes. Returns a pointer cast to ``TYPE*``. On return,
278278
*p* will be a pointer to the new memory area, or ``NULL`` in the event of
279279
failure.
280280

Doc/library/ftplib.rst

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,43 @@ Reference
5555
FTP objects
5656
^^^^^^^^^^^
5757

58-
.. class:: FTP(host='', user='', passwd='', acct='', timeout=None, source_address=None, *, encoding='utf-8')
59-
60-
Return a new instance of the :class:`FTP` class. When *host* is given, the
61-
method call ``connect(host)`` is made. When *user* is given, additionally
62-
the method call ``login(user, passwd, acct)`` is made (where *passwd* and
63-
*acct* default to the empty string when not given). The optional *timeout*
64-
parameter specifies a timeout in seconds for blocking operations like the
65-
connection attempt (if is not specified, the global default timeout setting
66-
will be used). *source_address* is a 2-tuple ``(host, port)`` for the socket
67-
to bind to as its source address before connecting. The *encoding* parameter
68-
specifies the encoding for directories and filenames.
58+
.. class:: FTP(host='', user='', passwd='', acct='', timeout=None, \
59+
source_address=None, *, encoding='utf-8')
60+
61+
Return a new instance of the :class:`FTP` class.
62+
When *host* is given, the method call :meth:`connect(host) <connect>`
63+
is made by the constructor.
64+
When *user* is given, additionally the method call
65+
:meth:`login(user, passwd, acct) <connect>` is made.
66+
67+
:param str host:
68+
The hostname to connect to.
69+
70+
:param str user:
71+
The username to log in with.
72+
If empty string, ``"anonymous"`` is used.
73+
74+
:param str passwd:
75+
The password to use when logging in.
76+
If not given, and if *passwd* is the empty string or ``"-"``,
77+
a password will be automatically generated.
78+
79+
:param str acct:
80+
Account information; see the ACCT FTP command.
81+
82+
:param timeout:
83+
A timeout in seconds for blocking operations like :meth:`connect`.
84+
If not specified, the global default timeout setting will be used.
85+
:type timeout: int | None
86+
87+
:param source_address:
88+
*source_address* is a 2-tuple ``(host, port)`` for the socket
89+
to bind to as its source address before connecting.
90+
:type source_address: tuple | None
91+
92+
:param str encoding:
93+
The *encoding* parameter specifies the encoding
94+
for directories and filenames.
6995

7096
The :class:`FTP` class supports the :keyword:`with` statement, e.g.:
7197

@@ -102,12 +128,15 @@ FTP objects
102128

103129
.. method:: FTP.set_debuglevel(level)
104130

105-
Set the instance's debugging level. This controls the amount of debugging
106-
output printed. The default, ``0``, produces no debugging output. A value of
107-
``1`` produces a moderate amount of debugging output, generally a single line
108-
per request. A value of ``2`` or higher produces the maximum amount of
109-
debugging output, logging each line sent and received on the control connection.
131+
Set the instance's debugging level as an :class:`int`.
132+
This controls the amount of debugging output printed.
133+
The debug levels are:
110134

135+
* ``0`` (default): No debug output.
136+
* ``1``: Produce a moderate amount of debug output,
137+
generally a single line per request.
138+
* ``2`` or higher: Produce the maximum amount of debugging output,
139+
logging each line sent and received on the control connection.
111140

112141
.. method:: FTP.connect(host='', port=0, timeout=None, source_address=None)
113142

@@ -192,7 +221,7 @@ FTP objects
192221
``NLST`` retrieves a list of file names.
193222
The *callback* function is called for each line with a string argument
194223
containing the line with the trailing CRLF stripped. The default *callback*
195-
prints the line to ``sys.stdout``.
224+
prints the line to :data:`sys.stdout`.
196225

197226

198227
.. method:: FTP.set_pasv(val)
@@ -282,7 +311,7 @@ FTP objects
282311
current server directory). Multiple arguments can be used to pass non-standard
283312
options to the ``LIST`` command. If the last argument is a function, it is used
284313
as a *callback* function as for :meth:`retrlines`; the default prints to
285-
``sys.stdout``. This method returns ``None``.
314+
:data:`sys.stdout`. This method returns ``None``.
286315

287316
.. note:: If your server supports the command, :meth:`mlsd` offers a better API.
288317

Doc/library/sqlite3.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -343,17 +343,17 @@ Module functions
343343
.. audit-event:: sqlite3.connect database sqlite3.connect
344344
.. audit-event:: sqlite3.connect/handle connection_handle sqlite3.connect
345345

346-
.. versionadded:: 3.4
347-
The *uri* parameter.
346+
.. versionchanged:: 3.4
347+
Added the *uri* parameter.
348348

349349
.. versionchanged:: 3.7
350350
*database* can now also be a :term:`path-like object`, not only a string.
351351

352-
.. versionadded:: 3.10
353-
The ``sqlite3.connect/handle`` auditing event.
352+
.. versionchanged:: 3.10
353+
Added the ``sqlite3.connect/handle`` auditing event.
354354

355-
.. versionadded:: 3.12
356-
The *autocommit* parameter.
355+
.. versionchanged:: 3.12
356+
Added the *autocommit* parameter.
357357

358358
.. versionchanged:: 3.13
359359
Positional use of the parameters *timeout*, *detect_types*,
@@ -747,8 +747,8 @@ Connection objects
747747
`deterministic <https://sqlite.org/deterministic.html>`_,
748748
which allows SQLite to perform additional optimizations.
749749

750-
.. versionadded:: 3.8
751-
The *deterministic* parameter.
750+
.. versionchanged:: 3.8
751+
Added the *deterministic* parameter.
752752

753753
Example:
754754

@@ -1132,8 +1132,8 @@ Connection objects
11321132
.. versionchanged:: 3.10
11331133
Added the ``sqlite3.load_extension`` auditing event.
11341134

1135-
.. versionadded:: 3.12
1136-
The *entrypoint* parameter.
1135+
.. versionchanged:: 3.12
1136+
Added the *entrypoint* parameter.
11371137

11381138
.. _Loading an Extension: https://www.sqlite.org/loadext.html#loading_an_extension_
11391139

@@ -1762,10 +1762,10 @@ Row objects
17621762
Blob objects
17631763
^^^^^^^^^^^^
17641764

1765-
.. versionadded:: 3.11
1766-
17671765
.. class:: Blob
17681766

1767+
.. versionadded:: 3.11
1768+
17691769
A :class:`Blob` instance is a :term:`file-like object`
17701770
that can read and write data in an SQLite :abbr:`BLOB (Binary Large OBject)`.
17711771
Call :func:`len(blob) <len>` to get the size (number of bytes) of the blob.

Doc/library/sys.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1655,7 +1655,7 @@ always available.
16551655
``'opcode'`` event type added; :attr:`~frame.f_trace_lines` and
16561656
:attr:`~frame.f_trace_opcodes` attributes added to frames
16571657

1658-
.. function:: set_asyncgen_hooks(firstiter, finalizer)
1658+
.. function:: set_asyncgen_hooks([firstiter] [, finalizer])
16591659

16601660
Accepts two optional keyword arguments which are callables that accept an
16611661
:term:`asynchronous generator iterator` as an argument. The *firstiter*

Doc/library/tty.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,15 @@ The :mod:`tty` module defines the following functions:
3535
Convert the tty attribute list *mode*, which is a list like the one returned
3636
by :func:`termios.tcgetattr`, to that of a tty in cbreak mode.
3737

38+
This clears the ``ECHO`` and ``ICANON`` local mode flags in *mode* as well
39+
as setting the minimum input to 1 byte with no delay.
40+
3841
.. versionadded:: 3.12
3942

43+
.. versionchanged:: 3.12.2
44+
The ``ICRNL`` flag is no longer cleared. This matches Linux and macOS
45+
``stty cbreak`` behavior and what :func:`setcbreak` historically did.
46+
4047

4148
.. function:: setraw(fd, when=termios.TCSAFLUSH)
4249

@@ -56,9 +63,17 @@ The :mod:`tty` module defines the following functions:
5663
:func:`termios.tcsetattr`. The return value of :func:`termios.tcgetattr`
5764
is saved before setting *fd* to cbreak mode; this value is returned.
5865

66+
This clears the ``ECHO`` and ``ICANON`` local mode flags as well as setting
67+
the minimum input to 1 byte with no delay.
68+
5969
.. versionchanged:: 3.12
6070
The return value is now the original tty attributes, instead of None.
6171

72+
.. versionchanged:: 3.12.2
73+
The ``ICRNL`` flag is no longer cleared. This restores the behavior
74+
of Python 3.11 and earlier as well as matching what Linux, macOS, & BSDs
75+
describe in their ``stty(1)`` man pages regarding cbreak mode.
76+
6277

6378
.. seealso::
6479

Doc/reference/datamodel.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,7 @@ Class method objects
15291529
A class method object, like a static method object, is a wrapper around another
15301530
object that alters the way in which that object is retrieved from classes and
15311531
class instances. The behaviour of class method objects upon such retrieval is
1532-
described above, under "User-defined methods". Class method objects are created
1532+
described above, under :ref:`"instance methods" <instance-methods>`. Class method objects are created
15331533
by the built-in :func:`classmethod` constructor.
15341534

15351535

Doc/tools/.nitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Doc/c-api/gcsupport.rst
1010
Doc/c-api/init.rst
1111
Doc/c-api/init_config.rst
1212
Doc/c-api/intro.rst
13-
Doc/c-api/memory.rst
1413
Doc/c-api/memoryview.rst
1514
Doc/c-api/module.rst
1615
Doc/c-api/object.rst

Lib/ftplib.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -900,11 +900,17 @@ def ftpcp(source, sourcename, target, targetname = '', type = 'I'):
900900

901901
def test():
902902
'''Test program.
903-
Usage: ftp [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ...
903+
Usage: ftplib [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ...
904904
905-
-d dir
906-
-l list
907-
-p password
905+
Options:
906+
-d increase debugging level
907+
-r[file] set alternate ~/.netrc file
908+
909+
Commands:
910+
-l[dir] list directory
911+
-d[dir] change the current directory
912+
-p toggle passive and active mode
913+
file retrieve the file and write it to stdout
908914
'''
909915

910916
if len(sys.argv) < 2:
@@ -930,15 +936,14 @@ def test():
930936
netrcobj = netrc.netrc(rcfile)
931937
except OSError:
932938
if rcfile is not None:
933-
sys.stderr.write("Could not open account file"
934-
" -- using anonymous login.")
939+
print("Could not open account file -- using anonymous login.",
940+
file=sys.stderr)
935941
else:
936942
try:
937943
userid, acct, passwd = netrcobj.authenticators(host)
938-
except KeyError:
944+
except (KeyError, TypeError):
939945
# no account for host
940-
sys.stderr.write(
941-
"No account -- using anonymous login.")
946+
print("No account -- using anonymous login.", file=sys.stderr)
942947
ftp.login(userid, passwd, acct)
943948
for file in sys.argv[2:]:
944949
if file[:2] == '-l':
@@ -951,7 +956,9 @@ def test():
951956
ftp.set_pasv(not ftp.passiveserver)
952957
else:
953958
ftp.retrbinary('RETR ' + file, \
954-
sys.stdout.write, 1024)
959+
sys.stdout.buffer.write, 1024)
960+
sys.stdout.buffer.flush()
961+
sys.stdout.flush()
955962
ftp.quit()
956963

957964

Lib/test/libregrtest/refleak.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from test import support
77
from test.support import os_helper
8+
from test.support import refleak_helper
89

910
from .runtests import HuntRefleak
1011
from .utils import clear_caches
@@ -96,7 +97,12 @@ def get_pooled_int(value):
9697
support.gc_collect()
9798

9899
for i in rep_range:
99-
results = test_func()
100+
current = refleak_helper._hunting_for_refleaks
101+
refleak_helper._hunting_for_refleaks = True
102+
try:
103+
results = test_func()
104+
finally:
105+
refleak_helper._hunting_for_refleaks = current
100106

101107
dash_R_cleanup(fs, ps, pic, zdc, abcs)
102108
support.gc_collect()

Lib/test/support/refleak_helper.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""
2+
Utilities for changing test behaviour while hunting
3+
for refleaks
4+
"""
5+
6+
_hunting_for_refleaks = False
7+
def hunting_for_refleaks():
8+
return _hunting_for_refleaks

0 commit comments

Comments
 (0)