##// END OF EJS Templates
Merge pull request #12110 from terrdavis/remove-py2-workarounds-1of2...
Matthias Bussonnier -
r25463:6b91afe8 merge
parent child Browse files
Show More
@@ -198,8 +198,7 b' def is_simple_callable(obj):'
198 198
199 199 @undoc
200 200 def getargspec(obj):
201 """Wrapper around :func:`inspect.getfullargspec` on Python 3, and
202 :func:inspect.getargspec` on Python 2.
201 """Wrapper around :func:`inspect.getfullargspec`
203 202
204 203 In addition to functions and methods, this can also handle objects with a
205 204 ``__call__`` attribute.
@@ -101,10 +101,7 b' import time'
101 101 import tokenize
102 102 import traceback
103 103
104 try: # Python 2
105 generate_tokens = tokenize.generate_tokens
106 except AttributeError: # Python 3
107 generate_tokens = tokenize.tokenize
104 from tokenize import generate_tokens
108 105
109 106 # For purposes of monkeypatching inspect to fix a bug in it.
110 107 from inspect import getsourcefile, getfile, getmodule, \
@@ -7,13 +7,7 b' passed. The :func:`reload` function in this module also reloads everything'
7 7 imported from that module, which is useful when you're changing files deep
8 8 inside a package.
9 9
10 To use this as your default reload function, type this for Python 2::
11
12 import __builtin__
13 from IPython.lib import deepreload
14 __builtin__.reload = deepreload.reload
15
16 Or this for Python 3::
10 To use this as your default reload function, type this::
17 11
18 12 import builtins
19 13 from IPython.lib import deepreload
@@ -129,7 +129,7 b' class IPythonPartialTracebackLexer(RegexLexer):'
129 129 """
130 130 Partial lexer for IPython tracebacks.
131 131
132 Handles all the non-python output. This works for both Python 2.x and 3.x.
132 Handles all the non-python output.
133 133
134 134 """
135 135 name = 'IPython Partial Traceback'
@@ -263,18 +263,7 b' class PrettyPrinter(_PrettyPrinterBase):'
263 263
264 264 def begin_group(self, indent=0, open=''):
265 265 """
266 Begin a group. If you want support for python < 2.5 which doesn't has
267 the with statement this is the preferred way:
268
269 p.begin_group(1, '{')
270 ...
271 p.end_group(1, '}')
272
273 The python 2.5 expression would be this:
274
275 with p.group(1, '{', '}'):
276 ...
277
266 Begin a group.
278 267 The first parameter specifies the indentation for the next line (usually
279 268 the width of the opening text), the second the opening text. All
280 269 parameters are optional.
@@ -775,12 +764,8 b' except AttributeError: # Python 3'
775 764 _dict_pprinter_factory('mappingproxy({', '})')
776 765 _type_pprinters[slice] = _repr_pprint
777 766
778 try:
779 _type_pprinters[long] = _repr_pprint
780 _type_pprinters[unicode] = _repr_pprint
781 except NameError:
782 _type_pprinters[range] = _repr_pprint
783 _type_pprinters[bytes] = _repr_pprint
767 _type_pprinters[range] = _repr_pprint
768 _type_pprinters[bytes] = _repr_pprint
784 769
785 770 #: printers for types specified by name
786 771 _deferred_type_pprinters = {
@@ -14,11 +14,7 b''
14 14 #-----------------------------------------------------------------------------
15 15 from tempfile import NamedTemporaryFile, mkdtemp
16 16 from os.path import split, join as pjoin, dirname
17 import sys
18 try:
19 import pathlib
20 except ImportError:
21 pass
17 import pathlib
22 18 from unittest import TestCase, mock
23 19 import struct
24 20 import wave
@@ -44,7 +44,7 b' def getdefaultencoding(prefer_stream=True):'
44 44 Then fall back on locale.getpreferredencoding(),
45 45 which should be a sensible platform default (that respects LANG environment),
46 46 and finally to sys.getdefaultencoding() which is the most conservative option,
47 and usually ASCII on Python 2 or UTF8 on Python 3.
47 and usually UTF8 as of Python 3.
48 48 """
49 49 enc = None
50 50 if prefer_stream:
@@ -66,8 +66,7 b' def read_py_file(filename, skip_encoding_cookie=True):'
66 66 The path to the file to read.
67 67 skip_encoding_cookie : bool
68 68 If True (the default), and the encoding declaration is found in the first
69 two lines, that line will be excluded from the output - compiling a
70 unicode string with an encoding declaration is a SyntaxError in Python 2.
69 two lines, that line will be excluded from the output.
71 70
72 71 Returns
73 72 -------
@@ -91,8 +90,7 b" def read_py_url(url, errors='replace', skip_encoding_cookie=True):"
91 90 bytes.decode(), but here 'replace' is the default.
92 91 skip_encoding_cookie : bool
93 92 If True (the default), and the encoding declaration is found in the first
94 two lines, that line will be excluded from the output - compiling a
95 unicode string with an encoding declaration is a SyntaxError in Python 2.
93 two lines, that line will be excluded from the output.
96 94
97 95 Returns
98 96 -------
@@ -35,5 +35,4 b' with dest:'
35 35 hist = HistoryAccessor()
36 36
37 37 for session, lineno, cell in hist.get_range(session=session_number, raw=raw):
38 cell = cell.encode('utf-8') # This line is only needed on Python 2.
39 38 dest.write(cell + '\n')
General Comments 0
You need to be logged in to leave comments. Login now