]> granicus.if.org Git - python/commitdiff
Fix SF bug #482171: webchecker dies on file: URLs w/o robots.txt
authorGuido van Rossum <guido@python.org>
Tue, 11 Dec 2001 22:41:24 +0000 (22:41 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 11 Dec 2001 22:41:24 +0000 (22:41 +0000)
The cause seems to be that when a file URL doesn't exist,
urllib.urlopen() raises OSError instead of IOError.  Simply add this
to the except clause.  Not elegant, but effective. :-)

Tools/webchecker/webchecker.py

index 091d0d2570d77337848f3df1b7fd690fc8fccf6c..071c2f680077c3815ec831609b1bebc8ecffee6f 100755 (executable)
@@ -335,7 +335,7 @@ class Checker:
         rp.set_url(url)
         try:
             rp.read()
-        except IOError, msg:
+        except (OSError, IOError), msg:
             self.note(1, "I/O error parsing %s: %s", url, msg)
 
     def run(self):
@@ -533,7 +533,7 @@ class Checker:
         url, fragment = url_pair
         try:
             return self.urlopener.open(url)
-        except IOError, msg:
+        except (OSError, IOError), msg:
             msg = self.sanitize(msg)
             self.note(0, "Error %s", msg)
             if self.verbose > 0: