Skip to content

Commit 109492c

Browse files
authored
Merge branch 'main' into gh-117657-remove-suppressions
2 parents 2e39075 + 51a56a3 commit 109492c

21 files changed

+234
-108
lines changed

Doc/library/ftplib.rst

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -524,14 +524,9 @@ FTP_TLS objects
524524
:class:`!FTP_TLS` class inherits from :class:`FTP`,
525525
defining these additional methods and attributes:
526526

527-
.. attribute:: FTP_TLS.ssl_version
528-
529-
The SSL version to use (defaults to :data:`ssl.PROTOCOL_SSLv23`).
530-
531527
.. method:: FTP_TLS.auth()
532528

533-
Set up a secure control connection by using TLS or SSL, depending on what
534-
is specified in the :attr:`ssl_version` attribute.
529+
Set up a secure control connection by using TLS.
535530

536531
.. versionchanged:: 3.4
537532
The method now supports hostname check with
@@ -548,7 +543,7 @@ FTP_TLS objects
548543

549544
.. method:: FTP_TLS.prot_p()
550545

551-
Set up secure data connection.
546+
Set up secure data connection by using TLS.
552547

553548
.. method:: FTP_TLS.prot_c()
554549

Doc/library/stdtypes.rst

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,6 +1844,14 @@ expression support in the :mod:`re` module).
18441844
lowercase letter ``'ß'`` is equivalent to ``"ss"``. Since it is already
18451845
lowercase, :meth:`lower` would do nothing to ``'ß'``; :meth:`casefold`
18461846
converts it to ``"ss"``.
1847+
For example:
1848+
1849+
.. doctest::
1850+
1851+
>>> 'straße'.lower()
1852+
'straße'
1853+
>>> 'straße'.casefold()
1854+
'strasse'
18471855

18481856
The casefolding algorithm is `described in section 3.13.3 'Default Case
18491857
Folding' of the Unicode Standard
@@ -2045,7 +2053,18 @@ expression support in the :mod:`re` module).
20452053
.. method:: str.index(sub[, start[, end]])
20462054

20472055
Like :meth:`~str.find`, but raise :exc:`ValueError` when the substring is
2048-
not found.
2056+
not found. For example:
2057+
2058+
.. doctest::
2059+
2060+
>>> 'spam, spam, spam'.index('eggs')
2061+
Traceback (most recent call last):
2062+
File "<python-input-0>", line 1, in <module>
2063+
'spam, spam, spam'.index('eggs')
2064+
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
2065+
ValueError: substring not found
2066+
2067+
See also :meth:`rindex`.
20492068

20502069

20512070
.. method:: str.isalnum()
@@ -2289,7 +2308,12 @@ expression support in the :mod:`re` module).
22892308
.. method:: str.lower()
22902309

22912310
Return a copy of the string with all the cased characters [4]_ converted to
2292-
lowercase.
2311+
lowercase. For example:
2312+
2313+
.. doctest::
2314+
2315+
>>> 'Lower Method Example'.lower()
2316+
'lower method example'
22932317

22942318
The lowercasing algorithm used is `described in section 3.13.2 'Default Case
22952319
Conversion' of the Unicode Standard

