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

Fix for #925, added support for tilda in provider ipc path #1049

Merged
merged 4 commits into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/core/providers/test_ipc_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ def test_ipc_no_path():
assert ipc.isConnected() is False


def test_ipc_tilda_in_path():
expectedPath = str(pathlib.Path.home()) + '/foo'
assert IPCProvider('~/foo').ipc_path == expectedPath
assert IPCProvider(pathlib.Path('~/foo')).ipc_path == expectedPath


@pytest.fixture
def simple_ipc_server(jsonrpc_ipc_pipe_path):
serv = socket.socket(socket.AF_UNIX)
Expand Down
6 changes: 3 additions & 3 deletions web3/providers/ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ class IPCProvider(JSONBaseProvider):
def __init__(self, ipc_path=None, timeout=10, *args, **kwargs):
if ipc_path is None:
self.ipc_path = get_default_ipc_path()
elif isinstance(ipc_path, str) or isinstance(ipc_path, Path):
self.ipc_path = str(Path(ipc_path).expanduser().resolve())
else:
if isinstance(ipc_path, Path):
ipc_path = str(ipc_path.resolve())
self.ipc_path = ipc_path
raise TypeError("ipc_path must be of type string or pathlib.Path")

self.timeout = timeout
self._lock = threading.Lock()
Expand Down