Skip to content

Commit 4ae1dab

Browse files
authored
Merge branch 'main' into gh-145668
2 parents caf7182 + 4485545 commit 4ae1dab

24 files changed

Lines changed: 208 additions & 62 deletions

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ Tools/unicode/data/
137137
/config.status
138138
/config.status.lineno
139139
/.ccache
140-
/cross-build/
140+
/cross-build*/
141141
/jit_stencils*.h
142142
/platform
143143
/profile-clean-stamp

Doc/c-api/type.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ Type Objects
274274
Return the module object associated with the given type when the type was
275275
created using :c:func:`PyType_FromModuleAndSpec`.
276276
277+
The returned reference is :term:`borrowed <borrowed reference>` from *type*,
278+
and will be valid as long as you hold a reference to *type*.
279+
Do not release it with :c:func:`Py_DECREF` or similar.
280+
277281
If no module is associated with the given type, sets :py:class:`TypeError`
278282
and returns ``NULL``.
279283

Doc/data/refcounts.dat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,6 +2427,9 @@ PyType_GetFlags:PyTypeObject*:type:0:
24272427
PyType_GetName:PyObject*::+1:
24282428
PyType_GetName:PyTypeObject*:type:0:
24292429

2430+
PyType_GetModule:PyObject*::0:
2431+
PyType_GetModule:PyTypeObject*:type:0:
2432+
24302433
PyType_GetModuleByToken:PyObject*::+1:
24312434
PyType_GetModuleByToken:PyTypeObject*:type:0:
24322435
PyType_GetModuleByToken:PyModuleDef*:def::

Doc/tutorial/introduction.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,11 @@ If you don't want characters prefaced by ``\`` to be interpreted as
184184
special characters, you can use *raw strings* by adding an ``r`` before
185185
the first quote::
186186

187-
>>> print('C:\some\name') # here \n means newline!
188-
C:\some
187+
>>> print('C:\this\name') # here \t means tab, \n means newline
188+
C: his
189189
ame
190-
>>> print(r'C:\some\name') # note the r before the quote
191-
C:\some\name
190+
>>> print(r'C:\this\name') # note the r before the quote
191+
C:\this\name
192192

193193
There is one subtle aspect to raw strings: a raw string may not end in
194194
an odd number of ``\`` characters; see

Lib/test/test_tools/test_compute_changes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ def test_ci_fuzz_stdlib(self):
5454
f = p / "file"
5555
elif p.is_file():
5656
f = p
57+
else:
58+
self.fail(f"LIBRARY_FUZZER_PATHS contains an invalid entry: {p!r}")
5759
result = process_changed_files({f})
5860
self.assertTrue(result.run_ci_fuzz_stdlib)
5961
self.assertTrue(is_fuzzable_library_file(f))

Makefile.pre.in

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,9 @@ FROZEN_FILES_IN = \
17291729
Lib/zipimport.py \
17301730
Lib/abc.py \
17311731
Lib/codecs.py \
1732+
Lib/encodings/__init__.py \
1733+
Lib/encodings/aliases.py \
1734+
Lib/encodings/utf_8.py \
17321735
Lib/io.py \
17331736
Lib/_collections_abc.py \
17341737
Lib/_sitebuiltins.py \
@@ -1738,6 +1741,7 @@ FROZEN_FILES_IN = \
17381741
Lib/os.py \
17391742
Lib/site.py \
17401743
Lib/stat.py \
1744+
Lib/linecache.py \
17411745
Lib/importlib/util.py \
17421746
Lib/importlib/machinery.py \
17431747
Lib/runpy.py \
@@ -1754,6 +1758,9 @@ FROZEN_FILES_OUT = \
17541758
Python/frozen_modules/zipimport.h \
17551759
Python/frozen_modules/abc.h \
17561760
Python/frozen_modules/codecs.h \
1761+
Python/frozen_modules/encodings.h \
1762+
Python/frozen_modules/encodings.aliases.h \
1763+
Python/frozen_modules/encodings.utf_8.h \
17571764
Python/frozen_modules/io.h \
17581765
Python/frozen_modules/_collections_abc.h \
17591766
Python/frozen_modules/_sitebuiltins.h \
@@ -1763,6 +1770,7 @@ FROZEN_FILES_OUT = \
17631770
Python/frozen_modules/os.h \
17641771
Python/frozen_modules/site.h \
17651772
Python/frozen_modules/stat.h \
1773+
Python/frozen_modules/linecache.h \
17661774
Python/frozen_modules/importlib.util.h \
17671775
Python/frozen_modules/importlib.machinery.h \
17681776
Python/frozen_modules/runpy.h \
@@ -1802,6 +1810,15 @@ Python/frozen_modules/abc.h: Lib/abc.py $(FREEZE_MODULE_DEPS)
18021810
Python/frozen_modules/codecs.h: Lib/codecs.py $(FREEZE_MODULE_DEPS)
18031811
$(FREEZE_MODULE) codecs $(srcdir)/Lib/codecs.py Python/frozen_modules/codecs.h
18041812

