aboutsummaryrefslogtreecommitdiff
path: root/uritemplate
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2013-07-28 20:40:31 -0500
committerIan Cordasco <graffatcolmingov@gmail.com>2013-07-28 20:40:31 -0500
commit7412f8725187670d0cdd4d427dcf53c0032446bd (patch)
treebd9fb9b1819620cb95d8afd4712b44fea9c93beb /uritemplate
parent5b66365eee9173b9b7574ab8e53c47214268e440 (diff)
downloaduritemplates-7412f8725187670d0cdd4d427dcf53c0032446bd.tar.gz
Convert non-string-ish types to strings
Diffstat (limited to 'uritemplate')
-rw-r--r--uritemplate/template.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/uritemplate/template.py b/uritemplate/template.py
index ddfb12a..491464d 100644
--- a/uritemplate/template.py
+++ b/uritemplate/template.py
@@ -16,10 +16,14 @@ What do you do?
"""
import re
+import sys
from uritemplate.variable import URIVariable
template_re = re.compile('{([^\}]+)}')
+if sys.version_info[0] == 3:
+ basestring = (str, bytes)
+
class URITemplate(object):
@@ -105,6 +109,10 @@ class URITemplate(object):
expansion = var_dict or {}
expansion.update(kwargs)
+ for (k, v) in expansion.items():
+ if not isinstance(v, basestring):
+ expansion[k] = str(v)
+
expanded = {}
for v in self.variables:
expanded.update(v.expand(expansion))