Show invalid config message on TraitErrors during init #921

Merged
merged 4 commits into from Oct 28, 2011

Conversation

Projects
None yet
2 participants
@minrk
Member

minrk commented Oct 22, 2011

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

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
unregister crash handler on call
prevents recursive invocation of the crash handler
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.
IPython/config/application.py
@@ -69,6 +71,26 @@ subcommand 'cmd', do: `{app} cmd -h`.
# Application class
#-----------------------------------------------------------------------------
+@decorator
+def catch_config(method, app, *args, **kwargs):

This comment has been minimized.

@fperez

fperez Oct 28, 2011

Member

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.

@fperez

fperez Oct 28, 2011

Member

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.

@fperez

This comment has been minimized.

Show comment
Hide comment
@fperez

fperez Oct 28, 2011

Member

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

Member

fperez commented Oct 28, 2011

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

@minrk

This comment has been minimized.

Show comment
Hide comment
@minrk

minrk Oct 28, 2011

Member

That makes sense.

Member

minrk commented Oct 28, 2011

That makes sense.

@minrk

This comment has been minimized.

Show comment
Hide comment
@minrk

minrk Oct 28, 2011

Member

renamed to catch_config_error

Member

minrk commented Oct 28, 2011

renamed to catch_config_error

@fperez

This comment has been minimized.

Show comment
Hide comment
@fperez

fperez Oct 28, 2011

Member

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

Member

fperez commented Oct 28, 2011

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

fperez added a commit that referenced this pull request Oct 28, 2011

Merge pull request #921 from minrk/traiterror
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-raising bugs in IPython itself, but only during initialization.

Also, deregister crash handler on use to avoid it being triggered recursively/repeatedly.

@fperez fperez merged commit 6fb30ae into ipython:master Oct 28, 2011

This was referenced Oct 29, 2011

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014

Merge pull request #921 from minrk/traiterror
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-raising bugs in IPython itself, but only during initialization.

Also, deregister crash handler on use to avoid it being triggered recursively/repeatedly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment