William, On 10/25/06, William Stein <[EMAIL PROTECTED]> wrote: > > Fernando, > > 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). But I realize that your pyrex-generated files will provide 'reasonable' information when queried, which is why you want to actually open them. Is there any way we can distinguish your files from non-pyrex, non-docstring-enhanced binary extensions? I want to provide access to the pyrex embedded info, but at the same time protect the users from terminal corruption from other binary libs. A last resort solution can be to analyze the returned string and try to guess that it's binary from the presence of high-order bits in it, but I'd like to know if your pyrex conventions provide a simpler solution. Regards, f --~--~---------~--~----~------------~-------~--~----~ 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/ -~----------~----~----~----~------~----~------~--~---