This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: smtplib SMTP_SSL._get_socket doesn't return a value
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.0, Python 3.1, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ajaksu2, fanda.vacek, farhan.ahmad, marcin.bachry, r.david.murray
Priority: critical Keywords: patch

Created on 2008-10-07 14:26 by marcin.bachry, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
smtplib.diff marcin.bachry, 2008-10-07 14:26 simple fix
smtplib_72551.diff farhan.ahmad, 2009-05-10 19:03 updated _get_socket to return value, expected behavior.
test_smtpnet.py marcin.bachry, 2009-05-10 21:17 simplified test from #4470
return_socket.diff ajaksu2, 2009-05-12 01:01 Farhan's patch and Marcin's test adapted to py3k.
Messages (7)
msg74452 - (view) Author: Marcin Bachry (marcin.bachry) Date: 2008-10-07 14:26
SMTP.connect method expects _get_socket() method to return socket object:

  self.sock = self._get_socket(host, port, self.timeout)

but overriden _get_socket() method in SMTP_SSL class doesnt' have return
statement (it sets self.sock instead).  Hence I get
SMTPServerDisconnected exception when I try to send mail over ssl.

The same seems to apply to LMTP class.
msg87537 - (view) Author: Farhan Ahmad (farhan.ahmad) Date: 2009-05-10 19:03
Marcin, thanks for finding the cause.  I have attached another diff
that, instead of removing the assignment, makes the _get_socket function
return the socket, which is the expected behavior.

You mentioned that the LMTP class also has this issue.  I looked through
that class, but didn't see any similar issues.  Can you please give more
details?

Thanks,
Farhan
msg87541 - (view) Author: Marcin Bachry (marcin.bachry) Date: 2009-05-10 20:20
Your diff is better than mine and looks quite similar to patch number 2
in #4470. If the whole #4470 can't be accepted for now, we could at
least apply this one change, because without it SMTP_SSL is totally
unusable. Daniel, maybe we can mark this bug or #4470 as critical?

LMTP seems ok indeed; I don't remember why I mentioned it. :)
msg87549 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-05-10 21:05
Marcin,
Done and set this one as a dependency of 4470. It would be very good to
have a test that flexes this patch, can you work on one?
msg87552 - (view) Author: Marcin Bachry (marcin.bachry) Date: 2009-05-10 21:17
Here's a dumbed down version of the test from #4470. It requires
network, but no gmail account is needed to run the test.
msg87598 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-05-12 01:01
Thanks, Marcin!

Same bug seems to apply to py3k, ported patches attached.
msg88221 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-05-23 02:53
Applied to trunk in r72835, with some test fixes after (to skip the test
if SSL isn't installed).  Applied to py3k in r72836, ditto on fixes.  I
also backported the fix and test to 26-maint and 30-maint.
History
Date User Action Args
2022-04-11 14:56:40adminsetgithub: 48316
2009-05-23 02:53:34r.david.murraysetstatus: open -> closed

versions: + Python 3.0, Python 2.7
nosy: + r.david.murray

messages: + msg88221
resolution: fixed
stage: patch review -> resolved
2009-05-12 01:01:02ajaksu2setfiles: + return_socket.diff

stage: patch review
messages: + msg87598
versions: + Python 3.1
2009-05-10 21:17:06marcin.bachrysetfiles: + test_smtpnet.py

messages: + msg87552
2009-05-10 21:05:01ajaksu2setpriority: critical

messages: + msg87549
2009-05-10 21:02:56ajaksu2linkissue4470 dependencies
2009-05-10 20:20:40marcin.bachrysetnosy: + ajaksu2
messages: + msg87541
2009-05-10 19:03:26farhan.ahmadsetfiles: + smtplib_72551.diff
nosy: + farhan.ahmad
messages: + msg87537

2009-05-08 16:10:28fanda.vaceksetnosy: + fanda.vacek
2008-10-07 14:26:15marcin.bachrycreate