##// END OF EJS Templates
Swallow potential exceptions from showtraceback() (#13934)...
Swallow potential exceptions from showtraceback() (#13934) The nbgrader project is aware of a form of cheating where students disrupt `InteractiveShell.showtraceback` in hopes of hiding exceptions to avoid losing points. They have implemented a solution to prevent this cheating from working on the client side, and have some tests to demonstrate this technique: https://github.com/jupyter/nbgrader/blob/main/nbgrader/tests/apps/files/submitted-cheat-attempt.ipynb https://github.com/jupyter/nbgrader/blob/main/nbgrader/tests/apps/files/submitted-cheat-attempt-alternative.ipynb In essence, these attacks import the interactive shell and erase the traceback handler so that their failing tests won't report failures. ```python import IPython.core.interactiveshell IPython.core.interactiveshell.InteractiveShell.showtraceback = None ``` The problem is that this causes an exception inside the kernel, leading to a stalled execution. The kernel has stopped working, but the client continues to wait for messages. So far, nbgrader's solution to this is to require a timeout value so the client can eventually decide it is done. This prevents allowing a value of `None` for `Execute.timeout` because this would cause a test case to infinitely hang. This commit addresses the problem by making `InteractiveShell._run_cell` a little more protective around it's call to `showtraceback()`. There is already a try/except block around running the cell. This commit adds a finally clause so that the method will _always_ return an `ExecutionResult`, even if a new exception is thrown within the except clause. For the record, the exception thrown is: TypeError: 'NoneType' object is not callable Accepting this change will allow nbgrader to update `nbgrader.preprocessors.Execute` to support a type of `Integer(allow_none=True)` as the parent `NotebookClient` intended. Discussion about this is ongoing in jupyter/nbgrader#1690.

File last commit:

r22590:c64b5204
r28101:e548ee23 merge
Show More
make.cmd
82 lines | 2.6 KiB | application/x-dos-batch | BatchLexer
@ECHO OFF
REM ~ Windows command line make file for Sphinx documentation
SETLOCAL
SET SPHINXOPTS=
SET SPHINXBUILD=sphinx-build
SET PAPER=
SET SRCDIR=source
SET PYTHON=python
IF "%PAPER%" == "" SET PAPER=a4
SET ALLSPHINXOPTS=-d build\doctrees -D latex_paper_size=%PAPER% %SPHINXOPTS% %SRCDIR%
FOR %%X IN (%SPHINXBUILD%.exe) DO SET P=%%~$PATH:X
FOR %%L IN (html html_noapi pickle htmlhelp latex changes linkcheck) DO (
IF "%1" == "%%L" (
IF "%P%" == "" (
ECHO.
ECHO Error: Sphinx is not available. Please make sure it is correctly installed.
GOTO END
)
MD build\doctrees 2>NUL
MD build\%1 || GOTO DIR_EXIST
%PYTHON% autogen_config.py && ECHO Created docs for config options
%PYTHON% autogen_magics.py && ECHO Created docs for line ^& cell magics
%PYTHON% autogen_shortcuts.py && ECHO Created docs for shortcuts
IF NOT "%1" == "html_noapi" (
%PYTHON% autogen_api.py && ECHO Build API docs finished
%SPHINXBUILD% -b %1 %ALLSPHINXOPTS% build\%1
) ELSE (
%SPHINXBUILD% -b html %ALLSPHINXOPTS% build\%1
)
IF NOT ERRORLEVEL 0 GOTO ERROR
ECHO.
ECHO Build finished. Results are in build\%1.
IF "%1" == "pickle" (
ECHO Now you can process the pickle files or run
ECHO sphinx-web build\pickle to start the sphinx-web server.
)
IF "%1" == "htmlhelp" (
ECHO Now you can run HTML Help Workshop with the
ECHO .hhp project file in build/htmlhelp.
)
IF "%1" == "linkcheck" (
ECHO Look for any errors in the above output
ECHO or in build\linkcheck\output.rst.
)
GOTO END
)
)
IF "%1" == "clean" (
RD /s /q build dist %SRCDIR%\api\generated 2>NUL
IF ERRORLEVEL 0 ECHO Build environment cleaned!
GOTO END
)
ECHO.
ECHO Please use "make [target]" where [target] is one of:
ECHO.
ECHO html to make standalone HTML files
ECHO html_noapi same as above, without the time consuming API docs
ECHO jsapi to make standalone HTML files for the Javascript API
ECHO pickle to make pickle files (usable by e.g. sphinx-web)
ECHO htmlhelp to make HTML files and a HTML help project
ECHO latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
ECHO changes to make an overview over all changed/added/deprecated items
ECHO linkcheck to check all external links for integrity
GOTO END
:DIR_EXIST
ECHO.
ECHO Info: Run "make clean" to clean build environment
:ERROR
ECHO.
ECHO Error: Build process failed!
:END
ENDLOCAL