Skip to content

Commit

Permalink
pythongh-107609: Fix duplicate module check in Argument Clinic
Browse files Browse the repository at this point in the history
  • Loading branch information
erlend-aasland committed Aug 3, 2023
1 parent 14fbd4e commit e1f3569
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Lib/test/test_clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,16 @@ def __init__(self):
"""
self.expect_failure(block, err, lineno=8)

def test_module_already_got_one(self):
err = "Already defined module 'm'!"
block = """
/*[clinic input]
module m
module m
[clinic start generated code]*/
"""
self.expect_failure(block, err, lineno=3)


class ClinicGroupPermuterTest(TestCase):
def _test(self, l, m, r, output):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix duplicate module check in Argument Clinic. Previously, a duplicate
definition would incorrectly be silently accepted. Patch by Erlend E.
Aasland.
2 changes: 1 addition & 1 deletion Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4478,7 +4478,7 @@ def directive_module(self, name: str) -> None:
if cls:
fail("Can't nest a module inside a class!")

if name in module.classes:
if name in module.modules:
fail("Already defined module " + repr(name) + "!")

m = Module(name, module)
Expand Down

0 comments on commit e1f3569

Please sign in to comment.