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

Regression in routing on Python 3.11.0b2: ValueError: line 1-0 is not a valid range #2425

Closed
mgorny opened this issue May 31, 2022 · 3 comments · Fixed by #2426
Closed

Regression in routing on Python 3.11.0b2: ValueError: line 1-0 is not a valid range #2425

mgorny opened this issue May 31, 2022 · 3 comments · Fixed by #2426
Milestone

Comments

@mgorny
Copy link
Contributor

mgorny commented May 31, 2022

After upgrading Python 3.11 to 3.11.0b2, the routing module seems to be broken. This is visible e.g. in werkzeug's tests. Example failure:

_____________________________________________ test_proxy_fix[ipv6 - port, host with port] _____________________________________________
tests/middleware/test_proxy_fix.py:183: in test_proxy_fix
    url_map = Map([Rule("/parrot", endpoint="parrot")])
.tox/py311/lib/python3.11/site-packages/werkzeug/routing.py:1505: in __init__
    self.add(rulefactory)
.tox/py311/lib/python3.11/site-packages/werkzeug/routing.py:1546: in add
    rule.bind(self)
.tox/py311/lib/python3.11/site-packages/werkzeug/routing.py:805: in bind
    self.compile()
.tox/py311/lib/python3.11/site-packages/werkzeug/routing.py:885: in compile
    self._build = self._compile_builder(False).__get__(self, None)
.tox/py311/lib/python3.11/site-packages/werkzeug/routing.py:1073: in _compile_builder
    code = compile(module, "<werkzeug routing>", "exec")
E   ValueError: line 1-0 is not a valid range

To reproduce:

  1. Install Python 3.11.0b2.
  2. tox -e py311

Environment:

  • Python version: 3.11.0b2
  • Werkzeug version: git main (bb21bf9)
@mgorny
Copy link
Contributor Author

mgorny commented Jun 1, 2022

FWIU now you need to set end_lineno along with lineno. I'm not sure if it's intentional, though.

@mgorny
Copy link
Contributor Author

mgorny commented Jun 1, 2022

FWICS it's python/cpython@5893b5d

Though pytest seems to be affected as well, so I don't really know how I managed to run tests yesterday.

@mgorny
Copy link
Contributor Author

mgorny commented Jun 1, 2022

Ah, there's more info on pytest-dev/pytest#10008. The tests can be run with --assert=plain to workaround pytest problem. FWICS upstream has also fixed this in CPython but I think that this particular issue is worth fixing in werkzeug too. I'll submit a PR shortly.

mgorny added a commit to mgorny/werkzeug that referenced this issue Jun 1, 2022
When setting the fallback values for lineno & col_offset, set them
also for end_lineno & end_col_offset.  This fixes a regression
in Python 3.11.0b2 where lineno without end_lineno would cause
an exception to be thrown.

Fixes pallets#2425
mgorny added a commit to mgorny/werkzeug that referenced this issue Jun 1, 2022
When setting the fallback values for lineno & col_offset, set them
also for end_lineno & end_col_offset.  This fixes a regression
in Python 3.11.0b2 where lineno without end_lineno would cause
an exception to be thrown.

Fixes pallets#2425
@davidism davidism added this to the 2.2.0 milestone Jul 2, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants