Skip to content

Commit 9846425

Browse files
committed
Merge pull request #11822 from kawochen/BUG-FIX-11808
BUG: GH11808 subclasses of DataFrame did not propagate AttributeError
2 parents def7462 + 9987366 commit 9846425

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

doc/source/whatsnew/v0.18.0.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ Bug Fixes
206206

207207

208208

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

212213

pandas/core/generic.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,8 +2356,7 @@ def __getattr__(self, name):
23562356
else:
23572357
if name in self._info_axis:
23582358
return self[name]
2359-
raise AttributeError("'%s' object has no attribute '%s'" %
2360-
(type(self).__name__, name))
2359+
return object.__getattribute__(self, name)
23612360

23622361
def __setattr__(self, name, value):
23632362
"""After regular attribute access, try setting the name

pandas/tests/test_frame.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15878,6 +15878,17 @@ class SubclassedPanel(Panel):
1587815878
dtype='int64')
1587915879
tm.assert_panel_equal(result, expected)
1588015880

15881+
def test_subclass_attr_err_propagation(self):
15882+
# GH 11808
15883+
class A(DataFrame):
15884+
15885+
@property
15886+
def bar(self):
15887+
return self.i_dont_exist
15888+
with tm.assertRaisesRegexp(AttributeError, '.*i_dont_exist.*'):
15889+
A().bar
15890+
15891+
1588115892
def skip_if_no_ne(engine='numexpr'):
1588215893
if engine == 'numexpr':
1588315894
try:

0 commit comments

Comments
 (0)