summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErlend E. Aasland <erlend@python.org>2023-08-04 05:28:25 (GMT)
committerGitHub <noreply@github.com>2023-08-04 05:28:25 (GMT)
commita443c310ac87f214164cb1e3f8af3f799668c867 (patch)
tree7216629cd0b28b0580141801a51a34df5a602046
parente52e87c349feeee77445205829bfc8db9fe4b80e (diff)
downloadcpython-a443c310ac87f214164cb1e3f8af3f799668c867.zip
cpython-a443c310ac87f214164cb1e3f8af3f799668c867.tar.gz
cpython-a443c310ac87f214164cb1e3f8af3f799668c867.tar.bz2
gh-107609: Fix duplicate module check in Argument Clinic (#107610)
Also remove duplicate module def from _testcapi.
-rw-r--r--Lib/test/test_clinic.py10
-rw-r--r--Misc/NEWS.d/next/Tools-Demos/2023-08-04-00-04-40.gh-issue-107609.2DqgtL.rst3
-rw-r--r--Modules/_testcapi/vectorcall.c3
-rwxr-xr-xTools/clinic/clinic.py2
4 files changed, 15 insertions, 3 deletions
diff --git a/Lib/test/test_clinic.py b/Lib/test/test_clinic.py
index 3aa4163..59669d6 100644
--- a/Lib/test/test_clinic.py
+++ b/Lib/test/test_clinic.py
@@ -416,6 +416,16 @@ class ClinicWholeFileTest(TestCase):
"""
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):
diff --git a/Misc/NEWS.d/next/Tools-Demos/2023-08-04-00-04-40.gh-issue-107609.2DqgtL.rst b/Misc/NEWS.d/next/Tools-Demos/2023-08-04-00-04-40.gh-issue-107609.2DqgtL.rst
new file mode 100644
index 0000000..080a6c1
--- /dev/null
+++ b/Misc/NEWS.d/next/Tools-Demos/2023-08-04-00-04-40.gh-issue-107609.2DqgtL.rst
@@ -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.
diff --git a/Modules/_testcapi/vectorcall.c b/Modules/_testcapi/vectorcall.c
index 61c6e0f..2b5110f 100644
--- a/Modules/_testcapi/vectorcall.c
+++ b/Modules/_testcapi/vectorcall.c
@@ -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
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 733a83e..7525c1c 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -4472,7 +4472,7 @@ class DSLParser:
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)