Show More
@@ -16,6 +16,7 b'' | |||
|
16 | 16 | #----------------------------------------------------------------------------- |
|
17 | 17 | |
|
18 | 18 | import __builtin__ |
|
19 | import __future__ | |
|
19 | 20 | import bdb |
|
20 | 21 | import inspect |
|
21 | 22 | import os |
@@ -209,9 +210,7 b' python-profiler package from non-free.""")' | |||
|
209 | 210 | |
|
210 | 211 | Has special code to detect magic functions. |
|
211 | 212 | """ |
|
212 | ||
|
213 | 213 | oname = oname.strip() |
|
214 | ||
|
215 | 214 | alias_ns = None |
|
216 | 215 | if namespaces is None: |
|
217 | 216 | # Namespaces to search in: |
@@ -225,8 +224,16 b' python-profiler package from non-free.""")' | |||
|
225 | 224 | alias_ns = self.shell.alias_manager.alias_table |
|
226 | 225 | |
|
227 | 226 | # initialize results to 'null' |
|
228 |
found = |
|
|
229 |
ismagic = |
|
|
227 | found = False; obj = None; ospace = None; ds = None; | |
|
228 | ismagic = False; isalias = False; parent = None | |
|
229 | ||
|
230 | # We need to special-case 'print', which as of python2.6 registers as a | |
|
231 | # function but should only be treated as one if print_function was | |
|
232 | # loaded with a future import. In this case, just bail. | |
|
233 | if (oname == 'print' and not (self.shell.compile.compiler.flags & | |
|
234 | __future__.CO_FUTURE_PRINT_FUNCTION)): | |
|
235 | return {'found':found, 'obj':obj, 'namespace':ospace, | |
|
236 | 'ismagic':ismagic, 'isalias':isalias, 'parent':parent} | |
|
230 | 237 | |
|
231 | 238 | # Look for the given name by splitting it in parts. If the head is |
|
232 | 239 | # found, then we look for all the remaining parts as members, and only |
@@ -251,10 +258,10 b' python-profiler package from non-free.""")' | |||
|
251 | 258 | break |
|
252 | 259 | else: |
|
253 | 260 | # If we finish the for loop (no break), we got all members |
|
254 |
found = |
|
|
261 | found = True | |
|
255 | 262 | ospace = nsname |
|
256 | 263 | if ns == alias_ns: |
|
257 |
isalias = |
|
|
264 | isalias = True | |
|
258 | 265 | break # namespace loop |
|
259 | 266 | |
|
260 | 267 | # Try to see if it's magic |
@@ -263,14 +270,14 b' python-profiler package from non-free.""")' | |||
|
263 | 270 | oname = oname[1:] |
|
264 | 271 | obj = getattr(self,'magic_'+oname,None) |
|
265 | 272 | if obj is not None: |
|
266 |
found = |
|
|
273 | found = True | |
|
267 | 274 | ospace = 'IPython internal' |
|
268 |
ismagic = |
|
|
275 | ismagic = True | |
|
269 | 276 | |
|
270 | 277 | # Last try: special-case some literals like '', [], {}, etc: |
|
271 | 278 | if not found and oname_head in ["''",'""','[]','{}','()']: |
|
272 | 279 | obj = eval(oname_head) |
|
273 |
found = |
|
|
280 | found = True | |
|
274 | 281 | ospace = 'Interactive' |
|
275 | 282 | |
|
276 | 283 | return {'found':found, 'obj':obj, 'namespace':ospace, |
General Comments 0
You need to be logged in to leave comments.
Login now