Skip to content

DOC: limit error traceback to one line for expected exceptions (GH10715) #10727

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

Conversation

jorisvandenbossche
Copy link
Member

Closes #10715

This gives you an output like

In [4]: s = pd.Series([1,3,5,np.nan,6,8])

In [5]: s.iloc[11]
---------------------------------------------------------------------------
IndexError: single positional indexer is out-of-bounds

for input

.. ipython:: python
   :okexcept:

   s = pd.Series([1,3,5,np.nan,6,8])
   s.iloc[10]

I think we would always want such a truncated traceback in the docs in cases that exceptions are expected, so I don't think it is needed to make it an extra new option.
I only should check for cases where the actual message spans multiple lines (now it is hardcoded to give me the last line of the error traceback)

@jreback with this we don't have to use the code-block s in eg whatsnew for the expect behaviour of to_datetime

@jorisvandenbossche jorisvandenbossche added this to the 0.17.0 milestone Aug 2, 2015
@jreback
Copy link
Contributor

jreback commented Aug 2, 2015

@jorisvandenbossche

yep, actually should prob go thru the code and fix up cases where we are doing this (so that it shows the actual trace-back rather then the copy/pasted code-block). but that is prob some work; maybe make a new issue.

@shoyer
Copy link
Member

shoyer commented Aug 3, 2015

Looks good, although my inclination is to remove one more line of the traceback:

In [5]: s.iloc[11]
IndexError: single positional indexer is out-of-bounds

@jorisvandenbossche
Copy link
Member Author

@shoyer yep, that's also certainly possible. I deliberately included the first (the line) and the last line (the message), in the idea that in this way it stands out a bit clearer as an error message. But if people prefer it without line, no problem for me and easy to change.

@jreback
Copy link
Contributor

jreback commented Aug 20, 2015

I prefer having just one line of the error message as @shoyer suggests.

@jorisvandenbossche
Copy link
Member Author

Updated with one line (already had it done locally, but forgot to push ..)

jorisvandenbossche added a commit that referenced this pull request Aug 21, 2015
DOC: limit error traceback to one line for expected exceptions (GH10715)
@jorisvandenbossche jorisvandenbossche merged commit d406273 into pandas-dev:master Aug 21, 2015
@jreback
Copy link
Contributor

jreback commented Aug 22, 2015

@jorisvandenbossche doc builds are stopping since this commit
https://travis-ci.org/pydata/pandas/jobs/76637871#L1800

any thoughts?

@jorisvandenbossche
Copy link
Member Author

Hmm, stupid I didn't look at the travis builds (it builds OK locally). Thanks for noting!

It halts in enhancingperf.rst, but I did not change anything there. The only reason I could think is because there is one okexcept in that file. But locally that one is parsed fine (will try later on a linux machine)

@jreback
Copy link
Contributor

jreback commented Aug 22, 2015

gr8 thanks!

jreback added a commit to jreback/pandas that referenced this pull request Aug 28, 2015
…phinx-traceback"

This reverts commit d406273, reversing
changes made to bd804aa.
jreback added a commit that referenced this pull request Aug 28, 2015
Revert "Merge pull request #10727 from jorisvandenbossche/sphinx-traceback
jorisvandenbossche added a commit that referenced this pull request Aug 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants