Skip to content

BUG: GH11808 subclasses of DataFrame did not propagate AttributeError #11822

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
Dec 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/source/whatsnew/v0.18.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ Bug Fixes



- Bug groupby on tz-aware data where selection not returning ``Timestamp`` (:issue:`11616`
- Bug in subclasses of `DataFrame` where `AttributeError` did not propagate (:issue:`11808`)
- Bug groupby on tz-aware data where selection not returning ``Timestamp`` (:issue:`11616`)
- Bug in ``pd.read_clipboard`` and ``pd.to_clipboard`` functions not supporting Unicode; upgrade included ``pyperclip`` to v1.5.15 (:issue:`9263`)


Expand Down
3 changes: 1 addition & 2 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2356,8 +2356,7 @@ def __getattr__(self, name):
else:
if name in self._info_axis:
return self[name]
raise AttributeError("'%s' object has no attribute '%s'" %
(type(self).__name__, name))
return object.__getattribute__(self, name)

def __setattr__(self, name, value):
"""After regular attribute access, try setting the name
Expand Down
11 changes: 11 additions & 0 deletions pandas/tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -15878,6 +15878,17 @@ class SubclassedPanel(Panel):
dtype='int64')
tm.assert_panel_equal(result, expected)

def test_subclass_attr_err_propagation(self):
# GH 11808
class A(DataFrame):

@property
def bar(self):
return self.i_dont_exist
with tm.assertRaisesRegexp(AttributeError, '.*i_dont_exist.*'):
A().bar


def skip_if_no_ne(engine='numexpr'):
if engine == 'numexpr':
try:
Expand Down