summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorDieter Verfaillie <dieterv@optionexplicit.be>2011-09-07 10:40:36 +0200
committerDieter Verfaillie <dieterv@optionexplicit.be>2011-09-07 19:22:29 +0200
commitb82d916635aa0b732840548088a3fcfcb2e41bc4 (patch)
tree16dedf21ec437cfca8bf7fd2459edb3432b401ea /demos
parent31db3ed3d233bd495c3a2f99b3fa51031bfa30c6 (diff)
downloadpygobject-b82d916635aa0b732840548088a3fcfcb2e41bc4.tar.gz
[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.
Diffstat (limited to 'demos')
-rwxr-xr-xdemos/gtk-demo/gtk-demo.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/demos/gtk-demo/gtk-demo.py b/demos/gtk-demo/gtk-demo.py
index 387b2fd2..d19eed27 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