##// END OF EJS Templates
Remove PY3 variable
Srinivas Reddy Thatiparthy -
Show More
@@ -36,7 +36,7 b' from IPython.core.magic import (Magics, magics_class, line_magic, cell_magic,'
36 line_cell_magic, on_off, needs_local_scope)
36 line_cell_magic, on_off, needs_local_scope)
37 from IPython.testing.skipdoctest import skip_doctest
37 from IPython.testing.skipdoctest import skip_doctest
38 from IPython.utils import py3compat
38 from IPython.utils import py3compat
39 from IPython.utils.py3compat import builtin_mod, PY3
39 from IPython.utils.py3compat import builtin_mod
40 from IPython.utils.contexts import preserve_keys
40 from IPython.utils.contexts import preserve_keys
41 from IPython.utils.capture import capture_output
41 from IPython.utils.capture import capture_output
42 from IPython.utils.ipstruct import Struct
42 from IPython.utils.ipstruct import Struct
@@ -45,11 +45,8 b' from IPython.utils.path import get_py_filename, shellglob'
45 from IPython.utils.timing import clock, clock2
45 from IPython.utils.timing import clock, clock2
46 from warnings import warn
46 from warnings import warn
47 from logging import error
47 from logging import error
48 from io import StringIO
48
49
49 if PY3:
50 from io import StringIO
51 else:
52 from StringIO import StringIO
53
50
54 #-----------------------------------------------------------------------------
51 #-----------------------------------------------------------------------------
55 # Magic implementation classes
52 # Magic implementation classes
@@ -652,9 +649,6 b' python-profiler package from non-free.""")'
652 args = shellglob(map(os.path.expanduser, arg_lst[1:]))
649 args = shellglob(map(os.path.expanduser, arg_lst[1:]))
653
650
654 sys.argv = [filename] + args # put in the proper filename
651 sys.argv = [filename] + args # put in the proper filename
655 # protect sys.argv from potential unicode strings on Python 2:
656 if not py3compat.PY3:
657 sys.argv = [ py3compat.cast_bytes(a) for a in sys.argv ]
658
652
659 if 'i' in opts:
653 if 'i' in opts:
660 # Run in user's interactive namespace
654 # Run in user's interactive namespace
@@ -28,10 +28,7 b' tests = ['
28 ('??%%hist4', ('', '??', '%%hist4', '')),
28 ('??%%hist4', ('', '??', '%%hist4', '')),
29 ('?x*', ('', '?', 'x*', '')),
29 ('?x*', ('', '?', 'x*', '')),
30 ]
30 ]
31 if py3compat.PY3:
31 tests.append((u"Pérez Fernando", (u'', u'', u'Pérez', u'Fernando')))
32 tests.append((u"Pérez Fernando", (u'', u'', u'Pérez', u'Fernando')))
33 else:
34 tests.append((u"Pérez Fernando", (u'', u'', u'P', u'érez Fernando')))
35
32
36 def test_split_user_input():
33 def test_split_user_input():
37 return tt.check_pairs(split_user_input, tests)
34 return tt.check_pairs(split_user_input, tests)
@@ -299,7 +299,10 b' def getargs(co):'
299
299
300 # Monkeypatch inspect to apply our bugfix.
300 # Monkeypatch inspect to apply our bugfix.
301 def with_patch_inspect(f):
301 def with_patch_inspect(f):
302 """decorator for monkeypatching inspect.findsource"""
302 """
303 Deprecated since IPython 6.0
304 decorator for monkeypatching inspect.findsource
305 """
303
306
304 def wrapped(*args, **kwargs):
307 def wrapped(*args, **kwargs):
305 save_findsource = inspect.findsource
308 save_findsource = inspect.findsource
@@ -315,16 +318,6 b' def with_patch_inspect(f):'
315 return wrapped
318 return wrapped
316
319
317
320
318 if py3compat.PY3:
319 fixed_getargvalues = inspect.getargvalues
320 else:
321 # Fixes for https://github.com/ipython/ipython/issues/8293
322 # and https://github.com/ipython/ipython/issues/8205.
323 # The relevant bug is caused by failure to correctly handle anonymous tuple
324 # unpacking, which only exists in Python 2.
325 fixed_getargvalues = with_patch_inspect(inspect.getargvalues)
326
327
328 def fix_frame_records_filenames(records):
321 def fix_frame_records_filenames(records):
329 """Try to fix the filenames in each record from inspect.getinnerframes().
322 """Try to fix the filenames in each record from inspect.getinnerframes().
330
323
@@ -879,7 +872,7 b' class VerboseTB(TBTools):'
879
872
880 file = py3compat.cast_unicode(file, util_path.fs_encoding)
873 file = py3compat.cast_unicode(file, util_path.fs_encoding)
881 link = tpl_link % file
874 link = tpl_link % file
882 args, varargs, varkw, locals = fixed_getargvalues(frame)
875 args, varargs, varkw, locals = inspect.getargvalues(frame)
883
876
884 if func == '?':
877 if func == '?':
885 call = ''
878 call = ''
@@ -10,8 +10,6 b' not to be used outside IPython.'
10 import unicodedata
10 import unicodedata
11 from wcwidth import wcwidth
11 from wcwidth import wcwidth
12
12
13 from IPython.utils.py3compat import PY3
14
15 from IPython.core.completer import IPCompleter
13 from IPython.core.completer import IPCompleter
16 from prompt_toolkit.completion import Completer, Completion
14 from prompt_toolkit.completion import Completer, Completion
17 from prompt_toolkit.layout.lexers import Lexer
15 from prompt_toolkit.layout.lexers import Lexer
@@ -78,7 +76,7 b' class IPythonPTLexer(Lexer):'
78 """
76 """
79 def __init__(self):
77 def __init__(self):
80 l = pygments_lexers
78 l = pygments_lexers
81 self.python_lexer = PygmentsLexer(l.Python3Lexer if PY3 else l.PythonLexer)
79 self.python_lexer = PygmentsLexer(l.Python3Lexer)
82 self.shell_lexer = PygmentsLexer(l.BashLexer)
80 self.shell_lexer = PygmentsLexer(l.BashLexer)
83
81
84 self.magic_lexers = {
82 self.magic_lexers = {
@@ -9,6 +9,7 b' import io as stdlib_io'
9 import os.path
9 import os.path
10 import stat
10 import stat
11 import sys
11 import sys
12 from io import StringIO
12
13
13 from subprocess import Popen, PIPE
14 from subprocess import Popen, PIPE
14 import unittest
15 import unittest
@@ -17,14 +18,9 b' import nose.tools as nt'
17
18
18 from IPython.testing.decorators import skipif, skip_win32
19 from IPython.testing.decorators import skipif, skip_win32
19 from IPython.utils.io import Tee, capture_output
20 from IPython.utils.io import Tee, capture_output
20 from IPython.utils.py3compat import doctest_refactor_print, PY3
21 from IPython.utils.py3compat import doctest_refactor_print
21 from IPython.utils.tempdir import TemporaryDirectory
22 from IPython.utils.tempdir import TemporaryDirectory
22
23
23 if PY3:
24 from io import StringIO
25 else:
26 from StringIO import StringIO
27
28
24
29 def test_tee_simple():
25 def test_tee_simple():
30 "Very simple check with stdout only"
26 "Very simple check with stdout only"
General Comments 0
You need to be logged in to leave comments. Login now