Skip to content

Relocate exceptions #14800 #15181

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

Closed

Conversation

m-charlton
Copy link
Contributor

@m-charlton m-charlton commented Jan 20, 2017

Deprecation warnings will only be issued when exceptions/warnings are raised. I did think of
putting a deprecation warning in pandas.common.core indicating that these exceptions
were deprecated but these would be seen when anything was imported from pandas.core.common. Please advise.

DataFrame.astype now allows changing the dtype of a column by
passing a dict mapping column name to dtype.
DataFrame.astype now allows setting the type of columns
by passing a dict mapping column to dtype.
Mistakenly added changes carried out in v0.19 to v0.20
Move exceptions/warnings from pandas.core.common to pandas.api.exceptions
The exceptions/warnings can still be imported from pandas.core.common however
a DeprecationWarning will be issued when they are raised.
@jorisvandenbossche
Copy link
Member

I think we had the same problem before (I seem to remember this from #14479), but decorating exceptions does not seem to work in practice:

In [1]: from pandas.core.common import UnsortedIndexError

In [2]: try:
   ...:     raise pd.api.exceptions.UnsortedIndexError()
   ...: except UnsortedIndexError:
   ...:     print('catched')
   ...:     
---------------------------------------------------------------------------
UnsortedIndexError                        Traceback (most recent call last)
<ipython-input-2-c3dad543bd57> in <module>()
      1 try:
----> 2     raise pd.api.exceptions.UnsortedIndexError()
      3 except UnsortedIndexError:

UnsortedIndexError: 

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-2-c3dad543bd57> in <module>()
      1 try:
      2     raise pd.api.exceptions.UnsortedIndexError()
----> 3 except UnsortedIndexError:
      4     print('gevangen')
      5 

TypeError: catching classes that do not inherit from BaseException is not allowed

@jorisvandenbossche jorisvandenbossche added Clean Deprecate Functionality to remove in pandas labels Jan 20, 2017
@m-charlton
Copy link
Contributor Author

O.K. Will wait further instructions.

@jreback
Copy link
Contributor

jreback commented Jan 20, 2017

so I think what you have to do here, is add an option to _DeprecatedModule to allow it to function as an entire proxy module, but not to show the deprecation warning, except on the removals.

IOW, we want to proxy pandas.core.common, and if its a _removals, then show the deprecation message.

So if you add an option (default it to True), to show the DeprecationWarning for the module itself (but when you call it here, you will pass False). add the _removals for the exceptions, this could work.

the _add_proxy is wrapping a function around the exception which doesn't work (and I don't think we are actually using this anywhere)

@jreback
Copy link
Contributor

jreback commented Mar 20, 2017

closing in favor of #15541

@jreback jreback closed this Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Deprecate Functionality to remove in pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DEPR: relocate exceptions in pandas.core.common
3 participants