Include/exports.h

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
#define Py_EXPORTED_SYMBOL
3636
#define Py_LOCAL_SYMBOL
3737
#endif
38+
/* module init functions outside the core must be exported */
39+
#if defined(Py_BUILD_CORE)
40+
#define _PyINIT_EXPORTED_SYMBOL Py_EXPORTED_SYMBOL
41+
#else
42+
#define _PyINIT_EXPORTED_SYMBOL __declspec(dllexport)
43+
#endif
3844
#else
3945
/*
4046
* If we only ever used gcc >= 5, we could use __has_attribute(visibility)
@@ -52,19 +58,16 @@
5258
#define Py_EXPORTED_SYMBOL
5359
#define Py_LOCAL_SYMBOL
5460
#endif
61+
#define _PyINIT_EXPORTED_SYMBOL Py_EXPORTED_SYMBOL
5562
#endif
5663

5764
/* only get special linkage if built as shared or platform is Cygwin */
5865
#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__)
5966
# if defined(HAVE_DECLSPEC_DLL)
6067
# if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
61-
# define PyAPI_FUNC(RTYPE) Py_EXPORTED_SYMBOL RTYPE
62-
# define PyAPI_DATA(RTYPE) extern Py_EXPORTED_SYMBOL RTYPE
6368
/* module init functions inside the core need no external linkage */
6469
/* except for Cygwin to handle embedding */
65-
# if defined(__CYGWIN__)
66-
# define _PyINIT_FUNC_DECLSPEC Py_EXPORTED_SYMBOL
67-
# else /* __CYGWIN__ */
70+
# if !defined(__CYGWIN__)
6871
# define _PyINIT_FUNC_DECLSPEC
6972
# endif /* __CYGWIN__ */
7073
# else /* Py_BUILD_CORE */
@@ -77,12 +80,6 @@
7780
# define PyAPI_FUNC(RTYPE) Py_IMPORTED_SYMBOL RTYPE
7881
# endif /* !__CYGWIN__ */
7982
# define PyAPI_DATA(RTYPE) extern Py_IMPORTED_SYMBOL RTYPE
80-
/* module init functions outside the core must be exported */
81-
# if defined(__cplusplus)
82-
# define _PyINIT_FUNC_DECLSPEC extern "C" Py_EXPORTED_SYMBOL
83-
# else /* __cplusplus */
84-
# define _PyINIT_FUNC_DECLSPEC Py_EXPORTED_SYMBOL
85-
# endif /* __cplusplus */
8683
# endif /* Py_BUILD_CORE */
8784
# endif /* HAVE_DECLSPEC_DLL */
8885
#endif /* Py_ENABLE_SHARED */
@@ -96,13 +93,17 @@
9693
#endif
9794
#ifndef _PyINIT_FUNC_DECLSPEC
9895
# if defined(__cplusplus)
99-
# define _PyINIT_FUNC_DECLSPEC extern "C" Py_EXPORTED_SYMBOL
96+
# define _PyINIT_FUNC_DECLSPEC extern "C" _PyINIT_EXPORTED_SYMBOL
10097
# else /* __cplusplus */
101-
# define _PyINIT_FUNC_DECLSPEC Py_EXPORTED_SYMBOL
98+
# define _PyINIT_FUNC_DECLSPEC _PyINIT_EXPORTED_SYMBOL
10299
# endif /* __cplusplus */
103100
#endif
104101

105-
#define PyMODINIT_FUNC _PyINIT_FUNC_DECLSPEC PyObject*
106-
#define PyMODEXPORT_FUNC _PyINIT_FUNC_DECLSPEC PyModuleDef_Slot*
102+
#ifndef PyMODINIT_FUNC
103+
#define PyMODINIT_FUNC _PyINIT_FUNC_DECLSPEC PyObject*
104+
#endif
105+
#ifndef PyMODEXPORT_FUNC
106+
#define PyMODEXPORT_FUNC _PyINIT_FUNC_DECLSPEC PyModuleDef_Slot*
107+
#endif
107108

108109
#endif /* Py_EXPORTS_H */

Include/internal/pycore_opcode_metadata.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_ids.h

Lines changed: 18 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_metadata.h

Lines changed: 11 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/pydoc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2004,10 +2004,11 @@ def interact(self):
20042004
while True:
20052005
try:
20062006
request = self.getline('help> ')
2007-
if not request: break
20082007
except (KeyboardInterrupt, EOFError):
20092008
break
20102009
request = request.strip()
2010+
if not request:
2011+
continue # back to the prompt
20112012

20122013
# Make sure significant trailing quoting marks of literals don't
20132014
# get deleted while cleaning input

Lib/test/test_capi/test_opt.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2937,6 +2937,23 @@ def testfunc(n):
29372937
self.assertLessEqual(count_ops(ex, "_POP_TOP"), 1)
29382938
self.assertIn("_POP_TOP_NOP", uops)
29392939

