Show invalid config message on TraitErrors during init #921

Merged
merged 4 commits into from Oct 28, 2011

2 participants

@minrk
IPython member

implemented via @catch_config decorator

Now, the event that was triggered by invalid app config (see --log-level 5) is triggered by bad config at any point during initialization.

This will catch TraitError-raising bugs in IPython itself, but only during initialization.

A less aggressive approach would be to look for all possible TraitError-raising points, and protect only those.

Also includes a tiny commit which unregisters crash_handler in __call__, because it should never be called twice. The fact that it calls exit() demonstrates that if it ever does get called twice, we are in a great big mess, and we should at least avoid printing pages and pages of extra crash messages.

minrk added some commits Oct 22, 2011
@minrk minrk Show invalid config message on TraitErrors during initialization
implemented via @catch_config decorator

Now, the event that was triggered by invalid app config (see `--log-level 5`) is triggered by bad config at any point during initialization.

This *will* catch TraitError bugs in IPython itself, but only during initialization.

closes gh-908
7ed219c
@minrk minrk unregister crash handler on call
prevents recursive invocation of the crash handler
074918c
@minrk minrk fix base64 code in nbformat.v2
base64 encoding functions were called, but had no effect, because
the notebook already has everything as b64-encoded bytestrings, which
are valid ascii literals on Python 2.

However, the encode/decode logic is actually triggered on Python 3, revealing its errors.

This fixes the base64 functions that had no effect to have their intended effect, but does not use them.  Rather, it is assumed that
bytes objects are already b64-encoded (and thus ascii-safe), which 
assumption was already made in Python 2.
6607706
@fperez fperez commented on an outdated diff Oct 28, 2011
IPython/config/application.py
@@ -69,6 +71,26 @@ subcommand 'cmd', do: `{app} cmd -h`.
# Application class
#-----------------------------------------------------------------------------
+@decorator
+def catch_config(method, app, *args, **kwargs):
@fperez
IPython member
fperez added a line comment Oct 28, 2011

This looks excellent, my only suggestion would be a name change: catch_config_error instead. It seems to me it will make the use of the decorator throughout the code much more self-documenting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@fperez
IPython member

Great work, thanks @minrk. All tests pass here, so once we agree on the final name choice, this one can go in.

@minrk
IPython member

That makes sense.

@minrk
IPython member

renamed to catch_config_error

@fperez
IPython member

Perfect! All looks good, tests pass, thanks for the name change. Merging now.

@fperez fperez merged commit 6fb30ae into ipython:master Oct 28, 2011
This was referenced Oct 29, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment