[Python-checkins] cpython (merge 3.5 -> default): Merge #25328: add missing raise keyword in decode_data+SMTPUTF8 check.

r.david.murray python-checkins at python.org
Fri Oct 9 10:24:04 EDT 2015


https://hg.python.org/cpython/rev/576128c0d068
changeset:   98621:576128c0d068
parent:      98619:92025e9c6b54
parent:      98620:d471cf4a73b2
user:        R David Murray <rdmurray at bitdance.com>
date:        Fri Oct 09 10:20:58 2015 -0400
summary:
  Merge #25328: add missing raise keyword in decode_data+SMTPUTF8 check.

files:
  Lib/smtpd.py           |  4 ++--
  Lib/test/test_smtpd.py |  6 ++++++
  Misc/NEWS              |  3 +++
  3 files changed, 11 insertions(+), 2 deletions(-)


diff --git a/Lib/smtpd.py b/Lib/smtpd.py
--- a/Lib/smtpd.py
+++ b/Lib/smtpd.py
@@ -137,8 +137,8 @@
         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
--- a/Lib/test/test_smtpd.py
+++ b/Lib/test/test_smtpd.py
@@ -313,6 +313,12 @@
             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
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -48,6 +48,9 @@
 Library
 -------
 
+- Issue #25328: smtpd's SMTPChannel now correctly raises a ValueError if both
+  decode_data and enable_SMTPUTF8 are set to true.
+
 - Issue #16099: RobotFileParser now supports Crawl-delay and Request-rate
   extensions.  Patch by Nikolay Bogoychev.
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list