Hi all,

here's a small patch for two little things I saw today:

1. The new mathtext has some unicode in it and on my system, python2.5
was throwing a syntax error due to the lack of an encoding
declaration.  I just stuck utf-8 though I don't know if that's really
corrrect.  Since the complaint was about characters in a comment it
doesn't matter too much, but it still might be a good idea to do the
right thing, so someone who actually knows should check what the right
value is.

2. Move a simple version check from runtime to class declaration time
in the cairo backend.  While this causes a repeated line, the code is
small enough that it seems cleaner not to pay the version check on
every method call.

Cheers,

f
Index: lib/matplotlib/mathtext.py
===================================================================
--- lib/matplotlib/mathtext.py	(revision 3715)
+++ lib/matplotlib/mathtext.py	(working copy)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 r"""
 
 OVERVIEW
Index: lib/matplotlib/backends/backend_gtkcairo.py
===================================================================
--- lib/matplotlib/backends/backend_gtkcairo.py	(revision 3715)
+++ lib/matplotlib/backends/backend_gtkcairo.py	(working copy)
@@ -29,12 +29,16 @@
 
 
 class RendererGTKCairo (backend_cairo.RendererCairo):
-    def set_pixmap (self, pixmap):
-        if gtk.pygtk_version >= (2,7,0):
+    # Do the version check at class declaration time, so we don't pay for it on
+    # every invocation of the set_pixmap method.
+    if gtk.pygtk_version >= (2,7,0):
+        def set_pixmap (self, pixmap):
             self.ctx = pixmap.cairo_create()
-        else:
+            self.ctx.save()  # restore, save  - when call new_gc()
+    else:
+        def set_pixmap (self, pixmap):
             self.ctx = cairo.gtk.gdk_cairo_create (pixmap)
-        self.ctx.save()  # restore, save  - when call new_gc()
+            self.ctx.save()  # restore, save  - when call new_gc()
 
 
 class FigureCanvasGTKCairo(FigureCanvasGTK):
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to