Skip to content

Commit 13a6835

Browse files
authored
Merge branch 'main' into refleak_datetime
2 parents 5673c7e + 745947c commit 13a6835

File tree

13 files changed

+54
-27
lines changed

13 files changed

+54
-27
lines changed

.github/CODEOWNERS

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -260,33 +260,33 @@ Include/pyhash.h @gpshead @picnixz
260260
Python/pyhash.c @gpshead @picnixz
261261

262262
# The import system (including importlib)
263-
**/*import* @brettcannon @ericsnowcurrently @ncoghlan @warsaw
264-
Python/import.c @brettcannon @ericsnowcurrently @ncoghlan @warsaw @kumaraditya303
263+
**/*import* @brettcannon @ericsnowcurrently @ncoghlan @warsaw @FFY00
264+
Python/import.c @brettcannon @ericsnowcurrently @ncoghlan @warsaw @FFY00 @kumaraditya303
265265
**/*freeze* @ericsnowcurrently
266266
**/*frozen* @ericsnowcurrently
267267
**/*modsupport* @ericsnowcurrently
268-
**/*modulefinder* @ericsnowcurrently
268+
**/*modulefinder* @ericsnowcurrently @FFY00
269269
**/*moduleobject* @ericsnowcurrently
270270
**/*multiphase* @ericsnowcurrently
271-
**/*pkgutil* @ericsnowcurrently
271+
**/*pkgutil* @ericsnowcurrently @FFY00
272272
**/*pythonrun* @ericsnowcurrently
273-
**/*runpy* @ericsnowcurrently
273+
**/*runpy* @ericsnowcurrently @FFY00
274274
**/*singlephase* @ericsnowcurrently
275275
Doc/c-api/module.rst @ericsnowcurrently
276276
Lib/test/test_module/ @ericsnowcurrently
277-
Python/dynload_*.c @ericsnowcurrently
277+
Python/dynload_*.c @ericsnowcurrently @FFY00
278278

279279
# Initialisation
280-
**/*initconfig* @ericsnowcurrently
281-
**/*pathconfig* @ericsnowcurrently
282-
**/*preconfig* @ericsnowcurrently
280+
**/*initconfig* @ericsnowcurrently @FFY00
281+
**/*pathconfig* @ericsnowcurrently @FFY00
282+
**/*preconfig* @ericsnowcurrently @FFY00
283283
Doc/library/sys_path_init.rst @FFY00
284284
Doc/c-api/init_config.rst @FFY00
285285

286286
# Interpreter main program
287-
Modules/main.c @ericsnowcurrently
288-
Programs/_bootstrap_python.c @ericsnowcurrently
289-
Programs/python.c @ericsnowcurrently
287+
Modules/main.c @ericsnowcurrently @FFY00
288+
Programs/_bootstrap_python.c @ericsnowcurrently @FFY00
289+
Programs/python.c @ericsnowcurrently @FFY00
290290

291291
# JIT
292292
.github/workflows/jit.yml @savannahostrowski
@@ -316,8 +316,8 @@ Tools/peg_generator/ @pablogsal @lysnikolaou
316316

317317
# Runtime state/lifecycle
318318
**/*gil* @ericsnowcurrently
319-
**/*pylifecycle* @ericsnowcurrently @ZeroIntensity
320-
**/*pystate* @ericsnowcurrently @ZeroIntensity
319+
**/*pylifecycle* @ericsnowcurrently @ZeroIntensity @FFY00
320+
**/*pystate* @ericsnowcurrently @ZeroIntensity @FFY00
321321
Include/internal/pycore_*_init.h @ericsnowcurrently
322322
Include/internal/pycore_*_state.h @ericsnowcurrently
323323
Include/internal/pycore_atexit.h @ericsnowcurrently
@@ -505,13 +505,13 @@ Lib/idlelib/ @terryjreedy
505505
Lib/turtledemo/ @terryjreedy
506506

507507
# importlib.metadata
508-
Doc/library/importlib.metadata.rst @jaraco @warsaw
509-
Lib/importlib/metadata/ @jaraco @warsaw
510-
Lib/test/test_importlib/metadata/ @jaraco @warsaw
508+
Doc/library/importlib.metadata.rst @jaraco @warsaw @FFY00
509+
Lib/importlib/metadata/ @jaraco @warsaw @FFY00
510+
Lib/test/test_importlib/metadata/ @jaraco @warsaw @FFY00
511511

512512
# importlib.resources
513-
Doc/library/importlib.resources.abc.rst @jaraco @warsaw
514-
Doc/library/importlib.resources.rst @jaraco @warsaw
513+
Doc/library/importlib.resources.abc.rst @jaraco @warsaw @FFY00
514+
Doc/library/importlib.resources.rst @jaraco @warsaw @FFY00
515515
Lib/importlib/resources/ @jaraco @warsaw @FFY00
516516
Lib/test/test_importlib/resources/ @jaraco @warsaw @FFY00
517517

Doc/library/stdtypes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4536,7 +4536,7 @@ copying.
45364536
types such as :class:`bytes` and :class:`bytearray`, an element is a single
45374537
byte, but other types such as :class:`array.array` may have bigger elements.
45384538

4539-
``len(view)`` is equal to the length of :class:`~memoryview.tolist`, which
4539+
``len(view)`` is equal to the length of :meth:`~memoryview.tolist`, which
45404540
is the nested list representation of the view. If ``view.ndim = 1``,
45414541
this is equal to the number of elements in the view.
45424542

