diff --git a/IPython/core/oinspect.py b/IPython/core/oinspect.py index c27d8b3..ab25eee 100644 --- a/IPython/core/oinspect.py +++ b/IPython/core/oinspect.py @@ -198,8 +198,7 @@ def is_simple_callable(obj): @undoc def getargspec(obj): - """Wrapper around :func:`inspect.getfullargspec` on Python 3, and - :func:inspect.getargspec` on Python 2. + """Wrapper around :func:`inspect.getfullargspec` In addition to functions and methods, this can also handle objects with a ``__call__`` attribute. diff --git a/IPython/core/ultratb.py b/IPython/core/ultratb.py index e1f8057..9e7e8fb 100644 --- a/IPython/core/ultratb.py +++ b/IPython/core/ultratb.py @@ -101,10 +101,7 @@ import time import tokenize import traceback -try: # Python 2 - generate_tokens = tokenize.generate_tokens -except AttributeError: # Python 3 - generate_tokens = tokenize.tokenize +from tokenize import generate_tokens # For purposes of monkeypatching inspect to fix a bug in it. from inspect import getsourcefile, getfile, getmodule, \ diff --git a/IPython/lib/deepreload.py b/IPython/lib/deepreload.py index 37dd21a..bd8c01b 100644 --- a/IPython/lib/deepreload.py +++ b/IPython/lib/deepreload.py @@ -7,13 +7,7 @@ passed. The :func:`reload` function in this module also reloads everything imported from that module, which is useful when you're changing files deep inside a package. -To use this as your default reload function, type this for Python 2:: - - import __builtin__ - from IPython.lib import deepreload - __builtin__.reload = deepreload.reload - -Or this for Python 3:: +To use this as your default reload function, type this:: import builtins from IPython.lib import deepreload diff --git a/IPython/lib/lexers.py b/IPython/lib/lexers.py index 1677054..4494da5 100644 --- a/IPython/lib/lexers.py +++ b/IPython/lib/lexers.py @@ -129,7 +129,7 @@ class IPythonPartialTracebackLexer(RegexLexer): """ Partial lexer for IPython tracebacks. - Handles all the non-python output. This works for both Python 2.x and 3.x. + Handles all the non-python output. """ name = 'IPython Partial Traceback' diff --git a/IPython/lib/pretty.py b/IPython/lib/pretty.py index 50cec70..3115d3f 100644 --- a/IPython/lib/pretty.py +++ b/IPython/lib/pretty.py @@ -263,18 +263,7 @@ class PrettyPrinter(_PrettyPrinterBase): def begin_group(self, indent=0, open=''): """ - Begin a group. If you want support for python < 2.5 which doesn't has - the with statement this is the preferred way: - - p.begin_group(1, '{') - ... - p.end_group(1, '}') - - The python 2.5 expression would be this: - - with p.group(1, '{', '}'): - ... - + Begin a group. The first parameter specifies the indentation for the next line (usually the width of the opening text), the second the opening text. All parameters are optional. @@ -775,12 +764,8 @@ except AttributeError: # Python 3 _dict_pprinter_factory('mappingproxy({', '})') _type_pprinters[slice] = _repr_pprint -try: - _type_pprinters[long] = _repr_pprint - _type_pprinters[unicode] = _repr_pprint -except NameError: - _type_pprinters[range] = _repr_pprint - _type_pprinters[bytes] = _repr_pprint +_type_pprinters[range] = _repr_pprint +_type_pprinters[bytes] = _repr_pprint #: printers for types specified by name _deferred_type_pprinters = { diff --git a/IPython/lib/tests/test_display.py b/IPython/lib/tests/test_display.py index 533bb46..7e98a18 100644 --- a/IPython/lib/tests/test_display.py +++ b/IPython/lib/tests/test_display.py @@ -14,11 +14,7 @@ #----------------------------------------------------------------------------- from tempfile import NamedTemporaryFile, mkdtemp from os.path import split, join as pjoin, dirname -import sys -try: - import pathlib -except ImportError: - pass +import pathlib from unittest import TestCase, mock import struct import wave diff --git a/IPython/utils/encoding.py b/IPython/utils/encoding.py index 387a247..69a319e 100644 --- a/IPython/utils/encoding.py +++ b/IPython/utils/encoding.py @@ -44,7 +44,7 @@ def getdefaultencoding(prefer_stream=True): Then fall back on locale.getpreferredencoding(), which should be a sensible platform default (that respects LANG environment), and finally to sys.getdefaultencoding() which is the most conservative option, - and usually ASCII on Python 2 or UTF8 on Python 3. + and usually UTF8 as of Python 3. """ enc = None if prefer_stream: diff --git a/IPython/utils/openpy.py b/IPython/utils/openpy.py index 3046c31..c90d2b5 100644 --- a/IPython/utils/openpy.py +++ b/IPython/utils/openpy.py @@ -66,8 +66,7 @@ def read_py_file(filename, skip_encoding_cookie=True): The path to the file to read. skip_encoding_cookie : bool If True (the default), and the encoding declaration is found in the first - two lines, that line will be excluded from the output - compiling a - unicode string with an encoding declaration is a SyntaxError in Python 2. + two lines, that line will be excluded from the output. Returns ------- @@ -91,8 +90,7 @@ def read_py_url(url, errors='replace', skip_encoding_cookie=True): bytes.decode(), but here 'replace' is the default. skip_encoding_cookie : bool If True (the default), and the encoding declaration is found in the first - two lines, that line will be excluded from the output - compiling a - unicode string with an encoding declaration is a SyntaxError in Python 2. + two lines, that line will be excluded from the output. Returns ------- diff --git a/examples/IPython Kernel/ipython-get-history.py b/examples/IPython Kernel/ipython-get-history.py index 5615842..5e68bf5 100755 --- a/examples/IPython Kernel/ipython-get-history.py +++ b/examples/IPython Kernel/ipython-get-history.py @@ -35,5 +35,4 @@ with dest: hist = HistoryAccessor() for session, lineno, cell in hist.get_range(session=session_number, raw=raw): - cell = cell.encode('utf-8') # This line is only needed on Python 2. dest.write(cell + '\n')