Exception and no error when loading invalid GPX file

Bug #1654898 reported by Mikkel Kirkgaard Nielsen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GPX Viewer
New
Undecided
Unassigned

Bug Description

On xenial (Ubuntu 16.04) using gpxviewer from universe (0.5.2-1) I get a missing attribute error from Gtk when trying to load a file which is not a valid GPX file. This happens both from the menus and from the command line:

$ gpxviewer /dev/null
/usr/bin/gpxviewer:28: PyGIWarning: Gdk was imported without specifying a version first. Use gi.require_version('Gdk', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import Gdk
/usr/share/gpxviewer/gpxviewer/ui.py:26: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import Gtk
/usr/share/gpxviewer/gpxviewer/ui.py:30: PyGIWarning: OsmGpsMap was imported without specifying a version first. Use gi.require_version('OsmGpsMap', '1.0') before import to ensure that the right version gets loaded.
  from gi.repository import OsmGpsMap
/usr/share/gpxviewer/gpxviewer/pygtk_chart/chart.py:42: PyGIWarning: PangoCairo was imported without specifying a version first. Use gi.require_version('PangoCairo', '1.0') before import to ensure that the right version gets loaded.
  from gi.repository import PangoCairo
Traceback (most recent call last):
  File "/usr/bin/gpxviewer", line 47, in <module>
    gui = MainWindow(ui_dir="%sui/" % prefix,files=files).main()
  File "/usr/share/gpxviewer/gpxviewer/ui.py", line 229, in __init__
    self.lazyLoadFiles(files)
  File "/usr/share/gpxviewer/gpxviewer/ui.py", line 254, in lazyLoadFiles
    trace = self.loadGPX(filename)
  File "/usr/share/gpxviewer/gpxviewer/ui.py", line 381, in loadGPX
    self.showGPXError()
  File "/usr/share/gpxviewer/gpxviewer/ui.py", line 400, in showGPXError
    message_box = Gtk.MessageDialog(parent=self.mainWindow,type=Gtk.MESSAGE_ERROR,buttons=Gtk.BUTTONS_OK,message_format=_("You selected an invalid GPX file. \n Please try again"))
  File "/usr/lib/python2.7/dist-packages/gi/overrides/__init__.py", line 39, in __getattr__
    return getattr(self._introspection_module, name)
  File "/usr/lib/python2.7/dist-packages/gi/module.py", line 139, in __getattr__
    self.__name__, name))
AttributeError: 'gi.repository.Gtk' object has no attribute 'MESSAGE_ERROR'

It seems to me like a namespace thing, cause according to the pygtk docs at http://www.pygtk.org/docs/pygtk/class-gtkmessagedialog.html the attribute MESSAGE_ERROR ought to exist. However, there it is referred to it as Gtk.MESSAGE_ERROR where the gpxviewer code uses Gtk.MESSAGE_ERROR. This seems to work for other parts of the code, though.

I've tried to remove the type and buttons (same issue with BUTTONS_OK) arguments to MessageDialog() and this produces a dialog with default type/buttons, which is clearly better.

$ diff /usr/share/gpxviewer/gpxviewer/ui.py_org /usr/share/gpxviewer/gpxviewer/ui.py
400c400
< message_box = Gtk.MessageDialog(parent=self.mainWindow,type=Gtk.MESSAGE_ERROR,buttons=Gtk.BUTTONS_OK,message_format=_("You selected an invalid GPX file. \n Please try again"))
---
> message_box = Gtk.MessageDialog(parent=self.mainWindow,message_format=_("You selected an invalid GPX file. \n Please try again"))

I've also tried importing gi.repository.Gtk as gtk and replaced all Gtk references with gtk, which gave the same result. That was where my lacking experience of python got me at the moment.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.