Skip to content

Commit 65ce365

Browse files
authored
gh-104683: Remove unused variables from Tools/clinic and tests for Tools/clinic (#107771)
1 parent 52fbcf6 commit 65ce365

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

Lib/test/test_clinic.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,6 @@ def test_directive_preserve_input(self):
567567
self.expect_failure(block, err, lineno=6)
568568

569569
def test_directive_preserve_output(self):
570-
err = "'preserve' only works for blocks that don't produce any output!"
571570
block = dedent("""
572571
/*[clinic input]
573572
output everything buffer
@@ -965,7 +964,6 @@ def test_param_no_docstring(self):
965964
follow_symlinks: bool = True
966965
something_else: str = ''
967966
""")
968-
p = function.parameters['follow_symlinks']
969967
self.assertEqual(3, len(function.parameters))
970968
conv = function.parameters['something_else'].converter
971969
self.assertIsInstance(conv, clinic.str_converter)
@@ -1929,17 +1927,14 @@ def test_scaffolding(self):
19291927
self.assertEqual(repr(clinic.NULL), '<Null>')
19301928

19311929
# test that fail fails
1932-
expected = (
1933-
'Error in file "clown.txt" on line 69:\n'
1934-
'The igloos are melting!\n'
1935-
)
19361930
with support.captured_stdout() as stdout:
19371931
errmsg = 'The igloos are melting'
19381932
with self.assertRaisesRegex(clinic.ClinicError, errmsg) as cm:
19391933
clinic.fail(errmsg, filename='clown.txt', line_number=69)
19401934
exc = cm.exception
19411935
self.assertEqual(exc.filename, 'clown.txt')
19421936
self.assertEqual(exc.lineno, 69)
1937+
self.assertEqual(stdout.getvalue(), "")
19431938

19441939
def test_non_ascii_character_in_docstring(self):
19451940
block = """
@@ -2408,7 +2403,7 @@ def test_file_dest(self):
24082403
"not overwriting!")
24092404
self.assertIn(expected_err, err)
24102405
# Run clinic again, this time with the -f option.
2411-
out = self.expect_success("-f", in_fn)
2406+
_ = self.expect_success("-f", in_fn)
24122407
# Read back the generated output.
24132408
with open(in_fn, encoding="utf-8") as f:
24142409
data = f.read()

Tools/clinic/cpp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def _main(filenames: list[str] | None = None) -> None:
186186
cpp = Monitor(filename, verbose=True)
187187
print()
188188
print(filename)
189-
for line_number, line in enumerate(f.read().split('\n'), 1):
189+
for line in f:
190190
cpp.writeline(line)
191191

192192

0 commit comments

Comments
 (0)