diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2017-11-23 23:57:58 (GMT) |
---|---|---|
committer | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2017-11-23 23:57:58 (GMT) |
commit | ff847d1ac7e6a8ee1fb6f8883cfb4aec4b4a9b03 (patch) | |
tree | 977839c6cf63c20540af78240c219ccd39a190cc /Lib/urllib | |
parent | a645b23ffc76073a2eb4e77b88cb7648cfc6ef77 (diff) | |
download | cpython-ff847d1ac7e6a8ee1fb6f8883cfb4aec4b4a9b03.zip cpython-ff847d1ac7e6a8ee1fb6f8883cfb4aec4b4a9b03.tar.gz cpython-ff847d1ac7e6a8ee1fb6f8883cfb4aec4b4a9b03.tar.bz2 |
bpo-31325: Fix usage of namedtuple in RobotFileParser.parse() (GH-4529) (#4533)
(cherry picked from commit 3df02dbc8e197053105f9dffeae40b04ec66766e)
Diffstat (limited to 'Lib/urllib')
-rw-r--r-- | Lib/urllib/robotparser.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Lib/urllib/robotparser.py b/Lib/urllib/robotparser.py index 9dab4c1..daac29c 100644 --- a/Lib/urllib/robotparser.py +++ b/Lib/urllib/robotparser.py @@ -16,6 +16,9 @@ import urllib.request __all__ = ["RobotFileParser"] +RequestRate = collections.namedtuple("RequestRate", "requests seconds") + + class RobotFileParser: """ This class provides a set of methods to read, parse and answer questions about a single robots.txt file. @@ -136,11 +139,7 @@ class RobotFileParser: # check if all values are sane if (len(numbers) == 2 and numbers[0].strip().isdigit() and numbers[1].strip().isdigit()): - req_rate = collections.namedtuple('req_rate', - 'requests seconds') - entry.req_rate = req_rate - entry.req_rate.requests = int(numbers[0]) - entry.req_rate.seconds = int(numbers[1]) + entry.req_rate = RequestRate(int(numbers[0]), int(numbers[1])) state = 2 if state == 2: self._add_entry(entry) |