1813+
Python/frozen_modules/encodings.h: Lib/encodings/__init__.py $(FREEZE_MODULE_DEPS)
1814+
$(FREEZE_MODULE) encodings $(srcdir)/Lib/encodings/__init__.py Python/frozen_modules/encodings.h
1815+
1816+
Python/frozen_modules/encodings.aliases.h: Lib/encodings/aliases.py $(FREEZE_MODULE_DEPS)
1817+
$(FREEZE_MODULE) encodings.aliases $(srcdir)/Lib/encodings/aliases.py Python/frozen_modules/encodings.aliases.h
1818+
1819+
Python/frozen_modules/encodings.utf_8.h: Lib/encodings/utf_8.py $(FREEZE_MODULE_DEPS)
1820+
$(FREEZE_MODULE) encodings.utf_8 $(srcdir)/Lib/encodings/utf_8.py Python/frozen_modules/encodings.utf_8.h
1821+
18051822
Python/frozen_modules/io.h: Lib/io.py $(FREEZE_MODULE_DEPS)
18061823
$(FREEZE_MODULE) io $(srcdir)/Lib/io.py Python/frozen_modules/io.h
18071824

@@ -1829,6 +1846,9 @@ Python/frozen_modules/site.h: Lib/site.py $(FREEZE_MODULE_DEPS)
18291846
Python/frozen_modules/stat.h: Lib/stat.py $(FREEZE_MODULE_DEPS)
18301847
$(FREEZE_MODULE) stat $(srcdir)/Lib/stat.py Python/frozen_modules/stat.h
18311848

1849+
Python/frozen_modules/linecache.h: Lib/linecache.py $(FREEZE_MODULE_DEPS)
1850+
$(FREEZE_MODULE) linecache $(srcdir)/Lib/linecache.py Python/frozen_modules/linecache.h
1851+
18321852
Python/frozen_modules/importlib.util.h: Lib/importlib/util.py $(FREEZE_MODULE_DEPS)
18331853
$(FREEZE_MODULE) importlib.util $(srcdir)/Lib/importlib/util.py Python/frozen_modules/importlib.util.h
18341854

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The :mod:`encodings` is now partially frozen, including
2+
the ``aliases`` and ``utf_8`` submodules.
3+
4+
The :mod:`linecache` is now frozen.

Modules/_cursesmodule.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,11 +1112,13 @@ _curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1,
11121112
attr_old = getattrs(self->win);
11131113
if (curses_wattrset(self, attr, "addstr") < 0) {
11141114
curses_release_wstr(strtype, wstr);
1115+
Py_XDECREF(bytesobj);
11151116
return NULL;
11161117
}
11171118
}
11181119
#ifdef HAVE_NCURSESW
11191120
if (strtype == 2) {
1121+
assert(bytesobj == NULL);
11201122
if (use_xy) {
11211123
rtn = mvwaddwstr(self->win,y,x,wstr);
11221124
funcname = "mvwaddwstr";
@@ -1130,6 +1132,7 @@ _curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1,
11301132
else
11311133
#endif
11321134
{
1135+
assert(wstr == NULL);
11331136
const char *str = PyBytes_AS_STRING(bytesobj);
11341137
if (use_xy) {
11351138
rtn = mvwaddstr(self->win,y,x,str);
@@ -1210,6 +1213,7 @@ _curses_window_addnstr_impl(PyCursesWindowObject *self, int group_left_1,
12101213
attr_old = getattrs(self->win);
12111214
if (curses_wattrset(self, attr, "addnstr") < 0) {
12121215
curses_release_wstr(strtype, wstr);
1216+
Py_XDECREF(bytesobj);
12131217
return NULL;
12141218
}
12151219
}
@@ -2212,6 +2216,7 @@ _curses_window_insstr_impl(PyCursesWindowObject *self, int group_left_1,
22122216
attr_old = getattrs(self->win);
22132217
if (curses_wattrset(self, attr, "insstr") < 0) {
22142218
curses_release_wstr(strtype, wstr);
2219+
Py_XDECREF(bytesobj);
22152220
return NULL;
22162221
}
22172222
}

Modules/_lsprof.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ PyObject* get_cfunc_from_callable(PyObject* callable, PyObject* self_arg, PyObje
702702
if (PyCFunction_Check(meth)) {
703703
return (PyObject*)((PyCFunctionObject *)meth);
704704
}
705+
Py_DECREF(meth);
705706
}
706707
return NULL;
707708
}
@@ -961,6 +962,8 @@ profiler_traverse(PyObject *op, visitproc visit, void *arg)
961962
ProfilerObject *self = ProfilerObject_CAST(op);
962963
Py_VISIT(Py_TYPE(op));
963964
Py_VISIT(self->externalTimer);
965+
Py_VISIT(self->missing);
966+
964967
return 0;
965968
}
966969

@@ -979,6 +982,7 @@ profiler_dealloc(PyObject *op)
979982

980983
flush_unmatched(self);
981984
clearEntries(self);
985+
Py_XDECREF(self->missing);
982986
Py_XDECREF(self->externalTimer);
983987
PyTypeObject *tp = Py_TYPE(self);
984988
tp->tp_free(self);
@@ -1017,7 +1021,7 @@ profiler_init_impl(ProfilerObject *self, PyObject *timer, double timeunit,
10171021
if (!monitoring) {
10181022
return -1;
10191023
}
1020-
self->missing = PyObject_GetAttrString(monitoring, "MISSING");
1024+
Py_XSETREF(self->missing, PyObject_GetAttrString(monitoring, "MISSING"));
10211025
if (!self->missing) {
10221026
Py_DECREF(monitoring);
10231027
return -1;

Modules/binascii.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ binascii_a2b_ascii85_impl(PyObject *module, Py_buffer *data, int foldspaces,
924924
}
925925
unsigned char *bin_data = PyBytesWriter_GetData(writer);
926926
if (bin_data == NULL) {
927-
return NULL;
927+
goto error;
928928
}
929929

930930
uint32_t leftchar = 0;

0 commit comments

Comments
 (0)