[pygobject] [gtk-demo] Fix syntax highlighter encoding issue



commit b82d916635aa0b732840548088a3fcfcb2e41bc4
Author: Dieter Verfaillie <dieterv optionexplicit be>
Date:   Wed Sep 7 10:40:36 2011 +0200

    [gtk-demo] Fix syntax highlighter encoding issue
    
    With Python 3, Gtk.TextBuffer.get_text returns a str (not bytes), with
    Python 2 however we get a str (not unicode). So with Python 2 the
    tokenizer returned bogus data when ran over a demo that contains real
    UTF-8 codepoints (like rotatedtext.py for example).
    
    This patch thus fixes the "Gtk-CRITICAL **: gtk_text_iter_set_line_offset:
    assertion `char_on_line <= chars_in_line` failed" assertions when selecting
    the rotated text demo in the treeview.

 demos/gtk-demo/gtk-demo.py |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/demos/gtk-demo/gtk-demo.py b/demos/gtk-demo/gtk-demo.py
index 387b2fd..d19eed2 100755
--- a/demos/gtk-demo/gtk-demo.py
+++ b/demos/gtk-demo/gtk-demo.py
@@ -333,6 +333,9 @@ class GtkDemoWindow(Gtk.Window):
                                            self.source_buffer.get_end_iter(),
                                            False)
 
+        if sys.version_info < (3, 0):
+            data = data.decode('utf-8')
+
         builtin_constants = ['None', 'True', 'False']
         is_decorator = False
         is_func = False



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]