Skip to content

Fix __isabstractmethod__ for class/static methods and properties#3479

Merged
youknowone merged 3 commits into
RustPython:mainfrom
chrismoradi:fix-abstractmethods
Jan 22, 2022
Merged

Fix __isabstractmethod__ for class/static methods and properties#3479
youknowone merged 3 commits into
RustPython:mainfrom
chrismoradi:fix-abstractmethods

Conversation

@chrismoradi
Copy link
Copy Markdown
Contributor

Includes a minor departure from CPython implementation of inspect.isabstract because TPFLAGS_IS_ABSTRACT is not set in obj.__flags__. Not sure if this is a problem but happy to revert this change if it is.

Includes a minor departure from CPython implementation of inspect.isabstract
because TPFLAGS_IS_ABSTRACT is not set in obj.__flags__.
Comment thread Lib/inspect.py Outdated

def isabstract(object):
"""Return true if the object is an abstract base class (ABC)."""
# TODO: RUSTPYTHON
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about leaving the original code as commented-out and put this comments on line 305? So future contributor can notice what's changed in the source code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure! Fixed this.


#[pyproperty(magic)]
fn isabstractmethod(&self, vm: &VirtualMachine) -> PyObjectRef {
let getter_abstract = match self.getter.read().to_owned() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@coolreader18 is to_owned the best way to handle this?

Copy link
Copy Markdown
Member

@youknowone youknowone Dec 9, 2021

Choose a reason for hiding this comment

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

@coolreader18 do you have any idea about this? otherwise i will merge this PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@youknowone & @coolreader18, Just wanted to check in on this PR. Should I work on trying to remove the to_owned()?

@youknowone youknowone merged commit e3fb3f1 into RustPython:main Jan 22, 2022
@youknowone
Copy link
Copy Markdown
Member

I am sorry to keep this unmerged for long time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants