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

smtplib.py initialisation defect #48552

Closed
piers mannequin opened this issue Nov 12, 2008 · 5 comments
Closed

smtplib.py initialisation defect #48552

piers mannequin opened this issue Nov 12, 2008 · 5 comments
Labels
release-blocker stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@piers
Copy link
Mannequin

piers mannequin commented Nov 12, 2008

BPO 4302
Nosy @loewis
Files
  • smtplib-diff-c: diff -c of patch
  • smtplib_minor_fix.patch
  • 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 2008-12-10.09:56:18.893>
    created_at = <Date 2008-11-12.08:17:19.173>
    labels = ['type-bug', 'library', 'release-blocker']
    title = 'smtplib.py initialisation defect'
    updated_at = <Date 2008-12-10.09:56:18.892>
    user = 'https://bugs.python.org/piers'

    bugs.python.org fields:

    activity = <Date 2008-12-10.09:56:18.892>
    actor = 'ocean-city'
    assignee = 'ocean-city'
    closed = True
    closed_date = <Date 2008-12-10.09:56:18.893>
    closer = 'ocean-city'
    components = ['Library (Lib)']
    creation = <Date 2008-11-12.08:17:19.173>
    creator = 'piers'
    dependencies = []
    files = ['11991', '11997']
    hgrepos = []
    issue_num = 4302
    keywords = ['patch']
    message_count = 5.0
    messages = ['75777', '75778', '77503', '77527', '77528']
    nosy_count = 3.0
    nosy_names = ['loewis', 'ocean-city', 'piers']
    pr_nums = []
    priority = 'release blocker'
    resolution = 'fixed'
    stage = 'commit review'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue4302'
    versions = ['Python 2.5.3']

    @piers
    Copy link
    Mannequin Author

    piers mannequin commented Nov 12, 2008

    smtplib does not initialise the valriable 'sock' in the case where
    'host' is NULL on instantiation of smtplib.SMTP.

    Eg:

    % python
    Python 2.5.2 (r252:60911, Oct  5 2008, 19:29:17) 
    [GCC 4.3.2] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import smtplib
    >>> client=smtplib.SMTP('')
    >>> client.sendmail('from@home', 'to@home', 'test')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python2.5/smtplib.py", line 676, in sendmail
        if not (200 <= self.ehlo()[0] <= 299):
      File "/usr/lib/python2.5/smtplib.py", line 397, in ehlo
        self.putcmd("ehlo", name or self.local_hostname)
      File "/usr/lib/python2.5/smtplib.py", line 333, in putcmd
        self.send(str)
      File "/usr/lib/python2.5/smtplib.py", line 318, in send
        if self.sock:
    AttributeError: SMTP instance has no attribute 'sock'
    >>>

    The fix is to add "self.sock = None" in __init__ if host is not set,
    and then the behaviour is much more helpful:

    % python
    Python 2.5.2 (r252:60911, Oct  5 2008, 19:29:17) 
    [GCC 4.3.2] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import smtplib
    >>> client=smtplib.SMTP('')
    >>> client.sendmail('from@home', 'to@home', 'test')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python2.5/smtplib.py", line 678, in sendmail
        if not (200 <= self.ehlo()[0] <= 299):
      File "/usr/lib/python2.5/smtplib.py", line 399, in ehlo
        self.putcmd("ehlo", name or self.local_hostname)
      File "/usr/lib/python2.5/smtplib.py", line 335, in putcmd
        self.send(str)
      File "/usr/lib/python2.5/smtplib.py", line 327, in send
        raise SMTPServerDisconnected('please run connect() first')
    smtplib.SMTPServerDisconnected: please run connect() first
    >>>

    @piers piers mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Nov 12, 2008
    @ocean-city
    Copy link
    Mannequin

    ocean-city mannequin commented Nov 12, 2008

    This issue can be fixed by backporting r60975.

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Dec 10, 2008

    Backporting is fine with me: any volunteers?

    @loewis loewis mannequin added the release-blocker label Dec 10, 2008
    @ocean-city
    Copy link
    Mannequin

    ocean-city mannequin commented Dec 10, 2008

    I will backport this.

    @ocean-city ocean-city mannequin self-assigned this Dec 10, 2008
    @ocean-city
    Copy link
    Mannequin

    ocean-city mannequin commented Dec 10, 2008

    Done. Fixed in r67686 (release25-maint).

    @ocean-city ocean-city mannequin closed this as completed Dec 10, 2008
    @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
    release-blocker stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    0 participants