diff options
author | Ben Bangert <ben@groovie.org> | 2020-10-13 19:24:22 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-13 19:24:22 -0700 |
commit | d3fc41c3c89b55082530dc275ffdbfdfaadf1a2f (patch) | |
tree | bb2a0368a07f18e3a1f003a692b2ad547e955458 /routes/route.py | |
parent | 620045e761f9b967026538ffb00fdd2e8216618c (diff) | |
parent | 723b071f26bdd62fb2e13e1226cef126c30fa18f (diff) | |
download | routes-d3fc41c3c89b55082530dc275ffdbfdfaadf1a2f.tar.gz |
Merge pull request #99 from bbangert/feat/python-3-compats
feat: add python 3.6+ compat
Diffstat (limited to 'routes/route.py')
-rw-r--r-- | routes/route.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/routes/route.py b/routes/route.py index cf6df10..719636a 100644 --- a/routes/route.py +++ b/routes/route.py @@ -364,7 +364,6 @@ class Route(object): self.prior = part (rest, noreqs, allblank) = self.buildnextreg(path[1:], clist, include_names) - if isinstance(part, dict) and part['type'] in (':', '.'): var = part['name'] typ = part['type'] @@ -502,7 +501,13 @@ class Route(object): reg += ')?' else: allblank = False - reg = re.escape(part) + rest + # Starting in Python 3.7, the / is no longer escaped, however quite a bit of + # route generation code relies on it being escaped. This forces the escape in + # Python 3.7+ so that the remainder of the code functions as intended. + if part == '/': + reg = r'\/' + rest + else: + reg = re.escape(part) + rest # We have a normal string here, this is a req, and it prevents us from # being all blank |