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 698711 - Gtk.TreePath.get_indices() returns [0] ?
Gtk.TreePath.get_indices() returns [0] ?
Status: RESOLVED DUPLICATE of bug 705810
Product: pygobject
Classification: Bindings
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2013-04-24 06:00 UTC by Xuan (Sean) Hu
Modified: 2013-09-12 08:06 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Xuan (Sean) Hu 2013-04-24 06:00:22 UTC
Just as the title said, the code snippet listed as follows

>>> from gi.repository import Gtk
>>> Gtk.TreePath().get_indices()
[0]

Besides, there is another example of empty TreePath returns []

>>> Gtk.TreePath.new().get_indices()
[]

The real problem I encountered is that I want to judge whether a TreePath is empty. For now I use 

>>> if p and p.get_indices():
>>>   pass

Was it the proper way to do that?
Comment 1 Xuan (Sean) Hu 2013-04-24 06:13:04 UTC
Currently I'm working on porting liblarch [1] from pyGTK to Gtk3 and the recent work I am dealing with is to solve the bugs related to Gtk.TreePath migration. The ideal situation we want to implement is that we can both support pyGtk and Gtk3 smoothly. The detailed progress can be found here [2]. Any advices are welcome.

[1] https://live.gnome.org/liblarch
[2] https://github.com/liblarch/liblarch/pull/8
Comment 2 Simon Feltman 2013-09-12 08:06:54 UTC
Having an implicit default of [0] is a bit unfortunate. There is a patch which deprecates this in bug 705810. Please use the class methods Gtk.TreePath.new and new_from_string explicitly to get what you want. Eventually, Gtk.TreePath() should either return an empty path or require an explicit array all the time.

*** This bug has been marked as a duplicate of bug 705810 ***