On Thu, 26 Oct 2006 15:46:05 -0500, Fernando Perez <[EMAIL PROTECTED]>  
wrote:
>> I just implemented "??" source code introspection for Pyrex-defined
>> function for SAGE.
>> E.g., one can now do this:
>
> I was about to apply this patch to the ipython tree, but I have one
> issue with this part:
>
>> @@ -402,11 +406,10 @@ class Inspector:
>>               linecache.checkcache()
>>               source_success = False
>>               try:
>> -                if not binary_file:
>> -                    source = self.format(inspect.getsource(obj))
>> -                    out.write(header('Source:\n')+source.rstrip())
>> -                    source_success = True
>> -            except:
>> +                source = self.format(inspect_getsource(obj))
>> +                out.write(header('Source:\n')+source.rstrip())
>> +                source_success = True
>> +            except Exception, msg:
>>                   pass
>
>
> The reason to have that 'if not binary_file' check, was to avoid
> dumping massive amounts of binary data on your screen if you happen to
> type foo?? where 'foo' is some arbitrary foo.so extension module.
> This happened several times to users, and since binary dumps in a
> terminal often end up corrupting the terminal state itself (the
> teminal interprets them as control codes), this is a Bad Thing (TM).

Do you have any examples where this happens.  Whenever I try to use
inspect.getsource on a binary file, I get

<type 'exceptions.TypeError'>: arg is not a module, class, method,  
function, traceback, frame, or code object

Maybe this problem you had was only with Python << 2.5?

Perhaps you could put the "if not binary_file" in your inspect_getsource  
instead?

William


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to