Skip to content

BUG: Fix unbound local in exception handling in core/index #5046

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
Sep 29, 2013
Merged
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
11 changes: 5 additions & 6 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3342,6 +3342,7 @@ def _apply_standard(self, func, axis, ignore_failures=False, reduce=True):
else: # pragma : no cover
raise AssertionError('Axis must be 0 or 1, got %s' % str(axis))

i = None
keys = []
results = {}
if ignore_failures:
Expand All @@ -3362,14 +3363,12 @@ def _apply_standard(self, func, axis, ignore_failures=False, reduce=True):
results[i] = func(v)
keys.append(v.name)
except Exception as e:
try:
if hasattr(e, 'args'):
if hasattr(e, 'args'):
# make sure i is defined
if i is not None:
k = res_index[i]
e.args = e.args + ('occurred at index %s' %
com.pprint_thing(k),)
except (NameError, UnboundLocalError): # pragma: no cover
# no k defined yet
pass
com.pprint_thing(k),)
raise

if len(results) > 0 and _is_sequence(results[0]):
Expand Down