Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ea1158f

Browse files
committed
Issue #6622: Fix 'variable referenced before assignment' bug in POP3.apop.
Thanks Vincent Legoll.
1 parent ba5c743 commit ea1158f

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

Lib/poplib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def apop(self, user, password):
282282
283283
NB: mailbox is locked by server from here to 'quit()'
284284
"""
285-
secret = bytes(secret, self.encoding)
285+
secret = bytes(password, self.encoding)
286286
m = self.timestamp.match(self.welcome)
287287
if not m:
288288
raise error_proto('-ERR APOP not supported by server')

Lib/test/test_poplib.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __init__(self, conn):
3636
asynchat.async_chat.__init__(self, conn)
3737
self.set_terminator(b"\r\n")
3838
self.in_buffer = []
39-
self.push('+OK dummy pop3 server ready.')
39+
self.push('+OK dummy pop3 server ready. <timestamp>')
4040

4141
def collect_incoming_data(self, data):
4242
self.in_buffer.append(data)
@@ -104,6 +104,9 @@ def cmd_noop(self, arg):
104104
def cmd_rpop(self, arg):
105105
self.push('+OK done nothing.')
106106

107+
def cmd_apop(self, arg):
108+
self.push('+OK done nothing.')
109+
107110

108111
class DummyPOP3Server(asyncore.dispatcher, threading.Thread):
109112

@@ -169,7 +172,8 @@ def tearDown(self):
169172
self.server.stop()
170173

171174
def test_getwelcome(self):
172-
self.assertEqual(self.client.getwelcome(), b'+OK dummy pop3 server ready.')
175+
self.assertEqual(self.client.getwelcome(),
176+
b'+OK dummy pop3 server ready. <timestamp>')
173177

174178
def test_exceptions(self):
175179
self.assertRaises(poplib.error_proto, self.client._shortcmd, 'echo -err')
@@ -209,6 +213,9 @@ def test_noop(self):
209213
def test_rpop(self):
210214
self.assertOK(self.client.rpop('foo'))
211215

216+
def test_apop(self):
217+
self.assertOK(self.client.apop('foo', 'dummypassword'))
218+
212219
def test_top(self):
213220
expected = (b'+OK 116 bytes',
214221
[b'From: [email protected]', b'Content-Type: text/plain',
@@ -239,7 +246,7 @@ def __init__(self, conn):
239246
self.set_socket(ssl_socket)
240247
self.set_terminator(b"\r\n")
241248
self.in_buffer = []
242-
self.push('+OK dummy pop3 server ready.')
249+
self.push('+OK dummy pop3 server ready. <timestamp>')
243250

244251
class TestPOP3_SSLClass(TestPOP3Class):
245252
# repeat previous tests by using poplib.POP3_SSL

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ C-API
6363
Library
6464
-------
6565

66+
- Issue #6622: Fix "local variable 'secret' referenced before
67+
assignment" bug in POP3.apop.
68+
6669
- Issue #2715: Remove remnants of Carbon.File from binhex module.
6770

6871
- Issue #6595: The Decimal constructor now allows arbitrary Unicode

0 commit comments

Comments
 (0)