Skip to content

TypeError in smtpd module with string arguments #70397

Closed

Description

@lorenzoancora
BPO 26209
Nosy @terryjreedy, @giampaolo, @bitdancer, @berkerpeksag
Files
  • smtpd_doc_updated.patch: smtpd Server documentation updated
  • smtpd_doc_updated_2.patch: smtpd patch 2 with review comments applied
  • smtpd_doc_updated_3.patch: smtpd patch 3 with review comments applied
  • 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 2016-09-07.18:11:15.624>
    created_at = <Date 2016-01-26.20:34:38.569>
    labels = ['easy', 'type-feature', 'library', 'docs']
    title = 'TypeError in smtpd module with string arguments'
    updated_at = <Date 2016-09-07.18:11:15.622>
    user = 'https://bugs.python.org/lorenzoancora'

    bugs.python.org fields:

    activity = <Date 2016-09-07.18:11:15.622>
    actor = 'r.david.murray'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2016-09-07.18:11:15.624>
    closer = 'r.david.murray'
    components = ['Documentation', 'Library (Lib)']
    creation = <Date 2016-01-26.20:34:38.569>
    creator = 'lorenzo.ancora'
    dependencies = []
    files = ['44045', '44047', '44055']
    hgrepos = []
    issue_num = 26209
    keywords = ['patch', 'easy']
    message_count = 15.0
    messages = ['258971', '259229', '259261', '259455', '259475', '259727', '259747', '259748', '259753', '272154', '272159', '272227', '274852', '274853', '274854']
    nosy_count = 8.0
    nosy_names = ['terry.reedy', 'giampaolo.rodola', 'r.david.murray', 'docs@python', 'python-dev', 'berker.peksag', 'lorenzo.ancora', 'rvallury']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue26209'
    versions = ['Python 2.7', 'Python 3.5', 'Python 3.6']

    Activity

    1. lorenzoancora commented on Jan 26, 2016

      lorenzoancoramannequin
      MannequinAuthor
      smtpd.PureProxy(localaddr="host1", remoteaddr="host2")

      ...produces the error:

      [...] smtpd.py", line 657, in __init__
      gai_results = socket.getaddrinfo(*localaddr, type=socket.SOCK_STREAM)
      TypeError: getaddrinfo() got multiple values for argument 'type'

      The module only works with:

      smtpd.PureProxy(localaddr=("host1", 25), remoteaddr=("host2", 25))

      The documentation does not specify the format of the INPUT parameters, only the CLI syntax with hostnames as "host:port" strings.
      The underlying library should convert them to tuples or at least the documentation should be completed.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on Jan 26, 2016
    3. terryjreedy commented on Jan 30, 2016

      @terryjreedy
      Member

      I am guessing that 25 is the default port. Autoconversion of 'host' to ('host', 25) would be a new feature ('enhancement') that would have to wait for the next Python version (3.6 or later). Is there any precedent for this in any other module?

      Does 2.7 act the same as 3.5? A doc improvement could go there also.

    4. berkerpeksag commented on Jan 30, 2016

      @berkerpeksag
      Member

      There is a strong change that smtpd is going to be deprecated in Python 3.6. See bpo-25008 for details.

      +1 for improving documentation.

    5. added
      docsDocumentation in the Doc dir
      and removed
      stdlibStandard Library Python modules in the Lib/ directory
      on Jan 30, 2016
    6. added
      type-featureA feature request or enhancement
      and removed
      type-bugAn unexpected behavior, bug, or error
      on Jan 30, 2016
    7. lorenzoancora commented on Feb 3, 2016

      lorenzoancoramannequin
      MannequinAuthor

      (msg259229) Terry J. Reedy i Suggest that a standard and globally accepted scheme to manage IPv4 addresses is:

      "Host:PortNumber" --> (host, PortNumber)
      "Host" --> (host, DefaultPortNumber)
      "IP:PortNumber" --> (host, PortNumber)
      "IP" --> (host, DefaultPortNumber)

      ...where DefaultPortNumber is protocol and system dependent (IANA standard, see the SMTP line in: http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml).

      A simple research reveals that all versions of the module are (sadly) poorly documented, but the module is an interface to a very important protocol that indeed must be offered by the standard library.
      The only little suggestion in the documentation of the module is: https://docs.python.org/3.6/library/socket.html#socket.socket.accept
      ...from a one-word link in: https://docs.python.org/3.6/library/smtpd.html#smtpd.SMTPChannel.addr
      Which has only an indirect relation with the object itself.

      Many users may not recognize the cause of the error if the documentation doesn't explicitate the information to correctly initialize the core objects of the module.
      I also Suggest that at least the object should return an helpful error in newer versions of Python.

      Thank you for your efforts guys. :-)

    8. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Feb 3, 2016
    9. terryjreedy commented on Feb 3, 2016

      @terryjreedy
      Member

      Doc fixes unrelated to security fixes are not applied to security-fix-only versions.

    10. lorenzoancora commented on Feb 6, 2016

      lorenzoancoramannequin
      MannequinAuthor

      (msg259475) Terry J. Reedy thank you for the correction, I've confused the versions affected with the versions actually supported.
      Since this doesn't only affect the documentation, is it correct to assign the issue to docs@python?
      The expert index indicates giampaolo.rodola as the module maintainer, so he should be moved from the nosy list to the field "Assigned To" and docs@python should be in the nosy list.

      Also, there is a documentation on how to send a patch for a specific module in Python 3.5?
      I'd like to help by creating a new source code patch. :-)

    11. terryjreedy commented on Feb 6, 2016

      @terryjreedy
      Member

      Code patches should not be assigned to 'docs'. But Berker, for the reason stated, thinks this should be doc only. Giampaolo is not currently active, so should not be assigned the issue by anyone else.

      After making a patch -- see the devguide -- use the File: Browse button to upload a file. You can suggest a specific doc change in a message, without a .patch or .diff file.

    12. terryjreedy commented on Feb 6, 2016

      @terryjreedy
      Member

      Note that the proposed code change would be a 3.6 only enhancement. Adding the other versions was part of changing to a doc-only issue. Note also that if the module is not deprecated, then a 3.6 code change could be considered. But only a doc change for now.

    13. lorenzoancora commented on Feb 7, 2016

      lorenzoancoramannequin
      MannequinAuthor

      (msg259748) ok, then I propose to correct https://docs.python.org/dev/library/smtpd.html?highlight=q#smtpd.SMTPServer from:

      .. class:: SMTPServer(localaddr, remoteaddr, data_size_limit=33554432,\
      map=None, enable_SMTPUTF8=False, decode_data=True)

      Create a new :class:`SMTPServer` object, which binds to local address
      *localaddr*. It will treat *remoteaddr* as an upstream SMTP relayer. It
      inherits from :class:`asyncore.dispatcher`, and so will insert itself into
      :mod:`asyncore`'s event loop on instantiation.

      To:

      .. class:: SMTPServer(localaddr, remoteaddr, data_size_limit=33554432,\
      map=None, enable_SMTPUTF8=False, decode_data=True)

      Creates a new :class:`SMTPServer` object, which binds to local address
      *localaddr* and uses *remoteaddr* as an upstream SMTP relayer.
      Both parameters should be a tuple in the form ``("host", portnumber)``, where *host* is a valid IP/FQDN.
      The object will insert itself into :mod:`asyncore`'s event loop on instantiation (inherits from :class:`asyncore.dispatcher`) and can be started with a call to :class:`asyncore.loop`.

      ---

      These clarifications should be also inserted in the source code as heredocs (without the Sphynx syntax).
      I really think that those changes will make the use of smtpd easier.

    14. rvallury commented on Aug 8, 2016

      rvallurymannequin
      Mannequin

      Updated the documentation of smtpd.
      https://docs.python.org/3/library/smtpd.html#smtpserver-objects

      • this is my first patch, please revert back to me or make learn if I do any mistake*
    15. rvallury commented on Aug 8, 2016

      rvallurymannequin
      Mannequin

      Submitting patch 2 for smtpd doc changes

    16. rvallury commented on Aug 9, 2016

      rvallurymannequin
      Mannequin

      added space before word portnumber. column space adjusted

    17. python-dev commented on Sep 7, 2016

      python-devmannequin
      Mannequin

      New changeset 1ed37f6e91bb by R David Murray in branch '3.5':
      bpo-26209: Clarify type of *localaddr*/remoteadr in smtpd docs.
      https://hg.python.org/cpython/rev/1ed37f6e91bb

      New changeset fe2ca2216334 by R David Murray in branch 'default':
      Merge: bpo-26209: Clarify type of *localaddr*/remoteadr in smtpd docs.
      https://hg.python.org/cpython/rev/fe2ca2216334

    18. bitdancer commented on Sep 7, 2016

      @bitdancer
      Member

      Thanks for the patch, Ram. I started from your patch but further clarified exactly what the tuple is by linking to the actual documentation in the socket docs of what a (host, port) tuple looks like. I'll apply my patch to 2.7 as well as soon as I confirm the docs build correctly.

    19. python-dev commented on Sep 7, 2016

      python-devmannequin
      Mannequin

      New changeset 7aaf8cff23e5 by R David Murray in branch '2.7':
      bpo-26209: Clarify type of *localaddr*/remoteadr in smtpd docs.
      https://hg.python.org/cpython/rev/7aaf8cff23e5

    20. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      docsDocumentation in the Doc direasystdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions