summaryrefslogtreecommitdiffstats
path: root/Lib/urllib
diff options
context:
space:
mode:
authorRĂ©mi Lapeyre <remi.lapeyre@henki.fr>2019-06-16 06:48:57 (GMT)
committerTal Einat <taleinat@gmail.com>2019-06-16 06:48:57 (GMT)
commit8047e0e1c620f69cc21f9ca48b24bf2cdd5c3668 (patch)
tree7b22a0fce0ff2d1170bfbbc41f929bcc8d68fc9f /Lib/urllib
parent3a1d50e7e573efb577714146bed5c03b9c95f466 (diff)
downloadcpython-8047e0e1c620f69cc21f9ca48b24bf2cdd5c3668.zip
cpython-8047e0e1c620f69cc21f9ca48b24bf2cdd5c3668.tar.gz
cpython-8047e0e1c620f69cc21f9ca48b24bf2cdd5c3668.tar.bz2
bpo-35922: Fix RobotFileParser when robots.txt has no relevant crawl delay or request rate (GH-11791)
Co-Authored-By: Tal Einat <taleinat+github@gmail.com>
Diffstat (limited to 'Lib/urllib')
-rw-r--r--Lib/urllib/robotparser.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/urllib/robotparser.py b/Lib/urllib/robotparser.py
index 7089916..c58565e 100644
--- a/Lib/urllib/robotparser.py
+++ b/Lib/urllib/robotparser.py
@@ -186,7 +186,9 @@ class RobotFileParser:
for entry in self.entries:
if entry.applies_to(useragent):
return entry.delay
- return self.default_entry.delay
+ if self.default_entry:
+ return self.default_entry.delay
+ return None
def request_rate(self, useragent):
if not self.mtime():
@@ -194,7 +196,9 @@ class RobotFileParser:
for entry in self.entries:
if entry.applies_to(useragent):
return entry.req_rate
- return self.default_entry.req_rate
+ if self.default_entry:
+ return self.default_entry.req_rate
+ return None
def site_maps(self):
if not self.sitemaps: