Skip to content

AC: Update unsupported_special_methods #24956

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 1 commit into from
Mar 25, 2021
Merged

Conversation

corona10
Copy link
Member

@corona10 corona10 commented Mar 21, 2021

cpython/Tools/clinic/clinic.py

Lines 4230 to 4241 in 8fba952

if fields[-1] == '__new__':
if (self.kind != CLASS_METHOD) or (not cls):
fail("__new__ must be a class method!")
self.kind = METHOD_NEW
elif fields[-1] == '__init__':
if (self.kind != CALLABLE) or (not cls):
fail("__init__ must be a normal method, not a class or static method!")
self.kind = METHOD_INIT
if not return_converter:
return_converter = init_return_converter()
elif fields[-1] in unsupported_special_methods:
fail(fields[-1] + " is a special method and cannot be converted to Argument Clinic! (Yet.)")

  1. AC already supports __new__ method, but the __new__ is still existed in the unsupported_special_methods
  2. The reason that this code does not raise any bug is that __new__ already satisfies the first if statement, so there was no chance to meet the last if statement.
  3. To prevent non-updated unsupported_special_methods, I move up the last if statement to the above of the first statement. by doing this next author can detect unsupported_special_methods is updated or not

@@ -4227,6 +4226,9 @@ def state_modulename_name(self, line):
module, cls = self.clinic._module_and_class(fields)

fields = full_name.split('.')
if fields[-1] in unsupported_special_methods:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear reviewers,
This change is intended to early detect the consistency of unsupported_special_methods.

@corona10
Copy link
Member Author

@pablogsal @serhiy-storchaka @vstinner gentle ping

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@corona10
Copy link
Member Author

@vstinner Thank you!

@corona10 corona10 merged commit df9ade9 into python:master Mar 25, 2021
@corona10 corona10 deleted the ac_fix branch March 25, 2021 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants