Show More
@@ -260,11 +260,14 b' class DisplayHook(Configurable):' | |||||
260 | self.flush() |
|
260 | self.flush() | |
261 | # Don't overwrite '_' and friends if '_' is in __builtin__ (otherwise |
|
261 | # Don't overwrite '_' and friends if '_' is in __builtin__ (otherwise | |
262 | # we cause buggy behavior for things like gettext). |
|
262 | # we cause buggy behavior for things like gettext). | |
|
263 | ||||
263 | if '_' not in __builtin__.__dict__: |
|
264 | if '_' not in __builtin__.__dict__: | |
264 | self.___ = self.__ |
|
265 | self.___ = self.__ | |
265 | self.__ = self._ |
|
266 | self.__ = self._ | |
266 | self._ = result |
|
267 | self._ = result | |
267 |
self.shell.user_ns.update({'_':self._, |
|
268 | self.shell.user_ns.update({'_':self._, | |
|
269 | '__':self.__, | |||
|
270 | '___':self.___}) | |||
268 |
|
271 | |||
269 | # hackish access to top-level namespace to create _1,_2... dynamically |
|
272 | # hackish access to top-level namespace to create _1,_2... dynamically | |
270 | to_main = {} |
|
273 | to_main = {} |
@@ -4,7 +4,7 b'' | |||||
4 | #----------------------------------------------------------------------------- |
|
4 | #----------------------------------------------------------------------------- | |
5 | # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> |
|
5 | # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> | |
6 | # Copyright (C) 2001-2007 Fernando Perez. <fperez@colorado.edu> |
|
6 | # Copyright (C) 2001-2007 Fernando Perez. <fperez@colorado.edu> | |
7 |
# Copyright (C) 2008-201 |
|
7 | # Copyright (C) 2008-2011 The IPython Development Team | |
8 | # |
|
8 | # | |
9 | # Distributed under the terms of the BSD License. The full license is in |
|
9 | # Distributed under the terms of the BSD License. The full license is in | |
10 | # the file COPYING, distributed as part of this software. |
|
10 | # the file COPYING, distributed as part of this software. | |
@@ -2154,15 +2154,28 b' class InteractiveShell(Configurable, Magic):' | |||||
2154 | self.execution_count += 1 |
|
2154 | self.execution_count += 1 | |
2155 |
|
2155 | |||
2156 | def run_one_block(self, block): |
|
2156 | def run_one_block(self, block): | |
2157 | """Run a single interactive block. |
|
2157 | """Run a single interactive block of source code. | |
2158 |
|
2158 | |||
2159 | If the block is single-line, dynamic transformations are applied to it |
|
2159 | If the block is single-line, dynamic transformations are applied to it | |
2160 | (like automagics, autocall and alias recognition). |
|
2160 | (like automagics, autocall and alias recognition). | |
|
2161 | ||||
|
2162 | If the block is multi-line, it must consist of valid Python code only. | |||
|
2163 | ||||
|
2164 | Parameters | |||
|
2165 | ---------- | |||
|
2166 | block : string | |||
|
2167 | A (possibly multiline) string of code to be executed. | |||
|
2168 | ||||
|
2169 | Returns | |||
|
2170 | ------- | |||
|
2171 | The output of the underlying execution method used, be it | |||
|
2172 | :meth:`run_source` or :meth:`run_single_line`. | |||
2161 | """ |
|
2173 | """ | |
2162 | if len(block.splitlines()) <= 1: |
|
2174 | if len(block.splitlines()) <= 1: | |
2163 | out = self.run_single_line(block) |
|
2175 | out = self.run_single_line(block) | |
2164 | else: |
|
2176 | else: | |
2165 | out = self.run_code(block) |
|
2177 | out = self.run_code(block) | |
|
2178 | #out = self.run_source(block) | |||
2166 | return out |
|
2179 | return out | |
2167 |
|
2180 | |||
2168 | def run_single_line(self, line): |
|
2181 | def run_single_line(self, line): | |
@@ -2316,7 +2329,7 b' class InteractiveShell(Configurable, Magic):' | |||||
2316 | try: |
|
2329 | try: | |
2317 | try: |
|
2330 | try: | |
2318 | self.hooks.pre_run_code_hook() |
|
2331 | self.hooks.pre_run_code_hook() | |
2319 | #rprint('Running code') # dbg |
|
2332 | #rprint('Running code', repr(code_obj)) # dbg | |
2320 | exec code_obj in self.user_global_ns, self.user_ns |
|
2333 | exec code_obj in self.user_global_ns, self.user_ns | |
2321 | finally: |
|
2334 | finally: | |
2322 | # Reset our crash handler in place |
|
2335 | # Reset our crash handler in place |
@@ -1,5 +1,10 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """Tests for the inputsplitter module. |
|
2 | """Tests for the inputsplitter module. | |
|
3 | ||||
|
4 | Authors | |||
|
5 | ------- | |||
|
6 | * Fernando Perez | |||
|
7 | * Robert Kern | |||
3 | """ |
|
8 | """ | |
4 | #----------------------------------------------------------------------------- |
|
9 | #----------------------------------------------------------------------------- | |
5 | # Copyright (C) 2010 The IPython Development Team |
|
10 | # Copyright (C) 2010 The IPython Development Team |
@@ -86,9 +86,11 b' class ipnsdict(dict):' | |||||
86 | self._checkpoint() |
|
86 | self._checkpoint() | |
87 | dict.update(self,other) |
|
87 | dict.update(self,other) | |
88 |
|
88 | |||
89 |
# If '_' is in the namespace, python won't set it when executing code |
|
89 | # If '_' is in the namespace, python won't set it when executing code | |
90 | # and we have examples that test it. So we ensure that the namespace |
|
90 | # *in doctests*, and we have multiple doctests that use '_'. So we | |
91 |
# is always 'clean' of it before it's used |
|
91 | # ensure that the namespace is always 'clean' of it before it's used | |
|
92 | # for test code execution. Note: this means that outside of doctests, | |||
|
93 | # our own testing | |||
92 | self.pop('_',None) |
|
94 | self.pop('_',None) | |
93 |
|
95 | |||
94 | # The builtins namespace must *always* be the real __builtin__ module, |
|
96 | # The builtins namespace must *always* be the real __builtin__ module, |
General Comments 0
You need to be logged in to leave comments.
Login now