[pygobject] do not pass in len(str) to the length argument of gtk_test_buffer_insert* apis



commit e7fcc326d64def610e5a1003cf6c7ca97023814d
Author: John (J5) Palmieri <johnp redhat com>
Date:   Thu Sep 15 17:46:46 2011 -0400

    do not pass in len(str) to the length argument of gtk_test_buffer_insert* apis
    
    * in python 3 len(str) returns the number of characters while the length
      parameter is expecting the number of bytes.  It also excepts -1 for null
      terminated string.  Since all of our strings are null terminated, just
      set length to that.

 gi/overrides/Gtk.py |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
---
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 97c8b40..4b025ab 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -625,11 +625,10 @@ class TextBuffer(Gtk.TextBuffer):
     def set_text(self, text, length=-1):
         Gtk.TextBuffer.set_text(self, text, length)
 
-    def insert(self, iter, text):
+    def insert(self, iter, text, lenth=-1):
         if not isinstance(text , _basestring):
             raise TypeError('text must be a string, not %s' % type(text))
 
-        length = len(text)
         Gtk.TextBuffer.insert(self, iter, text, length)
 
     def insert_with_tags(self, iter, text, *tags):
@@ -658,11 +657,10 @@ class TextBuffer(Gtk.TextBuffer):
 
         self.insert_with_tags(iter, text, *tag_objs)
 
-    def insert_at_cursor(self, text):
+    def insert_at_cursor(self, text, length=-1):
         if not isinstance(text , _basestring):
             raise TypeError('text must be a string, not %s' % type(text))
 
-        length = len(text)
         Gtk.TextBuffer.insert_at_cursor(self, text, length)
 
     def get_selection_bounds(self):



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