Show More
@@ -833,7 +833,7 b' class InteractiveShell(Component, Magic):' | |||
|
833 | 833 | # loaded at startup, so we can list later only variables defined in |
|
834 | 834 | # actual interactive use. Since it is always a subset of user_ns, it |
|
835 | 835 | # doesn't need to be separately tracked in the ns_table. |
|
836 |
self.user_ |
|
|
836 | self.user_ns_hidden = {} | |
|
837 | 837 | |
|
838 | 838 | # A namespace to keep track of internal data structures to prevent |
|
839 | 839 | # them from cluttering user-visible stuff. Will be updated later |
@@ -879,7 +879,7 b' class InteractiveShell(Component, Magic):' | |||
|
879 | 879 | # Similarly, track all namespaces where references can be held and that |
|
880 | 880 | # we can safely clear (so it can NOT include builtin). This one can be |
|
881 | 881 | # a simple list. |
|
882 |
self.ns_refs_table = [ user_ns, user_global_ns, self.user_ |
|
|
882 | self.ns_refs_table = [ user_ns, user_global_ns, self.user_ns_hidden, | |
|
883 | 883 | self.internal_ns, self._main_ns_cache ] |
|
884 | 884 | |
|
885 | 885 | def make_user_namespaces(self, user_ns=None, user_global_ns=None): |
@@ -978,7 +978,7 b' class InteractiveShell(Component, Magic):' | |||
|
978 | 978 | therm. |
|
979 | 979 | """ |
|
980 | 980 | # This function works in two parts: first we put a few things in |
|
981 |
# user_ns, and we sync that contents into user_ |
|
|
981 | # user_ns, and we sync that contents into user_ns_hidden so that these | |
|
982 | 982 | # initial variables aren't shown by %who. After the sync, we add the |
|
983 | 983 | # rest of what we *do* want the user to see with %who even on a new |
|
984 | 984 | # session (probably nothing, so theye really only see their own stuff) |
@@ -1018,9 +1018,9 b' class InteractiveShell(Component, Magic):' | |||
|
1018 | 1018 | # Store myself as the public api!!! |
|
1019 | 1019 | ns['get_ipython'] = self.get_ipython |
|
1020 | 1020 | |
|
1021 |
# Sync what we've added so far to user_ |
|
|
1021 | # Sync what we've added so far to user_ns_hidden so these aren't seen | |
|
1022 | 1022 | # by %who |
|
1023 |
self.user_ |
|
|
1023 | self.user_ns_hidden.update(ns) | |
|
1024 | 1024 | |
|
1025 | 1025 | # Anything put into ns now would show up in %who. Think twice before |
|
1026 | 1026 | # putting anything here, as we really want %who to show the user their |
@@ -1093,7 +1093,7 b' class InteractiveShell(Component, Magic):' | |||
|
1093 | 1093 | self.user_ns.update(vdict) |
|
1094 | 1094 | |
|
1095 | 1095 | # And configure interactive visibility |
|
1096 |
config_ns = self.user_ |
|
|
1096 | config_ns = self.user_ns_hidden | |
|
1097 | 1097 | if interactive: |
|
1098 | 1098 | for name, val in vdict.iteritems(): |
|
1099 | 1099 | config_ns.pop(name, None) |
@@ -2360,6 +2360,9 b' class InteractiveShell(Component, Magic):' | |||
|
2360 | 2360 | to make it easy to write extensions, you can also put your extensions |
|
2361 | 2361 | in ``os.path.join(self.ipython_dir, 'extensions')``. This directory |
|
2362 | 2362 | is added to ``sys.path`` automatically. |
|
2363 | ||
|
2364 | If :func:`load_ipython_extension` returns anything, this function | |
|
2365 | will return that object. | |
|
2363 | 2366 | """ |
|
2364 | 2367 | from IPython.utils.syspathcontext import prepended_to_syspath |
|
2365 | 2368 | |
@@ -2504,11 +2507,11 b' class InteractiveShell(Component, Magic):' | |||
|
2504 | 2507 | # We want to prevent the loading of pylab to pollute the user's |
|
2505 | 2508 | # namespace as shown by the %who* magics, so we execute the activation |
|
2506 | 2509 | # code in an empty namespace, and we update *both* user_ns and |
|
2507 |
# user_ |
|
|
2510 | # user_ns_hidden with this information. | |
|
2508 | 2511 | ns = {} |
|
2509 | 2512 | gui = pylab_activate(ns, gui) |
|
2510 | 2513 | self.user_ns.update(ns) |
|
2511 |
self.user_ |
|
|
2514 | self.user_ns_hidden.update(ns) | |
|
2512 | 2515 | # Now we must activate the gui pylab wants to use, and fix %run to take |
|
2513 | 2516 | # plot updates into account |
|
2514 | 2517 | enable_gui(gui) |
@@ -886,10 +886,10 b' Currently the magic system has the following functions:\\n"""' | |||
|
886 | 886 | |
|
887 | 887 | user_ns = self.shell.user_ns |
|
888 | 888 | internal_ns = self.shell.internal_ns |
|
889 |
user_ |
|
|
889 | user_ns_hidden = self.shell.user_ns_hidden | |
|
890 | 890 | out = [ i for i in user_ns |
|
891 | 891 | if not i.startswith('_') \ |
|
892 |
and not (i in internal_ns or i in user_ |
|
|
892 | and not (i in internal_ns or i in user_ns_hidden) ] | |
|
893 | 893 | |
|
894 | 894 | typelist = parameter_s.split() |
|
895 | 895 | if typelist: |
@@ -30,9 +30,9 b' ip = get_ipython()' | |||
|
30 | 30 | @dec.parametric |
|
31 | 31 | def test_reset(): |
|
32 | 32 | """reset must clear most namespaces.""" |
|
33 |
# The number of variables in the private user_ |
|
|
33 | # The number of variables in the private user_ns_hidden is not zero, but it | |
|
34 | 34 | # should be constant regardless of what we do |
|
35 |
nvars_config_ns = len(ip.user_ |
|
|
35 | nvars_config_ns = len(ip.user_ns_hidden) | |
|
36 | 36 | |
|
37 | 37 | # Check that reset runs without error |
|
38 | 38 | ip.reset() |
@@ -51,7 +51,7 b' def test_reset():' | |||
|
51 | 51 | for ns in ip.ns_refs_table: |
|
52 | 52 | if ns is ip.user_ns: |
|
53 | 53 | nvars_expected = nvars_user_ns |
|
54 |
elif ns is ip.user_ |
|
|
54 | elif ns is ip.user_ns_hidden: | |
|
55 | 55 | nvars_expected = nvars_config_ns |
|
56 | 56 | else: |
|
57 | 57 | nvars_expected = 0 |
@@ -18,6 +18,8 b' __test__ = {}' | |||
|
18 | 18 | # Imports |
|
19 | 19 | #------------------------------------------------------------------------------- |
|
20 | 20 | |
|
21 | from twisted.python import failure | |
|
22 | ||
|
21 | 23 | from IPython.kernel.core import error |
|
22 | 24 | |
|
23 | 25 | #------------------------------------------------------------------------------- |
@@ -27,6 +29,7 b' from IPython.kernel.core import error' | |||
|
27 | 29 | class KernelError(error.IPythonError): |
|
28 | 30 | pass |
|
29 | 31 | |
|
32 | ||
|
30 | 33 | class NotDefined(KernelError): |
|
31 | 34 | def __init__(self, name): |
|
32 | 35 | self.name = name |
@@ -37,78 +40,102 b' class NotDefined(KernelError):' | |||
|
37 | 40 | |
|
38 | 41 | __str__ = __repr__ |
|
39 | 42 | |
|
43 | ||
|
40 | 44 | class QueueCleared(KernelError): |
|
41 | 45 | pass |
|
42 | 46 | |
|
47 | ||
|
43 | 48 | class IdInUse(KernelError): |
|
44 | 49 | pass |
|
45 | 50 | |
|
51 | ||
|
46 | 52 | class ProtocolError(KernelError): |
|
47 | 53 | pass |
|
48 | 54 | |
|
55 | ||
|
49 | 56 | class ConnectionError(KernelError): |
|
50 | 57 | pass |
|
51 | 58 | |
|
59 | ||
|
52 | 60 | class InvalidEngineID(KernelError): |
|
53 | 61 | pass |
|
54 | ||
|
62 | ||
|
63 | ||
|
55 | 64 | class NoEnginesRegistered(KernelError): |
|
56 | 65 | pass |
|
57 | ||
|
66 | ||
|
67 | ||
|
58 | 68 | class InvalidClientID(KernelError): |
|
59 | 69 | pass |
|
60 | ||
|
70 | ||
|
71 | ||
|
61 | 72 | class InvalidDeferredID(KernelError): |
|
62 | 73 | pass |
|
63 | ||
|
74 | ||
|
75 | ||
|
64 | 76 | class SerializationError(KernelError): |
|
65 | 77 | pass |
|
66 | ||
|
78 | ||
|
79 | ||
|
67 | 80 | class MessageSizeError(KernelError): |
|
68 | 81 | pass |
|
69 | ||
|
82 | ||
|
83 | ||
|
70 | 84 | class PBMessageSizeError(MessageSizeError): |
|
71 | 85 | pass |
|
72 | ||
|
86 | ||
|
87 | ||
|
73 | 88 | class ResultNotCompleted(KernelError): |
|
74 | 89 | pass |
|
75 | ||
|
90 | ||
|
91 | ||
|
76 | 92 | class ResultAlreadyRetrieved(KernelError): |
|
77 | 93 | pass |
|
78 | ||
|
94 | ||
|
79 | 95 | class ClientError(KernelError): |
|
80 | 96 | pass |
|
81 | 97 | |
|
98 | ||
|
82 | 99 | class TaskAborted(KernelError): |
|
83 | 100 | pass |
|
84 | 101 | |
|
102 | ||
|
85 | 103 | class TaskTimeout(KernelError): |
|
86 | 104 | pass |
|
87 | 105 | |
|
106 | ||
|
88 | 107 | class NotAPendingResult(KernelError): |
|
89 | 108 | pass |
|
90 | 109 | |
|
110 | ||
|
91 | 111 | class UnpickleableException(KernelError): |
|
92 | 112 | pass |
|
93 | 113 | |
|
114 | ||
|
94 | 115 | class AbortedPendingDeferredError(KernelError): |
|
95 | 116 | pass |
|
96 | 117 | |
|
118 | ||
|
97 | 119 | class InvalidProperty(KernelError): |
|
98 | 120 | pass |
|
99 | 121 | |
|
122 | ||
|
100 | 123 | class MissingBlockArgument(KernelError): |
|
101 | 124 | pass |
|
102 | 125 | |
|
126 | ||
|
103 | 127 | class StopLocalExecution(KernelError): |
|
104 | 128 | pass |
|
105 | 129 | |
|
130 | ||
|
106 | 131 | class SecurityError(KernelError): |
|
107 | 132 | pass |
|
108 | 133 | |
|
134 | ||
|
109 | 135 | class FileTimeoutError(KernelError): |
|
110 | 136 | pass |
|
111 | 137 | |
|
138 | ||
|
112 | 139 | class TaskRejectError(KernelError): |
|
113 | 140 | """Exception to raise when a task should be rejected by an engine. |
|
114 | 141 | |
@@ -123,6 +150,7 b' class TaskRejectError(KernelError):' | |||
|
123 | 150 | properties don't have to be managed or tested by the controller. |
|
124 | 151 | """ |
|
125 | 152 | |
|
153 | ||
|
126 | 154 | class CompositeError(KernelError): |
|
127 | 155 | def __init__(self, message, elist): |
|
128 | 156 | Exception.__init__(self, *(message, elist)) |
@@ -177,9 +205,8 b' class CompositeError(KernelError):' | |||
|
177 | 205 | else: |
|
178 | 206 | raise et, ev, etb |
|
179 | 207 | |
|
180 | def collect_exceptions(rlist, method): | |
|
181 | from twisted.python import failure | |
|
182 | 208 | |
|
209 | def collect_exceptions(rlist, method): | |
|
183 | 210 | elist = [] |
|
184 | 211 | for r in rlist: |
|
185 | 212 | if isinstance(r, failure.Failure): |
@@ -188,12 +188,7 b' def get_home_dir():' | |||
|
188 | 188 | # is needed when running IPython on cluster where all paths have to |
|
189 | 189 | # be UNC. |
|
190 | 190 | try: |
|
191 | # A user with a lot of unix tools in win32 may have defined $HOME, | |
|
192 | # honor it if it exists, but otherwise let the more typical | |
|
193 | # %HOMESHARE% variable be used. | |
|
194 | homedir = env.get('HOME') | |
|
195 | if homedir is None: | |
|
196 | homedir = env['HOMESHARE'] | |
|
191 | homedir = env['HOMESHARE'] | |
|
197 | 192 | except KeyError: |
|
198 | 193 | pass |
|
199 | 194 | else: |
@@ -233,6 +228,16 b' def get_home_dir():' | |||
|
233 | 228 | if isdir(homedir): |
|
234 | 229 | return homedir.decode(sys.getfilesystemencoding()) |
|
235 | 230 | |
|
231 | # A user with a lot of unix tools in win32 may have defined $HOME. | |
|
232 | # Try this as a last ditch option. | |
|
233 | try: | |
|
234 | homedir = env['HOME'] | |
|
235 | except KeyError: | |
|
236 | pass | |
|
237 | else: | |
|
238 | if isdir(homedir): | |
|
239 | return homedir.decode(sys.getfilesystemencoding()) | |
|
240 | ||
|
236 | 241 | # If all else fails, raise HomeDirError |
|
237 | 242 | raise HomeDirError('No valid home directory could be found') |
|
238 | 243 | elif os.name == 'dos': |
General Comments 0
You need to be logged in to leave comments.
Login now