After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 680597 - Gtk.TextIter.forward_search has wrong arguments
Gtk.TextIter.forward_search has wrong arguments
Status: RESOLVED NOTABUG
Product: pygobject
Classification: Bindings
Component: introspection
3.0.x
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2012-07-25 15:53 UTC by Manuel Kaufmann
Modified: 2012-07-31 15:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test case with 0 as argument (656 bytes, application/octet-stream)
2012-07-30 11:42 UTC, Manuel Kaufmann
Details
test case with None as argument (659 bytes, text/x-python)
2012-07-30 11:43 UTC, Manuel Kaufmann
Details

Description Manuel Kaufmann 2012-07-25 15:53:17 UTC
Hello,

I'm porting[1] a Sugar Activity called Log[2] to GTK3 and I found a problem with the search that it does on a TextBuffer.

This is the relevant part of the code


  (Epdb) text
  'w'
  (Epdb) text_iter
  <GtkTextIter at 0x37bc000>
  (Epdb) text_iter.forward_search(text, Gtk.TextSearchFlags.CASE_INSENSITIVE, 0)
  *** TypeError: Expected Gtk.TextIter, but got StructMeta
  (Epdb) text_iter.forward_search(text_iter, Gtk.TextSearchFlags.CASE_INSENSITIVE, 0)
  *** TypeError: Must be string, not TextIter
  (Epdb)

Is this a bug or I should call this method in another way?

Thanks,

[1] http://wiki.sugarlabs.org/go/Features/GTK3/Porting/Log
[2] http://git.sugarlabs.org/log
Comment 1 Manuel Kaufmann 2012-07-25 16:22:24 UTC
This is the way this software was using on gtk2:

[... some code here ...]

 next_found = text_iter.forward_search(text, 0)
 if next_found is None:
     start, end = next_found

[... some code here ...]
Comment 2 Martin Pitt 2012-07-30 10:04:11 UTC
This seems to work fine for me, I just added a test case:

http://git.gnome.org/browse/pygobject/commit/?id=94e5d58e7794de91d3291e0e51c42070da4fc92b

Can you please attach a complete code example which breaks? Which version of
pygobject are you using?
Comment 3 Manuel Kaufmann 2012-07-30 11:41:25 UTC
Well, I don't know what I was doing. I test what you said and it worked without problems (I'm attaching my test example)

I change my code to:

 next_found = text_iter.forward_search(text, 0, None)

So, maybe the problem is with the final argument?

[...]

Yes! That's the problem! (example modified attached)
Comment 4 Manuel Kaufmann 2012-07-30 11:42:50 UTC
Created attachment 219880 [details]
test case with 0 as argument
Comment 5 Manuel Kaufmann 2012-07-30 11:43:30 UTC
Created attachment 219881 [details]
test case with None as argument
Comment 6 Martin Pitt 2012-07-31 15:06:47 UTC
Right, so it does not make sense to supply "0" as a "limit" argument (which needs to be a Gtk.TextIter). At least trunk now gives a more sensible error message:

TypeError: argument limit: Expected Gtk.TextIter, but got int

Thanks!