Skip to content
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

Closed
warsaw opened this issue Oct 6, 2015 · 6 comments
Closed

ValueError in smtpd.py __init__() is not raised #69515

warsaw opened this issue Oct 6, 2015 · 6 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@warsaw
Copy link
Member

warsaw commented Oct 6, 2015

BPO 25328
Nosy @warsaw, @bitdancer, @maurorodrigues, @zhangyangyu
Files
  • SMTPChannel_raise_ValueError.patch: add SMTPChannel's left out raise and the corresponding test
  • 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:

    assignee = None
    closed_at = <Date 2015-10-09.14:25:36.447>
    created_at = <Date 2015-10-06.19:59:27.891>
    labels = ['type-bug']
    title = 'ValueError in smtpd.py __init__() is not raised'
    updated_at = <Date 2015-10-09.14:25:36.446>
    user = 'https://github.com/warsaw'

    bugs.python.org fields:

    activity = <Date 2015-10-09.14:25:36.446>
    actor = 'r.david.murray'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-10-09.14:25:36.447>
    closer = 'r.david.murray'
    components = []
    creation = <Date 2015-10-06.19:59:27.891>
    creator = 'barry'
    dependencies = []
    files = ['40725']
    hgrepos = []
    issue_num = 25328
    keywords = ['patch']
    message_count = 6.0
    messages = ['252426', '252567', '252568', '252589', '252615', '252616']
    nosy_count = 5.0
    nosy_names = ['barry', 'r.david.murray', 'python-dev', 'maurosr', 'xiang.zhang']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue25328'
    versions = ['Python 3.5', 'Python 3.6']

    @warsaw
    Copy link
    Member Author

    warsaw commented Oct 6, 2015

    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.

    @maurorodrigues
    Copy link
    Mannequin

    maurorodrigues mannequin commented Oct 8, 2015

    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.

    @warsaw
    Copy link
    Member Author

    warsaw commented Oct 8, 2015

    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
    SMTPChannel.__init__() that's broken.

    @zhangyangyu
    Copy link
    Member

    I think this is a typo. The raise is left out.

    In test_smtpd.py, it only tests the raise condition in SMTPServer but
    not STMPChannel.

    I add the raise and a corresponding test in SMTPDChannelTest.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Oct 9, 2015

    New changeset d471cf4a73b2 by R David Murray in branch '3.5':
    bpo-25328: add missing raise keyword in decode_data+SMTPUTF8 check.
    https://hg.python.org/cpython/rev/d471cf4a73b2

    New changeset 576128c0d068 by R David Murray in branch 'default':
    Merge bpo-25328: add missing raise keyword in decode_data+SMTPUTF8 check.
    https://hg.python.org/cpython/rev/576128c0d068

    @bitdancer
    Copy link
    Member

    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.

    @bitdancer bitdancer added the type-bug An unexpected behavior, bug, or error label Oct 9, 2015
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants