mirror of
https://github.com/python/cpython
synced 2024-09-06 12:21:12 +00:00
gh-107609: Fix duplicate module check in Argument Clinic (#107610)
Also remove duplicate module def from _testcapi.
This commit is contained in:
parent
e52e87c349
commit
a443c310ac
|
@ -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):
|
||||
|
|
|
@ -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.
|
|
@ -155,10 +155,9 @@ VectorCallClass_vectorcall(PyObject *callable,
|
|||
}
|
||||
|
||||
/*[clinic input]
|
||||
module _testcapi
|
||||
class _testcapi.VectorCallClass "PyObject *" "&PyType_Type"
|
||||
[clinic start generated code]*/
|
||||
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=8423a8e919f2f0df]*/
|
||||
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=95c63c1a47f9a995]*/
|
||||
|
||||
/*[clinic input]
|
||||
_testcapi.VectorCallClass.set_vectorcall
|
||||
|
|
|
@ -4472,7 +4472,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)
|
||||
|
|
Loading…
Reference in a new issue