diff --git a/IPython/core/magics/execution.py b/IPython/core/magics/execution.py index 7279462..6334e7a 100644 --- a/IPython/core/magics/execution.py +++ b/IPython/core/magics/execution.py @@ -36,7 +36,7 @@ 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, PY3 +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 @@ -45,11 +45,8 @@ from IPython.utils.path import get_py_filename, shellglob from IPython.utils.timing import clock, clock2 from warnings import warn from logging import error +from io import StringIO -if PY3: - from io import StringIO -else: - from StringIO import StringIO #----------------------------------------------------------------------------- # Magic implementation classes @@ -652,9 +649,6 @@ python-profiler package from non-free.""") args = shellglob(map(os.path.expanduser, arg_lst[1:])) sys.argv = [filename] + args # put in the proper filename - # protect sys.argv from potential unicode strings on Python 2: - if not py3compat.PY3: - sys.argv = [ py3compat.cast_bytes(a) for a in sys.argv ] if 'i' in opts: # Run in user's interactive namespace diff --git a/IPython/core/tests/test_splitinput.py b/IPython/core/tests/test_splitinput.py index c789e10..170d923 100644 --- a/IPython/core/tests/test_splitinput.py +++ b/IPython/core/tests/test_splitinput.py @@ -28,10 +28,7 @@ tests = [ ('??%%hist4', ('', '??', '%%hist4', '')), ('?x*', ('', '?', 'x*', '')), ] -if py3compat.PY3: - tests.append((u"Pérez Fernando", (u'', u'', u'Pérez', u'Fernando'))) -else: - tests.append((u"Pérez Fernando", (u'', u'', u'P', u'érez Fernando'))) +tests.append((u"Pérez Fernando", (u'', u'', u'Pérez', u'Fernando'))) def test_split_user_input(): return tt.check_pairs(split_user_input, tests) diff --git a/IPython/core/ultratb.py b/IPython/core/ultratb.py index 3ccbb81..352c691 100644 --- a/IPython/core/ultratb.py +++ b/IPython/core/ultratb.py @@ -299,7 +299,10 @@ def getargs(co): # Monkeypatch inspect to apply our bugfix. def with_patch_inspect(f): - """decorator for monkeypatching inspect.findsource""" + """ + Deprecated since IPython 6.0 + decorator for monkeypatching inspect.findsource + """ def wrapped(*args, **kwargs): save_findsource = inspect.findsource @@ -315,16 +318,6 @@ def with_patch_inspect(f): return wrapped -if py3compat.PY3: - fixed_getargvalues = inspect.getargvalues -else: - # Fixes for https://github.com/ipython/ipython/issues/8293 - # and https://github.com/ipython/ipython/issues/8205. - # The relevant bug is caused by failure to correctly handle anonymous tuple - # unpacking, which only exists in Python 2. - fixed_getargvalues = with_patch_inspect(inspect.getargvalues) - - def fix_frame_records_filenames(records): """Try to fix the filenames in each record from inspect.getinnerframes(). @@ -879,7 +872,7 @@ class VerboseTB(TBTools): file = py3compat.cast_unicode(file, util_path.fs_encoding) link = tpl_link % file - args, varargs, varkw, locals = fixed_getargvalues(frame) + args, varargs, varkw, locals = inspect.getargvalues(frame) if func == '?': call = '' diff --git a/IPython/terminal/ptutils.py b/IPython/terminal/ptutils.py index 84515e1..d144005 100644 --- a/IPython/terminal/ptutils.py +++ b/IPython/terminal/ptutils.py @@ -10,8 +10,6 @@ not to be used outside IPython. import unicodedata from wcwidth import wcwidth -from IPython.utils.py3compat import PY3 - from IPython.core.completer import IPCompleter from prompt_toolkit.completion import Completer, Completion from prompt_toolkit.layout.lexers import Lexer @@ -78,7 +76,7 @@ class IPythonPTLexer(Lexer): """ def __init__(self): l = pygments_lexers - self.python_lexer = PygmentsLexer(l.Python3Lexer if PY3 else l.PythonLexer) + self.python_lexer = PygmentsLexer(l.Python3Lexer) self.shell_lexer = PygmentsLexer(l.BashLexer) self.magic_lexers = { diff --git a/IPython/utils/tests/test_io.py b/IPython/utils/tests/test_io.py index 5f9e87e..b23a4a3 100644 --- a/IPython/utils/tests/test_io.py +++ b/IPython/utils/tests/test_io.py @@ -9,6 +9,7 @@ import io as stdlib_io import os.path import stat import sys +from io import StringIO from subprocess import Popen, PIPE import unittest @@ -17,14 +18,9 @@ import nose.tools as nt from IPython.testing.decorators import skipif, skip_win32 from IPython.utils.io import Tee, capture_output -from IPython.utils.py3compat import doctest_refactor_print, PY3 +from IPython.utils.py3compat import doctest_refactor_print from IPython.utils.tempdir import TemporaryDirectory -if PY3: - from io import StringIO -else: - from StringIO import StringIO - def test_tee_simple(): "Very simple check with stdout only"