diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-07-12 23:41:19 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-07-12 23:41:19 (GMT) |
commit | 0522a9f1eba72a7fdb6b5b6065872654f1d6becc (patch) | |
tree | a7c3b777dc64f6216078456ac21c97e058224512 /Lib | |
parent | 24122593f07fe756aa5c9a5db908ae4f5d22f352 (diff) | |
download | cpython-0522a9f1eba72a7fdb6b5b6065872654f1d6becc.zip cpython-0522a9f1eba72a7fdb6b5b6065872654f1d6becc.tar.gz cpython-0522a9f1eba72a7fdb6b5b6065872654f1d6becc.tar.bz2 |
#1778443 robotparser fixes from Aristotelis Mikropoulos
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/robotparser.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/Lib/robotparser.py b/Lib/robotparser.py index 5b1d797..f249187 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() |