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: ValueError in smtpd.py __init__() is not raised
Type: behavior Stage: resolved
Components: Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: barry, maurosr, python-dev, r.david.murray, xiang.zhang
Priority: normal Keywords: patch

Created on 2015-10-06 19:59 by barry, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
SMTPChannel_raise_ValueError.patch xiang.zhang, 2015-10-09 06:23 add SMTPChannel's left out raise and the corresponding test review
Messages (6)
msg252426 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2015-10-06 19:59
In Python 3.5, SMTPChannel.__init__() ensures that enable_SMTPUTF8 and decode_data arguments are not both true.  This even seems to be tested in test_smtpd.py.  But it's clearly bogus because the exception is never raised!  It just creates and throws away the exception instance.
msg252567 - (view) Author: Mauro S. M. Rodrigues (maurosr) * Date: 2015-10-08 20:44
Hi Barry, I was testing this and it seems to work, am I doing something wrong in order to reproduce it? I've used the same parameters from the unit tests

Python 3.5.0+ (3.5:1e99ba6b7c98, Oct  8 2015, 17:12:06) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import smtpd
>>> smtpd.SMTPServer(("127.0.0.1", 0), ('b',0),enable_SMTPUTF8=True,decode_data=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/maurosr/dev/cpython/Lib/smtpd.py", line 645, in __init__
    raise ValueError("The decode_data and enable_SMTPUTF8"
ValueError: The decode_data and enable_SMTPUTF8 parameters cannot be set to True at the same time.
msg252568 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2015-10-08 20:48
On Oct 08, 2015, at 08:44 PM, Mauro S. M. Rodrigues wrote:

>Python 3.5.0+ (3.5:1e99ba6b7c98, Oct  8 2015, 17:12:06) 
>[GCC 4.8.4] on linux
>Type "help", "copyright", "credits" or "license" for more information.
>>>> import smtpd
>>>> smtpd.SMTPServer(("127.0.0.1", 0), ('b',0),enable_SMTPUTF8=True,decode_data=True)
>Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "/home/maurosr/dev/cpython/Lib/smtpd.py", line 645, in __init__
>    raise ValueError("The decode_data and enable_SMTPUTF8"
>ValueError: The decode_data and enable_SMTPUTF8 parameters cannot be set to True at the same time.

That's testing the SMTPServer.__init__() which looks fine.  It's the
SMTPChannel.__init__() that's broken.
msg252589 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2015-10-09 06:23
I think this is a typo. The raise is left out.

In test_smtpd.py, it only tests the raise condition in SMTPServer but
not STMPChannel.

I add the raise and a corresponding test in SMTPDChannelTest.
msg252615 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-10-09 14:22
New changeset d471cf4a73b2 by R David Murray in branch '3.5':
#25328: add missing raise keyword in decode_data+SMTPUTF8 check.
https://hg.python.org/cpython/rev/d471cf4a73b2

New changeset 576128c0d068 by R David Murray in branch 'default':
Merge #25328: add missing raise keyword in decode_data+SMTPUTF8 check.
https://hg.python.org/cpython/rev/576128c0d068
msg252616 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-10-09 14:25
Thanks, Xiang.  Your analysis was correct and your patch is good.

For anyone who is curious, Barry discovered this while writing tests for a new aiosmtpd, which is based on the existing smtpd code.
History
Date User Action Args
2022-04-11 14:58:22adminsetgithub: 69515
2015-10-09 14:25:36r.david.murraysetstatus: open -> closed
type: behavior
messages: + msg252616

resolution: fixed
stage: resolved
2015-10-09 14:22:58python-devsetnosy: + python-dev
messages: + msg252615
2015-10-09 06:23:18xiang.zhangsetfiles: + SMTPChannel_raise_ValueError.patch

nosy: + xiang.zhang
messages: + msg252589

keywords: + patch
2015-10-08 20:48:03barrysetmessages: + msg252568
2015-10-08 20:44:53maurosrsetnosy: + maurosr
messages: + msg252567
2015-10-06 19:59:27barrycreate