]> granicus.if.org Git - python/commitdiff
Merged revisions 74330 via svnmerge from
authorMark Dickinson <dickinsm@gmail.com>
Thu, 6 Aug 2009 16:08:07 +0000 (16:08 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Thu, 6 Aug 2009 16:08:07 +0000 (16:08 +0000)
svn+ssh://pythondev@www.python.org/python/branches/py3k

........
  r74330 | mark.dickinson | 2009-08-06 17:06:25 +0100 (Thu, 06 Aug 2009) | 3 lines

  Issue #6622:  Fix 'variable referenced before assignment' bug in POP3.apop.
  Thanks Vincent Legoll.
........

Lib/poplib.py
Lib/test/test_poplib.py
Misc/NEWS

index 770819e5c30138cb9c06a39f212df19060b64c18..1a529d0a138554d94292047dfd3e37a86c8f912c 100644 (file)
@@ -282,7 +282,7 @@ class POP3:
 
         NB: mailbox is locked by server from here to 'quit()'
         """
-        secret = bytes(secret, self.encoding)
+        secret = bytes(password, self.encoding)
         m = self.timestamp.match(self.welcome)
         if not m:
             raise error_proto('-ERR APOP not supported by server')
index ad00802a37b8288c6e5e102b8528387d678f81cf..1807bcadeb772010690c00a8e1a89494d1ae73a7 100644 (file)
@@ -36,7 +36,7 @@ class DummyPOP3Handler(asynchat.async_chat):
         asynchat.async_chat.__init__(self, conn)
         self.set_terminator(b"\r\n")
         self.in_buffer = []
-        self.push('+OK dummy pop3 server ready.')
+        self.push('+OK dummy pop3 server ready. <timestamp>')
 
     def collect_incoming_data(self, data):
         self.in_buffer.append(data)
@@ -104,6 +104,9 @@ class DummyPOP3Handler(asynchat.async_chat):
     def cmd_rpop(self, arg):
         self.push('+OK done nothing.')
 
+    def cmd_apop(self, arg):
+        self.push('+OK done nothing.')
+
 
 class DummyPOP3Server(asyncore.dispatcher, threading.Thread):
 
@@ -169,7 +172,8 @@ class TestPOP3Class(TestCase):
         self.server.stop()
 
     def test_getwelcome(self):
-        self.assertEqual(self.client.getwelcome(), b'+OK dummy pop3 server ready.')
+        self.assertEqual(self.client.getwelcome(),
+                         b'+OK dummy pop3 server ready. <timestamp>')
 
     def test_exceptions(self):
         self.assertRaises(poplib.error_proto, self.client._shortcmd, 'echo -err')
@@ -209,6 +213,9 @@ class TestPOP3Class(TestCase):
     def test_rpop(self):
         self.assertOK(self.client.rpop('foo'))
 
+    def test_apop(self):
+        self.assertOK(self.client.apop('foo', 'dummypassword'))
+
     def test_top(self):
         expected =  (b'+OK 116 bytes',
                      [b'From: postmaster@python.org', b'Content-Type: text/plain',
@@ -239,7 +246,7 @@ if hasattr(poplib, 'POP3_SSL'):
             self.set_socket(ssl_socket)
             self.set_terminator(b"\r\n")
             self.in_buffer = []
-            self.push('+OK dummy pop3 server ready.')
+            self.push('+OK dummy pop3 server ready. <timestamp>')
 
     class TestPOP3_SSLClass(TestPOP3Class):
         # repeat previous tests by using poplib.POP3_SSL
index f7c1302c48de844d9644421619282cd4b084b0e2..0de8ad58dafaa1832ce73ad49833404f39e760e6 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -42,6 +42,9 @@ C-API
 Library
 -------
 
+- Issue #6622: Fix "local variable 'secret' referenced before
+  assignment" bug in POP3.apop.
+
 - Issue #6637: defaultdict.copy() did not work when the default factory
   was left unspecified.  Also, the eval/repr round-trip would fail when
   the default_factory was None.