2940+
def test_to_bool_str(self):
2941+
def f(n):
2942+
for i in range(n):
2943+
false = i == TIER2_THRESHOLD
2944+
empty = "X"[:false]
2945+
if empty:
2946+
return 1
2947+
return 0
2948+
2949+
res, ex = self._run_with_optimizer(f, TIER2_THRESHOLD)
2950+
self.assertEqual(res, 0)
2951+
self.assertIsNotNone(ex)
2952+
uops = get_opnames(ex)
2953+
self.assertIn("_TO_BOOL_STR", uops)
2954+
self.assertLessEqual(count_ops(ex, "_POP_TOP"), 3)
2955+
self.assertIn("_POP_TOP_NOP", uops)
2956+
29402957
def test_to_bool_always_true(self):
29412958
def testfunc(n):
29422959
class A:

Lib/test/test_code.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
ctypes = None
211211
from test.support import (cpython_only,
212212
check_impl_detail, requires_debug_ranges,
213-
gc_collect, Py_GIL_DISABLED)
213+
gc_collect, Py_GIL_DISABLED, late_deletion)
214214
from test.support.script_helper import assert_python_ok
215215
from test.support import threading_helper, import_helper
216216
from test.support.bytecode_helper import instructions_with_positions
@@ -1555,6 +1555,11 @@ def myfree(ptr):
15551555

15561556
FREE_FUNC = freefunc(myfree)
15571557
FREE_INDEX = RequestCodeExtraIndex(FREE_FUNC)
1558+
# Make sure myfree sticks around at least as long as the interpreter,
1559+
# since we (currently) can't unregister the function and leaving a
1560+
# dangling pointer will cause a crash on deallocation of code objects if
1561+
# something else uses co_extras, like test_capi.test_misc.
1562+
late_deletion(myfree)
15581563

15591564
class CoExtra(unittest.TestCase):
15601565
def get_func(self):

Lib/test/test_pydoc/test_pydoc.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,10 +2147,47 @@ def test_url_requests(self):
21472147

21482148

21492149
class TestHelper(unittest.TestCase):
2150+
def mock_interactive_session(self, inputs):
2151+
"""
2152+
Given a list of inputs, run an interactive help session. Returns a string
2153+
of what would be shown on screen.
2154+
"""
2155+
input_iter = iter(inputs)
2156+
2157+
def mock_getline(prompt):
2158+
output.write(prompt)
2159+
next_input = next(input_iter)
2160+
output.write(next_input + os.linesep)
2161+
return next_input
2162+
2163+
with captured_stdout() as output:
2164+
helper = pydoc.Helper(output=output)
2165+
with unittest.mock.patch.object(helper, "getline", mock_getline):
2166+
helper.interact()
2167+
2168+
# handle different line endings across platforms consistently
2169+
return output.getvalue().strip().splitlines(keepends=False)
2170+
21502171
def test_keywords(self):
21512172
self.assertEqual(sorted(pydoc.Helper.keywords),
21522173
sorted(keyword.kwlist))
21532174

2175+
def test_interact_empty_line_continues(self):
2176+
# gh-138568: test pressing Enter without input should continue in help session
2177+
self.assertEqual(
2178+
self.mock_interactive_session(["", " ", "quit"]),
2179+
["help> ", "help> ", "help> quit"],
2180+
)
2181+
2182+
def test_interact_quit_commands_exit(self):
2183+
quit_commands = ["quit", "q", "exit"]
2184+
for quit_cmd in quit_commands:
2185+
with self.subTest(quit_command=quit_cmd):
2186+
self.assertEqual(
2187+
self.mock_interactive_session([quit_cmd]),
2188+
[f"help> {quit_cmd}"],
2189+
)
2190+
21542191

21552192
class PydocWithMetaClasses(unittest.TestCase):
21562193
def tearDown(self):

0 commit comments

Comments
 (0)