mirror of https://github.com/python/cpython
Fixed bugs regarding lines starting with '.' (both receiving and sending).
Added a minimal test function.
This commit is contained in:
parent
e20aef574a
commit
e2ed9df645
|
@ -137,6 +137,8 @@ class NNTP:
|
||||||
line = self.getline()
|
line = self.getline()
|
||||||
if line == '.':
|
if line == '.':
|
||||||
break
|
break
|
||||||
|
if line[:2] == '..':
|
||||||
|
line = line[1:]
|
||||||
list.append(line)
|
list.append(line)
|
||||||
return resp, list
|
return resp, list
|
||||||
|
|
||||||
|
@ -407,8 +409,8 @@ class NNTP:
|
||||||
break
|
break
|
||||||
if line[-1] == '\n':
|
if line[-1] == '\n':
|
||||||
line = line[:-1]
|
line = line[:-1]
|
||||||
if line == '.':
|
if line[:1] == '.':
|
||||||
line = '..'
|
line = '.' + line
|
||||||
self.putline(line)
|
self.putline(line)
|
||||||
self.putline('.')
|
self.putline('.')
|
||||||
return self.getresp()
|
return self.getresp()
|
||||||
|
@ -431,8 +433,8 @@ class NNTP:
|
||||||
break
|
break
|
||||||
if line[-1] == '\n':
|
if line[-1] == '\n':
|
||||||
line = line[:-1]
|
line = line[:-1]
|
||||||
if line == '.':
|
if line[:1] == '.':
|
||||||
line = '..'
|
line = '.' + line
|
||||||
self.putline(line)
|
self.putline(line)
|
||||||
self.putline('.')
|
self.putline('.')
|
||||||
return self.getresp()
|
return self.getresp()
|
||||||
|
@ -446,3 +448,22 @@ class NNTP:
|
||||||
self.sock.close()
|
self.sock.close()
|
||||||
del self.file, self.sock
|
del self.file, self.sock
|
||||||
return resp
|
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()
|
||||||
|
|
Loading…
Reference in New Issue