Skip to content

Commit e391218

Browse files
committed
Merge branch 'main' into nodeaddict
* main: pythongh-102493: fix normalization in PyErr_SetObject (python#102502) pythongh-87092: compiler's CFG construction moved to after codegen stage (python#102320) pythongh-95913: Consolidate build requirements changes in 3.11 WhatsNew (pythonGH-98781) Remove redundant `_ensure_future` in favor of `ensure_future` in `asyncio` (python#102398) pythongh-95913: Edit Faster CPython section in 3.11 WhatsNew (pythonGH-98429) pythongh-90110: Fix the c-analyzer Tool (python#102483) pythongh-101759: Update macOS installer SQLite 3.40.1 checksum (pythongh-102485) Remove unused import of `warnings` from `unittest.loader` (python#102479) Add gettext support to tools/extensions/c_annotations.py (python#101989)
2 parents 239981c + a33ca2a commit e391218

File tree

22 files changed

+605
-325
lines changed

22 files changed

+605
-325
lines changed

Doc/tools/extensions/c_annotations.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from docutils.parsers.rst import directives
2525
from docutils.parsers.rst import Directive
2626
from docutils.statemachine import StringList
27+
from sphinx.locale import _ as sphinx_gettext
2728
import csv
2829

2930
from sphinx import addnodes
@@ -168,11 +169,11 @@ def add_annotations(self, app, doctree):
168169
elif not entry.result_type.endswith("Object*"):
169170
continue
170171
if entry.result_refs is None:
171-
rc = 'Return value: Always NULL.'
172+
rc = sphinx_gettext('Return value: Always NULL.')
172173
elif entry.result_refs:
173-
rc = 'Return value: New reference.'
174+
rc = sphinx_gettext('Return value: New reference.')
174175
else:
175-
rc = 'Return value: Borrowed reference.'
176+
rc = sphinx_gettext('Return value: Borrowed reference.')
176177
node.insert(0, nodes.emphasis(rc, rc, classes=['refcount']))
177178

178179

Doc/tools/templates/dummy.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
{% trans %}Deprecated since version {deprecated}, will be removed in version {removed}{% endtrans %}
88
{% trans %}Deprecated since version {deprecated}, removed in version {removed}{% endtrans %}
99

10+
In extensions/c_annotations.py:
11+
12+
{% trans %}Return value: Always NULL.{% endtrans %}
13+
{% trans %}Return value: New reference.{% endtrans %}
14+
{% trans %}Return value: Borrowed reference.{% endtrans %}
1015

1116
In docsbuild-scripts, when rewriting indexsidebar.html with actual versions:
1217

Doc/whatsnew/3.11.rst

Lines changed: 116 additions & 92 deletions
Large diffs are not rendered by default.

Include/internal/pycore_global_objects.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ struct _Py_interp_static_objects {
8686
// hamt_empty is here instead of global because of its weakreflist.
8787
_PyGC_Head_UNUSED _hamt_empty_gc_not_used;
8888
PyHamtObject hamt_empty;
89+
PyBaseExceptionObject last_resort_memory_error;
8990
} singletons;
9091
};
9192

Include/internal/pycore_intrinsics.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
typedef PyObject *(*instrinsic_func1)(PyThreadState* tstate, PyObject *value);
2222
typedef PyObject *(*instrinsic_func2)(PyThreadState* tstate, PyObject *value1, PyObject *value2);
2323

24-
extern instrinsic_func1 _PyIntrinsics_UnaryFunctions[];
25-
extern instrinsic_func2 _PyIntrinsics_BinaryFunctions[];
24+
extern const instrinsic_func1 _PyIntrinsics_UnaryFunctions[];
25+
extern const instrinsic_func2 _PyIntrinsics_BinaryFunctions[];
2626

Include/internal/pycore_runtime_init.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ extern "C" {
1414
#include "pycore_obmalloc_init.h"
1515

1616

17+
extern PyTypeObject _PyExc_MemoryError;
18+
19+
1720
/* The static initializers defined here should only be used
1821
in the runtime init code (in pystate.c and pylifecycle.c). */
1922

@@ -120,6 +123,9 @@ extern "C" {
120123
.ob_base = _PyObject_IMMORTAL_INIT(&_PyHamt_Type), \
121124
.h_root = (PyHamtNode*)&_Py_SINGLETON(hamt_bitmap_node_empty), \
122125
}, \
126+
.last_resort_memory_error = { \
127+
_PyObject_IMMORTAL_INIT(&_PyExc_MemoryError), \
128+
}, \
123129
}, \
124130
}, \
125131
._initial_thread = _PyThreadState_INIT, \

Lib/asyncio/tasks.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -630,10 +630,6 @@ def ensure_future(coro_or_future, *, loop=None):
630630
631631
If the argument is a Future, it is returned directly.
632632
"""
633-
return _ensure_future(coro_or_future, loop=loop)
634-
635-
636-
def _ensure_future(coro_or_future, *, loop=None):
637633
if futures.isfuture(coro_or_future):
638634
if loop is not None and loop is not futures._get_loop(coro_or_future):
639635
raise ValueError('The future belongs to a different loop than '
@@ -798,7 +794,7 @@ def _done_callback(fut):
798794
outer = None # bpo-46672
799795
for arg in coros_or_futures:
800796
if arg not in arg_to_fut:
801-
fut = _ensure_future(arg, loop=loop)
797+
fut = ensure_future(arg, loop=loop)
802798
if loop is None:
803799
loop = futures._get_loop(fut)
804800
if fut is not arg:
@@ -855,7 +851,7 @@ def shield(arg):
855851
weak references to tasks. A task that isn't referenced elsewhere
856852
may get garbage collected at any time, even before it's done.
857853
"""
858-
inner = _ensure_future(arg)
854+
inner = ensure_future(arg)
859855
if inner.done():
860856
# Shortcut.
861857
return inner

Lib/test/test_capi/test_exceptions.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,34 @@ def test_err_restore(self):
140140
self.assertEqual(1, v.args[0])
141141
self.assertIs(tb, v.__traceback__.tb_next)
142142

143+
def test_set_object(self):
144+
145+
# new exception as obj is not an exception
146+
with self.assertRaises(ValueError) as e:
147+
_testcapi.exc_set_object(ValueError, 42)
148+
self.assertEqual(e.exception.args, (42,))
149+
150+
# wraps the exception because unrelated types
151+
with self.assertRaises(ValueError) as e:
152+
_testcapi.exc_set_object(ValueError, TypeError(1,2,3))
153+
wrapped = e.exception.args[0]
154+
self.assertIsInstance(wrapped, TypeError)
155+
self.assertEqual(wrapped.args, (1, 2, 3))
156+
157+
# is superclass, so does not wrap
158+
with self.assertRaises(PermissionError) as e:
159+
_testcapi.exc_set_object(OSError, PermissionError(24))
160+
self.assertEqual(e.exception.args, (24,))
161+
162+
class Meta(type):
163+
def __subclasscheck__(cls, sub):
164+
1/0
165+
166+
class Broken(Exception, metaclass=Meta):
167+
pass
168+
169+
with self.assertRaises(ZeroDivisionError) as e:
170+
_testcapi.exc_set_object(Broken, Broken())
143171

144172
if __name__ == "__main__":
145173
unittest.main()

Lib/unittest/loader.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import traceback
77
import types
88
import functools
9-
import warnings
109

1110
from fnmatch import fnmatch, fnmatchcase
1211

Mac/BuildScript/build-installer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def library_recipes():
361361
dict(
362362
name="SQLite 3.40.1",
363363
url="https://sqlite.org/2022/sqlite-autoconf-3400100.tar.gz",
364-
checksum="5498af3a357753d473ee713e363fa5b7",
364+
checksum="42175b1a1d23529cb133bbd2b5900afd",
365365
extra_cflags=('-Os '
366366
'-DSQLITE_ENABLE_FTS5 '
367367
'-DSQLITE_ENABLE_FTS4 '

0 commit comments

Comments
 (0)