Skip to content

Commit 048ca87

Browse files
committed
Try to be more careful about handling None in paths.
1 parent ab5b3b0 commit 048ca87

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

couchdb/http.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,12 @@ def put_json(self, *a, **k):
388388
def _request(self, method, path=None, body=None, headers=None, **params):
389389
all_headers = self.headers.copy()
390390
all_headers.update(headers or {})
391-
return self.session.request(method, urljoin(self.url, path, **params),
392-
body=body, headers=all_headers,
391+
if path is not None:
392+
url = urljoin(self.url, path, **params)
393+
else:
394+
url = urljoin(self.url, **params)
395+
return self.session.request(method, url, body=body,
396+
headers=all_headers,
393397
credentials=self.credentials)
394398

395399

@@ -461,13 +465,18 @@ def urljoin(base, *path, **query):
461465
'http://example.org/foo%2Fbar'
462466
>>> urljoin('http://example.org/', 'foo', '/bar/')
463467
'http://example.org/foo/%2Fbar%2F'
468+
469+
>>> urljoin('http://example.org/', None)
470+
Traceback (most recent call last):
471+
...
472+
TypeError: argument 2 to map() must support iteration
464473
"""
465474
if base and base.endswith('/'):
466475
base = base[:-1]
467476
retval = [base]
468477

469478
# build the path
470-
path = '/'.join([''] + [quote(s) for s in path if s is not None])
479+
path = '/'.join([''] + [quote(s) for s in path])
471480
if path:
472481
retval.append(path)
473482

0 commit comments

Comments
 (0)