@@ -113,7 +113,7 @@ def _restoreContext(self):
113113 try :
114114 cached = self ._statestack .pop (0 )
115115 except IndexError :
116- raise DeviceError , "Too many Context._restoreContext calls."
116+ raise DeviceError ( "Too many Context._restoreContext calls." )
117117
118118 for attr , val in zip (Context ._state_vars , cached ):
119119 setattr (self , attr , val )
@@ -204,7 +204,7 @@ def background(self, *args, **kwargs):
204204 elif isinstance (args [0 ], Image ):
205205 bg = Pattern (args [0 ])
206206 self .canvas .clear (args [0 ])
207- elif isinstance (args [0 ],basestring ) and (args [0 ].startswith ('http' ) or exists (expanduser (args [0 ]))):
207+ elif isinstance (args [0 ],str ) and (args [0 ].startswith ('http' ) or exists (expanduser (args [0 ]))):
208208 bg = Pattern (args [0 ])
209209 elif set (Gradient .kwargs ) >= set (kwargs ) and len (args )> 1 and all (Color .recognized (c ) for c in args ):
210210 bg = Gradient (* args , ** kwargs )
@@ -274,7 +274,7 @@ def moveto(self, *coords):
274274 """
275275 (x ,y ) = parse_coords (coords , [Point ])
276276 if self ._path is None :
277- raise DeviceError , "No active path. Use bezier() or beginpath() first."
277+ raise DeviceError ( "No active path. Use bezier() or beginpath() first." )
278278 self ._path .moveto (x ,y )
279279
280280 def lineto (self , * coords , ** kwargs ):
@@ -288,7 +288,7 @@ def lineto(self, *coords, **kwargs):
288288 close = kwargs .pop ('close' , False )
289289 (x ,y ) = parse_coords (coords , [Point ])
290290 if self ._path is None :
291- raise DeviceError , "No active path. Use bezier() or beginpath() first."
291+ raise DeviceError ( "No active path. Use bezier() or beginpath() first." )
292292 self ._path .lineto (x , y )
293293 if close :
294294 self ._path .closepath ()
@@ -308,7 +308,7 @@ def curveto(self, *coords, **kwargs):
308308 (x1 ,y1 ), (x2 ,y2 ), (x3 ,y3 ) = parse_coords (coords , [Point ,Point ,Point ])
309309
310310 if self ._path is None :
311- raise DeviceError , "No active path. Use bezier() or beginpath() first."
311+ raise DeviceError ( "No active path. Use bezier() or beginpath() first." )
312312 self ._path .curveto (x1 , y1 , x2 , y2 , x3 , y3 )
313313 if close :
314314 self ._path .closepath ()
@@ -346,7 +346,7 @@ def arcto(self, *coords, **kwargs):
346346 (x1 ,y1 ) = parse_coords (coords , [Point ])
347347
348348 if self ._path is None :
349- raise DeviceError , "No active path. Use bezier() or beginpath() first."
349+ raise DeviceError ( "No active path. Use bezier() or beginpath() first." )
350350 self ._path .arcto (x1 , y1 , x2 , y2 , radius , ccw )
351351 if close :
352352 self ._path .closepath ()
@@ -509,14 +509,14 @@ def beginpath(self, x=None, y=None):
509509
510510 def closepath (self ):
511511 if self ._path is None :
512- raise DeviceError , "No active path. Use bezier() or beginpath() first."
512+ raise DeviceError ( "No active path. Use bezier() or beginpath() first." )
513513 if not self ._pathclosed :
514514 self ._path .closepath ()
515515 self ._pathclosed = True
516516
517517 def endpath (self , ** kwargs ):
518518 if self ._path is None :
519- raise DeviceError , "No active path. Use bezier() or beginpath() first."
519+ raise DeviceError ( "No active path. Use bezier() or beginpath() first." )
520520 if self ._autoclosepath :
521521 self .closepath ()
522522 p = self ._path
@@ -558,8 +558,8 @@ def pop(self):
558558 try :
559559 self ._transform = Transform (self ._transformstack [0 ])
560560 del self ._transformstack [0 ]
561- except IndexError , e :
562- raise DeviceError , "pop: too many pops!"
561+ except IndexError as e :
562+ raise DeviceError ( "pop: too many pops!" )
563563
564564 def transform (self , mode = None , matrix = None ):
565565 """Change the transform mode or begin a `with`-statement-scoped set of transformations
@@ -797,7 +797,7 @@ def fill(self, *args, **kwargs):
797797 if isinstance (args [0 ], Image ):
798798 clr = Pattern (args [0 ])
799799 self .canvas .clear (args [0 ])
800- elif isinstance (args [0 ],basestring ) and (args [0 ].startswith ('http' ) or exists (expanduser (args [0 ]))):
800+ elif isinstance (args [0 ],str ) and (args [0 ].startswith ('http' ) or exists (expanduser (args [0 ]))):
801801 clr = Pattern (args [0 ])
802802 elif set (Gradient .kwargs ) >= set (kwargs ) and len (args )> 1 and all (Color .recognized (c ) for c in args ):
803803 clr = Gradient (* args , ** kwargs )
@@ -882,15 +882,15 @@ def capstyle(self, style=None):
882882 """Legacy command. Equivalent to: pen(caps=style)"""
883883 if style is not None :
884884 if style not in (BUTT , ROUND , SQUARE ):
885- raise DeviceError , 'Line cap style should be BUTT, ROUND or SQUARE.'
885+ raise DeviceError ( 'Line cap style should be BUTT, ROUND or SQUARE.' )
886886 self ._penstyle = self ._penstyle ._replace (cap = style )
887887 return self ._penstyle .cap
888888
889889 def joinstyle (self , style = None ):
890890 """Legacy command. Equivalent to: pen(joins=style)"""
891891 if style is not None :
892892 if style not in (MITER , ROUND , BEVEL ):
893- raise DeviceError , 'Line join style should be MITER, ROUND or BEVEL.'
893+ raise DeviceError ( 'Line join style should be MITER, ROUND or BEVEL.' )
894894 self ._penstyle = self ._penstyle ._replace (join = style )
895895 return self ._penstyle .join
896896
@@ -1478,7 +1478,7 @@ def export(self, fname, fps=None, loop=None, bitrate=1.0, cmyk=False):
14781478
14791479 To export a movie:
14801480 with export('anim.mov', fps=30, bitrate=1.8) as movie:
1481- for i in xrange (100):
1481+ for i in range (100):
14821482 with movie.frame:
14831483 ... # draw the next frame
14841484
@@ -1537,7 +1537,7 @@ def measure(self, obj=None, width=None, height=None, **kwargs):
15371537 If `obj` if a file() object, PlotDevice will treat it as an image file and
15381538 return its pixel dimensions.
15391539 """
1540- if isinstance (obj , basestring ):
1540+ if isinstance (obj , str ):
15411541 obj = Text (obj , 0 , 0 , width , height , ** kwargs )
15421542
15431543 if hasattr (obj , 'metrics' ):
@@ -1711,8 +1711,8 @@ def pop(self):
17111711 try :
17121712 del self ._stack [0 ]
17131713 self ._container = self ._stack [0 ]
1714- except IndexError , e :
1715- raise DeviceError , "pop: too many canvas pops!"
1714+ except IndexError as e :
1715+ raise DeviceError ( "pop: too many canvas pops!" )
17161716
17171717 def draw (self ):
17181718 if self .background is not None :
0 commit comments