[New-bugs-announce] [issue21641] smtplib leaves open sockets around if SMTPResponseException is raised in __init__

Claudiu.Popa report at bugs.python.org
Mon Jun 2 16:55:42 CEST 2014


New submission from Claudiu.Popa:

Hello!

I noticed that test_smtplib raises a ResourceWarning, tracking this to this piece of code:

   self.assertRaises(smtplib.SMTPResponseException, smtplib.SMTP,
                     HOST, self.port, 'localhost', 3)

What happens is that `SMTP.getreply` is called in `SMTP.__init__` after the socket was opened, but if getreply raises SMTPResponseException, the socket remains opened. The attached patch fixes this.

----------
components: Library (Lib)
files: smtplib_resource_warning.patch
keywords: patch
messages: 219592
nosy: Claudiu.Popa
priority: normal
severity: normal
status: open
title: smtplib leaves open sockets around if SMTPResponseException is raised in __init__
type: enhancement
versions: Python 3.5
Added file: http://bugs.python.org/file35459/smtplib_resource_warning.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21641>
_______________________________________


More information about the New-bugs-announce mailing list