Opened 7 years ago

Closed 7 years ago

#5640 enhancement closed fixed (fixed)

clientFromString unix "path" argument undocumented and not positional

Reported by: Matt Owned by: Jean-Paul Calderone
Priority: normal Milestone:
Component: core Keywords:
Cc: Matt Branch:
Author:

Description

When creating a UNIX socket client using endpoints.clientFromString, the "path" argument is not documented and is required to be a keyword (instead of positional, like for TCP's host)

Here's the problem:

>>> from twisted.internet.endpoints import clientFromString
>>> clientFromString(object(), 'unix:/var/foo/bar')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Twisted-10.2.0-py2.6-macosx-10.3-fat.egg/twisted/internet/endpoints.py", line 1005, in clientFromString
    kwargs = _clientParsers[name](*args, **kwargs)
TypeError: _parseClientUNIX() takes exactly 0 arguments (1 given)
>>> clientFromString(object(), 'unix:host=/var/foo/bar')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Twisted-10.2.0-py2.6-macosx-10.3-fat.egg/twisted/internet/endpoints.py", line 1006, in clientFromString
    return _endpointClientFactories[name](reactor, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'host'
>>> clientFromString(object(), 'unix:path=/var/foo/bar')
<twisted.internet.endpoints.UNIXClientEndpoint object at 0x3a91b0>

I will attach a patch that adds documentation and allows the "path" argument to be positionally given.

Attachments (1)

unix-client-patch.patch (3.0 KB) - added by Matt 7 years ago.
Patch for docs and positional path arg

Download all attachments as: .zip

Change History (5)

Changed 7 years ago by Matt

Attachment: unix-client-patch.patch added

Patch for docs and positional path arg

comment:1 Changed 7 years ago by Matt

Cc: Matt added
Keywords: review added

comment:2 Changed 7 years ago by Jean-Paul Calderone

Owner: set to Jean-Paul Calderone
Status: newassigned

comment:3 Changed 7 years ago by Jean-Paul Calderone

Keywords: review removed

Thanks! This patch looks really good. The only tiny issue I see is that the new test method makes the same mistake as many of the existing test methods: in its document, it says L{endpointClient}, which I think was an old in-development-only name of clientFromString. I'll adjust the docstring of all the test methods that make this mistake, add a news file, and apply the change. Thanks again.

comment:4 Changed 7 years ago by Jean-Paul Calderone

Resolution: fixed
Status: assignedclosed

(In [34222]) Add support for positional path values to the UNIX client endpoint string description syntax

Author: magmatt Reviewer: exarkun Fixes: #5640

Note: See TracTickets for help on using tickets.