Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ecc05e2

Browse filesBrowse files
authored
gh-106368: Argument clinic: Fix minor bug in state_modulename_name (#107387)
1 parent 3a1d819 commit ecc05e2
Copy full SHA for ecc05e2

File tree

Expand file treeCollapse file tree

2 files changed

+20
-5
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+20
-5
lines changed

‎Lib/test/test_clinic.py

Copy file name to clipboardExpand all lines: Lib/test/test_clinic.py
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def __init__(self):
8484
('parser_definition', d('block')),
8585
('impl_definition', d('block')),
8686
))
87+
self.functions = []
8788

8889
def get_destination(self, name):
8990
d = self.destinations.get(name)
@@ -104,6 +105,9 @@ def directive(self, name, args):
104105

105106
_module_and_class = clinic.Clinic._module_and_class
106107

108+
def __repr__(self):
109+
return "<FakeClinic object>"
110+
107111

108112
class ClinicWholeFileTest(_ParserBase):
109113
def setUp(self):
@@ -672,6 +676,19 @@ def test_c_name(self):
672676
""")
673677
self.assertEqual("os_stat_fn", function.c_basename)
674678

679+
def test_cloning_nonexistent_function_correctly_fails(self):
680+
stdout = self.parse_function_should_fail("""
681+
cloned = fooooooooooooooooooooooo
682+
This is trying to clone a nonexistent function!!
683+
""")
684+
expected_error = """\
685+
cls=None, module=<FakeClinic object>, existing='fooooooooooooooooooooooo'
686+
(cls or module).functions=[]
687+
Error on line 0:
688+
Couldn't find existing function 'fooooooooooooooooooooooo'!
689+
"""
690+
self.assertEqual(expected_error, stdout)
691+
675692
def test_return_converter(self):
676693
function = self.parse_function("""
677694
module os

‎Tools/clinic/clinic.py

Copy file name to clipboardExpand all lines: Tools/clinic/clinic.py
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4707,11 +4707,9 @@ def state_modulename_name(self, line: str | None) -> None:
47074707
if existing_function.name == function_name:
47084708
break
47094709
else:
4710-
existing_function = None
4711-
if not existing_function:
4712-
print("class", cls, "module", module, "existing", existing)
4713-
print("cls. functions", cls.functions)
4714-
fail("Couldn't find existing function " + repr(existing) + "!")
4710+
print(f"{cls=}, {module=}, {existing=}")
4711+
print(f"{(cls or module).functions=}")
4712+
fail(f"Couldn't find existing function {existing!r}!")
47154713

47164714
fields = [x.strip() for x in full_name.split('.')]
47174715
function_name = fields.pop()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.