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