File tree Expand file tree Collapse file tree 1 file changed +3
-12
lines changed Expand file tree Collapse file tree 1 file changed +3
-12
lines changed Original file line number Diff line number Diff line change @@ -389,27 +389,18 @@ def source_synopsis(file):
389389
390390    if  hasattr (file , 'buffer' ):
391391        file  =  file .buffer 
392-     if  isinstance (file , io .TextIOBase ):
393-         try :
394-             source  =  file .read ()
395-         except  UnicodeDecodeError :
396-             return  None 
397-     else :
398-         # Binary file 
399-         try :
400-             source  =  tokenize .untokenize (tokenize .tokenize (file .readline ))
401-         except  (tokenize .TokenError , UnicodeDecodeError ):
402-             return  None 
403392
404393    try :
394+         source  =  file .read ()
405395        tree  =  ast .parse (source )
396+ 
406397        if  (tree .body  and  isinstance (tree .body [0 ], ast .Expr ) and 
407398                isinstance (tree .body [0 ].value , ast .Constant ) and 
408399                isinstance (tree .body [0 ].value .value , str )):
409400            docstring  =  tree .body [0 ].value .value 
410401            return  docstring .strip ().split ('\n ' )[0 ].strip ()
411402        return  None 
412-     except  (SyntaxError , ValueError ) as  e :
403+     except  (UnicodeDecodeError ,  SyntaxError , ValueError ) as  e :
413404        return  None 
414405
415406def  synopsis (filename , cache = {}):
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments