Show More
@@ -244,8 +244,8 b' class DisplayHook(Configurable):' | |||||
244 |
|
244 | |||
245 | def flush(self): |
|
245 | def flush(self): | |
246 | if not self.do_full_cache: |
|
246 | if not self.do_full_cache: | |
247 |
raise ValueError |
|
247 | raise ValueError("You shouldn't have reached the cache flush " | |
248 | "if full caching is not enabled!" |
|
248 | "if full caching is not enabled!") | |
249 | # delete auto-generated vars from global namespace |
|
249 | # delete auto-generated vars from global namespace | |
250 |
|
250 | |||
251 | for n in range(1,self.prompt_count + 1): |
|
251 | for n in range(1,self.prompt_count + 1): |
@@ -906,7 +906,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
906 | def _set_call_pdb(self,val): |
|
906 | def _set_call_pdb(self,val): | |
907 |
|
907 | |||
908 | if val not in (0,1,False,True): |
|
908 | if val not in (0,1,False,True): | |
909 |
raise ValueError |
|
909 | raise ValueError('new call_pdb value must be boolean') | |
910 |
|
910 | |||
911 | # store value in instance |
|
911 | # store value in instance | |
912 | self._call_pdb = val |
|
912 | self._call_pdb = val |
@@ -54,7 +54,7 b' class Logger(object):' | |||||
54 | # logmode is a validated property |
|
54 | # logmode is a validated property | |
55 | def _set_mode(self,mode): |
|
55 | def _set_mode(self,mode): | |
56 | if mode not in ['append','backup','global','over','rotate']: |
|
56 | if mode not in ['append','backup','global','over','rotate']: | |
57 |
raise ValueError |
|
57 | raise ValueError('invalid log mode %s given' % mode) | |
58 | self._logmode = mode |
|
58 | self._logmode = mode | |
59 |
|
59 | |||
60 | def _get_mode(self): |
|
60 | def _get_mode(self): | |
@@ -131,8 +131,8 b' class Logger(object):' | |||||
131 | """Switch logging on/off. val should be ONLY a boolean.""" |
|
131 | """Switch logging on/off. val should be ONLY a boolean.""" | |
132 |
|
132 | |||
133 | if val not in [False,True,0,1]: |
|
133 | if val not in [False,True,0,1]: | |
134 | raise ValueError, \ |
|
134 | raise ValueError('Call switch_log ONLY with a boolean argument, ' | |
135 | 'Call switch_log ONLY with a boolean argument, not with:',val |
|
135 | 'not with: %s' % val) | |
136 |
|
136 | |||
137 | label = {0:'OFF',1:'ON',False:'OFF',True:'ON'} |
|
137 | label = {0:'OFF',1:'ON',False:'OFF',True:'ON'} | |
138 |
|
138 |
@@ -568,7 +568,7 b' class Magics(object):' | |||||
568 |
|
568 | |||
569 | mode = kw.get('mode','string') |
|
569 | mode = kw.get('mode','string') | |
570 | if mode not in ['string','list']: |
|
570 | if mode not in ['string','list']: | |
571 |
raise ValueError |
|
571 | raise ValueError('incorrect mode given: %s' % mode) | |
572 | # Get options |
|
572 | # Get options | |
573 | list_all = kw.get('list_all',0) |
|
573 | list_all = kw.get('list_all',0) | |
574 | posix = kw.get('posix', os.name == 'posix') |
|
574 | posix = kw.get('posix', os.name == 'posix') |
@@ -1103,8 +1103,8 b' class FormattedTB(VerboseTB, ListTB):' | |||||
1103 | len(self.valid_modes) |
|
1103 | len(self.valid_modes) | |
1104 | self.mode = self.valid_modes[new_idx] |
|
1104 | self.mode = self.valid_modes[new_idx] | |
1105 | elif mode not in self.valid_modes: |
|
1105 | elif mode not in self.valid_modes: | |
1106 |
raise ValueError |
|
1106 | raise ValueError('Unrecognized mode in FormattedTB: <'+mode+'>\n' | |
1107 | 'Valid modes: '+str(self.valid_modes) |
|
1107 | 'Valid modes: '+str(self.valid_modes)) | |
1108 | else: |
|
1108 | else: | |
1109 | self.mode = mode |
|
1109 | self.mode = mode | |
1110 | # include variable details only in 'Verbose' mode |
|
1110 | # include variable details only in 'Verbose' mode |
@@ -217,7 +217,7 b' def knownfailureif(fail_condition, msg=None):' | |||||
217 | import nose |
|
217 | import nose | |
218 | def knownfailer(*args, **kwargs): |
|
218 | def knownfailer(*args, **kwargs): | |
219 | if fail_val(): |
|
219 | if fail_val(): | |
220 |
raise KnownFailureTest |
|
220 | raise KnownFailureTest(msg) | |
221 | else: |
|
221 | else: | |
222 | return f(*args, **kwargs) |
|
222 | return f(*args, **kwargs) | |
223 | return nose.tools.make_decorator(f)(knownfailer) |
|
223 | return nose.tools.make_decorator(f)(knownfailer) |
@@ -608,11 +608,11 b' class spawnb(object):' | |||||
608 |
|
608 | |||
609 | parent_fd, child_fd = os.openpty() |
|
609 | parent_fd, child_fd = os.openpty() | |
610 | if parent_fd < 0 or child_fd < 0: |
|
610 | if parent_fd < 0 or child_fd < 0: | |
611 |
raise ExceptionPexpect |
|
611 | raise ExceptionPexpect("Error! Could not open pty with os.openpty().") | |
612 |
|
612 | |||
613 | pid = os.fork() |
|
613 | pid = os.fork() | |
614 | if pid < 0: |
|
614 | if pid < 0: | |
615 |
raise ExceptionPexpect |
|
615 | raise ExceptionPexpect("Error! Failed os.fork().") | |
616 | elif pid == 0: |
|
616 | elif pid == 0: | |
617 | # Child. |
|
617 | # Child. | |
618 | os.close(parent_fd) |
|
618 | os.close(parent_fd) | |
@@ -655,7 +655,7 b' class spawnb(object):' | |||||
655 | fd = os.open("/dev/tty", os.O_RDWR | os.O_NOCTTY); |
|
655 | fd = os.open("/dev/tty", os.O_RDWR | os.O_NOCTTY); | |
656 | if fd >= 0: |
|
656 | if fd >= 0: | |
657 | os.close(fd) |
|
657 | os.close(fd) | |
658 |
raise ExceptionPexpect |
|
658 | raise ExceptionPexpect("Error! Failed to disconnect from controlling tty. It is still possible to open /dev/tty.") | |
659 | except: |
|
659 | except: | |
660 | # Good! We are disconnected from a controlling tty. |
|
660 | # Good! We are disconnected from a controlling tty. | |
661 | pass |
|
661 | pass | |
@@ -663,14 +663,14 b' class spawnb(object):' | |||||
663 | # Verify we can open child pty. |
|
663 | # Verify we can open child pty. | |
664 | fd = os.open(child_name, os.O_RDWR); |
|
664 | fd = os.open(child_name, os.O_RDWR); | |
665 | if fd < 0: |
|
665 | if fd < 0: | |
666 |
raise ExceptionPexpect |
|
666 | raise ExceptionPexpect("Error! Could not open child pty, " + child_name) | |
667 | else: |
|
667 | else: | |
668 | os.close(fd) |
|
668 | os.close(fd) | |
669 |
|
669 | |||
670 | # Verify we now have a controlling tty. |
|
670 | # Verify we now have a controlling tty. | |
671 | fd = os.open("/dev/tty", os.O_WRONLY) |
|
671 | fd = os.open("/dev/tty", os.O_WRONLY) | |
672 | if fd < 0: |
|
672 | if fd < 0: | |
673 |
raise ExceptionPexpect |
|
673 | raise ExceptionPexpect("Error! Could not open controlling tty, /dev/tty") | |
674 | else: |
|
674 | else: | |
675 | os.close(fd) |
|
675 | os.close(fd) | |
676 |
|
676 |
@@ -375,8 +375,7 b' class BackgroundJobBase(threading.Thread):' | |||||
375 | stat_dead_c = -1 |
|
375 | stat_dead_c = -1 | |
376 |
|
376 | |||
377 | def __init__(self): |
|
377 | def __init__(self): | |
378 | raise NotImplementedError, \ |
|
378 | raise NotImplementedError("This class can not be instantiated directly.") | |
379 | "This class can not be instantiated directly." |
|
|||
380 |
|
379 | |||
381 | def _init(self): |
|
380 | def _init(self): | |
382 | """Common initialization for all BackgroundJob objects""" |
|
381 | """Common initialization for all BackgroundJob objects""" |
@@ -36,7 +36,7 b' def getargspec(obj):' | |||||
36 | elif inspect.ismethod(obj): |
|
36 | elif inspect.ismethod(obj): | |
37 | func_obj = obj.im_func |
|
37 | func_obj = obj.im_func | |
38 | else: |
|
38 | else: | |
39 |
raise TypeError |
|
39 | raise TypeError('arg is not a Python function') | |
40 | args, varargs, varkw = inspect.getargs(func_obj.func_code) |
|
40 | args, varargs, varkw = inspect.getargs(func_obj.func_code) | |
41 | return args, varargs, varkw, func_obj.func_defaults |
|
41 | return args, varargs, varkw, func_obj.func_defaults | |
42 |
|
42 |
@@ -33,8 +33,8 b' def mutex_opts(dict,ex_op):' | |||||
33 | Call: mutex_opts(dict,[[op1a,op1b],[op2a,op2b]...]""" |
|
33 | Call: mutex_opts(dict,[[op1a,op1b],[op2a,op2b]...]""" | |
34 | for op1,op2 in ex_op: |
|
34 | for op1,op2 in ex_op: | |
35 | if op1 in dict and op2 in dict: |
|
35 | if op1 in dict and op2 in dict: | |
36 |
raise ValueError |
|
36 | raise ValueError('\n*** ERROR in Arguments *** '\ | |
37 | 'Options '+op1+' and '+op2+' are mutually exclusive.' |
|
37 | 'Options '+op1+' and '+op2+' are mutually exclusive.') | |
38 |
|
38 | |||
39 |
|
39 | |||
40 | class EvalDict: |
|
40 | class EvalDict: |
@@ -145,7 +145,7 b' class ColorSchemeTable(dict):' | |||||
145 |
|
145 | |||
146 | if scheme_list: |
|
146 | if scheme_list: | |
147 | if default_scheme == '': |
|
147 | if default_scheme == '': | |
148 |
raise ValueError |
|
148 | raise ValueError('you must specify the default color scheme') | |
149 | for scheme in scheme_list: |
|
149 | for scheme in scheme_list: | |
150 | self.add_scheme(scheme) |
|
150 | self.add_scheme(scheme) | |
151 | self.set_active_scheme(default_scheme) |
|
151 | self.set_active_scheme(default_scheme) | |
@@ -157,7 +157,7 b' class ColorSchemeTable(dict):' | |||||
157 | def add_scheme(self,new_scheme): |
|
157 | def add_scheme(self,new_scheme): | |
158 | """Add a new color scheme to the table.""" |
|
158 | """Add a new color scheme to the table.""" | |
159 | if not isinstance(new_scheme,ColorScheme): |
|
159 | if not isinstance(new_scheme,ColorScheme): | |
160 |
raise ValueError |
|
160 | raise ValueError('ColorSchemeTable only accepts ColorScheme instances') | |
161 | self[new_scheme.name] = new_scheme |
|
161 | self[new_scheme.name] = new_scheme | |
162 |
|
162 | |||
163 | def set_active_scheme(self,scheme,case_sensitive=0): |
|
163 | def set_active_scheme(self,scheme,case_sensitive=0): | |
@@ -176,8 +176,8 b' class ColorSchemeTable(dict):' | |||||
176 | try: |
|
176 | try: | |
177 | scheme_idx = valid_schemes.index(scheme_test) |
|
177 | scheme_idx = valid_schemes.index(scheme_test) | |
178 | except ValueError: |
|
178 | except ValueError: | |
179 |
raise ValueError |
|
179 | raise ValueError('Unrecognized color scheme: ' + scheme + \ | |
180 | '\nValid schemes: '+str(scheme_names).replace("'', ",'') |
|
180 | '\nValid schemes: '+str(scheme_names).replace("'', ",'')) | |
181 | else: |
|
181 | else: | |
182 | active = scheme_names[scheme_idx] |
|
182 | active = scheme_names[scheme_idx] | |
183 | self.active_scheme_name = active |
|
183 | self.active_scheme_name = active |
@@ -107,7 +107,7 b' def get_py_filename(name, force_win32=None):' | |||||
107 | if os.path.isfile(name): |
|
107 | if os.path.isfile(name): | |
108 | return name |
|
108 | return name | |
109 | else: |
|
109 | else: | |
110 |
raise IOError |
|
110 | raise IOError('File `%r` not found.' % name) | |
111 |
|
111 | |||
112 |
|
112 | |||
113 | def filefind(filename, path_dirs=None): |
|
113 | def filefind(filename, path_dirs=None): |
General Comments 0
You need to be logged in to leave comments.
Login now