Lib/sqlite3/__main__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,11 @@ def main(*args):
133133
theme = get_theme()
134134
s = theme.syntax
135135

136-
sys.ps1 = f"{s.prompt}sqlite> {s.reset}"
137-
sys.ps2 = f"{s.prompt} ... {s.reset}"
136+
# Use RL_PROMPT_START_IGNORE (\001) and RL_PROMPT_END_IGNORE (\002) to
137+
# bracket non-printing characters. This tells readline to ignore them
138+
# when calculating screen space for redisplay during history scrolling.
139+
sys.ps1 = f"\001{s.prompt}\002sqlite> \001{s.reset}\002"
140+
sys.ps2 = f"\001{s.prompt}\002 ... \001{s.reset}\002"
138141

139142
con = sqlite3.connect(args.filename, isolation_level=None)
140143
try:

Lib/test/test_lazy_import/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import os
1313

1414
from test import support
15+
from test.support.script_helper import assert_python_ok
1516

1617
try:
1718
import _testcapi
@@ -219,6 +220,16 @@ def test_lazy_import_type_cant_construct(self):
219220
"""LazyImportType should not be directly constructible."""
220221
self.assertRaises(TypeError, types.LazyImportType, {}, "module")
221222

223+
@support.requires_subprocess()
224+
def test_lazy_import_type_attributes_accessible(self):
225+
"""Check that static PyLazyImport_Type is initialized at startup."""
226+
code = textwrap.dedent("""
227+
lazy import json
228+
print(globals()["json"].resolve)
229+
""")
230+
proc = assert_python_ok("-c", code)
231+
self.assertIn(b"<built-in method resolve of lazy_import object at", proc.out)
232+
222233

223234
class SyntaxRestrictionTests(unittest.TestCase):
224235
"""Tests for syntax restrictions on lazy imports."""

Lib/test/test_sqlite3/test_cli.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ def test_cli_on_disk_db(self):
8080
@force_not_colorized_test_class
8181
class InteractiveSession(unittest.TestCase):
8282
MEMORY_DB_MSG = "Connected to a transient in-memory database"
83-
PS1 = "sqlite> "
84-
PS2 = "... "
83+
PS1 = "\001\002sqlite> \001\002"
84+
PS2 = "\001\002 ... \001\002"
8585

8686
def run_cli(self, *args, commands=()):
8787
with (
@@ -202,8 +202,8 @@ def test_interact_on_disk_file(self):
202202
def test_color(self):
203203
with unittest.mock.patch("_colorize.can_colorize", return_value=True):
204204
out, err = self.run_cli(commands="TEXT\n")
205-
self.assertIn("\x1b[1;35msqlite> \x1b[0m", out)
206-
self.assertIn("\x1b[1;35m ... \x1b[0m\x1b", out)
205+
self.assertIn("\x01\x1b[1;35m\x02sqlite> \x01\x1b[0m\x02", out)
206+
self.assertIn("\x01\x1b[1;35m\x02 ... \x01\x1b[0m\x02\x01\x1b", out)
207207
out, err = self.run_cli(commands=("sel;",))
208208
self.assertIn('\x1b[1;35mOperationalError (SQLITE_ERROR)\x1b[0m: '
209209
'\x1b[35mnear "sel": syntax error\x1b[0m', err)
@@ -212,6 +212,10 @@ def test_color(self):
212212
@requires_subprocess()
213213
@force_not_colorized_test_class
214214
class Completion(unittest.TestCase):
215+
# run_pty() creates a real terminal environment, where sqlite3 CLI
216+
# SqliteInteractiveConsole invokes GNU Readline for input. Readline's
217+
# _rl_strip_prompt() strips \001 and \002 from the output, so test
218+
# assertions use the plain prompt.
215219
PS1 = "sqlite> "
216220

217221
@classmethod
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix reference leaks in various unusual error scenarios.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix :mod:`sqlite3`'s :ref:`interactive shell <sqlite3-cli>` keeping part of
2+
previous commands when scrolling history.

Modules/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ pymain_run_interactive_hook(int *exitcode)
506506
}
507507

508508
if (PySys_Audit("cpython.run_interactivehook", "O", hook) < 0) {
509+
Py_DECREF(hook);
509510
goto error;
510511
}
511512

Objects/object.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "pycore_instruction_sequence.h" // _PyInstructionSequence_Type
1818
#include "pycore_interpframe.h" // _PyFrame_Stackbase()
1919
#include "pycore_interpolation.h" // _PyInterpolation_Type
20+
#include "pycore_lazyimportobject.h" // PyLazyImport_Type
2021
#include "pycore_list.h" // _PyList_DebugMallocStats()
2122
#include "pycore_long.h" // _PyLong_GetZero()
2223
#include "pycore_memoryobject.h" // _PyManagedBuffer_Type
@@ -2540,6 +2541,7 @@ static PyTypeObject* static_types[] = {
25402541
&PyGen_Type,
25412542
&PyGetSetDescr_Type,
25422543
&PyInstanceMethod_Type,
2544+
&PyLazyImport_Type,
25432545
&PyListIter_Type,
25442546
&PyListRevIter_Type,
25452547
&PyList_Type,

Python/crossinterp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ check_missing___main___attr(PyObject *exc)
609609
// Get the error message.
610610
PyObject *args = PyException_GetArgs(exc);
611611
if (args == NULL || args == Py_None || PyObject_Size(args) < 1) {
612+
Py_XDECREF(args);
612613
assert(!PyErr_Occurred());
613614
return 0;
614615
}

0 commit comments

Comments
 (0)