From 5f9ad606a8e9b4086c2ec9f059cfdc99a7ff0ad5 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Tue, 1 Oct 2019 22:08:59 +0200 Subject: [PATCH] URIs now allow spaces in location part. Fixes #222 --- docs/source/changelog.rst | 1 + examples/timezones/client.py | 1 + src/Pyro4/core.py | 2 +- tests/PyroTests/test_core.py | 6 ++++++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 82333bcd..d4338402 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -6,6 +6,7 @@ Change Log - dropped support for Python 3.4 (which has reached end-of-life status). Supported Python versions are now 2.7, and 3.5 or newer. (the life cycle status of the Python versions can be seen here https://devguide.python.org/#status-of-python-branches) +- URIs now allow spaces in the location part. Useful for unix domain sockets. **Pyro 4.76** diff --git a/examples/timezones/client.py b/examples/timezones/client.py index 773dc41d..e776c749 100644 --- a/examples/timezones/client.py +++ b/examples/timezones/client.py @@ -41,6 +41,7 @@ def test(): # pickle. print("\n******* pickle *******") +print("******* (expecting no errors) ******") Pyro4.config.SERIALIZER = "pickle" try: test() diff --git a/src/Pyro4/core.py b/src/Pyro4/core.py index a871bd69..151ecb01 100644 --- a/src/Pyro4/core.py +++ b/src/Pyro4/core.py @@ -47,7 +47,7 @@ class URI(object): You can write the protocol in lowercase if you like (``pyro:...``) but it will automatically be converted to uppercase internally. """ - uriRegEx = re.compile(r"(?P[Pp][Yy][Rr][Oo][a-zA-Z]*):(?P\S+?)(@(?P\S+))?$") + uriRegEx = re.compile(r"(?P[Pp][Yy][Rr][Oo][a-zA-Z]*):(?P\S+?)(@(?P.+))?$") def __init__(self, uri): if isinstance(uri, URI): diff --git a/tests/PyroTests/test_core.py b/tests/PyroTests/test_core.py index 434f381e..da5b9bcf 100644 --- a/tests/PyroTests/test_core.py +++ b/tests/PyroTests/test_core.py @@ -132,6 +132,9 @@ def testUriStrAndRepr(self): self.assertEqual(uri, str(p)) self.assertEqual(unicodeuri, unicode(p)) self.assertTrue(type(p.sockname) is unicode) + uri = "PYRO:12345@./u:sock name with strings" + p = Pyro4.core.URI(uri) + self.assertEqual(uri, str(p)) def testUriParsingPyro(self): p = Pyro4.core.URI("PYRONAME:some_obj_name") @@ -159,6 +162,9 @@ def testUriParsingPyro(self): p = Pyro4.core.URI("PYRO:12345@./u:/tmp/sockname") self.assertEqual("12345", p.object) self.assertEqual("/tmp/sockname", p.sockname) + p = Pyro4.core.URI("PYRO:12345@./u:/path with spaces/sockname ") + self.assertEqual("12345", p.object) + self.assertEqual("/path with spaces/sockname ", p.sockname) p = Pyro4.core.URI("PYRO:12345@./u:../sockname") self.assertEqual("12345", p.object) self.assertEqual("../sockname", p.sockname)