diff --git a/IPython/core/displayhook.py b/IPython/core/displayhook.py index f1ae03f..9890b3d 100644 --- a/IPython/core/displayhook.py +++ b/IPython/core/displayhook.py @@ -244,8 +244,8 @@ class DisplayHook(Configurable): def flush(self): if not self.do_full_cache: - raise ValueError,"You shouldn't have reached the cache flush "\ - "if full caching is not enabled!" + raise ValueError("You shouldn't have reached the cache flush " + "if full caching is not enabled!") # delete auto-generated vars from global namespace for n in range(1,self.prompt_count + 1): diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 359f1c5..cf10a63 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -906,7 +906,7 @@ class InteractiveShell(SingletonConfigurable): def _set_call_pdb(self,val): if val not in (0,1,False,True): - raise ValueError,'new call_pdb value must be boolean' + raise ValueError('new call_pdb value must be boolean') # store value in instance self._call_pdb = val diff --git a/IPython/core/logger.py b/IPython/core/logger.py index 63fd765..d6eff7a 100644 --- a/IPython/core/logger.py +++ b/IPython/core/logger.py @@ -54,7 +54,7 @@ class Logger(object): # logmode is a validated property def _set_mode(self,mode): if mode not in ['append','backup','global','over','rotate']: - raise ValueError,'invalid log mode %s given' % mode + raise ValueError('invalid log mode %s given' % mode) self._logmode = mode def _get_mode(self): @@ -131,8 +131,8 @@ class Logger(object): """Switch logging on/off. val should be ONLY a boolean.""" if val not in [False,True,0,1]: - raise ValueError, \ - 'Call switch_log ONLY with a boolean argument, not with:',val + raise ValueError('Call switch_log ONLY with a boolean argument, ' + 'not with: %s' % val) label = {0:'OFF',1:'ON',False:'OFF',True:'ON'} diff --git a/IPython/core/magic.py b/IPython/core/magic.py index db52820..1be6d12 100644 --- a/IPython/core/magic.py +++ b/IPython/core/magic.py @@ -568,7 +568,7 @@ class Magics(object): mode = kw.get('mode','string') if mode not in ['string','list']: - raise ValueError,'incorrect mode given: %s' % mode + raise ValueError('incorrect mode given: %s' % mode) # Get options list_all = kw.get('list_all',0) posix = kw.get('posix', os.name == 'posix') diff --git a/IPython/core/ultratb.py b/IPython/core/ultratb.py index 72a46fd..49dfb0e 100644 --- a/IPython/core/ultratb.py +++ b/IPython/core/ultratb.py @@ -1103,8 +1103,8 @@ class FormattedTB(VerboseTB, ListTB): len(self.valid_modes) self.mode = self.valid_modes[new_idx] elif mode not in self.valid_modes: - raise ValueError, 'Unrecognized mode in FormattedTB: <'+mode+'>\n'\ - 'Valid modes: '+str(self.valid_modes) + raise ValueError('Unrecognized mode in FormattedTB: <'+mode+'>\n' + 'Valid modes: '+str(self.valid_modes)) else: self.mode = mode # include variable details only in 'Verbose' mode diff --git a/IPython/external/decorators/_decorators.py b/IPython/external/decorators/_decorators.py index 75e2ee8..b87a455 100644 --- a/IPython/external/decorators/_decorators.py +++ b/IPython/external/decorators/_decorators.py @@ -217,7 +217,7 @@ def knownfailureif(fail_condition, msg=None): import nose def knownfailer(*args, **kwargs): if fail_val(): - raise KnownFailureTest, msg + raise KnownFailureTest(msg) else: return f(*args, **kwargs) return nose.tools.make_decorator(f)(knownfailer) diff --git a/IPython/external/pexpect/_pexpect.py b/IPython/external/pexpect/_pexpect.py index 0e6bfaa..3b8a4ea 100644 --- a/IPython/external/pexpect/_pexpect.py +++ b/IPython/external/pexpect/_pexpect.py @@ -608,11 +608,11 @@ class spawnb(object): parent_fd, child_fd = os.openpty() if parent_fd < 0 or child_fd < 0: - raise ExceptionPexpect, "Error! Could not open pty with os.openpty()." + raise ExceptionPexpect("Error! Could not open pty with os.openpty().") pid = os.fork() if pid < 0: - raise ExceptionPexpect, "Error! Failed os.fork()." + raise ExceptionPexpect("Error! Failed os.fork().") elif pid == 0: # Child. os.close(parent_fd) @@ -655,7 +655,7 @@ class spawnb(object): fd = os.open("/dev/tty", os.O_RDWR | os.O_NOCTTY); if fd >= 0: os.close(fd) - raise ExceptionPexpect, "Error! Failed to disconnect from controlling tty. It is still possible to open /dev/tty." + raise ExceptionPexpect("Error! Failed to disconnect from controlling tty. It is still possible to open /dev/tty.") except: # Good! We are disconnected from a controlling tty. pass @@ -663,14 +663,14 @@ class spawnb(object): # Verify we can open child pty. fd = os.open(child_name, os.O_RDWR); if fd < 0: - raise ExceptionPexpect, "Error! Could not open child pty, " + child_name + raise ExceptionPexpect("Error! Could not open child pty, " + child_name) else: os.close(fd) # Verify we now have a controlling tty. fd = os.open("/dev/tty", os.O_WRONLY) if fd < 0: - raise ExceptionPexpect, "Error! Could not open controlling tty, /dev/tty" + raise ExceptionPexpect("Error! Could not open controlling tty, /dev/tty") else: os.close(fd) diff --git a/IPython/lib/backgroundjobs.py b/IPython/lib/backgroundjobs.py index 8b57bea..e14feed 100644 --- a/IPython/lib/backgroundjobs.py +++ b/IPython/lib/backgroundjobs.py @@ -375,8 +375,7 @@ class BackgroundJobBase(threading.Thread): stat_dead_c = -1 def __init__(self): - raise NotImplementedError, \ - "This class can not be instantiated directly." + raise NotImplementedError("This class can not be instantiated directly.") def _init(self): """Common initialization for all BackgroundJob objects""" diff --git a/IPython/testing/tests/test_decorators.py b/IPython/testing/tests/test_decorators.py index 5ce0a6b..9929b52 100644 --- a/IPython/testing/tests/test_decorators.py +++ b/IPython/testing/tests/test_decorators.py @@ -36,7 +36,7 @@ def getargspec(obj): elif inspect.ismethod(obj): func_obj = obj.im_func else: - raise TypeError, 'arg is not a Python function' + raise TypeError('arg is not a Python function') args, varargs, varkw = inspect.getargs(func_obj.func_code) return args, varargs, varkw, func_obj.func_defaults diff --git a/IPython/utils/attic.py b/IPython/utils/attic.py index 7b580a8..18d53b0 100644 --- a/IPython/utils/attic.py +++ b/IPython/utils/attic.py @@ -33,8 +33,8 @@ def mutex_opts(dict,ex_op): Call: mutex_opts(dict,[[op1a,op1b],[op2a,op2b]...]""" for op1,op2 in ex_op: if op1 in dict and op2 in dict: - raise ValueError,'\n*** ERROR in Arguments *** '\ - 'Options '+op1+' and '+op2+' are mutually exclusive.' + raise ValueError('\n*** ERROR in Arguments *** '\ + 'Options '+op1+' and '+op2+' are mutually exclusive.') class EvalDict: diff --git a/IPython/utils/coloransi.py b/IPython/utils/coloransi.py index 7997ff1..51267d6 100644 --- a/IPython/utils/coloransi.py +++ b/IPython/utils/coloransi.py @@ -145,7 +145,7 @@ class ColorSchemeTable(dict): if scheme_list: if default_scheme == '': - raise ValueError,'you must specify the default color scheme' + raise ValueError('you must specify the default color scheme') for scheme in scheme_list: self.add_scheme(scheme) self.set_active_scheme(default_scheme) @@ -157,7 +157,7 @@ class ColorSchemeTable(dict): def add_scheme(self,new_scheme): """Add a new color scheme to the table.""" if not isinstance(new_scheme,ColorScheme): - raise ValueError,'ColorSchemeTable only accepts ColorScheme instances' + raise ValueError('ColorSchemeTable only accepts ColorScheme instances') self[new_scheme.name] = new_scheme def set_active_scheme(self,scheme,case_sensitive=0): @@ -176,8 +176,8 @@ class ColorSchemeTable(dict): try: scheme_idx = valid_schemes.index(scheme_test) except ValueError: - raise ValueError,'Unrecognized color scheme: ' + scheme + \ - '\nValid schemes: '+str(scheme_names).replace("'', ",'') + raise ValueError('Unrecognized color scheme: ' + scheme + \ + '\nValid schemes: '+str(scheme_names).replace("'', ",'')) else: active = scheme_names[scheme_idx] self.active_scheme_name = active diff --git a/IPython/utils/path.py b/IPython/utils/path.py index 2fed989..79cff4c 100644 --- a/IPython/utils/path.py +++ b/IPython/utils/path.py @@ -107,7 +107,7 @@ def get_py_filename(name, force_win32=None): if os.path.isfile(name): return name else: - raise IOError,'File `%r` not found.' % name + raise IOError('File `%r` not found.' % name) def filefind(filename, path_dirs=None):