Skip to content

Commit 8d54414

Browse files
committed
remove some dead code especially wrt py3compat
1 parent 8d13184 commit 8d54414

File tree

5 files changed

+18
-48
lines changed

5 files changed

+18
-48
lines changed

IPython/core/completer.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,6 @@
178178
MATCHES_LIMIT = 500
179179

180180

181-
class Sentinel:
182-
def __repr__(self):
183-
return "<deprecated sentinel>"
184-
185-
186-
_deprecation_readline_sentinel = Sentinel()
187-
188-
189181
class ProvisionalCompleterWarning(FutureWarning):
190182
"""
191183
Exception raise by an experimental feature in this module.
@@ -618,8 +610,6 @@ class Completer(Configurable):
618610
"Includes completion of latex commands, unicode names, and expanding "
619611
"unicode characters back to latex commands.").tag(config=True)
620612

621-
622-
623613
def __init__(self, namespace=None, global_namespace=None, **kwargs):
624614
"""Create a new completer for the command line.
625615
@@ -1119,8 +1109,9 @@ def _limit_to_all_changed(self, change):
11191109
'no effects and then removed in future version of IPython.',
11201110
UserWarning)
11211111

1122-
def __init__(self, shell=None, namespace=None, global_namespace=None,
1123-
use_readline=_deprecation_readline_sentinel, config=None, **kwargs):
1112+
def __init__(
1113+
self, shell=None, namespace=None, global_namespace=None, config=None, **kwargs
1114+
):
11241115
"""IPCompleter() -> completer
11251116
11261117
Return a completer object.
@@ -1144,10 +1135,6 @@ def __init__(self, shell=None, namespace=None, global_namespace=None,
11441135
self.magic_escape = ESC_MAGIC
11451136
self.splitter = CompletionSplitter()
11461137

1147-
if use_readline is not _deprecation_readline_sentinel:
1148-
warnings.warn('The `use_readline` parameter is deprecated and ignored since IPython 6.0.',
1149-
DeprecationWarning, stacklevel=2)
1150-
11511138
# _greedy_changed() depends on splitter and readline being defined:
11521139
Completer.__init__(self, namespace=namespace, global_namespace=global_namespace,
11531140
config=config, **kwargs)

IPython/core/tests/test_iplib.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def doctest_tb_sysexit():
133133
In [20]: %tb
134134
Traceback (most recent call last):
135135
File ..., in execfile
136-
exec(compiler(f.read(), fname, 'exec'), glob, loc)
136+
exec(compiler(f.read(), fname, "exec"), glob, loc)
137137
File ..., in <module>
138138
bar(mode)
139139
File ..., in bar
@@ -149,9 +149,9 @@ def doctest_tb_sysexit():
149149
---------------------------------------------------------------------------
150150
SystemExit Traceback (most recent call last)
151151
File ..., in execfile(fname, glob, loc, compiler)
152-
70 with open(fname, 'rb') as f:
153-
71 compiler = compiler or compile
154-
---> 72 exec(compiler(f.read(), fname, 'exec'), glob, loc)
152+
... with open(fname, "rb") as f:
153+
... compiler = compiler or compile
154+
---> ... exec(compiler(f.read(), fname, "exec"), glob, loc)
155155
...<module>
156156
30 except IndexError:
157157
31 mode = 'div'

IPython/utils/_process_cli.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import os
2020

2121
# Import IPython libraries:
22-
from IPython.utils import py3compat
2322
from ._process_common import arg_split
2423

2524

IPython/utils/_process_posix.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
# Our own
2626
from ._process_common import getoutput, arg_split
27-
from IPython.utils import py3compat
2827
from IPython.utils.encoding import DEFAULT_ENCODING
2928

3029
#-----------------------------------------------------------------------------

IPython/utils/py3compat.py

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@
33
44
This file is deprecated and will be removed in a future version.
55
"""
6-
import functools
7-
import os
8-
import sys
9-
import re
10-
import shutil
11-
import types
126
import platform
7+
import builtins as builtin_mod
138

149
from .encoding import DEFAULT_ENCODING
1510

@@ -18,6 +13,7 @@ def decode(s, encoding=None):
1813
encoding = encoding or DEFAULT_ENCODING
1914
return s.decode(encoding, "replace")
2015

16+
2117
def encode(u, encoding=None):
2218
encoding = encoding or DEFAULT_ENCODING
2319
return u.encode(encoding, "replace")
@@ -28,16 +24,6 @@ def cast_unicode(s, encoding=None):
2824
return decode(s, encoding)
2925
return s
3026

31-
def cast_bytes(s, encoding=None):
32-
if not isinstance(s, bytes):
33-
return encode(s, encoding)
34-
return s
35-
36-
def buffer_to_bytes(buf):
37-
"""Cast a buffer object to bytes"""
38-
if not isinstance(buf, bytes):
39-
buf = bytes(buf)
40-
return buf
4127

4228
def safe_unicode(e):
4329
"""unicode(e) with various fallbacks. Used for exceptions, which may not be
@@ -53,30 +39,29 @@ def safe_unicode(e):
5339
except UnicodeError:
5440
pass
5541

56-
return u'Unrecoverably corrupt evalue'
42+
return "Unrecoverably corrupt evalue"
43+
5744

5845
# keep reference to builtin_mod because the kernel overrides that value
5946
# to forward requests to a frontend.
60-
def input(prompt=''):
47+
def input(prompt=""):
6148
return builtin_mod.input(prompt)
6249

63-
builtin_mod_name = "builtins"
64-
import builtins as builtin_mod
65-
66-
MethodType = types.MethodType
6750

6851
def execfile(fname, glob, loc=None, compiler=None):
6952
loc = loc if (loc is not None) else glob
70-
with open(fname, 'rb') as f:
53+
with open(fname, "rb") as f:
7154
compiler = compiler or compile
72-
exec(compiler(f.read(), fname, 'exec'), glob, loc)
55+
exec(compiler(f.read(), fname, "exec"), glob, loc)
56+
7357

7458
PYPY = platform.python_implementation() == "PyPy"
7559

7660
# Cython still rely on that as a Dec 28 2019
7761
# See https://github.com/cython/cython/pull/3291 and
7862
# https://github.com/ipython/ipython/issues/12068
7963
def no_code(x, encoding=None):
80-
return x
81-
unicode_to_str = cast_bytes_py2 = no_code
64+
return x
8265

66+
67+
unicode_to_str = cast_bytes_py2 = no_code

0 commit comments

Comments
 (0)