Show More
@@ -478,7 +478,7 b' class CommandLineConfigLoader(ConfigLoader):' | |||||
478 | # This case happens if the rhs is a string. |
|
478 | # This case happens if the rhs is a string. | |
479 | value = rhs |
|
479 | value = rhs | |
480 |
|
480 | |||
481 |
exec |
|
481 | exec(u'self.config.%s = value' % lhs) | |
482 |
|
482 | |||
483 | def _load_flag(self, cfg): |
|
483 | def _load_flag(self, cfg): | |
484 | """update self.config from a flag, which can be a dict or Config""" |
|
484 | """update self.config from a flag, which can be a dict or Config""" | |
@@ -734,7 +734,7 b' class ArgParseConfigLoader(CommandLineConfigLoader):' | |||||
734 | def _convert_to_config(self): |
|
734 | def _convert_to_config(self): | |
735 | """self.parsed_data->self.config""" |
|
735 | """self.parsed_data->self.config""" | |
736 | for k, v in vars(self.parsed_data).iteritems(): |
|
736 | for k, v in vars(self.parsed_data).iteritems(): | |
737 |
exec |
|
737 | exec("self.config.%s = v"%k, locals(), globals()) | |
738 |
|
738 | |||
739 | class KVArgParseConfigLoader(ArgParseConfigLoader): |
|
739 | class KVArgParseConfigLoader(ArgParseConfigLoader): | |
740 | """A config loader that loads aliases and flags with argparse, |
|
740 | """A config loader that loads aliases and flags with argparse, |
@@ -256,7 +256,7 b' class TestConfig(TestCase):' | |||||
256 |
|
256 | |||
257 | def test_builtin(self): |
|
257 | def test_builtin(self): | |
258 | c1 = Config() |
|
258 | c1 = Config() | |
259 |
exec |
|
259 | exec('foo = True', c1) | |
260 | self.assertEqual(c1.foo, True) |
|
260 | self.assertEqual(c1.foo, True) | |
261 | c1.format = "json" |
|
261 | c1.format = "json" | |
262 |
|
262 |
@@ -2461,7 +2461,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
2461 | def ex(self, cmd): |
|
2461 | def ex(self, cmd): | |
2462 | """Execute a normal python statement in user namespace.""" |
|
2462 | """Execute a normal python statement in user namespace.""" | |
2463 | with self.builtin_trap: |
|
2463 | with self.builtin_trap: | |
2464 |
exec |
|
2464 | exec(cmd, self.user_global_ns, self.user_ns) | |
2465 |
|
2465 | |||
2466 | def ev(self, expr): |
|
2466 | def ev(self, expr): | |
2467 | """Evaluate python expression expr in user namespace. |
|
2467 | """Evaluate python expression expr in user namespace. | |
@@ -2842,7 +2842,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
2842 | try: |
|
2842 | try: | |
2843 | self.hooks.pre_run_code_hook() |
|
2843 | self.hooks.pre_run_code_hook() | |
2844 | #rprint('Running code', repr(code_obj)) # dbg |
|
2844 | #rprint('Running code', repr(code_obj)) # dbg | |
2845 |
exec |
|
2845 | exec(code_obj, self.user_global_ns, self.user_ns) | |
2846 | finally: |
|
2846 | finally: | |
2847 | # Reset our crash handler in place |
|
2847 | # Reset our crash handler in place | |
2848 | sys.excepthook = old_excepthook |
|
2848 | sys.excepthook = old_excepthook |
@@ -150,7 +150,7 b' class ConfigMagics(Magics):' | |||||
150 | # leave quotes on args when splitting, because we want |
|
150 | # leave quotes on args when splitting, because we want | |
151 | # unquoted args to eval in user_ns |
|
151 | # unquoted args to eval in user_ns | |
152 | cfg = Config() |
|
152 | cfg = Config() | |
153 |
exec |
|
153 | exec("cfg."+line, locals(), self.shell.user_ns) | |
154 |
|
154 | |||
155 | for configurable in configurables: |
|
155 | for configurable in configurables: | |
156 | try: |
|
156 | try: |
@@ -977,7 +977,7 b' python-profiler package from non-free.""")' | |||||
977 | tc = clock()-t0 |
|
977 | tc = clock()-t0 | |
978 |
|
978 | |||
979 | ns = {} |
|
979 | ns = {} | |
980 |
exec |
|
980 | exec(code, self.shell.user_ns, ns) | |
981 | timer.inner = ns["inner"] |
|
981 | timer.inner = ns["inner"] | |
982 |
|
982 | |||
983 | if number == 0: |
|
983 | if number == 0: | |
@@ -1100,7 +1100,7 b' python-profiler package from non-free.""")' | |||||
1100 | end = clock2() |
|
1100 | end = clock2() | |
1101 | else: |
|
1101 | else: | |
1102 | st = clock2() |
|
1102 | st = clock2() | |
1103 |
exec |
|
1103 | exec(code, glob, local_ns) | |
1104 | end = clock2() |
|
1104 | end = clock2() | |
1105 | out = None |
|
1105 | out = None | |
1106 | wall_end = wtime() |
|
1106 | wall_end = wtime() |
@@ -275,12 +275,12 b' def import_pylab(user_ns, import_all=True):' | |||||
275 | "np = numpy\n" |
|
275 | "np = numpy\n" | |
276 | "plt = pyplot\n" |
|
276 | "plt = pyplot\n" | |
277 | ) |
|
277 | ) | |
278 |
exec |
|
278 | exec(s, user_ns) | |
279 |
|
279 | |||
280 | if import_all: |
|
280 | if import_all: | |
281 | s = ("from matplotlib.pylab import *\n" |
|
281 | s = ("from matplotlib.pylab import *\n" | |
282 | "from numpy import *\n") |
|
282 | "from numpy import *\n") | |
283 |
exec |
|
283 | exec(s, user_ns) | |
284 |
|
284 | |||
285 | # IPython symbols to add |
|
285 | # IPython symbols to add | |
286 | user_ns['figsize'] = figsize |
|
286 | user_ns['figsize'] = figsize |
@@ -366,7 +366,7 b' class InteractiveLoopTestCase(unittest.TestCase):' | |||||
366 | """ |
|
366 | """ | |
367 | src = mini_interactive_loop(pseudo_input(lines)) |
|
367 | src = mini_interactive_loop(pseudo_input(lines)) | |
368 | test_ns = {} |
|
368 | test_ns = {} | |
369 |
exec |
|
369 | exec(src, test_ns) | |
370 | # We can't check that the provided ns is identical to the test_ns, |
|
370 | # We can't check that the provided ns is identical to the test_ns, | |
371 | # because Python fills test_ns with extra keys (copyright, etc). But |
|
371 | # because Python fills test_ns with extra keys (copyright, etc). But | |
372 | # we can check that the given dict is *contained* in test_ns |
|
372 | # we can check that the given dict is *contained* in test_ns |
@@ -45,7 +45,7 b' class FakeShell(object):' | |||||
45 | self.auto_magics.pre_run_code_hook(self) |
|
45 | self.auto_magics.pre_run_code_hook(self) | |
46 | except TryNext: |
|
46 | except TryNext: | |
47 | pass |
|
47 | pass | |
48 |
exec |
|
48 | exec(code, self.ns) | |
49 |
|
49 | |||
50 | def push(self, items): |
|
50 | def push(self, items): | |
51 | self.ns.update(items) |
|
51 | self.ns.update(items) |
@@ -161,7 +161,7 b' class FunctionMaker(object):' | |||||
161 | try: |
|
161 | try: | |
162 | code = compile(src, '<string>', 'single') |
|
162 | code = compile(src, '<string>', 'single') | |
163 | # print >> sys.stderr, 'Compiling %s' % src |
|
163 | # print >> sys.stderr, 'Compiling %s' % src | |
164 |
exec |
|
164 | exec(code, evaldict) | |
165 | except: |
|
165 | except: | |
166 | print('Error in generated code:', file=sys.stderr) |
|
166 | print('Error in generated code:', file=sys.stderr) | |
167 | print(src, file=sys.stderr) |
|
167 | print(src, file=sys.stderr) |
@@ -596,7 +596,7 b' class Kernel(Configurable):' | |||||
596 | working.update(ns) |
|
596 | working.update(ns) | |
597 | code = "%s = %s(*%s,**%s)" % (resultname, fname, argname, kwargname) |
|
597 | code = "%s = %s(*%s,**%s)" % (resultname, fname, argname, kwargname) | |
598 | try: |
|
598 | try: | |
599 |
exec |
|
599 | exec(code, shell.user_global_ns, shell.user_ns) | |
600 | result = working.get(resultname) |
|
600 | result = working.get(resultname) | |
601 | finally: |
|
601 | finally: | |
602 | for key in ns.iterkeys(): |
|
602 | for key in ns.iterkeys(): |
@@ -421,7 +421,7 b' class Demo(object):' | |||||
421 | def run_cell(self,source): |
|
421 | def run_cell(self,source): | |
422 | """Execute a string with one or more lines of code""" |
|
422 | """Execute a string with one or more lines of code""" | |
423 |
|
423 | |||
424 |
exec |
|
424 | exec(source, self.user_ns) | |
425 |
|
425 | |||
426 | def __call__(self,index=None): |
|
426 | def __call__(self,index=None): | |
427 | """run a block of the demo. |
|
427 | """run a block of the demo. |
@@ -482,7 +482,7 b' class IPControllerApp(BaseParallelApplication):' | |||||
482 | for s in statements: |
|
482 | for s in statements: | |
483 | try: |
|
483 | try: | |
484 | self.log.msg("Executing statement: '%s'" % s) |
|
484 | self.log.msg("Executing statement: '%s'" % s) | |
485 |
exec |
|
485 | exec(s, globals(), locals()) | |
486 | except: |
|
486 | except: | |
487 | self.log.msg("Error running statement: %s" % s) |
|
487 | self.log.msg("Error running statement: %s" % s) | |
488 |
|
488 |
@@ -355,7 +355,7 b' class IPEngineApp(BaseParallelApplication):' | |||||
355 | try: |
|
355 | try: | |
356 | self.log.info("Initializing MPI:") |
|
356 | self.log.info("Initializing MPI:") | |
357 | self.log.info(mpi_import_statement) |
|
357 | self.log.info(mpi_import_statement) | |
358 |
exec |
|
358 | exec(mpi_import_statement, globals()) | |
359 | except: |
|
359 | except: | |
360 | mpi = None |
|
360 | mpi = None | |
361 | else: |
|
361 | else: |
@@ -80,7 +80,7 b' def _require(*modules, **mapping):' | |||||
80 | user_ns = globals() |
|
80 | user_ns = globals() | |
81 | for name in modules: |
|
81 | for name in modules: | |
82 | try: |
|
82 | try: | |
83 |
exec |
|
83 | exec('import %s' % name, user_ns) | |
84 | except ImportError: |
|
84 | except ImportError: | |
85 | raise UnmetDependency(name) |
|
85 | raise UnmetDependency(name) | |
86 |
|
86 |
@@ -232,7 +232,7 b' def _push(**ns):' | |||||
232 | try: |
|
232 | try: | |
233 | for name, value in ns.iteritems(): |
|
233 | for name, value in ns.iteritems(): | |
234 | user_ns[tmp] = value |
|
234 | user_ns[tmp] = value | |
235 |
exec |
|
235 | exec("%s = %s" % (name, tmp), user_ns) | |
236 | finally: |
|
236 | finally: | |
237 | user_ns.pop(tmp, None) |
|
237 | user_ns.pop(tmp, None) | |
238 |
|
238 | |||
@@ -247,7 +247,7 b' def _pull(keys):' | |||||
247 | @interactive |
|
247 | @interactive | |
248 | def _execute(code): |
|
248 | def _execute(code): | |
249 | """helper method for implementing `client.execute` via `client.apply`""" |
|
249 | """helper method for implementing `client.execute` via `client.apply`""" | |
250 |
exec |
|
250 | exec(code, globals()) | |
251 |
|
251 | |||
252 | #-------------------------------------------------------------------------- |
|
252 | #-------------------------------------------------------------------------- | |
253 | # extra process management utilities |
|
253 | # extra process management utilities |
@@ -98,7 +98,7 b' if sys.version_info[0] >= 3:' | |||||
98 | def execfile(fname, glob, loc=None): |
|
98 | def execfile(fname, glob, loc=None): | |
99 | loc = loc if (loc is not None) else glob |
|
99 | loc = loc if (loc is not None) else glob | |
100 | with open(fname, 'rb') as f: |
|
100 | with open(fname, 'rb') as f: | |
101 |
exec |
|
101 | exec(compile(f.read(), fname, 'exec'), glob, loc) | |
102 |
|
102 | |||
103 | # Refactor print statements in doctests. |
|
103 | # Refactor print statements in doctests. | |
104 | _print_statement_re = re.compile(r"\bprint (?P<expr>.*)$", re.MULTILINE) |
|
104 | _print_statement_re = re.compile(r"\bprint (?P<expr>.*)$", re.MULTILINE) | |
@@ -196,7 +196,7 b' else:' | |||||
196 | filename = unicode_to_str(fname) |
|
196 | filename = unicode_to_str(fname) | |
197 | else: |
|
197 | else: | |
198 | filename = fname |
|
198 | filename = fname | |
199 |
exec |
|
199 | exec(compile(scripttext, filename, 'exec'), glob, loc) | |
200 | else: |
|
200 | else: | |
201 | def execfile(fname, *where): |
|
201 | def execfile(fname, *where): | |
202 | if isinstance(fname, unicode): |
|
202 | if isinstance(fname, unicode): |
General Comments 0
You need to be logged in to leave comments.
Login now