From 6166ba7e131ef77f9748488a02dc5e699928a17d Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Wed, 8 Aug 2012 12:05:52 +0100 Subject: [PATCH] Accept objects with string representations as URLs. --- requests/models.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/requests/models.py b/requests/models.py index d8c0f3e8..20a28807 100644 --- a/requests/models.py +++ b/requests/models.py @@ -71,7 +71,14 @@ class Request(object): self.timeout = timeout #: Request URL. - self.url = url + #: Accept objects that have string representations. + try: + self.url = unicode(url) + except NameError: + # We're on Python 3. + self.url = str(url) + except UnicodeDecodeError: + self.url = url #: Dictionary of HTTP Headers to attach to the :class:`Request `. self.headers = dict(headers or [])