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.LMTP.connect() raises TypeError if timeout is not specified #86922

Closed
wuestengecko mannequin opened this issue Dec 27, 2020 · 8 comments
Closed

smtplib.LMTP.connect() raises TypeError if timeout is not specified #86922

wuestengecko mannequin opened this issue Dec 27, 2020 · 8 comments
Labels
3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@wuestengecko
Copy link
Mannequin

wuestengecko mannequin commented Dec 27, 2020

BPO 42756
Nosy @vstinner, @corona10, @rrhodes, @Wuestengecko
PRs
  • bpo-42756: Configure LMTP Unix-domain socket to use global default timeout when timeout not provided #23969
  • [3.9] bpo-42756: Configure LMTP Unix-domain socket to use global defa… #24050
  • 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 2021-01-02.03:48:39.689>
    created_at = <Date 2020-12-27.13:11:53.374>
    labels = ['type-bug', 'library', '3.9', '3.10']
    title = 'smtplib.LMTP.connect() raises TypeError if `timeout` is not specified'
    updated_at = <Date 2021-01-02.03:48:39.688>
    user = 'https://github.com/wuestengecko'

    bugs.python.org fields:

    activity = <Date 2021-01-02.03:48:39.688>
    actor = 'corona10'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-01-02.03:48:39.689>
    closer = 'corona10'
    components = ['Library (Lib)']
    creation = <Date 2020-12-27.13:11:53.374>
    creator = 'wuestengecko'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 42756
    keywords = ['patch']
    message_count = 8.0
    messages = ['383850', '383867', '384011', '384152', '384153', '384186', '384214', '384215']
    nosy_count = 4.0
    nosy_names = ['vstinner', 'corona10', 'trrhodes', 'wuestengecko']
    pr_nums = ['23969', '24050']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue42756'
    versions = ['Python 3.9', 'Python 3.10']

    @wuestengecko
    Copy link
    Mannequin Author

    wuestengecko mannequin commented Dec 27, 2020

    Since Python 3.9, calling smtplib.LMTP.connect() without explicitly specifying any timeout= raises a TypeError. Specifying None or any integer value works correctly.

    >>> import smtplib
    >>> smtplib.LMTP("/tmp/lmtp.sock")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python3.9/smtplib.py", line 1071, in __init__
        super().__init__(host, port, local_hostname=local_hostname,
      File "/usr/lib/python3.9/smtplib.py", line 253, in __init__
        (code, msg) = self.connect(host, port)
      File "/usr/lib/python3.9/smtplib.py", line 1085, in connect
        self.sock.settimeout(self.timeout)
    TypeError: an integer is required (got type object)
    >>> l = smtplib.LMTP()
    >>> l.connect("/tmp/lmtp.sock")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python3.9/smtplib.py", line 1085, in connect
        self.sock.settimeout(self.timeout)
    TypeError: an integer is required (got type object)
    

    Upon investigation with pdb, the default object for the timeout parameter (socket._GLOBAL_DEFAULT_TIMEOUT) is passed through to the self.sock.settimeout call, instead of being handled as "no timeout specified". The relevant changes were introduced as fix for bpo-39329.

    @wuestengecko wuestengecko mannequin added type-crash A hard crash of the interpreter, possibly with a core dump 3.9 only security fixes stdlib Python modules in the Lib dir labels Dec 27, 2020
    @rrhodes
    Copy link
    Mannequin

    rrhodes mannequin commented Dec 27, 2020

    Hello Wüstengecko,

    Thanks for raising this issue. I've opened a PR which I believe will resolve the problem, but it's difficult to verify this against the mock socket setup. Feel free to leave feedback.

    @wuestengecko
    Copy link
    Mannequin Author

    wuestengecko mannequin commented Dec 29, 2020

    Hello,
    I can confirm that the PR resolves the issue.
    Thanks for the quick fix!

    @corona10
    Copy link
    Member

    corona10 commented Jan 1, 2021

    This

    @corona10 corona10 added the 3.10 only security fixes label Jan 1, 2021
    @corona10
    Copy link
    Member

    corona10 commented Jan 1, 2021

    This is a regression bug that should be fixed.

    @corona10 corona10 added type-bug An unexpected behavior, bug, or error and removed type-crash A hard crash of the interpreter, possibly with a core dump labels Jan 1, 2021
    @corona10
    Copy link
    Member

    corona10 commented Jan 1, 2021

    New changeset 3bf0532 by Ross in branch 'master':
    bpo-42756: Configure LMTP Unix-domain socket to use global default timeout when timeout not provided (GH-23969)
    3bf0532

    @corona10
    Copy link
    Member

    corona10 commented Jan 2, 2021

    New changeset 6912061 by Ross in branch '3.9':
    [3.9] bpo-42756: Configure LMTP Unix-domain socket to use global default timeout when timeout not provided (GH-23969) (GH-24050)
    6912061

    @corona10
    Copy link
    Member

    corona10 commented Jan 2, 2021

    Thanks, Ross Rhodes for the fix!
    And thanks, Wüstengecko for the report!

    @corona10 corona10 closed this as completed Jan 2, 2021
    @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
    3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant