From 40708d452dbeef2603c641fa067671e0c5079734 2014-09-07 18:36:53 From: Scott Sanderson Date: 2014-09-07 18:36:53 Subject: [PATCH] MAINT: Move `InputRejected` to `IPython.core.error`. --- diff --git a/IPython/core/error.py b/IPython/core/error.py index 5346498..684cbc8 100644 --- a/IPython/core/error.py +++ b/IPython/core/error.py @@ -51,3 +51,10 @@ class StdinNotImplementedError(IPythonCoreError, NotImplementedError): For use in IPython kernels, where only some frontends may support stdin requests. """ + +class InputRejected(Exception): + """Input rejected by ast transformer. + + Raise this in your NodeTransformer to indicate that InteractiveShell should + not execute the supplied input. + """ diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 0722cdb..56aea6d 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -41,7 +41,7 @@ from IPython.core.compilerop import CachingCompiler, check_linecache_ipython from IPython.core.display_trap import DisplayTrap from IPython.core.displayhook import DisplayHook from IPython.core.displaypub import DisplayPublisher -from IPython.core.error import UsageError +from IPython.core.error import InputRejected, UsageError from IPython.core.extensions import ExtensionManager from IPython.core.formatters import DisplayFormatter from IPython.core.history import HistoryManager @@ -54,7 +54,6 @@ from IPython.core.profiledir import ProfileDir from IPython.core.prompts import PromptManager from IPython.core.usage import default_banner from IPython.lib.latextools import LaTeXTool -from IPython.lib.security import InputRejected from IPython.testing.skipdoctest import skip_doctest from IPython.utils import PyColorize from IPython.utils import io diff --git a/IPython/core/tests/test_interactiveshell.py b/IPython/core/tests/test_interactiveshell.py index 326a84b..4d95a68 100644 --- a/IPython/core/tests/test_interactiveshell.py +++ b/IPython/core/tests/test_interactiveshell.py @@ -24,8 +24,8 @@ from os.path import join import nose.tools as nt +from IPython.core.error import InputRejected from IPython.core.inputtransformer import InputTransformer -from IPython.lib.security import InputRejected from IPython.testing.decorators import ( skipif, skip_win32, onlyif_unicode_paths, onlyif_cmds_exist, ) diff --git a/IPython/lib/security.py b/IPython/lib/security.py index 564410d..eab67bb 100644 --- a/IPython/lib/security.py +++ b/IPython/lib/security.py @@ -114,13 +114,3 @@ def passwd_check(hashed_passphrase, passphrase): h.update(cast_bytes(passphrase, 'utf-8') + cast_bytes(salt, 'ascii')) return h.hexdigest() == pw_digest - -#----------------------------------------------------------------------------- -# Exception classes -#----------------------------------------------------------------------------- -class InputRejected(Exception): - """Input rejected by ast transformer. - - To be raised by user-supplied ast.NodeTransformers when an input should not - be executed. - """