Show More
@@ -18,6 +18,7 b' Authors:' | |||||
18 | #----------------------------------------------------------------------------- |
|
18 | #----------------------------------------------------------------------------- | |
19 | # Imports |
|
19 | # Imports | |
20 | #----------------------------------------------------------------------------- |
|
20 | #----------------------------------------------------------------------------- | |
|
21 | from __future__ import print_function | |||
21 |
|
22 | |||
22 | import os |
|
23 | import os | |
23 | import sys |
|
24 | import sys | |
@@ -159,18 +160,18 b' class CrashHandler(object):' | |||||
159 |
|
160 | |||
160 | # print traceback to screen |
|
161 | # print traceback to screen | |
161 | if self.show_crash_traceback: |
|
162 | if self.show_crash_traceback: | |
162 |
print |
|
163 | print(traceback, file=sys.stderr) | |
163 |
|
164 | |||
164 | # and generate a complete report on disk |
|
165 | # and generate a complete report on disk | |
165 | try: |
|
166 | try: | |
166 | report = open(report_name,'w') |
|
167 | report = open(report_name,'w') | |
167 | except: |
|
168 | except: | |
168 |
print |
|
169 | print('Could not create crash report on disk.', file=sys.stderr) | |
169 | return |
|
170 | return | |
170 |
|
171 | |||
171 | # Inform user on stderr of what happened |
|
172 | # Inform user on stderr of what happened | |
172 |
print |
|
173 | print('\n'+'*'*70+'\n', file=sys.stderr) | |
173 |
print |
|
174 | print(self.message_template.format(**self.info), file=sys.stderr) | |
174 |
|
175 | |||
175 | # Construct report on disk |
|
176 | # Construct report on disk | |
176 | report.write(self.make_report(traceback)) |
|
177 | report.write(self.make_report(traceback)) | |
@@ -210,5 +211,5 b' def crash_handler_lite(etype, evalue, tb):' | |||||
210 | else: |
|
211 | else: | |
211 | # we are not in a shell, show generic config |
|
212 | # we are not in a shell, show generic config | |
212 | config = "c." |
|
213 | config = "c." | |
213 |
print |
|
214 | print(_lite_message_template.format(email=author_email, config=config), file=sys.stderr) | |
214 |
|
215 |
@@ -24,6 +24,7 b' http://www.python.org/2.2.3/license.html"""' | |||||
24 | # |
|
24 | # | |
25 | # |
|
25 | # | |
26 | #***************************************************************************** |
|
26 | #***************************************************************************** | |
|
27 | from __future__ import print_function | |||
27 |
|
28 | |||
28 | import bdb |
|
29 | import bdb | |
29 | import linecache |
|
30 | import linecache | |
@@ -46,7 +47,7 b" if '--pydb' in sys.argv:" | |||||
46 | # better protect against it. |
|
47 | # better protect against it. | |
47 | has_pydb = True |
|
48 | has_pydb = True | |
48 | except ImportError: |
|
49 | except ImportError: | |
49 |
print |
|
50 | print("Pydb (http://bashdb.sourceforge.net/pydb/) does not seem to be available") | |
50 |
|
51 | |||
51 | if has_pydb: |
|
52 | if has_pydb: | |
52 | from pydb import Pdb as OldPdb |
|
53 | from pydb import Pdb as OldPdb | |
@@ -60,12 +61,12 b' else:' | |||||
60 | # the Tracer constructor. |
|
61 | # the Tracer constructor. | |
61 | def BdbQuit_excepthook(et,ev,tb): |
|
62 | def BdbQuit_excepthook(et,ev,tb): | |
62 | if et==bdb.BdbQuit: |
|
63 | if et==bdb.BdbQuit: | |
63 |
print |
|
64 | print('Exiting Debugger.') | |
64 | else: |
|
65 | else: | |
65 | BdbQuit_excepthook.excepthook_ori(et,ev,tb) |
|
66 | BdbQuit_excepthook.excepthook_ori(et,ev,tb) | |
66 |
|
67 | |||
67 | def BdbQuit_IPython_excepthook(self,et,ev,tb,tb_offset=None): |
|
68 | def BdbQuit_IPython_excepthook(self,et,ev,tb,tb_offset=None): | |
68 |
print |
|
69 | print('Exiting Debugger.') | |
69 |
|
70 | |||
70 |
|
71 | |||
71 | class Tracer(object): |
|
72 | class Tracer(object): | |
@@ -294,7 +295,7 b' class Pdb(OldPdb):' | |||||
294 | def print_stack_entry(self,frame_lineno,prompt_prefix='\n-> ', |
|
295 | def print_stack_entry(self,frame_lineno,prompt_prefix='\n-> ', | |
295 | context = 3): |
|
296 | context = 3): | |
296 | #frame, lineno = frame_lineno |
|
297 | #frame, lineno = frame_lineno | |
297 |
print |
|
298 | print(self.format_stack_entry(frame_lineno, '', context), file=io.stdout) | |
298 |
|
299 | |||
299 | # vds: >> |
|
300 | # vds: >> | |
300 | frame, lineno = frame_lineno |
|
301 | frame, lineno = frame_lineno | |
@@ -434,7 +435,7 b' class Pdb(OldPdb):' | |||||
434 | src.append(line) |
|
435 | src.append(line) | |
435 | self.lineno = lineno |
|
436 | self.lineno = lineno | |
436 |
|
437 | |||
437 |
print |
|
438 | print(''.join(src), file=io.stdout) | |
438 |
|
439 | |||
439 | except KeyboardInterrupt: |
|
440 | except KeyboardInterrupt: | |
440 | pass |
|
441 | pass | |
@@ -455,7 +456,7 b' class Pdb(OldPdb):' | |||||
455 | else: |
|
456 | else: | |
456 | first = max(1, int(x) - 5) |
|
457 | first = max(1, int(x) - 5) | |
457 | except: |
|
458 | except: | |
458 |
print |
|
459 | print('*** Error in argument:', repr(arg)) | |
459 | return |
|
460 | return | |
460 | elif self.lineno is None: |
|
461 | elif self.lineno is None: | |
461 | first = max(1, self.curframe.f_lineno - 5) |
|
462 | first = max(1, self.curframe.f_lineno - 5) | |
@@ -514,12 +515,12 b' class Pdb(OldPdb):' | |||||
514 | ####################################################################### |
|
515 | ####################################################################### | |
515 |
|
516 | |||
516 | if not line: |
|
517 | if not line: | |
517 |
print |
|
518 | print('End of file', file=self.stdout) | |
518 | return 0 |
|
519 | return 0 | |
519 | line = line.strip() |
|
520 | line = line.strip() | |
520 | # Don't allow setting breakpoint at a blank line |
|
521 | # Don't allow setting breakpoint at a blank line | |
521 | if (not line or (line[0] == '#') or |
|
522 | if (not line or (line[0] == '#') or | |
522 | (line[:3] == '"""') or line[:3] == "'''"): |
|
523 | (line[:3] == '"""') or line[:3] == "'''"): | |
523 |
print |
|
524 | print('*** Blank or comment', file=self.stdout) | |
524 | return 0 |
|
525 | return 0 | |
525 | return lineno |
|
526 | return lineno |
@@ -21,6 +21,7 b' Authors:' | |||||
21 | #----------------------------------------------------------------------------- |
|
21 | #----------------------------------------------------------------------------- | |
22 | # Imports |
|
22 | # Imports | |
23 | #----------------------------------------------------------------------------- |
|
23 | #----------------------------------------------------------------------------- | |
|
24 | from __future__ import print_function | |||
24 |
|
25 | |||
25 | import __builtin__ |
|
26 | import __builtin__ | |
26 |
|
27 | |||
@@ -179,7 +180,7 b' class DisplayHook(Configurable):' | |||||
179 | # But avoid extraneous empty lines. |
|
180 | # But avoid extraneous empty lines. | |
180 | result_repr = '\n' + result_repr |
|
181 | result_repr = '\n' + result_repr | |
181 |
|
182 | |||
182 |
print |
|
183 | print(result_repr, file=io.stdout) | |
183 |
|
184 | |||
184 | def update_user_ns(self, result): |
|
185 | def update_user_ns(self, result): | |
185 | """Update user_ns with various things like _, __, _1, etc.""" |
|
186 | """Update user_ns with various things like _, __, _1, etc.""" | |
@@ -188,7 +189,7 b' class DisplayHook(Configurable):' | |||||
188 | if result is not self.shell.user_ns['_oh']: |
|
189 | if result is not self.shell.user_ns['_oh']: | |
189 | if len(self.shell.user_ns['_oh']) >= self.cache_size and self.do_full_cache: |
|
190 | if len(self.shell.user_ns['_oh']) >= self.cache_size and self.do_full_cache: | |
190 | warn('Output cache limit (currently '+ |
|
191 | warn('Output cache limit (currently '+ | |
191 |
|
|
192 | repr(self.cache_size)+' entries) hit.\n' | |
192 | 'Flushing cache and resetting history counter...\n' |
|
193 | 'Flushing cache and resetting history counter...\n' | |
193 | 'The only history variables available will be _,__,___ and _1\n' |
|
194 | 'The only history variables available will be _,__,___ and _1\n' | |
194 | 'with the current result.') |
|
195 | 'with the current result.') | |
@@ -208,7 +209,7 b' class DisplayHook(Configurable):' | |||||
208 | # hackish access to top-level namespace to create _1,_2... dynamically |
|
209 | # hackish access to top-level namespace to create _1,_2... dynamically | |
209 | to_main = {} |
|
210 | to_main = {} | |
210 | if self.do_full_cache: |
|
211 | if self.do_full_cache: | |
211 |
new_result = '_'+ |
|
212 | new_result = '_'+repr(self.prompt_count) | |
212 | to_main[new_result] = result |
|
213 | to_main[new_result] = result | |
213 | self.shell.push(to_main, interactive=False) |
|
214 | self.shell.push(to_main, interactive=False) | |
214 | self.shell.user_ns['_oh'][self.prompt_count] = result |
|
215 | self.shell.user_ns['_oh'][self.prompt_count] = result | |
@@ -243,12 +244,12 b' class DisplayHook(Configurable):' | |||||
243 |
|
244 | |||
244 | def flush(self): |
|
245 | def flush(self): | |
245 | if not self.do_full_cache: |
|
246 | if not self.do_full_cache: | |
246 |
raise ValueError |
|
247 | raise ValueError("You shouldn't have reached the cache flush " | |
247 | "if full caching is not enabled!" |
|
248 | "if full caching is not enabled!") | |
248 | # delete auto-generated vars from global namespace |
|
249 | # delete auto-generated vars from global namespace | |
249 |
|
250 | |||
250 | for n in range(1,self.prompt_count + 1): |
|
251 | for n in range(1,self.prompt_count + 1): | |
251 |
key = '_'+ |
|
252 | key = '_'+repr(n) | |
252 | try: |
|
253 | try: | |
253 | del self.shell.user_ns[key] |
|
254 | del self.shell.user_ns[key] | |
254 | except: pass |
|
255 | except: pass |
@@ -16,6 +16,7 b'' | |||||
16 |
|
16 | |||
17 | from __future__ import with_statement |
|
17 | from __future__ import with_statement | |
18 | from __future__ import absolute_import |
|
18 | from __future__ import absolute_import | |
|
19 | from __future__ import print_function | |||
19 |
|
20 | |||
20 | import __builtin__ as builtin_mod |
|
21 | import __builtin__ as builtin_mod | |
21 | import __future__ |
|
22 | import __future__ | |
@@ -792,8 +793,8 b' class InteractiveShell(SingletonConfigurable):' | |||||
792 |
|
793 | |||
793 | dp = getattr(self.hooks, name, None) |
|
794 | dp = getattr(self.hooks, name, None) | |
794 | if name not in IPython.core.hooks.__all__: |
|
795 | if name not in IPython.core.hooks.__all__: | |
795 |
print |
|
796 | print("Warning! Hook '%s' is not one of %s" % \ | |
796 | (name, IPython.core.hooks.__all__ ) |
|
797 | (name, IPython.core.hooks.__all__ )) | |
797 | if not dp: |
|
798 | if not dp: | |
798 | dp = IPython.core.hooks.CommandChainDispatcher() |
|
799 | dp = IPython.core.hooks.CommandChainDispatcher() | |
799 |
|
800 | |||
@@ -901,7 +902,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
901 | def _set_call_pdb(self,val): |
|
902 | def _set_call_pdb(self,val): | |
902 |
|
903 | |||
903 | if val not in (0,1,False,True): |
|
904 | if val not in (0,1,False,True): | |
904 |
raise ValueError |
|
905 | raise ValueError('new call_pdb value must be boolean') | |
905 |
|
906 | |||
906 | # store value in instance |
|
907 | # store value in instance | |
907 | self._call_pdb = val |
|
908 | self._call_pdb = val | |
@@ -1314,7 +1315,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
1314 | try: |
|
1315 | try: | |
1315 | vdict[name] = eval(name, cf.f_globals, cf.f_locals) |
|
1316 | vdict[name] = eval(name, cf.f_globals, cf.f_locals) | |
1316 | except: |
|
1317 | except: | |
1317 |
print |
|
1318 | print('Could not get variable %s from %s' % | |
1318 | (name,cf.f_code.co_name)) |
|
1319 | (name,cf.f_code.co_name)) | |
1319 | else: |
|
1320 | else: | |
1320 | raise ValueError('variables must be a dict/str/list/tuple') |
|
1321 | raise ValueError('variables must be a dict/str/list/tuple') | |
@@ -1489,7 +1490,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
1489 | else: |
|
1490 | else: | |
1490 | pmethod(info.obj, oname) |
|
1491 | pmethod(info.obj, oname) | |
1491 | else: |
|
1492 | else: | |
1492 |
print |
|
1493 | print('Object `%s` not found.' % oname) | |
1493 | return 'not found' # so callers can take other action |
|
1494 | return 'not found' # so callers can take other action | |
1494 |
|
1495 | |||
1495 | def object_inspect(self, oname, detail_level=0): |
|
1496 | def object_inspect(self, oname, detail_level=0): | |
@@ -1583,10 +1584,10 b' class InteractiveShell(SingletonConfigurable):' | |||||
1583 | "The custom exceptions must be given AS A TUPLE." |
|
1584 | "The custom exceptions must be given AS A TUPLE." | |
1584 |
|
1585 | |||
1585 | def dummy_handler(self,etype,value,tb,tb_offset=None): |
|
1586 | def dummy_handler(self,etype,value,tb,tb_offset=None): | |
1586 |
print |
|
1587 | print('*** Simple custom exception handler ***') | |
1587 |
print |
|
1588 | print('Exception type :',etype) | |
1588 |
print |
|
1589 | print('Exception value:',value) | |
1589 |
print |
|
1590 | print('Traceback :',tb) | |
1590 | #print 'Source code :','\n'.join(self.buffer) |
|
1591 | #print 'Source code :','\n'.join(self.buffer) | |
1591 |
|
1592 | |||
1592 | def validate_stb(stb): |
|
1593 | def validate_stb(stb): | |
@@ -1627,11 +1628,11 b' class InteractiveShell(SingletonConfigurable):' | |||||
1627 | except: |
|
1628 | except: | |
1628 | # clear custom handler immediately |
|
1629 | # clear custom handler immediately | |
1629 | self.set_custom_exc((), None) |
|
1630 | self.set_custom_exc((), None) | |
1630 |
print |
|
1631 | print("Custom TB Handler failed, unregistering", file=io.stderr) | |
1631 | # show the exception in handler first |
|
1632 | # show the exception in handler first | |
1632 | stb = self.InteractiveTB.structured_traceback(*sys.exc_info()) |
|
1633 | stb = self.InteractiveTB.structured_traceback(*sys.exc_info()) | |
1633 |
print |
|
1634 | print(self.InteractiveTB.stb2text(stb), file=io.stdout) | |
1634 |
print |
|
1635 | print("The original exception:", file=io.stdout) | |
1635 | stb = self.InteractiveTB.structured_traceback( |
|
1636 | stb = self.InteractiveTB.structured_traceback( | |
1636 | (etype,value,tb), tb_offset=tb_offset |
|
1637 | (etype,value,tb), tb_offset=tb_offset | |
1637 | ) |
|
1638 | ) | |
@@ -1755,7 +1756,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
1755 | Subclasses may override this method to put the traceback on a different |
|
1756 | Subclasses may override this method to put the traceback on a different | |
1756 | place, like a side channel. |
|
1757 | place, like a side channel. | |
1757 | """ |
|
1758 | """ | |
1758 |
print |
|
1759 | print(self.InteractiveTB.stb2text(stb), file=io.stdout) | |
1759 |
|
1760 | |||
1760 | def showsyntaxerror(self, filename=None): |
|
1761 | def showsyntaxerror(self, filename=None): | |
1761 | """Display the syntax error that just occurred. |
|
1762 | """Display the syntax error that just occurred. | |
@@ -2331,9 +2332,9 b' class InteractiveShell(SingletonConfigurable):' | |||||
2331 | # plain ascii works better w/ pyreadline, on some machines, so |
|
2332 | # plain ascii works better w/ pyreadline, on some machines, so | |
2332 | # we use it and only print uncolored rewrite if we have unicode |
|
2333 | # we use it and only print uncolored rewrite if we have unicode | |
2333 | rw = str(rw) |
|
2334 | rw = str(rw) | |
2334 |
print |
|
2335 | print(rw, file=io.stdout) | |
2335 | except UnicodeEncodeError: |
|
2336 | except UnicodeEncodeError: | |
2336 |
print |
|
2337 | print("------> " + cmd) | |
2337 |
|
2338 | |||
2338 | #------------------------------------------------------------------------- |
|
2339 | #------------------------------------------------------------------------- | |
2339 | # Things related to extracting values/expressions from kernel and user_ns |
|
2340 | # Things related to extracting values/expressions from kernel and user_ns | |
@@ -2622,17 +2623,17 b' class InteractiveShell(SingletonConfigurable):' | |||||
2622 | try: |
|
2623 | try: | |
2623 | func() |
|
2624 | func() | |
2624 | except KeyboardInterrupt: |
|
2625 | except KeyboardInterrupt: | |
2625 |
print |
|
2626 | print("\nKeyboardInterrupt", file=io.stderr) | |
2626 | except Exception: |
|
2627 | except Exception: | |
2627 | # register as failing: |
|
2628 | # register as failing: | |
2628 | self._post_execute[func] = False |
|
2629 | self._post_execute[func] = False | |
2629 | self.showtraceback() |
|
2630 | self.showtraceback() | |
2630 |
print |
|
2631 | print('\n'.join([ | |
2631 | "post-execution function %r produced an error." % func, |
|
2632 | "post-execution function %r produced an error." % func, | |
2632 | "If this problem persists, you can disable failing post-exec functions with:", |
|
2633 | "If this problem persists, you can disable failing post-exec functions with:", | |
2633 | "", |
|
2634 | "", | |
2634 | " get_ipython().disable_failing_post_execute = True" |
|
2635 | " get_ipython().disable_failing_post_execute = True" | |
2635 | ]) |
|
2636 | ]), file=io.stderr) | |
2636 |
|
2637 | |||
2637 | if store_history: |
|
2638 | if store_history: | |
2638 | # Write output to the database. Does nothing unless |
|
2639 | # Write output to the database. Does nothing unless | |
@@ -2694,7 +2695,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
2694 |
|
2695 | |||
2695 | # Flush softspace |
|
2696 | # Flush softspace | |
2696 | if softspace(sys.stdout, 0): |
|
2697 | if softspace(sys.stdout, 0): | |
2697 |
|
2698 | print() | ||
2698 |
|
2699 | |||
2699 | except: |
|
2700 | except: | |
2700 | # It's possible to have exceptions raised here, typically by |
|
2701 | # It's possible to have exceptions raised here, typically by |
@@ -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): | |
@@ -117,7 +117,7 b' class Logger(object):' | |||||
117 | for f in old: |
|
117 | for f in old: | |
118 | root, ext = os.path.splitext(f) |
|
118 | root, ext = os.path.splitext(f) | |
119 | num = int(ext[1:-1])+1 |
|
119 | num = int(ext[1:-1])+1 | |
120 |
os.rename(f, root+'.'+ |
|
120 | os.rename(f, root+'.'+repr(num).zfill(3)+'~') | |
121 | os.rename(self.logfname, self.logfname+'.001~') |
|
121 | os.rename(self.logfname, self.logfname+'.001~') | |
122 | self.logfile = io.open(self.logfname, 'w', encoding='utf-8') |
|
122 | self.logfile = io.open(self.logfname, 'w', encoding='utf-8') | |
123 |
|
123 | |||
@@ -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') |
@@ -254,14 +254,14 b' python-profiler package from non-free.""")' | |||||
254 | dump_file = unquote_filename(dump_file) |
|
254 | dump_file = unquote_filename(dump_file) | |
255 | prof.dump_stats(dump_file) |
|
255 | prof.dump_stats(dump_file) | |
256 | print '\n*** Profile stats marshalled to file',\ |
|
256 | print '\n*** Profile stats marshalled to file',\ | |
257 |
|
|
257 | repr(dump_file)+'.',sys_exit | |
258 | if text_file: |
|
258 | if text_file: | |
259 | text_file = unquote_filename(text_file) |
|
259 | text_file = unquote_filename(text_file) | |
260 | pfile = open(text_file,'w') |
|
260 | pfile = open(text_file,'w') | |
261 | pfile.write(output) |
|
261 | pfile.write(output) | |
262 | pfile.close() |
|
262 | pfile.close() | |
263 | print '\n*** Profile printout saved to text file',\ |
|
263 | print '\n*** Profile printout saved to text file',\ | |
264 |
|
|
264 | repr(text_file)+'.',sys_exit | |
265 |
|
265 | |||
266 | if opts.has_key('r'): |
|
266 | if opts.has_key('r'): | |
267 | return stats |
|
267 | return stats |
@@ -13,6 +13,7 b' reference the name under which an object is being read.' | |||||
13 | # Distributed under the terms of the BSD License. The full license is in |
|
13 | # Distributed under the terms of the BSD License. The full license is in | |
14 | # the file COPYING, distributed as part of this software. |
|
14 | # the file COPYING, distributed as part of this software. | |
15 | #***************************************************************************** |
|
15 | #***************************************************************************** | |
|
16 | from __future__ import print_function | |||
16 |
|
17 | |||
17 | __all__ = ['Inspector','InspectColors'] |
|
18 | __all__ = ['Inspector','InspectColors'] | |
18 |
|
19 | |||
@@ -335,11 +336,11 b' class Inspector:' | |||||
335 |
|
336 | |||
336 | def noinfo(self, msg, oname): |
|
337 | def noinfo(self, msg, oname): | |
337 | """Generic message when no information is found.""" |
|
338 | """Generic message when no information is found.""" | |
338 |
print |
|
339 | print('No %s found' % msg, end=' ') | |
339 | if oname: |
|
340 | if oname: | |
340 |
print |
|
341 | print('for %s' % oname) | |
341 | else: |
|
342 | else: | |
342 |
|
343 | print() | ||
343 |
|
344 | |||
344 | def pdef(self, obj, oname=''): |
|
345 | def pdef(self, obj, oname=''): | |
345 | """Print the definition header for any callable object. |
|
346 | """Print the definition header for any callable object. | |
@@ -347,7 +348,7 b' class Inspector:' | |||||
347 | If the object is a class, print the constructor information.""" |
|
348 | If the object is a class, print the constructor information.""" | |
348 |
|
349 | |||
349 | if not callable(obj): |
|
350 | if not callable(obj): | |
350 |
print |
|
351 | print('Object is not callable.') | |
351 | return |
|
352 | return | |
352 |
|
353 | |||
353 | header = '' |
|
354 | header = '' | |
@@ -362,7 +363,7 b' class Inspector:' | |||||
362 | if output is None: |
|
363 | if output is None: | |
363 | self.noinfo('definition header',oname) |
|
364 | self.noinfo('definition header',oname) | |
364 | else: |
|
365 | else: | |
365 |
print |
|
366 | print(header,self.format(output), end=' ', file=io.stdout) | |
366 |
|
367 | |||
367 | # In Python 3, all classes are new-style, so they all have __init__. |
|
368 | # In Python 3, all classes are new-style, so they all have __init__. | |
368 | @skip_doctest_py3 |
|
369 | @skip_doctest_py3 | |
@@ -449,9 +450,9 b' class Inspector:' | |||||
449 | # is defined, as long as the file isn't binary and is actually on the |
|
450 | # is defined, as long as the file isn't binary and is actually on the | |
450 | # filesystem. |
|
451 | # filesystem. | |
451 | if ofile.endswith(('.so', '.dll', '.pyd')): |
|
452 | if ofile.endswith(('.so', '.dll', '.pyd')): | |
452 |
print |
|
453 | print('File %r is binary, not printing.' % ofile) | |
453 | elif not os.path.isfile(ofile): |
|
454 | elif not os.path.isfile(ofile): | |
454 |
print |
|
455 | print('File %r does not exist, not printing.' % ofile) | |
455 | else: |
|
456 | else: | |
456 | # Print only text files, not extension binaries. Note that |
|
457 | # Print only text files, not extension binaries. Note that | |
457 | # getsourcelines returns lineno with 1-offset and page() uses |
|
458 | # getsourcelines returns lineno with 1-offset and page() uses |
@@ -25,6 +25,7 b' rid of that dependency, we could move it there.' | |||||
25 | #----------------------------------------------------------------------------- |
|
25 | #----------------------------------------------------------------------------- | |
26 | # Imports |
|
26 | # Imports | |
27 | #----------------------------------------------------------------------------- |
|
27 | #----------------------------------------------------------------------------- | |
|
28 | from __future__ import print_function | |||
28 |
|
29 | |||
29 | import os |
|
30 | import os | |
30 | import re |
|
31 | import re | |
@@ -57,18 +58,18 b' def page_dumb(strng, start=0, screen_lines=25):' | |||||
57 | out_ln = strng.splitlines()[start:] |
|
58 | out_ln = strng.splitlines()[start:] | |
58 | screens = chop(out_ln,screen_lines-1) |
|
59 | screens = chop(out_ln,screen_lines-1) | |
59 | if len(screens) == 1: |
|
60 | if len(screens) == 1: | |
60 |
print |
|
61 | print(os.linesep.join(screens[0]), file=io.stdout) | |
61 | else: |
|
62 | else: | |
62 | last_escape = "" |
|
63 | last_escape = "" | |
63 | for scr in screens[0:-1]: |
|
64 | for scr in screens[0:-1]: | |
64 | hunk = os.linesep.join(scr) |
|
65 | hunk = os.linesep.join(scr) | |
65 |
print |
|
66 | print(last_escape + hunk, file=io.stdout) | |
66 | if not page_more(): |
|
67 | if not page_more(): | |
67 | return |
|
68 | return | |
68 | esc_list = esc_re.findall(hunk) |
|
69 | esc_list = esc_re.findall(hunk) | |
69 | if len(esc_list) > 0: |
|
70 | if len(esc_list) > 0: | |
70 | last_escape = esc_list[-1] |
|
71 | last_escape = esc_list[-1] | |
71 |
print |
|
72 | print(last_escape + os.linesep.join(screens[-1]), file=io.stdout) | |
72 |
|
73 | |||
73 | def _detect_screen_size(use_curses, screen_lines_def): |
|
74 | def _detect_screen_size(use_curses, screen_lines_def): | |
74 | """Attempt to work out the number of lines on the screen. |
|
75 | """Attempt to work out the number of lines on the screen. | |
@@ -163,7 +164,7 b' def page(strng, start=0, screen_lines=0, pager_cmd=None):' | |||||
163 | # Ugly kludge, but calling curses.initscr() flat out crashes in emacs |
|
164 | # Ugly kludge, but calling curses.initscr() flat out crashes in emacs | |
164 | TERM = os.environ.get('TERM','dumb') |
|
165 | TERM = os.environ.get('TERM','dumb') | |
165 | if TERM in ['dumb','emacs'] and os.name != 'nt': |
|
166 | if TERM in ['dumb','emacs'] and os.name != 'nt': | |
166 |
print |
|
167 | print(strng) | |
167 | return |
|
168 | return | |
168 | # chop off the topmost part of the string we don't want to see |
|
169 | # chop off the topmost part of the string we don't want to see | |
169 | str_lines = strng.splitlines()[start:] |
|
170 | str_lines = strng.splitlines()[start:] | |
@@ -183,13 +184,13 b' def page(strng, start=0, screen_lines=0, pager_cmd=None):' | |||||
183 | try: |
|
184 | try: | |
184 | screen_lines += _detect_screen_size(use_curses, screen_lines_def) |
|
185 | screen_lines += _detect_screen_size(use_curses, screen_lines_def) | |
185 | except (TypeError, UnsupportedOperation): |
|
186 | except (TypeError, UnsupportedOperation): | |
186 |
print |
|
187 | print(str_toprint, file=io.stdout) | |
187 | return |
|
188 | return | |
188 |
|
189 | |||
189 | #print 'numlines',numlines,'screenlines',screen_lines # dbg |
|
190 | #print 'numlines',numlines,'screenlines',screen_lines # dbg | |
190 | if numlines <= screen_lines : |
|
191 | if numlines <= screen_lines : | |
191 | #print '*** normal print' # dbg |
|
192 | #print '*** normal print' # dbg | |
192 |
print |
|
193 | print(str_toprint, file=io.stdout) | |
193 | else: |
|
194 | else: | |
194 | # Try to open pager and default to internal one if that fails. |
|
195 | # Try to open pager and default to internal one if that fails. | |
195 | # All failure modes are tagged as 'retval=1', to match the return |
|
196 | # All failure modes are tagged as 'retval=1', to match the return | |
@@ -250,7 +251,7 b' def page_file(fname, start=0, pager_cmd=None):' | |||||
250 | start -= 1 |
|
251 | start -= 1 | |
251 | page(open(fname).read(),start) |
|
252 | page(open(fname).read(),start) | |
252 | except: |
|
253 | except: | |
253 |
print |
|
254 | print('Unable to show file',repr(fname)) | |
254 |
|
255 | |||
255 |
|
256 | |||
256 | def get_pager_cmd(pager_cmd=None): |
|
257 | def get_pager_cmd(pager_cmd=None): | |
@@ -325,13 +326,13 b" def snip_print(str,width = 75,print_full = 0,header = ''):" | |||||
325 | page(header+str) |
|
326 | page(header+str) | |
326 | return 0 |
|
327 | return 0 | |
327 |
|
328 | |||
328 |
print |
|
329 | print(header, end=' ') | |
329 | if len(str) < width: |
|
330 | if len(str) < width: | |
330 |
print |
|
331 | print(str) | |
331 | snip = 0 |
|
332 | snip = 0 | |
332 | else: |
|
333 | else: | |
333 | whalf = int((width -5)/2) |
|
334 | whalf = int((width -5)/2) | |
334 |
print |
|
335 | print(str[:whalf] + ' <...> ' + str[-whalf:]) | |
335 | snip = 1 |
|
336 | snip = 1 | |
336 | if snip and print_full == 2: |
|
337 | if snip and print_full == 2: | |
337 | if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y': |
|
338 | if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y': |
@@ -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 | |
@@ -1231,7 +1231,7 b' if __name__ == "__main__":' | |||||
1231 | try: |
|
1231 | try: | |
1232 | print spam(1, (2, 3)) |
|
1232 | print spam(1, (2, 3)) | |
1233 | except: |
|
1233 | except: | |
1234 |
|
|
1234 | handler(*sys.exc_info()) | |
1235 | print '' |
|
1235 | print '' | |
1236 |
|
1236 | |||
1237 | handler = VerboseTB() |
|
1237 | handler = VerboseTB() | |
@@ -1239,6 +1239,6 b' if __name__ == "__main__":' | |||||
1239 | try: |
|
1239 | try: | |
1240 | print spam(1, (2, 3)) |
|
1240 | print spam(1, (2, 3)) | |
1241 | except: |
|
1241 | except: | |
1242 |
|
|
1242 | handler(*sys.exc_info()) | |
1243 | print '' |
|
1243 | print '' | |
1244 |
|
1244 |
@@ -87,6 +87,7 b' Some of the known remaining caveats are:' | |||||
87 |
|
87 | |||
88 | - C extension modules cannot be reloaded, and so cannot be autoreloaded. |
|
88 | - C extension modules cannot be reloaded, and so cannot be autoreloaded. | |
89 | """ |
|
89 | """ | |
|
90 | from __future__ import print_function | |||
90 |
|
91 | |||
91 | skip_doctest = True |
|
92 | skip_doctest = True | |
92 |
|
93 | |||
@@ -244,8 +245,8 b' class ModuleReloader(object):' | |||||
244 | if py_filename in self.failed: |
|
245 | if py_filename in self.failed: | |
245 | del self.failed[py_filename] |
|
246 | del self.failed[py_filename] | |
246 | except: |
|
247 | except: | |
247 |
print |
|
248 | print("[autoreload of %s failed: %s]" % ( | |
248 | modname, traceback.format_exc(1)) |
|
249 | modname, traceback.format_exc(1)), file=sys.stderr) | |
249 | self.failed[py_filename] = pymtime |
|
250 | self.failed[py_filename] = pymtime | |
250 |
|
251 | |||
251 | #------------------------------------------------------------------------------ |
|
252 | #------------------------------------------------------------------------------ |
@@ -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 |
@@ -13,6 +13,7 b'' | |||||
13 | #----------------------------------------------------------------------------- |
|
13 | #----------------------------------------------------------------------------- | |
14 | # Imports |
|
14 | # Imports | |
15 | #----------------------------------------------------------------------------- |
|
15 | #----------------------------------------------------------------------------- | |
|
16 | from __future__ import print_function | |||
16 |
|
17 | |||
17 | import bdb |
|
18 | import bdb | |
18 | import os |
|
19 | import os | |
@@ -59,8 +60,8 b' def get_default_editor():' | |||||
59 | def get_pasted_lines(sentinel, l_input=py3compat.input): |
|
60 | def get_pasted_lines(sentinel, l_input=py3compat.input): | |
60 | """ Yield pasted lines until the user enters the given sentinel value. |
|
61 | """ Yield pasted lines until the user enters the given sentinel value. | |
61 | """ |
|
62 | """ | |
62 |
print |
|
63 | print("Pasting code; enter '%s' alone on the line to stop or use Ctrl-D." \ | |
63 | % sentinel |
|
64 | % sentinel) | |
64 | while True: |
|
65 | while True: | |
65 | try: |
|
66 | try: | |
66 | l = l_input(':') |
|
67 | l = l_input(':') | |
@@ -69,7 +70,7 b' def get_pasted_lines(sentinel, l_input=py3compat.input):' | |||||
69 | else: |
|
70 | else: | |
70 | yield l |
|
71 | yield l | |
71 | except EOFError: |
|
72 | except EOFError: | |
72 |
print |
|
73 | print('<EOF>') | |
73 | return |
|
74 | return | |
74 |
|
75 | |||
75 |
|
76 | |||
@@ -153,7 +154,7 b' class TerminalMagics(Magics):' | |||||
153 | if name: |
|
154 | if name: | |
154 | # If storing it for further editing |
|
155 | # If storing it for further editing | |
155 | self.shell.user_ns[name] = SList(b.splitlines()) |
|
156 | self.shell.user_ns[name] = SList(b.splitlines()) | |
156 |
print |
|
157 | print("Block assigned to '%s'" % name) | |
157 | else: |
|
158 | else: | |
158 | self.shell.user_ns['pasted_block'] = b |
|
159 | self.shell.user_ns['pasted_block'] = b | |
159 | self.shell.run_cell(b) |
|
160 | self.shell.run_cell(b) | |
@@ -170,7 +171,7 b' class TerminalMagics(Magics):' | |||||
170 | raise UsageError( |
|
171 | raise UsageError( | |
171 | "Variable 'pasted_block' is not a string, can't execute") |
|
172 | "Variable 'pasted_block' is not a string, can't execute") | |
172 |
|
173 | |||
173 |
print |
|
174 | print("Re-executing '%s...' (%d chars)"% (b.split('\n',1)[0], len(b))) | |
174 | self.shell.run_cell(b) |
|
175 | self.shell.run_cell(b) | |
175 |
|
176 | |||
176 | @line_magic |
|
177 | @line_magic | |
@@ -178,7 +179,7 b' class TerminalMagics(Magics):' | |||||
178 | """Toggle autoindent on/off (if available).""" |
|
179 | """Toggle autoindent on/off (if available).""" | |
179 |
|
180 | |||
180 | self.shell.set_autoindent() |
|
181 | self.shell.set_autoindent() | |
181 |
print |
|
182 | print("Automatic indentation is:",['OFF','ON'][self.shell.autoindent]) | |
182 |
|
183 | |||
183 | @skip_doctest |
|
184 | @skip_doctest | |
184 | @line_magic |
|
185 | @line_magic |
@@ -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""" |
@@ -168,6 +168,7 b" print 'bye!'" | |||||
168 | # the file COPYING, distributed as part of this software. |
|
168 | # the file COPYING, distributed as part of this software. | |
169 | # |
|
169 | # | |
170 | #***************************************************************************** |
|
170 | #***************************************************************************** | |
|
171 | from __future__ import print_function | |||
171 |
|
172 | |||
172 | import os |
|
173 | import os | |
173 | import re |
|
174 | import re | |
@@ -318,7 +319,7 b' class Demo(object):' | |||||
318 |
|
319 | |||
319 | if index is None: |
|
320 | if index is None: | |
320 | if self.finished: |
|
321 | if self.finished: | |
321 |
print |
|
322 | print('Demo finished. Use <demo_name>.reset() if you want to rerun it.', file=io.stdout) | |
322 | return None |
|
323 | return None | |
323 | index = self.block_index |
|
324 | index = self.block_index | |
324 | else: |
|
325 | else: | |
@@ -387,9 +388,9 b' class Demo(object):' | |||||
387 | if index is None: |
|
388 | if index is None: | |
388 | return |
|
389 | return | |
389 |
|
390 | |||
390 |
print |
|
391 | print(self.marquee('<%s> block # %s (%s remaining)' % | |
391 | (self.title,index,self.nblocks-index-1)) |
|
392 | (self.title,index,self.nblocks-index-1)), file=io.stdout) | |
392 |
print |
|
393 | print((self.src_blocks_colored[index]), file=io.stdout) | |
393 | sys.stdout.flush() |
|
394 | sys.stdout.flush() | |
394 |
|
395 | |||
395 | def show_all(self): |
|
396 | def show_all(self): | |
@@ -402,12 +403,12 b' class Demo(object):' | |||||
402 | marquee = self.marquee |
|
403 | marquee = self.marquee | |
403 | for index,block in enumerate(self.src_blocks_colored): |
|
404 | for index,block in enumerate(self.src_blocks_colored): | |
404 | if silent[index]: |
|
405 | if silent[index]: | |
405 |
print |
|
406 | print(marquee('<%s> SILENT block # %s (%s remaining)' % | |
406 | (title,index,nblocks-index-1)) |
|
407 | (title,index,nblocks-index-1)), file=io.stdout) | |
407 | else: |
|
408 | else: | |
408 |
print |
|
409 | print(marquee('<%s> block # %s (%s remaining)' % | |
409 | (title,index,nblocks-index-1)) |
|
410 | (title,index,nblocks-index-1)), file=io.stdout) | |
410 |
print |
|
411 | print(block, end=' ', file=io.stdout) | |
411 | sys.stdout.flush() |
|
412 | sys.stdout.flush() | |
412 |
|
413 | |||
413 | def run_cell(self,source): |
|
414 | def run_cell(self,source): | |
@@ -432,18 +433,18 b' class Demo(object):' | |||||
432 | next_block = self.src_blocks[index] |
|
433 | next_block = self.src_blocks[index] | |
433 | self.block_index += 1 |
|
434 | self.block_index += 1 | |
434 | if self._silent[index]: |
|
435 | if self._silent[index]: | |
435 |
print |
|
436 | print(marquee('Executing silent block # %s (%s remaining)' % | |
436 | (index,self.nblocks-index-1)) |
|
437 | (index,self.nblocks-index-1)), file=io.stdout) | |
437 | else: |
|
438 | else: | |
438 | self.pre_cmd() |
|
439 | self.pre_cmd() | |
439 | self.show(index) |
|
440 | self.show(index) | |
440 | if self.auto_all or self._auto[index]: |
|
441 | if self.auto_all or self._auto[index]: | |
441 |
print |
|
442 | print(marquee('output:'), file=io.stdout) | |
442 | else: |
|
443 | else: | |
443 |
print |
|
444 | print(marquee('Press <q> to quit, <Enter> to execute...'), end=' ', file=io.stdout) | |
444 | ans = raw_input().strip() |
|
445 | ans = raw_input().strip() | |
445 | if ans: |
|
446 | if ans: | |
446 |
print |
|
447 | print(marquee('Block NOT executed'), file=io.stdout) | |
447 | return |
|
448 | return | |
448 | try: |
|
449 | try: | |
449 | save_argv = sys.argv |
|
450 | save_argv = sys.argv | |
@@ -462,9 +463,9 b' class Demo(object):' | |||||
462 | mq1 = self.marquee('END OF DEMO') |
|
463 | mq1 = self.marquee('END OF DEMO') | |
463 | if mq1: |
|
464 | if mq1: | |
464 | # avoid spurious print >>io.stdout,s if empty marquees are used |
|
465 | # avoid spurious print >>io.stdout,s if empty marquees are used | |
465 |
print |
|
466 | print(file=io.stdout) | |
466 |
print |
|
467 | print(mq1, file=io.stdout) | |
467 |
print |
|
468 | print(self.marquee('Use <demo_name>.reset() if you want to rerun it.'), file=io.stdout) | |
468 | self.finished = True |
|
469 | self.finished = True | |
469 |
|
470 | |||
470 | # These methods are meant to be overridden by subclasses who may wish to |
|
471 | # These methods are meant to be overridden by subclasses who may wish to |
@@ -29,6 +29,7 b' NOTES:' | |||||
29 | - Because pexpect only works under Unix or Windows-Cygwin, this has the same |
|
29 | - Because pexpect only works under Unix or Windows-Cygwin, this has the same | |
30 | limitations. This means that it will NOT work under native windows Python. |
|
30 | limitations. This means that it will NOT work under native windows Python. | |
31 | """ |
|
31 | """ | |
|
32 | from __future__ import print_function | |||
32 |
|
33 | |||
33 | # Stdlib imports |
|
34 | # Stdlib imports | |
34 | import optparse |
|
35 | import optparse | |
@@ -248,7 +249,7 b' class InteractiveRunner(object):' | |||||
248 | if end_normal: |
|
249 | if end_normal: | |
249 | if interact: |
|
250 | if interact: | |
250 | c.send('\n') |
|
251 | c.send('\n') | |
251 |
print |
|
252 | print('<< Starting interactive mode >>', end=' ') | |
252 | try: |
|
253 | try: | |
253 | c.interact() |
|
254 | c.interact() | |
254 | except OSError: |
|
255 | except OSError: | |
@@ -261,7 +262,7 b' class InteractiveRunner(object):' | |||||
261 | else: |
|
262 | else: | |
262 | if interact: |
|
263 | if interact: | |
263 | e="Further interaction is not possible: child process is dead." |
|
264 | e="Further interaction is not possible: child process is dead." | |
264 |
print |
|
265 | print(e, file=sys.stderr) | |
265 |
|
266 | |||
266 | # Leave the child ready for more input later on, otherwise select just |
|
267 | # Leave the child ready for more input later on, otherwise select just | |
267 | # hangs on the second invocation. |
|
268 | # hangs on the second invocation. | |
@@ -283,7 +284,7 b' class InteractiveRunner(object):' | |||||
283 | opts,args = parser.parse_args(argv) |
|
284 | opts,args = parser.parse_args(argv) | |
284 |
|
285 | |||
285 | if len(args) != 1: |
|
286 | if len(args) != 1: | |
286 |
print |
|
287 | print("You must supply exactly one file to run.", file=sys.stderr) | |
287 | sys.exit(1) |
|
288 | sys.exit(1) | |
288 |
|
289 | |||
289 | self.run_file(args[0],opts.interact) |
|
290 | self.run_file(args[0],opts.interact) |
@@ -2,6 +2,7 b'' | |||||
2 |
|
2 | |||
3 | Not the most elegant or fine-grained, but it does cover at least the bulk |
|
3 | Not the most elegant or fine-grained, but it does cover at least the bulk | |
4 | functionality.""" |
|
4 | functionality.""" | |
|
5 | from __future__ import print_function | |||
5 |
|
6 | |||
6 | # Global to make tests extra verbose and help debugging |
|
7 | # Global to make tests extra verbose and help debugging | |
7 | VERBOSE = True |
|
8 | VERBOSE = True | |
@@ -50,10 +51,10 b' class RunnerTestCase(unittest.TestCase):' | |||||
50 | if ol1 != ol2: |
|
51 | if ol1 != ol2: | |
51 | mismatch += 1 |
|
52 | mismatch += 1 | |
52 | if VERBOSE: |
|
53 | if VERBOSE: | |
53 |
print |
|
54 | print('<<< line %s does not match:' % n) | |
54 |
print |
|
55 | print(repr(ol1)) | |
55 |
print |
|
56 | print(repr(ol2)) | |
56 |
print |
|
57 | print('>>>') | |
57 | self.assert_(mismatch==0,'Number of mismatched lines: %s' % |
|
58 | self.assert_(mismatch==0,'Number of mismatched lines: %s' % | |
58 | mismatch) |
|
59 | mismatch) | |
59 |
|
60 |
@@ -1,6 +1,7 b'' | |||||
1 | """Test suite for pylab_import_all magic |
|
1 | """Test suite for pylab_import_all magic | |
2 | Modified from the irunner module but using regex. |
|
2 | Modified from the irunner module but using regex. | |
3 | """ |
|
3 | """ | |
|
4 | from __future__ import print_function | |||
4 |
|
5 | |||
5 | # Global to make tests extra verbose and help debugging |
|
6 | # Global to make tests extra verbose and help debugging | |
6 | VERBOSE = True |
|
7 | VERBOSE = True | |
@@ -58,10 +59,10 b' class RunnerTestCase(unittest.TestCase):' | |||||
58 | if not re.match(ol1,ol2): |
|
59 | if not re.match(ol1,ol2): | |
59 | mismatch += 1 |
|
60 | mismatch += 1 | |
60 | if VERBOSE: |
|
61 | if VERBOSE: | |
61 |
print |
|
62 | print('<<< line %s does not match:' % n) | |
62 |
print |
|
63 | print(repr(ol1)) | |
63 |
print |
|
64 | print(repr(ol2)) | |
64 |
print |
|
65 | print('>>>') | |
65 | self.assert_(mismatch==0,'Number of mismatched lines: %s' % |
|
66 | self.assert_(mismatch==0,'Number of mismatched lines: %s' % | |
66 | mismatch) |
|
67 | mismatch) | |
67 |
|
68 |
@@ -11,6 +11,7 b' Authors:' | |||||
11 | # Distributed under the terms of the BSD License. The full license is in |
|
11 | # Distributed under the terms of the BSD License. The full license is in | |
12 | # the file COPYING, distributed as part of this software. |
|
12 | # the file COPYING, distributed as part of this software. | |
13 | #------------------------------------------------------------------------------- |
|
13 | #------------------------------------------------------------------------------- | |
|
14 | from __future__ import print_function | |||
14 |
|
15 | |||
15 | import sys |
|
16 | import sys | |
16 | import tempfile |
|
17 | import tempfile | |
@@ -70,13 +71,13 b' def generate_output():' | |||||
70 | import sys |
|
71 | import sys | |
71 | from IPython.core.display import display, HTML, Math |
|
72 | from IPython.core.display import display, HTML, Math | |
72 |
|
73 | |||
73 |
print |
|
74 | print("stdout") | |
74 | print >> sys.stderr, "stderr" |
|
75 | print("stderr", file=sys.stderr) | |
75 |
|
76 | |||
76 | display(HTML("<b>HTML</b>")) |
|
77 | display(HTML("<b>HTML</b>")) | |
77 |
|
78 | |||
78 |
print |
|
79 | print("stdout2") | |
79 | print >> sys.stderr, "stderr2" |
|
80 | print("stderr2", file=sys.stderr) | |
80 |
|
81 | |||
81 | display(Math(r"\alpha=\beta")) |
|
82 | display(Math(r"\alpha=\beta")) | |
82 |
|
83 | |||
@@ -154,7 +155,7 b' class ClusterTestCase(BaseZMQTestCase):' | |||||
154 | time.sleep(0.1) |
|
155 | time.sleep(0.1) | |
155 | self.client.spin() |
|
156 | self.client.spin() | |
156 | if not f(): |
|
157 | if not f(): | |
157 |
print |
|
158 | print("Warning: Awaited condition never arrived") | |
158 |
|
159 | |||
159 | def setUp(self): |
|
160 | def setUp(self): | |
160 | BaseZMQTestCase.setUp(self) |
|
161 | BaseZMQTestCase.setUp(self) | |
@@ -180,4 +181,4 b' class ClusterTestCase(BaseZMQTestCase):' | |||||
180 | # self.context.term() |
|
181 | # self.context.term() | |
181 | # print tempfile.TemporaryFile().fileno(), |
|
182 | # print tempfile.TemporaryFile().fileno(), | |
182 | # sys.stdout.flush() |
|
183 | # sys.stdout.flush() | |
183 | No newline at end of file |
|
184 |
@@ -24,6 +24,7 b' itself from the command line. There are two ways of running this script:' | |||||
24 | #----------------------------------------------------------------------------- |
|
24 | #----------------------------------------------------------------------------- | |
25 | # Imports |
|
25 | # Imports | |
26 | #----------------------------------------------------------------------------- |
|
26 | #----------------------------------------------------------------------------- | |
|
27 | from __future__ import print_function | |||
27 |
|
28 | |||
28 | # Stdlib |
|
29 | # Stdlib | |
29 | import glob |
|
30 | import glob | |
@@ -423,7 +424,7 b' class IPTester(object):' | |||||
423 |
|
424 | |||
424 | for pid in self.pids: |
|
425 | for pid in self.pids: | |
425 | try: |
|
426 | try: | |
426 |
print |
|
427 | print('Cleaning stale PID:', pid) | |
427 | os.kill(pid, signal.SIGKILL) |
|
428 | os.kill(pid, signal.SIGKILL) | |
428 | except OSError: |
|
429 | except OSError: | |
429 | # This is just a best effort, if we fail or the process was |
|
430 | # This is just a best effort, if we fail or the process was | |
@@ -527,8 +528,8 b' def run_iptestall():' | |||||
527 | t_start = time.time() |
|
528 | t_start = time.time() | |
528 | try: |
|
529 | try: | |
529 | for (name, runner) in runners: |
|
530 | for (name, runner) in runners: | |
530 |
print |
|
531 | print('*'*70) | |
531 |
print |
|
532 | print('IPython test group:',name) | |
532 | res = runner.run() |
|
533 | res = runner.run() | |
533 | if res: |
|
534 | if res: | |
534 | failed.append( (name, runner) ) |
|
535 | failed.append( (name, runner) ) | |
@@ -539,26 +540,26 b' def run_iptestall():' | |||||
539 | nrunners = len(runners) |
|
540 | nrunners = len(runners) | |
540 | nfail = len(failed) |
|
541 | nfail = len(failed) | |
541 | # summarize results |
|
542 | # summarize results | |
542 |
|
543 | print() | ||
543 |
print |
|
544 | print('*'*70) | |
544 |
print |
|
545 | print('Test suite completed for system with the following information:') | |
545 |
print |
|
546 | print(report()) | |
546 |
print |
|
547 | print('Ran %s test groups in %.3fs' % (nrunners, t_tests)) | |
547 |
|
548 | print() | ||
548 |
print |
|
549 | print('Status:') | |
549 | if not failed: |
|
550 | if not failed: | |
550 |
print |
|
551 | print('OK') | |
551 | else: |
|
552 | else: | |
552 | # If anything went wrong, point out what command to rerun manually to |
|
553 | # If anything went wrong, point out what command to rerun manually to | |
553 | # see the actual errors and individual summary |
|
554 | # see the actual errors and individual summary | |
554 |
print |
|
555 | print('ERROR - %s out of %s test groups failed.' % (nfail, nrunners)) | |
555 | for name, failed_runner in failed: |
|
556 | for name, failed_runner in failed: | |
556 |
print |
|
557 | print('-'*40) | |
557 |
print |
|
558 | print('Runner failed:',name) | |
558 |
print |
|
559 | print('You may wish to rerun this one individually, with:') | |
559 | failed_call_args = [py3compat.cast_unicode(x) for x in failed_runner.call_args] |
|
560 | failed_call_args = [py3compat.cast_unicode(x) for x in failed_runner.call_args] | |
560 |
print |
|
561 | print(u' '.join(failed_call_args)) | |
561 |
|
562 | print() | ||
562 | # Ensure that our exit code indicates failure |
|
563 | # Ensure that our exit code indicates failure | |
563 | sys.exit(1) |
|
564 | sys.exit(1) | |
564 |
|
565 |
@@ -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 |
@@ -28,11 +28,13 b' It shows how to use the built-in keyword, token and tokenize modules to' | |||||
28 | scan Python source code and re-emit it with no changes to its original |
|
28 | scan Python source code and re-emit it with no changes to its original | |
29 | formatting (which is the hard part). |
|
29 | formatting (which is the hard part). | |
30 | """ |
|
30 | """ | |
|
31 | from __future__ import print_function | |||
31 |
|
32 | |||
32 | __all__ = ['ANSICodeColors','Parser'] |
|
33 | __all__ = ['ANSICodeColors','Parser'] | |
33 |
|
34 | |||
34 | _scheme_default = 'Linux' |
|
35 | _scheme_default = 'Linux' | |
35 |
|
36 | |||
|
37 | ||||
36 | # Imports |
|
38 | # Imports | |
37 | import StringIO |
|
39 | import StringIO | |
38 | import keyword |
|
40 | import keyword | |
@@ -283,7 +285,7 b' If no filename is given, or if filename is -, read standard input."""' | |||||
283 | try: |
|
285 | try: | |
284 | stream = open(fname) |
|
286 | stream = open(fname) | |
285 | except IOError as msg: |
|
287 | except IOError as msg: | |
286 |
print |
|
288 | print(msg, file=sys.stderr) | |
287 | sys.exit(1) |
|
289 | sys.exit(1) | |
288 |
|
290 | |||
289 | parser = Parser() |
|
291 | parser = Parser() |
@@ -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): |
@@ -11,6 +11,7 b'' | |||||
11 | #----------------------------------------------------------------------------- |
|
11 | #----------------------------------------------------------------------------- | |
12 | # Imports |
|
12 | # Imports | |
13 | #----------------------------------------------------------------------------- |
|
13 | #----------------------------------------------------------------------------- | |
|
14 | from __future__ import print_function | |||
14 |
|
15 | |||
15 | import sys |
|
16 | import sys | |
16 |
|
17 | |||
@@ -33,7 +34,7 b' def test_tee_simple():' | |||||
33 | chan = StringIO() |
|
34 | chan = StringIO() | |
34 | text = 'Hello' |
|
35 | text = 'Hello' | |
35 | tee = Tee(chan, channel='stdout') |
|
36 | tee = Tee(chan, channel='stdout') | |
36 | print >> chan, text |
|
37 | print(text, file=chan) | |
37 | nt.assert_equal(chan.getvalue(), text+"\n") |
|
38 | nt.assert_equal(chan.getvalue(), text+"\n") | |
38 |
|
39 | |||
39 |
|
40 | |||
@@ -48,7 +49,7 b' class TeeTestCase(dec.ParametricTestCase):' | |||||
48 | setattr(sys, channel, trap) |
|
49 | setattr(sys, channel, trap) | |
49 |
|
50 | |||
50 | tee = Tee(chan, channel=channel) |
|
51 | tee = Tee(chan, channel=channel) | |
51 | print >> chan, text, |
|
52 | print(text, end='', file=chan) | |
52 | setattr(sys, channel, std_ori) |
|
53 | setattr(sys, channel, std_ori) | |
53 | trap_val = trap.getvalue() |
|
54 | trap_val = trap.getvalue() | |
54 | nt.assert_equals(chan.getvalue(), text) |
|
55 | nt.assert_equals(chan.getvalue(), text) | |
@@ -78,8 +79,8 b' def test_capture_output():' | |||||
78 | """capture_output() context works""" |
|
79 | """capture_output() context works""" | |
79 |
|
80 | |||
80 | with capture_output() as io: |
|
81 | with capture_output() as io: | |
81 |
print |
|
82 | print('hi, stdout') | |
82 | print >> sys.stderr, 'hi, stderr' |
|
83 | print('hi, stderr', file=sys.stderr) | |
83 |
|
84 | |||
84 | nt.assert_equals(io.stdout, 'hi, stdout\n') |
|
85 | nt.assert_equals(io.stdout, 'hi, stdout\n') | |
85 | nt.assert_equals(io.stderr, 'hi, stderr\n') |
|
86 | nt.assert_equals(io.stderr, 'hi, stderr\n') |
@@ -13,6 +13,7 b" Utilities for warnings. Shoudn't we just use the built in warnings module." | |||||
13 | #----------------------------------------------------------------------------- |
|
13 | #----------------------------------------------------------------------------- | |
14 | # Imports |
|
14 | # Imports | |
15 | #----------------------------------------------------------------------------- |
|
15 | #----------------------------------------------------------------------------- | |
|
16 | from __future__ import print_function | |||
16 |
|
17 | |||
17 | import sys |
|
18 | import sys | |
18 |
|
19 | |||
@@ -43,7 +44,7 b' def warn(msg,level=2,exit_val=1):' | |||||
43 | header = ['','','WARNING: ','ERROR: ','FATAL ERROR: '] |
|
44 | header = ['','','WARNING: ','ERROR: ','FATAL ERROR: '] | |
44 | io.stderr.write('%s%s' % (header[level],msg)) |
|
45 | io.stderr.write('%s%s' % (header[level],msg)) | |
45 | if level == 4: |
|
46 | if level == 4: | |
46 |
print |
|
47 | print('Exiting.\n', file=io.stderr) | |
47 | sys.exit(exit_val) |
|
48 | sys.exit(exit_val) | |
48 |
|
49 | |||
49 |
|
50 |
@@ -5,6 +5,8 b'' | |||||
5 | #----------------------------------------------------------------------------- |
|
5 | #----------------------------------------------------------------------------- | |
6 | # Imports |
|
6 | # Imports | |
7 | #----------------------------------------------------------------------------- |
|
7 | #----------------------------------------------------------------------------- | |
|
8 | from __future__ import print_function | |||
|
9 | ||||
8 | # stdlib |
|
10 | # stdlib | |
9 | import cPickle as pickle |
|
11 | import cPickle as pickle | |
10 | import code |
|
12 | import code | |
@@ -57,25 +59,25 b' class Console(code.InteractiveConsole):' | |||||
57 | return |
|
59 | return | |
58 | c = omsg.content.code.rstrip() |
|
60 | c = omsg.content.code.rstrip() | |
59 | if c: |
|
61 | if c: | |
60 |
print |
|
62 | print('[IN from %s]' % omsg.parent_header.username) | |
61 |
print |
|
63 | print(c) | |
62 |
|
64 | |||
63 | def handle_pyout(self, omsg): |
|
65 | def handle_pyout(self, omsg): | |
64 | #print omsg # dbg |
|
66 | #print omsg # dbg | |
65 | if omsg.parent_header.session == self.session.session: |
|
67 | if omsg.parent_header.session == self.session.session: | |
66 |
print |
|
68 | print("%s%s" % (sys.ps3, omsg.content.data)) | |
67 | else: |
|
69 | else: | |
68 |
print |
|
70 | print('[Out from %s]' % omsg.parent_header.username) | |
69 |
print |
|
71 | print(omsg.content.data) | |
70 |
|
72 | |||
71 | def print_pyerr(self, err): |
|
73 | def print_pyerr(self, err): | |
72 |
print |
|
74 | print(err.etype,':', err.evalue, file=sys.stderr) | |
73 |
print |
|
75 | print(''.join(err.traceback), file=sys.stderr) | |
74 |
|
76 | |||
75 | def handle_pyerr(self, omsg): |
|
77 | def handle_pyerr(self, omsg): | |
76 | if omsg.parent_header.session == self.session.session: |
|
78 | if omsg.parent_header.session == self.session.session: | |
77 | return |
|
79 | return | |
78 |
print |
|
80 | print('[ERR from %s]' % omsg.parent_header.username, file=sys.stderr) | |
79 | self.print_pyerr(omsg.content) |
|
81 | self.print_pyerr(omsg.content) | |
80 |
|
82 | |||
81 | def handle_stream(self, omsg): |
|
83 | def handle_stream(self, omsg): | |
@@ -83,8 +85,8 b' class Console(code.InteractiveConsole):' | |||||
83 | outstream = sys.stdout |
|
85 | outstream = sys.stdout | |
84 | else: |
|
86 | else: | |
85 | outstream = sys.stderr |
|
87 | outstream = sys.stderr | |
86 |
print |
|
88 | print('*ERR*', end=' ', file=outstream) | |
87 |
print |
|
89 | print(omsg.content.data, end=' ', file=outstream) | |
88 |
|
90 | |||
89 | def handle_output(self, omsg): |
|
91 | def handle_output(self, omsg): | |
90 | handler = self.handlers.get(omsg.msg_type, None) |
|
92 | handler = self.handlers.get(omsg.msg_type, None) | |
@@ -107,12 +109,12 b' class Console(code.InteractiveConsole):' | |||||
107 | if rep.content.status == 'error': |
|
109 | if rep.content.status == 'error': | |
108 | self.print_pyerr(rep.content) |
|
110 | self.print_pyerr(rep.content) | |
109 | elif rep.content.status == 'aborted': |
|
111 | elif rep.content.status == 'aborted': | |
110 |
print |
|
112 | print("ERROR: ABORTED", file=sys.stderr) | |
111 | ab = self.messages[rep.parent_header.msg_id].content |
|
113 | ab = self.messages[rep.parent_header.msg_id].content | |
112 | if 'code' in ab: |
|
114 | if 'code' in ab: | |
113 |
print |
|
115 | print(ab.code, file=sys.stderr) | |
114 | else: |
|
116 | else: | |
115 |
print |
|
117 | print(ab, file=sys.stderr) | |
116 |
|
118 | |||
117 | def recv_reply(self): |
|
119 | def recv_reply(self): | |
118 | ident,rep = self.session.recv(self.request_socket) |
|
120 | ident,rep = self.session.recv(self.request_socket) | |
@@ -153,7 +155,7 b' class Console(code.InteractiveConsole):' | |||||
153 | time.sleep(0.05) |
|
155 | time.sleep(0.05) | |
154 | else: |
|
156 | else: | |
155 | # We exited without hearing back from the kernel! |
|
157 | # We exited without hearing back from the kernel! | |
156 |
print |
|
158 | print('ERROR!!! kernel never got back to us!!!', file=sys.stderr) | |
157 |
|
159 | |||
158 |
|
160 | |||
159 | class InteractiveClient(object): |
|
161 | class InteractiveClient(object): |
@@ -6,6 +6,7 b' use from bintree_script.py' | |||||
6 | Provides parallel [all]reduce functionality |
|
6 | Provides parallel [all]reduce functionality | |
7 |
|
7 | |||
8 | """ |
|
8 | """ | |
|
9 | from __future__ import print_function | |||
9 |
|
10 | |||
10 | import cPickle as pickle |
|
11 | import cPickle as pickle | |
11 | import re |
|
12 | import re | |
@@ -92,7 +93,7 b' def depth(n, tree):' | |||||
92 | def print_bintree(tree, indent=' '): |
|
93 | def print_bintree(tree, indent=' '): | |
93 | """print a binary tree""" |
|
94 | """print a binary tree""" | |
94 | for n in sorted(tree.keys()): |
|
95 | for n in sorted(tree.keys()): | |
95 |
print |
|
96 | print("%s%s" % (indent * depth(n,tree), n)) | |
96 |
|
97 | |||
97 | #---------------------------------------------------------------------------- |
|
98 | #---------------------------------------------------------------------------- | |
98 | # Communicator class for a binary-tree map |
|
99 | # Communicator class for a binary-tree map |
@@ -270,6 +270,8 b" if 'setuptools' in sys.modules:" | |||||
270 | # anything. |
|
270 | # anything. | |
271 | setuptools_extra_args['use_2to3_exclude_fixers'] = [ |
|
271 | setuptools_extra_args['use_2to3_exclude_fixers'] = [ | |
272 | 'lib2to3.fixes.fix_except', |
|
272 | 'lib2to3.fixes.fix_except', | |
|
273 | 'lib2to3.fixes.fix_apply', | |||
|
274 | 'lib2to3.fixes.fix_repr', | |||
273 | ] |
|
275 | ] | |
274 | from setuptools.command.build_py import build_py |
|
276 | from setuptools.command.build_py import build_py | |
275 | setup_args['cmdclass'] = {'build_py': record_commit_info('IPython', build_cmd=build_py)} |
|
277 | setup_args['cmdclass'] = {'build_py': record_commit_info('IPython', build_cmd=build_py)} |
General Comments 0
You need to be logged in to leave comments.
Login now