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