Skip to content

Commit

Permalink
Merge pull request #1049 from pjryan93/home-directory-support
Browse files Browse the repository at this point in the history
Fix for #925, added support for tilda in provider ipc path
  • Loading branch information
kclowes authored Apr 25, 2019
2 parents b687f20 + f59deef commit 71b8bf0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
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

0 comments on commit 71b8bf0

Please sign in to comment.