]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#25328: add missing raise keyword in decode_data+SMTPUTF8 check.
authorR David Murray <rdmurray@bitdance.com>
Fri, 9 Oct 2015 14:19:33 +0000 (10:19 -0400)
committerR David Murray <rdmurray@bitdance.com>
Fri, 9 Oct 2015 14:19:33 +0000 (10:19 -0400)
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.

Lib/smtpd.py
Lib/test/test_smtpd.py
Misc/NEWS

index ff86e7d2065ceb03faa09d2cfabc916dfecf4e34..732066ef9a5a35814590435ae7c0a2de0af06455 100755 (executable)
@@ -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;"
index 1aa55d21440dd9639d931a3006ea4d09780ed605..88dbfdf6f011021e723a68466655ec817c62de83 100644 (file)
@@ -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()
 
index 410caa29e02de31bc7a355ef2cdb8d351a7b0980..8113dd36a68a240ac4d8623460d66157a0527979 100644 (file)
--- 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.