diff -r ca696ca204e0 Lib/smtpd.py --- a/Lib/smtpd.py Sat Aug 09 16:40:49 2014 -0400 +++ b/Lib/smtpd.py Tue Aug 12 11:51:04 2014 +0200 @@ -122,10 +122,8 @@ @property def max_command_size_limit(self): - try: - return max(self.command_size_limits.values()) - except ValueError: - return self.command_size_limit + return max(self.command_size_limits.values(), + default=self.command_size_limit) def __init__(self, server, conn, addr, data_size_limit=DATA_SIZE_DEFAULT, map=None, enable_SMTPUTF8=False, decode_data=None): @@ -137,8 +135,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;" @@ -747,7 +745,7 @@ class PureProxy(SMTPServer): def __init__(self, *args, **kwargs): - if 'enable_SMTPUTF8' in kwargs and kwargs['enable_SMTPUTF8']: + if kwargs.get('enable_SMTPUTF8'): raise ValueError("PureProxy does not support SMTPUTF8.") super(PureProxy, self).__init__(*args, **kwargs) diff -r ca696ca204e0 Lib/test/test_smtpd.py --- a/Lib/test/test_smtpd.py Sat Aug 09 16:40:49 2014 -0400 +++ b/Lib/test/test_smtpd.py Tue Aug 12 11:51:04 2014 +0200 @@ -176,6 +176,15 @@ ------------ END MESSAGE ------------ """)) + def test_decode_data_and_enable_SMTPUTF8_raises(self): + server = smtpd.DebuggingServer( + (support.HOST, 0), ('b', 0), decode_data=True) + conn, addr = server.accept() + self.assertRaises( + ValueError, + smtpd.SMTPChannel, + server, conn, addr, enable_SMTPUTF8=True, decode_data=True) + def tearDown(self): asyncore.close_all() asyncore.socket = smtpd.socket = socket