Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
The following code is silently accepted by Argument Clinic:
/*[clinic input]module mmodule m[clinic start generated code]*/
The duplicatemodule m should have been caught by Argument Clinic, but the guard is faulty:
cpython/Tools/clinic/clinic.py
Lines 4481 to 4482 in9e6590b
| ifnameinmodule.classes: | |
| fail("Already defined module "+repr(name)+"!") |
The check should be against.modules, not.classes:
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.pyindex 1bcdb6b1c3..dc4a7f9318 100755--- a/Tools/clinic/clinic.py+++ b/Tools/clinic/clinic.py@@ -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)
See also theModule class:
cpython/Tools/clinic/clinic.py
Lines 2384 to 2392 in9e6590b
| classModule: | |
| name:str | |
| module:Module|Clinic | |
| def__post_init__(self)->None: | |
| self.parent=self.module | |
| self.modules:ModuleDict= {} | |
| self.classes:ClassDict= {} | |
| self.functions:list[Function]= [] |