Changeset 5639

Show
Ignore:
Timestamp:
08/05/12 14:33:12 (7 years ago)
Author:
albert
Message:

Interim fix for #1080.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • seattle/trunk/repy/safe.py

    r5637 r5639  
    313313     
    314314    # Read the output and close the pipe 
    315     output = proc.stdout.read() 
     315    rawoutput = proc.stdout.read() 
    316316    proc.stdout.close() 
    317      
     317 
     318    # Interim fix for #1080: Get rid of stray debugging output on Android 
     319    # of the form "dlopen libpython2.6.so" and "dlopen /system/lib/libc.so", 
     320    # yet preserve all of the other output (including empty lines). 
     321 
     322    output = "" 
     323    for line in rawoutput.split("\n"): 
     324      # Preserve empty lines 
     325      if line == "": 
     326        output += "\n" 
     327        continue 
     328      # Suppress debug messages we know can turn up 
     329      wordlist = line.split() 
     330      if wordlist[0]=="dlopen": 
     331        if wordlist[-1]=="/system/lib/libc.so": 
     332          continue 
     333        if wordlist[-1].startswith("libpython") and \ 
     334          wordlist[-1].endswith(".so"): 
     335          # We expect "libpython" + version number + ".so". 
     336          # The version number should be a string convertible to float. 
     337          # If it's not, raise an exception. 
     338          try: 
     339            versionstring = (wordlist[-1].replace("libpython",  
     340              "")).replace(".so", "") 
     341            junk = float(versionstring) 
     342          except TypeError, ValueError: 
     343            raise Exception("Unexpected debug output '" + line +  
     344              "' while evaluating code safety!") 
     345      else: 
     346        output += line + "\n" 
     347 
     348    # Strip off the last newline character we added 
     349    output = output[0:-1] 
     350 
    318351    # Check the output, None is success, else it is a failure 
    319352    if output == "None":