summaryrefslogtreecommitdiff
path: root/Lib/nntplib.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-08-26 23:26:18 +0000
committerGuido van Rossum <guido@python.org>1997-08-26 23:26:18 +0000
commit2b5ee9bd7814802d2b9f2ee91d94970b4312d493 (patch)
tree48e4364ac54ee9b7b87c2870065a3168e8082735 /Lib/nntplib.py
parentb157866869dce87c68906d1eabcdd4f0e7da4044 (diff)
downloadcpython-2b5ee9bd7814802d2b9f2ee91d94970b4312d493.tar.gz
Fixed bugs regarding lines starting with '.' (both receiving and sending).
Added a minimal test function.
Diffstat (limited to 'Lib/nntplib.py')
-rw-r--r--Lib/nntplib.py29
1 files changed, 25 insertions, 4 deletions
diff --git a/Lib/nntplib.py b/Lib/nntplib.py
index 4759374eb2..a5e023430a 100644
--- a/Lib/nntplib.py
+++ b/Lib/nntplib.py
@@ -137,6 +137,8 @@ class NNTP:
line = self.getline()
if line == '.':
break
+ if line[:2] == '..':
+ line = line[1:]
list.append(line)
return resp, list
@@ -407,8 +409,8 @@ class NNTP:
break
if line[-1] == '\n':
line = line[:-1]
- if line == '.':
- line = '..'
+ if line[:1] == '.':
+ line = '.' + line
self.putline(line)
self.putline('.')
return self.getresp()
@@ -431,8 +433,8 @@ class NNTP:
break
if line[-1] == '\n':
line = line[:-1]
- if line == '.':
- line = '..'
+ if line[:1] == '.':
+ line = '.' + line
self.putline(line)
self.putline('.')
return self.getresp()
@@ -446,3 +448,22 @@ class NNTP:
self.sock.close()
del self.file, self.sock
return resp
+
+
+# Minimal test function
+def _test():
+ s = NNTP('news')
+ resp, count, first, last, name = s.group('comp.lang.python')
+ print resp
+ print 'Group', name, 'has', count, 'articles, range', first, 'to', last
+ resp, subs = s.xhdr('subject', first + '-' + last)
+ print resp
+ for item in subs:
+ print "%7s %s" % item
+ resp = s.quit()
+ print resp
+
+
+# Run the test when run as a script
+if __name__ == '__main__':
+ _test()