New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ValueError in smtpd.py __init__() is not raised #69515
Comments
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. |
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. |
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 |
I think this is a typo. The raise is left out. In test_smtpd.py, it only tests the raise condition in SMTPServer but I add the raise and a corresponding test in SMTPDChannelTest. |
New changeset d471cf4a73b2 by R David Murray in branch '3.5': New changeset 576128c0d068 by R David Murray in branch 'default': |
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. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: