Skip to content

Commit 41eb685

Browse files
authored
Merge branch 'main' into email-utils-doc-param-names
2 parents ae5ee1e + b90572a commit 41eb685

23 files changed

Lines changed: 238 additions & 190 deletions

File tree

‎.github/ISSUE_TEMPLATE/documentation.yml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@ body:
77
value: |
88
> [!NOTE]
99
> Trivial changes (for example typos) don’t require an issue before opening a PR.
10+
- type: input
11+
id: url
12+
attributes:
13+
label: "Documentation URL"
14+
description: "A link to the relevant documentation page, if applicable."
15+
placeholder: "https://docs.python.org/3/..."
1016
- type: textarea
1117
id: description
1218
attributes:
1319
label: "Documentation"
14-
description: "A clear and concise description of the issue. Include a link to the page."
20+
description: "A clear and concise description of the issue."
1521
validations:
1622
required: true

‎Doc/data/refcounts.dat‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,6 +2417,9 @@ PyType_GenericNew:PyObject*:type:0:
24172417
PyType_GenericNew:PyObject*:args:0:
24182418
PyType_GenericNew:PyObject*:kwds:0:
24192419

2420+
PyType_GetDict:PyObject*::+1:
2421+
PyType_GetDict:PyTypeObject*:type:0:
2422+
24202423
PyType_GetFlags:unsigned long:::
24212424
PyType_GetFlags:PyTypeObject*:type:0:
24222425

‎Doc/library/this.rst‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
:orphan:
2+
3+
:mod:`!this` --- The Zen of Python
4+
==================================
5+
6+
.. module:: this
7+
:synopsis: The Zen of Python
8+
9+
..
10+
This easter egg module is deliberately missing from the table of contents.
11+
12+
:pep:`20` -- The Zen of Python, by Tim Peters (RIP).
13+
14+
| Beautiful is better than ugly.
15+
| Explicit is better than implicit.
16+
| Simple is better than complex.
17+
| Complex is better than complicated.
18+
| Flat is better than nested.
19+
| Sparse is better than dense.
20+
| Readability counts.
21+
| Special cases aren't special enough to break the rules.
22+
| Although practicality beats purity.
23+
| Errors should never pass silently.
24+
| Unless explicitly silenced.
25+
| In the face of ambiguity, refuse the temptation to guess.
26+
| There should be one-\- and preferably only one -\-obvious way to do it.
27+
| Although that way may not be obvious at first unless you're Dutch.
28+
| Now is better than never.
29+
| Although never is often better than *right* now.
30+
| If the implementation is hard to explain, it's a bad idea.
31+
| If the implementation is easy to explain, it may be a good idea.
32+
| Namespaces are one honking great idea -\- let's do more of those!
33+
34+
`In Memoriam: Tim Peters 1952-2026 <https://discuss.python.org/t/in-memoriam-tim-peters-1952-2026/110028>`__.
35+
36+
37+
Usage
38+
-----
39+
40+
.. code-block:: shell-session
41+
42+
$ python3 -m this

‎Doc/using/ios.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ To add Python to an iOS Xcode project:
226226
.. code-block:: bash
227227
228228
set -e
229-
source $PROJECT_DIR/Python.xcframework/build/build_utils.sh
229+
source "$PROJECT_DIR/Python.xcframework/build/utils.sh"
230230
install_python Python.xcframework app
231231
232232
If you have placed your XCframework somewhere other than the root of your

‎Lib/json/decoder.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def py_scanstring(s, end, strict=True,
112112
char = _b[esc]
113113
except KeyError:
114114
msg = "Invalid \\escape: {0!r}".format(esc)
115-
raise JSONDecodeError(msg, s, end)
115+
raise JSONDecodeError(msg, s, end - 1)
116116
end += 1
117117
else:
118118
uni = _decode_uXXXX(s, end)

‎Lib/test/test_capi/test_unicode.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1883,7 +1883,9 @@ def test_check_interned(self):
18831883

18841884
def fresh_string(text):
18851885
# Create a new string object by decoding a bytes string.
1886-
return text.encode().decode()
1886+
# Add a suffix to make sure that it's not interned, even if
1887+
# the string is interned in the PYC file (Free Threading).
1888+
return (text + ' suffix').encode().decode()
18871889

18881890
s = fresh_string('hello')
18891891
self.assertEqual(check_interned(s), SSTATE_NOT_INTERNED)

‎Lib/test/test_external_inspection.py‎

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
try:
5656
from _remote_debugging import PROCESS_VM_READV_SUPPORTED
5757
from _remote_debugging import RemoteUnwinder
58-
from _remote_debugging import FrameInfo, CoroInfo, TaskInfo
58+
from _remote_debugging import FrameInfo, CoroInfo, TaskInfo, AwaitedInfo
5959
except ImportError:
6060
raise unittest.SkipTest(
6161
"Test only runs when _remote_debugging is available"
@@ -487,6 +487,23 @@ def _extract_coroutine_funcnames(self, trace):
487487
for task in info.awaited_by
488488
}
489489

490+
@skip_if_not_supported
491+
def test_async_awaited_info(self):
492+
async def main():
493+
task = asyncio.current_task()
494+
unwinder = RemoteUnwinder(os.getpid())
495+
for method in (unwinder.get_async_stack_trace,
496+
unwinder.get_all_awaited_by):
497+
with self.subTest(method=method.__name__):
498+
info, = (info for info in method()
499+
if info.thread_id == threading.get_native_id())
500+
self.assertIsInstance(info, AwaitedInfo)
501+
task_info, = info.awaited_by
502+
self.assertEqual(task_info.task_id, id(task))
503+
self.assertEqual(task_info.task_name, task.get_name())
504+
505+
asyncio.run(main())
506+
490507
@skip_if_not_supported
491508
def test_long_task_name_is_truncated(self):
492509
# gh-157788
@@ -520,6 +537,22 @@ async def rec(n):
520537

521538
self.assertEqual(asyncio.run(rec(3)), ["rec"] * 4)
522539

540+
@skip_if_not_supported
541+
def test_future_waiter_has_empty_stack(self):
542+
async def main():
543+
task = asyncio.current_task()
544+
future = asyncio.get_running_loop().create_future()
545+
asyncio.future_add_to_awaited_by(task, future)
546+
try:
547+
trace = RemoteUnwinder(os.getpid()).get_all_awaited_by()
548+
task_info = self._get_task_id_map(trace)[id(task)]
549+
self.assertEqual(task_info.awaited_by, [([], id(future))])
550+
self.assertTrue(task_info.coroutine_stack[0].call_stack)
551+
finally:
552+
asyncio.future_discard_from_awaited_by(task, future)
553+
554+
asyncio.run(main())
555+
523556
@skip_if_not_supported
524557
def test_async_generator_stack_is_not_truncated(self):
525558
# gh-159620
@@ -663,6 +696,17 @@ async def main():
663696
stacks = self._extract_coroutine_funcnames(asyncio.run(main()))
664697
self.assertEqual(stacks["consumer"], ["consumer"])
665698

699+
@skip_if_not_supported
700+
def test_self_trace_with_empty_linetable(self):
701+
def sample():
702+
return RemoteUnwinder(os.getpid()).get_stack_trace()
703+
704+
sample.__code__ = sample.__code__.replace(co_linetable=b"")
705+
frame = self._find_frame_in_trace(
706+
sample(), lambda f: f.funcname == sample.__qualname__
707+
)
708+
self.assertEqual(frame.location, (-1, -1, -1, -1))
709+
666710
@skip_if_not_supported
667711
@unittest.skipIf(
668712
sys.platform == "linux" and not PROCESS_VM_READV_SUPPORTED,

‎Lib/test/test_interpreters/test_api.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,21 @@ def test_failure(self):
947947
with self.assertRaises(ExecutionFailed):
948948
interp.exec('raise Exception')
949949

950+
def test_failure_with_broken_exception_str(self):
951+
interp = interpreters.create()
952+
for raised, expected in [
953+
('ValueError', interpreters.InterpreterError),
954+
('MemoryError', MemoryError),
955+
]:
956+
with self.subTest(raised=raised):
957+
with self.assertRaises(expected):
958+
interp.exec(dedent(f"""
959+
class BrokenError(Exception):
960+
def __str__(self):
961+
raise {raised}
962+
raise BrokenError
963+
"""))
964+
950965
@force_not_colorized
951966
def test_display_preserved_exception(self):
952967
tempdir = self.temp_dir()

‎Lib/test/test_json/test_fail.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,24 @@ def test_unexpected_data(self):
201201
'%s: line 1 column %d (char %d)' %
202202
(msg, idx + 1, idx))
203203

204+
def test_invalid_escape_position(self):
205+
# The position points to the backslash of the invalid escape.
206+
test_cases = [
207+
('"\\a"', 1),
208+
('"ab\\x"', 3),
209+
('["\\\'"]', 2),
210+
('{"k": "v\\ "}', 8),
211+
]
212+
for data, idx in test_cases:
213+
with self.subTest(data=data):
214+
with self.assertRaises(self.JSONDecodeError) as cm:
215+
self.loads(data)
216+
err = cm.exception
217+
self.assertStartsWith(err.msg, 'Invalid \\escape')
218+
self.assertEqual(err.pos, idx)
219+
self.assertEqual(err.lineno, 1)
220+
self.assertEqual(err.colno, idx + 1)
221+
204222
def test_extra_data(self):
205223
test_cases = [
206224
('[]]', 'Extra data', 2),
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix a crash in :meth:`concurrent.interpreters.Interpreter.exec` when the
2+
uncaught exception's ``__str__`` raises.

0 commit comments

Comments
 (0)