[issue21641] smtplib leaves open sockets around if SMTPResponseException is raised in __init__

2014-06-03 Thread Claudiu.Popa

Claudiu.Popa added the comment:

It's actually better to close the socket in __init__ in this case.

--
Added file: http://bugs.python.org/file35466/issue21641.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21641
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21641] smtplib leaves open sockets around if SMTPResponseException is raised in __init__

2014-06-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset d5c76646168d by Senthil Kumaran in branch '3.4':
Fix issue #21641: Close the socket before raising the SMTPResponseException. 
Fixes the ResourceWarning in the test run.
http://hg.python.org/cpython/rev/d5c76646168d

New changeset 7ea84a25d863 by Senthil Kumaran in branch 'default':
merge from 3.4
http://hg.python.org/cpython/rev/7ea84a25d863

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21641
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21641] smtplib leaves open sockets around if SMTPResponseException is raised in __init__

2014-06-03 Thread Senthil Kumaran

Senthil Kumaran added the comment:

The first patch was correct and consistent with how other Exceptions were 
closing the socket. Fixed this and thanks for the patch.

--
assignee:  - orsenthil
nosy: +orsenthil
resolution:  - fixed
stage:  - resolved
status: open - closed
versions: +Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21641
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21641] smtplib leaves open sockets around if SMTPResponseException is raised in __init__

2014-06-02 Thread Claudiu.Popa

Claudiu.Popa added the comment:

An alternative to this approach would be to catch the error in __init__ and 
close the socket there.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21641
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21641] smtplib leaves open sockets around if SMTPResponseException is raised in __init__

2014-06-02 Thread Claudiu.Popa

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 rep...@bugs.python.org
http://bugs.python.org/issue21641
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com