Skip to content

BUG: Fix __instancecheck__ and __subclasscheck__ of metaclass in pandas.core.dtypes.generic #46719

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 6 commits into from
Apr 10, 2022

Conversation

leonarduschen
Copy link
Contributor

@leonarduschen leonarduschen commented Apr 9, 2022


#46684 is caused by wrong __instancecheck__ implementation, but __subclasscheck__ implementation is also wrong. I fixed both.

import pandas as pd
from pandas.core.dtypes.generic import ABCDataFrame

print(isinstance(pd.DataFrame, ABCDataFrame)) # Should have returned False, returned True instead
print(issubclass(pd.DataFrame(), ABCDataFrame)) # Should have raised, returned True instead

@leonarduschen leonarduschen marked this pull request as ready for review April 9, 2022 10:03
@leonarduschen leonarduschen changed the title Fix __instancecheck__ and __subclasscheck__ of metaclass in pandas.core.dtypes.generic BUG: Fix __instancecheck__ and __subclasscheck__ of metaclass in pandas.core.dtypes.generic Apr 9, 2022
Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Looks really good, but I suppose a test should also be added for apply as well.

@rhshadrach rhshadrach added the Bug label Apr 9, 2022
@rhshadrach rhshadrach added this to the 1.5 milestone Apr 9, 2022
@rhshadrach rhshadrach added Apply Apply, Aggregate, Transform, Map Internals Related to non-user accessible pandas implementation labels Apr 9, 2022
@leonarduschen
Copy link
Contributor Author

Alright done!

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

lgtm over to you @rhshadrach

Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

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

lgtm

@rhshadrach rhshadrach merged commit cec066d into pandas-dev:main Apr 10, 2022
@rhshadrach
Copy link
Member

Thanks @leonarduschen!

yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apply Apply, Aggregate, Transform, Map Bug Internals Related to non-user accessible pandas implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: apply on DataFrame results in TypeError: copy() missing 1 required positional argument: 'self'
3 participants