Skip to content

CLN/COMPAT: Remove raise StopIteration syntax in SparseArray.__iter__ #11622

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
Nov 18, 2015

Conversation

kawochen
Copy link
Contributor

closes #11108

@jreback
Copy link
Contributor

jreback commented Nov 17, 2015

why is this bad? e.g. if you are iterating with a generator with works just fine

@kawochen
Copy link
Contributor Author

this causes a PendingDeprecationWarning in 3.5 and will be deprecated in 3.7 (PEP479)
this syntax doesn't cause a problem here, but it could if combined with a context manager, where the StopIteration exception will be caught in __exit__() and potentially causes the context manager to take a different path (depending on the presence of try-except constructs in the context manager)

@jreback
Copy link
Contributor

jreback commented Nov 17, 2015

is this an API change though?

@jreback jreback added the Compat pandas objects compatability with Numpy or Python functions label Nov 17, 2015
@kawochen
Copy link
Contributor Author

No. Using return (or just leaving it out, since there is no more code) and raise StopIteration are the same in this function (except for the warnings). They are different only when there is something inside the generator that could interfere with exception propagation.

@jreback
Copy link
Contributor

jreback commented Nov 17, 2015

ok seems reasonable. add a whatsnew note.

@jreback jreback added this to the 0.17.1 milestone Nov 17, 2015
@kawochen
Copy link
Contributor Author

which section?

@jreback
Copy link
Contributor

jreback commented Nov 17, 2015

I guess API changes; this is mainly to have a record of this.

@kawochen
Copy link
Contributor Author

green

jreback added a commit that referenced this pull request Nov 18, 2015
CLN/COMPAT: Remove raise StopIteration syntax in SparseArray.__iter__
@jreback jreback merged commit 89f46a5 into pandas-dev:master Nov 18, 2015
@jreback
Copy link
Contributor

jreback commented Nov 18, 2015

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

COMPAT: return instead of raising StopIteration in generator
2 participants