Show More
@@ -1,31 +1,14 b'' | |||||
1 | """ |
|
1 | """ | |
2 |
A context manager for managing things injected into :mod:` |
|
2 | A context manager for managing things injected into :mod:`builtins`. | |
3 |
|
||||
4 | Authors: |
|
|||
5 |
|
||||
6 | * Brian Granger |
|
|||
7 | * Fernando Perez |
|
|||
8 | """ |
|
3 | """ | |
9 | #----------------------------------------------------------------------------- |
|
4 | # Copyright (c) IPython Development Team. | |
10 | # Copyright (C) 2010-2011 The IPython Development Team. |
|
5 | # Distributed under the terms of the Modified BSD License. | |
11 | # |
|
6 | import builtins as builtin_mod | |
12 | # Distributed under the terms of the BSD License. |
|
|||
13 | # |
|
|||
14 | # Complete license in the file COPYING.txt, distributed with this software. |
|
|||
15 | #----------------------------------------------------------------------------- |
|
|||
16 |
|
||||
17 | #----------------------------------------------------------------------------- |
|
|||
18 | # Imports |
|
|||
19 | #----------------------------------------------------------------------------- |
|
|||
20 |
|
7 | |||
21 | from traitlets.config.configurable import Configurable |
|
8 | from traitlets.config.configurable import Configurable | |
22 |
|
9 | |||
23 | from IPython.utils.py3compat import builtin_mod |
|
|||
24 | from traitlets import Instance |
|
10 | from traitlets import Instance | |
25 |
|
11 | |||
26 | #----------------------------------------------------------------------------- |
|
|||
27 | # Classes and functions |
|
|||
28 | #----------------------------------------------------------------------------- |
|
|||
29 |
|
12 | |||
30 | class __BuiltinUndefined(object): pass |
|
13 | class __BuiltinUndefined(object): pass | |
31 | BuiltinUndefined = __BuiltinUndefined() |
|
14 | BuiltinUndefined = __BuiltinUndefined() |
@@ -15,6 +15,7 b' upstream and were accepted as of Python 2.3,' | |||||
15 |
|
15 | |||
16 |
|
16 | |||
17 | import __main__ |
|
17 | import __main__ | |
|
18 | import builtins as builtin_mod | |||
18 | import glob |
|
19 | import glob | |
19 | import inspect |
|
20 | import inspect | |
20 | import itertools |
|
21 | import itertools | |
@@ -35,7 +36,7 b' from IPython.utils import generics' | |||||
35 | from IPython.utils.decorators import undoc |
|
36 | from IPython.utils.decorators import undoc | |
36 | from IPython.utils.dir2 import dir2, get_real_method |
|
37 | from IPython.utils.dir2 import dir2, get_real_method | |
37 | from IPython.utils.process import arg_split |
|
38 | from IPython.utils.process import arg_split | |
38 |
from IPython.utils.py3compat import |
|
39 | from IPython.utils.py3compat import cast_unicode_py2 | |
39 | from traitlets import Bool, Enum, observe |
|
40 | from traitlets import Bool, Enum, observe | |
40 |
|
41 | |||
41 | from functools import wraps |
|
42 | from functools import wraps |
@@ -7,13 +7,13 b' This defines a callable class that IPython uses for `sys.displayhook`.' | |||||
7 | # Copyright (c) IPython Development Team. |
|
7 | # Copyright (c) IPython Development Team. | |
8 | # Distributed under the terms of the Modified BSD License. |
|
8 | # Distributed under the terms of the Modified BSD License. | |
9 |
|
9 | |||
10 |
|
10 | import builtins as builtin_mod | ||
11 | import sys |
|
11 | import sys | |
12 | import io as _io |
|
12 | import io as _io | |
13 | import tokenize |
|
13 | import tokenize | |
14 |
|
14 | |||
15 | from traitlets.config.configurable import Configurable |
|
15 | from traitlets.config.configurable import Configurable | |
16 |
from IPython.utils.py3compat import |
|
16 | from IPython.utils.py3compat import cast_unicode_py2 | |
17 | from traitlets import Instance, Float |
|
17 | from traitlets import Instance, Float | |
18 | from warnings import warn |
|
18 | from warnings import warn | |
19 |
|
19 |
@@ -15,6 +15,7 b' import __future__' | |||||
15 | import abc |
|
15 | import abc | |
16 | import ast |
|
16 | import ast | |
17 | import atexit |
|
17 | import atexit | |
|
18 | import builtins as builtin_mod | |||
18 | import functools |
|
19 | import functools | |
19 | import os |
|
20 | import os | |
20 | import re |
|
21 | import re | |
@@ -67,7 +68,6 b' from IPython.utils.ipstruct import Struct' | |||||
67 | from IPython.paths import get_ipython_dir |
|
68 | from IPython.paths import get_ipython_dir | |
68 | from IPython.utils.path import get_home_dir, get_py_filename, ensure_dir_exists |
|
69 | from IPython.utils.path import get_home_dir, get_py_filename, ensure_dir_exists | |
69 | from IPython.utils.process import system, getoutput |
|
70 | from IPython.utils.process import system, getoutput | |
70 | from IPython.utils.py3compat import builtin_mod |
|
|||
71 | from IPython.utils.strdispatch import StrDispatch |
|
71 | from IPython.utils.strdispatch import StrDispatch | |
72 | from IPython.utils.syspathcontext import prepended_to_syspath |
|
72 | from IPython.utils.syspathcontext import prepended_to_syspath | |
73 | from IPython.utils.text import format_screen, LSString, SList, DollarFormatter |
|
73 | from IPython.utils.text import format_screen, LSString, SList, DollarFormatter |
@@ -7,6 +7,7 b'' | |||||
7 |
|
7 | |||
8 | import ast |
|
8 | import ast | |
9 | import bdb |
|
9 | import bdb | |
|
10 | import builtins as builtin_mod | |||
10 | import gc |
|
11 | import gc | |
11 | import itertools |
|
12 | import itertools | |
12 | import os |
|
13 | import os | |
@@ -35,8 +36,6 b' from IPython.core.macro import Macro' | |||||
35 | from IPython.core.magic import (Magics, magics_class, line_magic, cell_magic, |
|
36 | from IPython.core.magic import (Magics, magics_class, line_magic, cell_magic, | |
36 | line_cell_magic, on_off, needs_local_scope) |
|
37 | line_cell_magic, on_off, needs_local_scope) | |
37 | from IPython.testing.skipdoctest import skip_doctest |
|
38 | from IPython.testing.skipdoctest import skip_doctest | |
38 | from IPython.utils import py3compat |
|
|||
39 | from IPython.utils.py3compat import builtin_mod |
|
|||
40 | from IPython.utils.contexts import preserve_keys |
|
39 | from IPython.utils.contexts import preserve_keys | |
41 | from IPython.utils.capture import capture_output |
|
40 | from IPython.utils.capture import capture_output | |
42 | from IPython.utils.ipstruct import Struct |
|
41 | from IPython.utils.ipstruct import Struct |
@@ -32,6 +32,7 b' re-implementation of hierarchical module import.' | |||||
32 | # the file COPYING, distributed as part of this software. |
|
32 | # the file COPYING, distributed as part of this software. | |
33 | #***************************************************************************** |
|
33 | #***************************************************************************** | |
34 |
|
34 | |||
|
35 | import builtins as builtin_mod | |||
35 | from contextlib import contextmanager |
|
36 | from contextlib import contextmanager | |
36 | import imp |
|
37 | import imp | |
37 | import sys |
|
38 | import sys | |
@@ -39,8 +40,6 b' import sys' | |||||
39 | from types import ModuleType |
|
40 | from types import ModuleType | |
40 | from warnings import warn |
|
41 | from warnings import warn | |
41 |
|
42 | |||
42 | from IPython.utils.py3compat import builtin_mod, builtin_mod_name |
|
|||
43 |
|
||||
44 | original_import = builtin_mod.__import__ |
|
43 | original_import = builtin_mod.__import__ | |
45 |
|
44 | |||
46 | @contextmanager |
|
45 | @contextmanager | |
@@ -320,13 +319,10 b' def deep_reload_hook(m):' | |||||
320 | return newm |
|
319 | return newm | |
321 |
|
320 | |||
322 | # Save the original hooks |
|
321 | # Save the original hooks | |
323 | try: |
|
322 | original_reload = imp.reload # Python 3 | |
324 | original_reload = builtin_mod.reload |
|
|||
325 | except AttributeError: |
|
|||
326 | original_reload = imp.reload # Python 3 |
|
|||
327 |
|
323 | |||
328 | # Replacement for reload() |
|
324 | # Replacement for reload() | |
329 |
def reload(module, exclude=('sys', 'os.path', builtin |
|
325 | def reload(module, exclude=('sys', 'os.path', 'builtins', '__main__', | |
330 | 'numpy', 'numpy._globals')): |
|
326 | 'numpy', 'numpy._globals')): | |
331 | """Recursively reload all modules used in the given module. Optionally |
|
327 | """Recursively reload all modules used in the given module. Optionally | |
332 | takes a list of modules to exclude from reloading. The default exclude |
|
328 | takes a list of modules to exclude from reloading. The default exclude |
@@ -9,6 +9,7 b' done.' | |||||
9 | # Copyright (c) IPython Development Team. |
|
9 | # Copyright (c) IPython Development Team. | |
10 | # Distributed under the terms of the Modified BSD License. |
|
10 | # Distributed under the terms of the Modified BSD License. | |
11 |
|
11 | |||
|
12 | import builtins as builtin_mod | |||
12 | import sys |
|
13 | import sys | |
13 | import warnings |
|
14 | import warnings | |
14 |
|
15 | |||
@@ -17,7 +18,6 b' from . import tools' | |||||
17 | from IPython.core import page |
|
18 | from IPython.core import page | |
18 | from IPython.utils import io |
|
19 | from IPython.utils import io | |
19 | from IPython.utils import py3compat |
|
20 | from IPython.utils import py3compat | |
20 | from IPython.utils.py3compat import builtin_mod |
|
|||
21 | from IPython.terminal.interactiveshell import TerminalInteractiveShell |
|
21 | from IPython.terminal.interactiveshell import TerminalInteractiveShell | |
22 |
|
22 | |||
23 |
|
23 |
@@ -19,6 +19,7 b' Limitations:' | |||||
19 | # Module imports |
|
19 | # Module imports | |
20 |
|
20 | |||
21 | # From the standard library |
|
21 | # From the standard library | |
|
22 | import builtins as builtin_mod | |||
22 | import doctest |
|
23 | import doctest | |
23 | import inspect |
|
24 | import inspect | |
24 | import logging |
|
25 | import logging | |
@@ -45,9 +46,6 b' from doctest import (REPORTING_FLAGS, REPORT_ONLY_FIRST_FAILURE,' | |||||
45 | from nose.plugins import doctests, Plugin |
|
46 | from nose.plugins import doctests, Plugin | |
46 | from nose.util import anyp, tolist |
|
47 | from nose.util import anyp, tolist | |
47 |
|
48 | |||
48 | # Our own imports |
|
|||
49 | from IPython.utils.py3compat import builtin_mod |
|
|||
50 |
|
||||
51 | #----------------------------------------------------------------------------- |
|
49 | #----------------------------------------------------------------------------- | |
52 | # Module globals and other constants |
|
50 | # Module globals and other constants | |
53 | #----------------------------------------------------------------------------- |
|
51 | #----------------------------------------------------------------------------- |
General Comments 0
You need to be logged in to leave comments.
Login now