File tree Expand file tree Collapse file tree 4 files changed +29
-9
lines changed Expand file tree Collapse file tree 4 files changed +29
-9
lines changed Original file line number Diff line number Diff line change 1- import  itertools 
21from  collections  import  defaultdict 
32import  attr 
43import  numpy  as  np 
4+ from  pypytools .util  import  PY3 
5+ 
6+ if  not  PY3 :
7+     import  itertools 
58
69@attr .s  
710class  Event (object ):
@@ -46,15 +49,15 @@ def add_event(self, ev):
4649
4750    def  print_summary (self ):
4851        fmt  =  '%-28s %6s %8s' 
49-         print   fmt  %  ('section' , 'n' , 'delta' )
50-         print   '-' * 44 
52+         print ( fmt  %  ('section' , 'n' , 'delta' ) )
53+         print ( '-' * 44 ) 
5154        for  name , events  in  sorted (self .sections .iteritems ()):
5255            total  =  0 
5356            for  ev  in  events :
5457                delta  =  ev .end  -  ev .start 
5558                assert  delta  >=  0 
5659                total  +=  delta 
57-             print   fmt  %  (name , len (events ), format (delta , '.4f' ))
60+             print ( fmt  %  (name , len (events ), format (delta , '.4f' ) ))
5861
5962class  Series (object ):
6063
@@ -79,8 +82,12 @@ def __len__(self):
7982        return  len (self .X )
8083
8184    def  __iter__ (self ):
82-         for  x , y  in  itertools .izip (self .X , self .Y ):
83-             yield  x , y 
85+         if  PY3 :
86+             for  x , y  in  zip (self .X , self .Y ):
87+                 yield  x , y 
88+         else :
89+             for  x , y  in  itertools .izip (self .X , self .Y ):
90+                 yield  x , y 
8491
8592    def  __getitem__ (self , i ):
8693        return  self .X [i ], self .Y [i ]
Original file line number Diff line number Diff line change 11import  re 
22import  attr 
33from  pypytools .pypylog  import  model 
4+ from  pypytools .util  import  PY3 
45
56# stolen from rpython/tool/logparse.py 
67_color  =  "(?:\x1b .*?m)?" 
@@ -35,6 +36,8 @@ def parse_file(f):
3536        # 
3637        if  log  is  None :
3738            log  =  model .PyPyLog ()
39+         if  PY3 :
40+             basestring  =  str 
3841        if  isinstance (fname , basestring ):
3942            with  open (fname ) as  f :
4043                return  parse_file (f )
Original file line number Diff line number Diff line change 11import  pytest 
22import  textwrap 
3- from  cStringIO  import  StringIO 
3+ 
4+ from  pypytools .util  import  PY3 
5+ 
6+ if  PY3 :
7+     from  io  import  StringIO 
8+ else :
9+     from  cStringIO  import  StringIO 
10+ 
411from  pypytools .pypylog  import  parse 
512from  pypytools .pypylog  import  model 
613from  pypytools .pypylog .model  import  Event , GcMinor , GcCollectStep 
@@ -33,7 +40,7 @@ def test_mismatch(self):
3340        [456] foo} 
3441        [0ab] bar} 
3542        """ 
36-         pytest .raises (parse .ParseError ,  " self.parse(log)" 
43+         pytest .raises (parse .ParseError ( self .parse (log )) )
3744
3845    def  test_nested (self ):
3946        log  =  self .parse (""" 
@@ -124,4 +131,4 @@ def test_parse_frequency():
124131    assert  pf ('40 KHz' ) ==  40e3 
125132    assert  pf ('40 MHz' ) ==  40e6 
126133    assert  pf ('40 GHz' ) ==  40e9 
127-     pytest .raises (ValueError ,  " pf('')" 
134+     pytest .raises (ValueError ( pf ('' )) )
Original file line number Diff line number Diff line change 22from  sys  import  version_info 
33
44PY3  =  version_info .major  ==  3 
5+ PY3M  =  version_info .minor 
56
67def  clonefunc (f ):
78    """Deep clone the given function to create a new one. 
@@ -22,6 +23,8 @@ def clonefunc(f):
2223            co .co_firstlineno , co .co_lnotab , co .co_freevars , co .co_cellvars ]
2324    if  PY3 :
2425        args .insert (1 , co .co_kwonlyargcount )
26+     if  PY3  and  PY3M  >=  8 :
27+         args .insert (1 , co .co_posonlyargcount )
2528    co2  =  types .CodeType (* args )
2629    # 
2730    # then, we clone the function itself, using the new co2 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments