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