Logged In: YES user_id=366566 I wonder why NNTP_SSL.getline() uses a regular expression to find a newline. Wouldn't it be simpler and more efficient to rewrite the method like this (untested, but I bet it works, and hopefully it gets the idea across anyway): | def getline(self):
newline = self.buffer.find('\n')
while newline == -1:
self._fillBuffer()
newline = self.buffer.find('\n')
line = self.buffer[:newline]
self.buffer = self.buffer[newline + 1:]
if line.endswith('\r'):
line = line[:-1]
return line Also, wouldn't it be nice if the line handling code here weren't a duplicate of the line handling code in at least two other stdlib modules? I don't mean to single out this patch, but maybe instead of compounding the problem, this could be taken as an opportunity to reduce the code duplication in this area by doing some refactoring of the various line-based protocol implementations to share code for this common requirement.
Logged In: YES user_id=814251 NNTP_SSL.getline() uses a regular expression because the NNTP_SSL code is a rather straightforward port of the corresponding SSL code from the poplib.py module. I think it is a good idea to refactor the code to avoid code duplication in the various modules using SSL (and maybe also for the different authentication methods like AUTH CRAM_MD5 etc.), however such a large refactoring is probably beyond the scope of a submitted patch.