From 0522a9f1eba72a7fdb6b5b6065872654f1d6becc Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sat, 12 Jul 2008 23:41:19 +0000 Subject: [PATCH] #1778443 robotparser fixes from Aristotelis Mikropoulos --- Lib/robotparser.py | 9 +++------ Misc/ACKS | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Lib/robotparser.py b/Lib/robotparser.py index 5b1d797fe86..f249187e2c5 100644 --- a/Lib/robotparser.py +++ b/Lib/robotparser.py @@ -55,11 +55,8 @@ class RobotFileParser: """Reads the robots.txt URL and feeds it to the parser.""" opener = URLopener() f = opener.open(self.url) - lines = [] - line = f.readline() - while line: - lines.append(line.strip()) - line = f.readline() + lines = [line.strip() for line in f] + f.close() self.errcode = opener.errcode if self.errcode in (401, 403): self.disallow_all = True @@ -84,7 +81,7 @@ class RobotFileParser: entry = Entry() for line in lines: - linenumber = linenumber + 1 + linenumber += 1 if not line: if state == 1: entry = Entry() diff --git a/Misc/ACKS b/Misc/ACKS index e79f20a237d..ac445ae8155 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -460,6 +460,7 @@ Luke Mewburn Mike Meyer Steven Miale Trent Mick +Aristotelis Mikropoulos Damien Miller Chad Miller Jay T. Miller