From 81d5575c375284a3360f11287b142f24be9c6f05 2017-01-09 13:33:23 From: Thomas Kluyver Date: 2017-01-09 13:33:23 Subject: [PATCH] Remove uses of compatibility builtin_mod and builtin_mod_name --- diff --git a/IPython/core/builtin_trap.py b/IPython/core/builtin_trap.py index b9d4e95..a8ea4ab 100644 --- a/IPython/core/builtin_trap.py +++ b/IPython/core/builtin_trap.py @@ -1,31 +1,14 @@ """ -A context manager for managing things injected into :mod:`__builtin__`. - -Authors: - -* Brian Granger -* Fernando Perez +A context manager for managing things injected into :mod:`builtins`. """ -#----------------------------------------------------------------------------- -# Copyright (C) 2010-2011 The IPython Development Team. -# -# Distributed under the terms of the BSD License. -# -# Complete license in the file COPYING.txt, distributed with this software. -#----------------------------------------------------------------------------- - -#----------------------------------------------------------------------------- -# Imports -#----------------------------------------------------------------------------- +# Copyright (c) IPython Development Team. +# Distributed under the terms of the Modified BSD License. +import builtins as builtin_mod from traitlets.config.configurable import Configurable -from IPython.utils.py3compat import builtin_mod from traitlets import Instance -#----------------------------------------------------------------------------- -# Classes and functions -#----------------------------------------------------------------------------- class __BuiltinUndefined(object): pass BuiltinUndefined = __BuiltinUndefined() diff --git a/IPython/core/completer.py b/IPython/core/completer.py index 2712abb..6062ea1 100644 --- a/IPython/core/completer.py +++ b/IPython/core/completer.py @@ -15,6 +15,7 @@ upstream and were accepted as of Python 2.3, import __main__ +import builtins as builtin_mod import glob import inspect import itertools @@ -35,7 +36,7 @@ from IPython.utils import generics from IPython.utils.decorators import undoc from IPython.utils.dir2 import dir2, get_real_method from IPython.utils.process import arg_split -from IPython.utils.py3compat import builtin_mod, cast_unicode_py2 +from IPython.utils.py3compat import cast_unicode_py2 from traitlets import Bool, Enum, observe from functools import wraps diff --git a/IPython/core/displayhook.py b/IPython/core/displayhook.py index 4877d02..3680a72 100644 --- a/IPython/core/displayhook.py +++ b/IPython/core/displayhook.py @@ -7,13 +7,13 @@ This defines a callable class that IPython uses for `sys.displayhook`. # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. - +import builtins as builtin_mod import sys import io as _io import tokenize from traitlets.config.configurable import Configurable -from IPython.utils.py3compat import builtin_mod, cast_unicode_py2 +from IPython.utils.py3compat import cast_unicode_py2 from traitlets import Instance, Float from warnings import warn diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 22f6a56..0b96152 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -15,6 +15,7 @@ import __future__ import abc import ast import atexit +import builtins as builtin_mod import functools import os import re @@ -67,7 +68,6 @@ from IPython.utils.ipstruct import Struct from IPython.paths import get_ipython_dir from IPython.utils.path import get_home_dir, get_py_filename, ensure_dir_exists from IPython.utils.process import system, getoutput -from IPython.utils.py3compat import builtin_mod from IPython.utils.strdispatch import StrDispatch from IPython.utils.syspathcontext import prepended_to_syspath from IPython.utils.text import format_screen, LSString, SList, DollarFormatter diff --git a/IPython/core/magics/execution.py b/IPython/core/magics/execution.py index 6334e7a..9410f65 100644 --- a/IPython/core/magics/execution.py +++ b/IPython/core/magics/execution.py @@ -7,6 +7,7 @@ import ast import bdb +import builtins as builtin_mod import gc import itertools import os @@ -35,8 +36,6 @@ from IPython.core.macro import Macro from IPython.core.magic import (Magics, magics_class, line_magic, cell_magic, line_cell_magic, on_off, needs_local_scope) from IPython.testing.skipdoctest import skip_doctest -from IPython.utils import py3compat -from IPython.utils.py3compat import builtin_mod from IPython.utils.contexts import preserve_keys from IPython.utils.capture import capture_output from IPython.utils.ipstruct import Struct diff --git a/IPython/lib/deepreload.py b/IPython/lib/deepreload.py index c5c4adb..b9d52c4 100644 --- a/IPython/lib/deepreload.py +++ b/IPython/lib/deepreload.py @@ -32,6 +32,7 @@ re-implementation of hierarchical module import. # the file COPYING, distributed as part of this software. #***************************************************************************** +import builtins as builtin_mod from contextlib import contextmanager import imp import sys @@ -39,8 +40,6 @@ import sys from types import ModuleType from warnings import warn -from IPython.utils.py3compat import builtin_mod, builtin_mod_name - original_import = builtin_mod.__import__ @contextmanager @@ -320,13 +319,10 @@ def deep_reload_hook(m): return newm # Save the original hooks -try: - original_reload = builtin_mod.reload -except AttributeError: - original_reload = imp.reload # Python 3 +original_reload = imp.reload # Python 3 # Replacement for reload() -def reload(module, exclude=('sys', 'os.path', builtin_mod_name, '__main__', +def reload(module, exclude=('sys', 'os.path', 'builtins', '__main__', 'numpy', 'numpy._globals')): """Recursively reload all modules used in the given module. Optionally takes a list of modules to exclude from reloading. The default exclude diff --git a/IPython/testing/globalipapp.py b/IPython/testing/globalipapp.py index 2f065da..f9b1d3a 100644 --- a/IPython/testing/globalipapp.py +++ b/IPython/testing/globalipapp.py @@ -9,6 +9,7 @@ done. # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. +import builtins as builtin_mod import sys import warnings @@ -17,7 +18,6 @@ from . import tools from IPython.core import page from IPython.utils import io from IPython.utils import py3compat -from IPython.utils.py3compat import builtin_mod from IPython.terminal.interactiveshell import TerminalInteractiveShell diff --git a/IPython/testing/plugin/ipdoctest.py b/IPython/testing/plugin/ipdoctest.py index 79e41b4..70da416 100644 --- a/IPython/testing/plugin/ipdoctest.py +++ b/IPython/testing/plugin/ipdoctest.py @@ -19,6 +19,7 @@ Limitations: # Module imports # From the standard library +import builtins as builtin_mod import doctest import inspect import logging @@ -45,9 +46,6 @@ from doctest import (REPORTING_FLAGS, REPORT_ONLY_FIRST_FAILURE, from nose.plugins import doctests, Plugin from nose.util import anyp, tolist -# Our own imports -from IPython.utils.py3compat import builtin_mod - #----------------------------------------------------------------------------- # Module globals and other constants #-----------------------------------------------------------------------------