deskbar-applet r2114 - in trunk: . deskbar/handlers



Author: sebp
Date: Mon Apr 14 14:49:19 2008
New Revision: 2114
URL: http://svn.gnome.org/viewvc/deskbar-applet?rev=2114&view=rev

Log:
Fixed exception that variable stream is unbound

Modified:
   trunk/ChangeLog
   trunk/deskbar/handlers/googlecodesearch.py
   trunk/deskbar/handlers/yahoo.py

Modified: trunk/deskbar/handlers/googlecodesearch.py
==============================================================================
--- trunk/deskbar/handlers/googlecodesearch.py	(original)
+++ trunk/deskbar/handlers/googlecodesearch.py	Mon Apr 14 14:49:19 2008
@@ -51,6 +51,7 @@
                  'max-results': MAX_RESULTS})
         
         matches = []
+        stream = None
         try:
             try:
                 stream = urllib.urlopen(url, proxies=get_proxy())
@@ -61,7 +62,8 @@
             except xml.sax.SAXParseException, e:
                 LOGGER.exception(e)
         finally:
-            stream.close()
+            if stream != None:
+                stream.close()
             
         results = handler.get_results()
         for result in results:

Modified: trunk/deskbar/handlers/yahoo.py
==============================================================================
--- trunk/deskbar/handlers/yahoo.py	(original)
+++ trunk/deskbar/handlers/yahoo.py	Mon Apr 14 14:49:19 2008
@@ -99,6 +99,7 @@
         LOGGER.debug("Retrieving %s", url)
         
         matches = []
+        stream = 0
         try:
             try:
                 stream = urllib.urlopen(url, proxies=get_proxy())
@@ -109,7 +110,8 @@
             except xml.sax.SAXParseException, e:
                 LOGGER.exception(e)
         finally:
-            stream.close()
+            if stream != None:
+                stream.close()
         
         LOGGER.debug('Got yahoo answer for: %s', qstring)
          
@@ -263,6 +265,7 @@
         LOGGER.debug("Retrieving %s", url)
     
         matches = []
+        stream = None
         try:
             try:
                 stream = urllib.urlopen(url, proxies=get_proxy())
@@ -273,7 +276,8 @@
             except xml.sax.SAXParseException, e:
                 LOGGER.exception(e)
         finally:
-            stream.close()
+            if stream != None:
+                stream.close()
             
         num_results = len(handler.get_suggestions())
         for i, suggestion in enumerate(handler.get_suggestions()):



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