Skip to content

Commit bbf636e

Browse files
authored
Merge branch 'main' into check-simd-headers
2 parents 08a1928 + 99088ab commit bbf636e

File tree

6 files changed

+56
-16
lines changed

6 files changed

+56
-16
lines changed

Lib/pdb.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1758,7 +1758,10 @@ def do_quit(self, arg):
17581758
17591759
Quit from the debugger. The program being executed is aborted.
17601760
"""
1761-
if self.mode == 'inline':
1761+
# Show prompt to kill process when in 'inline' mode and if pdb was not
1762+
# started from an interactive console. The attribute sys.ps1 is only
1763+
# defined if the interpreter is in interactive mode.
1764+
if self.mode == 'inline' and not hasattr(sys, 'ps1'):
17621765
while True:
17631766
try:
17641767
reply = input('Quitting pdb will kill the process. Quit anyway? [y/n] ')

Lib/test/test_code_module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ def test_ps2(self):
5050
self.infunc.side_effect = EOFError('Finished')
5151
self.console.interact()
5252
self.assertEqual(self.sysmod.ps2, '... ')
53-
self.sysmod.ps1 = 'custom2> '
53+
self.sysmod.ps2 = 'custom2> '
5454
self.console.interact()
55-
self.assertEqual(self.sysmod.ps1, 'custom2> ')
55+
self.assertEqual(self.sysmod.ps2, 'custom2> ')
5656

5757
def test_console_stderr(self):
5858
self.infunc.side_effect = ["'antioch'", "", EOFError('Finished')]

Lib/test/test_pdb.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from test.support import force_not_colorized, os_helper
2020
from test.support.import_helper import import_module
2121
from test.support.pty_helper import run_pty, FakeInput
22+
from test.support.script_helper import kill_python
2223
from unittest.mock import patch
2324

2425
SKIP_CORO_TESTS = False
@@ -4342,6 +4343,29 @@ def test_quit(self):
43424343
self.assertEqual(stdout.count("Quit anyway"), 2)
43434344

43444345

4346+
@support.force_not_colorized_test_class
4347+
@support.requires_subprocess()
4348+
class TestREPLSession(unittest.TestCase):
4349+
def test_return_from_inline_mode_to_REPL(self):
4350+
# GH-124703: Raise BdbQuit when exiting pdb in REPL session.
4351+
# This allows the REPL session to continue.
4352+
from test.test_repl import spawn_repl
4353+
p = spawn_repl()
4354+
user_input = """
4355+
x = 'Spam'
4356+
import pdb
4357+
pdb.set_trace(commands=['x + "During"', 'q'])
4358+
x + 'After'
4359+
"""
4360+
p.stdin.write(textwrap.dedent(user_input))
4361+
output = kill_python(p)
4362+
self.assertIn('SpamDuring', output)
4363+
self.assertNotIn("Quit anyway", output)
4364+
self.assertIn('BdbQuit', output)
4365+
self.assertIn('SpamAfter', output)
4366+
self.assertEqual(p.returncode, 0)
4367+
4368+
43454369
@support.requires_subprocess()
43464370
class PdbTestReadline(unittest.TestCase):
43474371
def setUpClass():
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Executing ``quit`` command in :mod:`pdb` will raise :exc:`bdb.BdbQuit` when :mod:`pdb` is started from an interactive console using :func:`breakpoint` or :func:`pdb.set_trace`.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The iOS testbed will now run successfully on a machine that has not
2+
previously run Xcode tests (such as CI configurations).

iOS/testbed/__main__.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,29 @@ async def async_check_output(*args, **kwargs):
8282

8383
# Return a list of UDIDs associated with booted simulators
8484
async def list_devices():
85-
# List the testing simulators, in JSON format
86-
raw_json = await async_check_output(
87-
"xcrun", "simctl", "--set", "testing", "list", "-j"
88-
)
89-
json_data = json.loads(raw_json)
90-
91-
# Filter out the booted iOS simulators
92-
return [
93-
simulator["udid"]
94-
for runtime, simulators in json_data["devices"].items()
95-
for simulator in simulators
96-
if runtime.split(".")[-1].startswith("iOS") and simulator["state"] == "Booted"
97-
]
85+
try:
86+
# List the testing simulators, in JSON format
87+
raw_json = await async_check_output(
88+
"xcrun", "simctl", "--set", "testing", "list", "-j"
89+
)
90+
json_data = json.loads(raw_json)
91+
92+
# Filter out the booted iOS simulators
93+
return [
94+
simulator["udid"]
95+
for runtime, simulators in json_data["devices"].items()
96+
for simulator in simulators
97+
if runtime.split(".")[-1].startswith("iOS") and simulator["state"] == "Booted"
98+
]
99+
except subprocess.CalledProcessError as e:
100+
# If there's no ~/Library/Developer/XCTestDevices folder (which is the
101+
# case on fresh installs, and in some CI environments), `simctl list`
102+
# returns error code 1, rather than an empty list. Handle that case,
103+
# but raise all other errors.
104+
if e.returncode == 1:
105+
return []
106+
else:
107+
raise
98108

99109

100110
async def find_device(initial_devices):

0 commit comments

Comments
 (0)