Show More
@@ -2623,10 +2623,10 b' class InteractiveShell(SingletonConfigurable):' | |||
|
2623 | 2623 | stb = self.InteractiveTB.get_exception_only(etype, evalue) |
|
2624 | 2624 | |
|
2625 | 2625 | exc_info = { |
|
2626 |
|
|
|
2627 |
|
|
|
2628 |
|
|
|
2629 |
|
|
|
2626 | "status": "error", | |
|
2627 | "traceback": stb, | |
|
2628 | "ename": etype.__name__, | |
|
2629 | "evalue": py3compat.safe_unicode(evalue), | |
|
2630 | 2630 | } |
|
2631 | 2631 | |
|
2632 | 2632 | return exc_info |
@@ -16,7 +16,6 b' from IPython.core.magic import (' | |||
|
16 | 16 | Magics, magics_class, line_magic, cell_magic |
|
17 | 17 | ) |
|
18 | 18 | from IPython.lib.backgroundjobs import BackgroundJobManager |
|
19 | from IPython.utils import py3compat | |
|
20 | 19 | from IPython.utils.process import arg_split |
|
21 | 20 | from traitlets import List, Dict, default |
|
22 | 21 |
@@ -2,7 +2,6 b' import tokenize' | |||
|
2 | 2 | import nose.tools as nt |
|
3 | 3 | |
|
4 | 4 | from IPython.testing import tools as tt |
|
5 | from IPython.utils import py3compat | |
|
6 | 5 | |
|
7 | 6 | from IPython.core import inputtransformer as ipt |
|
8 | 7 |
@@ -55,72 +55,6 b' def safe_unicode(e):' | |||
|
55 | 55 | |
|
56 | 56 | return u'Unrecoverably corrupt evalue' |
|
57 | 57 | |
|
58 | # shutil.which from Python 3.4 | |
|
59 | def _shutil_which(cmd, mode=os.F_OK | os.X_OK, path=None): | |
|
60 | """Given a command, mode, and a PATH string, return the path which | |
|
61 | conforms to the given mode on the PATH, or None if there is no such | |
|
62 | file. | |
|
63 | ||
|
64 | `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result | |
|
65 | of os.environ.get("PATH"), or can be overridden with a custom search | |
|
66 | path. | |
|
67 | ||
|
68 | This is a backport of shutil.which from Python 3.4 | |
|
69 | """ | |
|
70 | # Check that a given file can be accessed with the correct mode. | |
|
71 | # Additionally check that `file` is not a directory, as on Windows | |
|
72 | # directories pass the os.access check. | |
|
73 | def _access_check(fn, mode): | |
|
74 | return (os.path.exists(fn) and os.access(fn, mode) | |
|
75 | and not os.path.isdir(fn)) | |
|
76 | ||
|
77 | # If we're given a path with a directory part, look it up directly rather | |
|
78 | # than referring to PATH directories. This includes checking relative to the | |
|
79 | # current directory, e.g. ./script | |
|
80 | if os.path.dirname(cmd): | |
|
81 | if _access_check(cmd, mode): | |
|
82 | return cmd | |
|
83 | return None | |
|
84 | ||
|
85 | if path is None: | |
|
86 | path = os.environ.get("PATH", os.defpath) | |
|
87 | if not path: | |
|
88 | return None | |
|
89 | path = path.split(os.pathsep) | |
|
90 | ||
|
91 | if sys.platform == "win32": | |
|
92 | # The current directory takes precedence on Windows. | |
|
93 | if not os.curdir in path: | |
|
94 | path.insert(0, os.curdir) | |
|
95 | ||
|
96 | # PATHEXT is necessary to check on Windows. | |
|
97 | pathext = os.environ.get("PATHEXT", "").split(os.pathsep) | |
|
98 | # See if the given file matches any of the expected path extensions. | |
|
99 | # This will allow us to short circuit when given "python.exe". | |
|
100 | # If it does match, only test that one, otherwise we have to try | |
|
101 | # others. | |
|
102 | if any(cmd.lower().endswith(ext.lower()) for ext in pathext): | |
|
103 | files = [cmd] | |
|
104 | else: | |
|
105 | files = [cmd + ext for ext in pathext] | |
|
106 | else: | |
|
107 | # On other platforms you don't have things like PATHEXT to tell you | |
|
108 | # what file suffixes are executable, so just pass on cmd as-is. | |
|
109 | files = [cmd] | |
|
110 | ||
|
111 | seen = set() | |
|
112 | for dir in path: | |
|
113 | normdir = os.path.normcase(dir) | |
|
114 | if not normdir in seen: | |
|
115 | seen.add(normdir) | |
|
116 | for thefile in files: | |
|
117 | name = os.path.join(dir, thefile) | |
|
118 | if _access_check(name, mode): | |
|
119 | return name | |
|
120 | return None | |
|
121 | ||
|
122 | PY3 = True | |
|
123 | ||
|
124 | 58 | # keep reference to builtin_mod because the kernel overrides that value |
|
125 | 59 | # to forward requests to a frontend. |
|
126 | 60 | def input(prompt=''): |
@@ -129,16 +63,6 b" def input(prompt=''):" | |||
|
129 | 63 | builtin_mod_name = "builtins" |
|
130 | 64 | import builtins as builtin_mod |
|
131 | 65 | |
|
132 | ||
|
133 | which = shutil.which | |
|
134 | ||
|
135 | def isidentifier(s, dotted=False): | |
|
136 | if dotted: | |
|
137 | return all(isidentifier(a) for a in s.split(".")) | |
|
138 | return s.isidentifier() | |
|
139 | ||
|
140 | getcwd = os.getcwd | |
|
141 | ||
|
142 | 66 | MethodType = types.MethodType |
|
143 | 67 | |
|
144 | 68 | def execfile(fname, glob, loc=None, compiler=None): |
@@ -147,7 +71,6 b' def execfile(fname, glob, loc=None, compiler=None):' | |||
|
147 | 71 | compiler = compiler or compile |
|
148 | 72 | exec(compiler(f.read(), fname, 'exec'), glob, loc) |
|
149 | 73 | |
|
150 | PY2 = not PY3 | |
|
151 | 74 | PYPY = platform.python_implementation() == "PyPy" |
|
152 | 75 | |
|
153 | 76 | # Cython still rely on that as a Dec 28 2019 |
General Comments 0
You need to be logged in to leave comments.
Login now