diff Lib/robotparser.py @ 63465:4a002da7fbfb 2.7

Merged revisions 83238 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r83238 | georg.brandl | 2010-07-29 19:55:01 +0200 (Do, 29 Jul 2010) | 1 line #4108: the first default entry (User-agent: *) wins. ........
author Georg Brandl <georg@python.org>
date Sun, 01 Aug 2010 20:59:03 +0000
parents 0bb47c51e933
children b36cb4602e21
line wrap: on
line diff
--- a/Lib/robotparser.py	Sun Aug 01 20:54:30 2010 +0000
+++ b/Lib/robotparser.py	Sun Aug 01 20:59:03 2010 +0000
@@ -68,7 +68,9 @@
     def _add_entry(self, entry):
         if "*" in entry.useragents:
             # the default entry is considered last
-            self.default_entry = entry
+            if self.default_entry is None:
+                # the first default entry wins
+                self.default_entry = entry
         else:
             self.entries.append(entry)
 
@@ -120,7 +122,7 @@
                         entry.rulelines.append(RuleLine(line[1], True))
                         state = 2
         if state == 2:
-            self.entries.append(entry)
+            self._add_entry(entry)
 
 
     def can_fetch(self, useragent, url):