8000 gh-114258: Refactor Argument Clinic function name parser by erlend-aasland · Pull Request #114930 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-114258: Refactor Argument Clinic function name parser #114930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Feb 15, 2024
Prev Previous commit
Next Next commit
Address Nikita's review
  • Loading branch information
erlend-aasland committed Feb 5, 2024
commit be244f23633ff1e9da8e9f7975fa5b2cd973cc73
8 changes: 4 additions & 4 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5158,9 +5158,8 @@ def normalize_function_kind(self, fullname: str) -> None:
fail(f"{name!r} must be a normal method; got '{self.kind}'!")
if name == '__new__' and (self.kind is not CLASS_METHOD or not cls):
fail("'__new__' must be a class method!")
if self.kind in {GETTER, SETTER}:
if not cls:
fail("@getter and @setter must be methods")
if self.kind in {GETTER, SETTER} and not cls:
fail("@getter and @setter must be methods")

# Normalise self.kind.
if name == '__new__':
Expand Down Expand Up @@ -5200,8 +5199,9 @@ def parse_cloned_function(self, names: FunctionNames, existing: str) -> None:
fields = [x.strip() for x in existing.split('.')]
function_name = fields.pop()
module, cls = self.clinic._module_and_class(fields)
parent = module or cls

for existing_function in (cls or module).functions:
for existing_function in parent.functions:
if existing_function.name == function_name:
break
else:
Expand Down
0