summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2015-10-09 10:19:33 -0400
committerR David Murray <rdmurray@bitdance.com>2015-10-09 10:19:33 -0400
commit1a815389cccef2e28e2d27f14e71a1b708cfb20f (patch)
tree96b2c80b81916c20b03bd91988b6dac4e0b63294
parent5ae56919ab46e07e9bd6e5530cddac75e0276505 (diff)
downloadcpython-git-1a815389cccef2e28e2d27f14e71a1b708cfb20f.tar.gz
#25328: add missing raise keyword in decode_data+SMTPUTF8 check.
This is a relatively benign bug, since having both be true was correctly rejected at in SMTPServer even before this patch. Patch by Xiang Zhang.
-rwxr-xr-xLib/smtpd.py4
-rw-r--r--Lib/test/test_smtpd.py6
-rw-r--r--Misc/NEWS3
3 files changed, 11 insertions, 2 deletions
diff --git a/Lib/smtpd.py b/Lib/smtpd.py
index ff86e7d206..732066ef9a 100755
--- a/Lib/smtpd.py
+++ b/Lib/smtpd.py
@@ -137,8 +137,8 @@ class SMTPChannel(asynchat.async_chat):
self.enable_SMTPUTF8 = enable_SMTPUTF8
if enable_SMTPUTF8:
if decode_data:
- ValueError("decode_data and enable_SMTPUTF8 cannot be set to"
- " True at the same time")
+ raise ValueError("decode_data and enable_SMTPUTF8 cannot"
+ " be set to True at the same time")
decode_data = False
if decode_data is None:
warn("The decode_data default of True will change to False in 3.6;"
diff --git a/Lib/test/test_smtpd.py b/Lib/test/test_smtpd.py
index 1aa55d2144..88dbfdf6f0 100644
--- a/Lib/test/test_smtpd.py
+++ b/Lib/test/test_smtpd.py
@@ -313,6 +313,12 @@ class SMTPDChannelTest(unittest.TestCase):
DummyDispatcherBroken, BrokenDummyServer,
(support.HOST, 0), ('b', 0), decode_data=True)
+ def test_decode_data_and_enable_SMTPUTF8_raises(self):
+ self.assertRaises(
+ ValueError, smtpd.SMTPChannel,
+ self.server, self.channel.conn, self.channel.addr,
+ enable_SMTPUTF8=True, decode_data=True)
+
def test_server_accept(self):
self.server.handle_accept()
diff --git a/Misc/NEWS b/Misc/NEWS
index 410caa29e0..8113dd36a6 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -37,6 +37,9 @@ Core and Builtins
Library
-------
+- Issue #25328: smtpd's SMTPChannel now correctly raises a ValueError if both
+ decode_data and enable_SMTPUTF8 are set to true.
+
- Issue #25316: distutils raises OSError instead of DistutilsPlatformError
when MSVC is not installed.