[2.7] bpo-32861: robotparser fix incomplete __str__ methods. (GH-5711) (GH-6795) (GH-6817)
The robotparser's __str__ representation now includes wildcard
entries.
(cherry picked from commit c3fa1f2b93fa4bf96a8aadc74ee196384cefa31e)
Co-authored-by: Michael Lazar <lazar.michael22@gmail.com>.
diff --git a/Lib/robotparser.py b/Lib/robotparser.py
index a7137a3..4e13f7f 100644
--- a/Lib/robotparser.py
+++ b/Lib/robotparser.py
@@ -160,7 +160,10 @@
def __str__(self):
- return ''.join([str(entry) + "\n" for entry in self.entries])
+ entries = self.entries
+ if self.default_entry is not None:
+ entries = entries + [self.default_entry]
+ return '\n'.join(map(str, entries)) + '\n'
class RuleLine: