simple-browser.py example doesn't work

Bug #63804 reported by Stuart Langridge
4
Affects Status Importance Assigned to Milestone
PyGTK
Fix Released
Medium
gnome-python-extras (Ubuntu)
Fix Released
Low
Ubuntu Desktop Bugs

Bug Description

Binary package hint: python-gnome2-extras

The example /usr/share/doc/python-gnome2-extras/examples/gtkhtml2/simple-browser.py doesn't work properly. Running it, with python /usr/share/doc/python-gnome2-extras/examples/gtkhtml2/simple-browser.py, shows the initial example page (with "Hello world!" and a link to the Gnome site saying "click me") correctly. Clicking the link, however, makes it disappear, and it does not show the site as expected. It writes the following on the terminal:

link_clicked: http://www.gnome.org/

/usr/share/doc/python-gnome2-extras/examples/gtkhtml2/simple-browser.py:45: Warning: invalid uninstantiatable type `(null)' in cast to `GObject'

  document.close_stream()

/usr/share/doc/python-gnome2-extras/examples/gtkhtml2/simple-browser.py:45: Warning: g_object_unref: assertion `G_IS_OBJECT (object)' failed
  document.close_stream()

** (simple-browser.py:7542): CRITICAL **: dom_Document__get_documentElement: assertion `doc != NULL' failed

Revision history for this message
Stuart Langridge (sil) wrote :

The problem seems to be that gtkhtml2.Document.open_stream() doesn't handle a Content-type with a charset specified. http://www.gnome.org/ has a Content-type of "text/html; charset=utf-8". The following hack resolves the problem, but it should be done better:

--- /usr/share/doc/python-gnome2-extras/examples/gtkhtml2/simple-browser.py 2002-04-30 02:02:20.000000000 +0100
+++ simple-browser.py 2006-10-03 18:41:07.000000000 +0100
@@ -38,6 +38,7 @@
     headers = f.info()
     mime = headers.getheader('Content-type')
     if mime:
+ if mime.find(';') != -1: mime = mime.split(';')[0]
         document.open_stream(mime)
     else:
         document.open_stream('text/plain')

Revision history for this message
Pradeep (pradeep+-deactivatedaccount) wrote :

My output isn't so verbose though:

python /usr/share/doc/python-gnome2-extras/examples/gtkhtml2/simple-browser.py
link_clicked: http://www.gnome.org/
Segmentation fault (core dumped)

Changed in gnome-python-extras:
status: Unconfirmed → Confirmed
Revision history for this message
Jani Monoses (jani) wrote :

a bit cleaner patch

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks for the bug and the patch, I've forwarded them upstream: http://bugzilla.gnome.org/show_bug.cgi?id=360891

Changed in gnome-python-extras:
assignee: nobody → desktop-bugs
importance: Undecided → Low
Revision history for this message
Sebastien Bacher (seb128) wrote :

it was already fixed upstream

Changed in gnome-python-extras:
status: Confirmed → Fix Committed
Changed in pygtk:
status: Unknown → Fix Released
Revision history for this message
Sebastien Bacher (seb128) wrote :

fixed in 7.04

Changed in gnome-python-extras:
status: Fix Committed → Fix Released
Changed in pygtk:
importance: Unknown → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Patches

Remote bug watches

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