Show More
@@ -15,6 +15,7 b'' | |||
|
15 | 15 | |
|
16 | 16 | # Python standard modules |
|
17 | 17 | import __builtin__ |
|
18 | import __future__ | |
|
18 | 19 | import bdb |
|
19 | 20 | import inspect |
|
20 | 21 | import os |
@@ -192,9 +193,7 b' python-profiler package from non-free.""")' | |||
|
192 | 193 | |
|
193 | 194 | Has special code to detect magic functions. |
|
194 | 195 | """ |
|
195 | ||
|
196 | 196 | oname = oname.strip() |
|
197 | ||
|
198 | 197 | alias_ns = None |
|
199 | 198 | if namespaces is None: |
|
200 | 199 | # Namespaces to search in: |
@@ -208,8 +207,16 b' python-profiler package from non-free.""")' | |||
|
208 | 207 | alias_ns = self.shell.alias_table |
|
209 | 208 | |
|
210 | 209 | # initialize results to 'null' |
|
211 |
found = |
|
|
212 |
ismagic = |
|
|
210 | found = False; obj = None; ospace = None; ds = None; | |
|
211 | ismagic = False; isalias = False; parent = None | |
|
212 | ||
|
213 | # We need to special-case 'print', which as of python2.6 registers as a | |
|
214 | # function but should only be treated as one if print_function was | |
|
215 | # loaded with a future import. In this case, just bail. | |
|
216 | if (oname == 'print' and not (self.shell.compile.compiler.flags & | |
|
217 | __future__.CO_FUTURE_PRINT_FUNCTION)): | |
|
218 | return {'found':found, 'obj':obj, 'namespace':ospace, | |
|
219 | 'ismagic':ismagic, 'isalias':isalias, 'parent':parent} | |
|
213 | 220 | |
|
214 | 221 | # Look for the given name by splitting it in parts. If the head is |
|
215 | 222 | # found, then we look for all the remaining parts as members, and only |
@@ -234,10 +241,10 b' python-profiler package from non-free.""")' | |||
|
234 | 241 | break |
|
235 | 242 | else: |
|
236 | 243 | # If we finish the for loop (no break), we got all members |
|
237 |
found = |
|
|
244 | found = True | |
|
238 | 245 | ospace = nsname |
|
239 | 246 | if ns == alias_ns: |
|
240 |
isalias = |
|
|
247 | isalias = True | |
|
241 | 248 | break # namespace loop |
|
242 | 249 | |
|
243 | 250 | # Try to see if it's magic |
@@ -246,14 +253,14 b' python-profiler package from non-free.""")' | |||
|
246 | 253 | oname = oname[1:] |
|
247 | 254 | obj = getattr(self,'magic_'+oname,None) |
|
248 | 255 | if obj is not None: |
|
249 |
found = |
|
|
256 | found = True | |
|
250 | 257 | ospace = 'IPython internal' |
|
251 |
ismagic = |
|
|
258 | ismagic = True | |
|
252 | 259 | |
|
253 | 260 | # Last try: special-case some literals like '', [], {}, etc: |
|
254 | 261 | if not found and oname_head in ["''",'""','[]','{}','()']: |
|
255 | 262 | obj = eval(oname_head) |
|
256 |
found = |
|
|
263 | found = True | |
|
257 | 264 | ospace = 'Interactive' |
|
258 | 265 | |
|
259 | 266 | return {'found':found, 'obj':obj, 'namespace':ospace, |
General Comments 0
You need to be logged in to leave comments.
Login now