diff options
author | Erlend Egeberg Aasland <erlend.aasland@protonmail.com> | 2022-07-07 10:12:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-07 10:12:47 (GMT) |
commit | c0b7868db28cb8840b67844984133cdfb29b6bcb (patch) | |
tree | f478cab8434c95318392245a662c73f8714e19d6 /Tools | |
parent | 74c953d396816c0ef3de80276c00d29f79cbf8bf (diff) | |
download | cpython-c0b7868db28cb8840b67844984133cdfb29b6bcb.zip cpython-c0b7868db28cb8840b67844984133cdfb29b6bcb.tar.gz cpython-c0b7868db28cb8840b67844984133cdfb29b6bcb.tar.bz2 |
[3.11] gh-94430: Allow params named `module` or `self` with custom C names in AC (GH-94431) (#94649)
(cherry picked from commit 8bbd70b4d130f060f87e3f53810dc747a49fa369)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
Diffstat (limited to 'Tools')
-rwxr-xr-x | Tools/clinic/clinic.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index 791d434..cd0446d 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -4721,9 +4721,14 @@ class DSLParser: p = Parameter(parameter_name, kind, function=self.function, converter=converter, default=value, group=self.group) - if parameter_name in self.function.parameters: + names = [k.name for k in self.function.parameters.values()] + if parameter_name in names[1:]: fail("You can't have two parameters named " + repr(parameter_name) + "!") - self.function.parameters[parameter_name] = p + elif names and parameter_name == names[0] and c_name is None: + fail(f"Parameter '{parameter_name}' requires a custom C name") + + key = f"{parameter_name}_as_{c_name}" if c_name else parameter_name + self.function.parameters[key] = p def parse_converter(self, annotation): if (hasattr(ast, 'Constant') and |