Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.7 compat issue with re? #227

Closed
gcmurphy opened this issue Sep 10, 2018 · 3 comments
Closed

Python 3.7 compat issue with re? #227

gcmurphy opened this issue Sep 10, 2018 · 3 comments
Labels

Comments

@gcmurphy
Copy link

The re module doesn't seem to like Python 3.7. This error happens on the most simple @app.route('/example').

python proxy.py
Traceback (most recent call last):
  File "/Users/grantmurphy/.local/share/virtualenvs/elastic_proxy-jpNTIbJ1/lib/python3.7/sre_parse.py", line 1021, in parse_template
    this = chr(ESCAPES[this][1])
KeyError: '\\d'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "proxy.py", line 22, in <module>
    @app.route(u'/sitemap')
  File "/Users/grantmurphy/.local/share/virtualenvs/elastic_proxy-jpNTIbJ1/lib/python3.7/site-packages/weppy/expose.py", line 188, in __call__
    routeobj = Route(self, path, idx)
  File "/Users/grantmurphy/.local/share/virtualenvs/elastic_proxy-jpNTIbJ1/lib/python3.7/site-packages/weppy/expose.py", line 295, in __init__
    self.schemes, self.hostname, self.methods, self.path)
  File "/Users/grantmurphy/.local/share/virtualenvs/elastic_proxy-jpNTIbJ1/lib/python3.7/site-packages/weppy/expose.py", line 115, in build_regex
    path = cls.REGEX_INT.sub('(?P<\g<1>>\d+)', path)
  File "/Users/grantmurphy/.local/share/virtualenvs/elastic_proxy-jpNTIbJ1/lib/python3.7/re.py", line 309, in _subx
    template = _compile_repl(template, pattern)
  File "/Users/grantmurphy/.local/share/virtualenvs/elastic_proxy-jpNTIbJ1/lib/python3.7/re.py", line 300, in _compile_repl
    return sre_parse.parse_template(repl, pattern)
  File "/Users/grantmurphy/.local/share/virtualenvs/elastic_proxy-jpNTIbJ1/lib/python3.7/sre_parse.py", line 1024, in parse_template
    raise s.error('bad escape %s' % this, len(this))
re.error: bad escape \d at position 10
(elastic_proxy-jpNTIbJ1) 

Managed to fix this by:

  1. pip install regex
  2. Adding import regex as re to the weppy/expose.py

There's more than likely a 'more correct' fix for this.

@gi0baro
Copy link
Member

gi0baro commented Sep 10, 2018

@gcmurphy oh. That sucks. I need to inspect what's changed in re module. This may take a while.

@gi0baro gi0baro added the bug label Sep 10, 2018
@gi0baro
Copy link
Member

gi0baro commented Sep 11, 2018

@gcmurphy current master should be fixed due to 244aab0

@gcmurphy
Copy link
Author

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants