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

aiohttp webserver with python 3.7 broken #1839

Closed
wumpus opened this issue Apr 23, 2017 · 10 comments
Closed

aiohttp webserver with python 3.7 broken #1839

wumpus opened this issue Apr 23, 2017 · 10 comments
Assignees
Labels

Comments

@wumpus
Copy link

wumpus commented Apr 23, 2017

I have python3.7-dev and python-nightly in my CI script. Recently they started failing when I call app.router.add_get()

This is a minimal reproducer, works on 3.6 and fails on 3.7-dev

import re

r = re.compile(re.escape('/foo'))
print(r)
print(r.pattern)
assert r.pattern.startswith('\\/')

Python 3.7-dev output:

re.compile('/foo')
/foo
Traceback (most recent call last):
 File "aiohttp-issue.py", line 6, in <module>
   assert r.pattern.startswith('\\/')
AssertionError

python 3.6.0 output (success):

re.compile('\\/foo')
\/foo

This is the actual traceback my full app gets in 3.7-dev and aiohttp-2.0.7:

Traceback (most recent call last):
  File "../scripts/crawl.py", line 89, in <module>
    main()
  File "../scripts/crawl.py", line 67, in main
    app = webserver.make_app(loop, config)
  File "/home/travis/build/cocrawler/cocrawler/cocrawler/webserver.py", line 16, in make_app
    app.router.add_get('/api/{name}', api)
  File "/home/travis/virtualenv/python3.7-dev/lib/python3.7/site-packages/aiohttp/web_urldispatcher.py", line 865, in add_get
    self.add_route(hdrs.METH_HEAD, *args, name=head_name, **kwargs)
  File "/home/travis/virtualenv/python3.7-dev/lib/python3.7/site-packages/aiohttp/web_urldispatcher.py", line 823, in add_rout
    resource = self.add_resource(path, name=name)
  File "/home/travis/virtualenv/python3.7-dev/lib/python3.7/site-packages/aiohttp/web_urldispatcher.py", line 817, in add_resource
    resource = DynamicResource(compiled, formatter, name=name)
  File "/home/travis/virtualenv/python3.7-dev/lib/python3.7/site-packages/aiohttp/web_urldispatcher.py", line 332, in __init__
    assert pattern.pattern.startswith('\\/')
AssertionError

Your environment

The above 3.6 and 3.7 output was run on CentOS 7 with python installed by pyenv.

@fafhrd91
Copy link
Member

That's seems like regression in cpython.

@wumpus
Copy link
Author

wumpus commented Apr 23, 2017

Oh, right, I didn't check the documentation for "re" -- after looking at compiled.pattern I think you're correct.

@wumpus wumpus closed this as completed Apr 23, 2017
@wumpus
Copy link
Author

wumpus commented Apr 23, 2017

@wumpus
Copy link
Author

wumpus commented Apr 23, 2017

The python folks say that re.escape() was escaping too much in the past, and has been fixed. Their response to my bug report was to add more documentation to "porting to 3.7".

http://bugs.python.org/issue29995 -- bug for re.escape over-escaping

http://bugs.python.org/issue30147 -- my bug report

So, basically, they say your test is now wrong.

@wumpus wumpus reopened this Apr 23, 2017
@fafhrd91
Copy link
Member

does it work with "python -OO "?

@wumpus
Copy link
Author

wumpus commented Apr 28, 2017

Yes, python 3.7-dev passes with "python -OO". Which is pretty weird.

$ pyenv local 3.7-dev
$ python bug.py
re.compile('/foo')
/foo
Traceback (most recent call last):
  File "bug.py", line 6, in <module>
    assert r.pattern.startswith('\\/')
AssertionError
$ python -OO bug.py
re.compile('/foo')
/foo

@fafhrd91
Copy link
Member

but does web server work?

@fafhrd91
Copy link
Member

@asvetlov could you look into this problem too?

@asvetlov
Copy link
Member

@wumpus thanks for raising the issue

asvetlov pushed a commit that referenced this issue May 22, 2017
…eme and host resolution (#1881)

* #1134 Support X-Forwarded-* and Forwarded implicitly

* #1134 tests

* added myself to contributors

* added line to changes.rst

* Update CHANGES.rst

* Update CHANGES.rst

* deprecating secure_proxy_ssl_header

* more extensive Forwarded parsing

* flake

* make isort with new parameters

* Fix #1839: python 3.7 regression for regexp escaping (#1908)

* Fix #1839: python 3.7 regression for regexp escaping

* Fix import sort order

* small changes

* unpacking tuple implicit

* #1134 Support X-Forwarded-* and Forwarded implicitly

* #1134 tests

* added myself to contributors

* added line to changes.rst

* deprecating secure_proxy_ssl_header

* more extensive Forwarded parsing

* flake

* small changes

* unpacking tuple implicit

* handling multiple field-values, fixed quoted-pair bug (now using vchar instead of tchar), changed return type of forwarded
@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants