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

Fix SyntaxError on python 2.7.5 #1545

Merged
merged 1 commit into from May 15, 2019
Merged

Fix SyntaxError on python 2.7.5 #1545

merged 1 commit into from May 15, 2019

Conversation

asottile
Copy link
Contributor

Resolves #1544

Here's the test plan I used, since we can't install 2.7.5 in CI this'll have to do:

$ docker run --rm -ti -v "$PWD:/code:ro" centos:7
...
[root@9b75ddb7a51a code]# python -m compileall src/werkzeug/routing.py 
Compiling src/werkzeug/routing.py ...
SyntaxError: unqualified exec is not allowed in function '_compile_builder' it contains a nested function with free variables (routing.py, line 948)

    # outside of docker, I did `git apply patch` to get to the code you see in this PR

[root@9b75ddb7a51a code]# python -m compileall src/werkzeug/routing.py 
Compiling src/werkzeug/routing.py ...
Sorry [Errno 30] Read-only file system: 'src/werkzeug/routing.pyc'

@davidism
Copy link
Member

Would you retarget to 0.15.x?

Also, this seems to break the tests.

tests/test_routing.py:29: in test_basic_routing
    r.Rule("/bar/", endpoint="bar"),
.tox/py/lib/python3.7/site-packages/werkzeug/routing.py:1347: in __init__
    self.add(rulefactory)
.tox/py/lib/python3.7/site-packages/werkzeug/routing.py:1388: in add
    rule.bind(self)
.tox/py/lib/python3.7/site-packages/werkzeug/routing.py:730: in bind
    self.compile()
.tox/py/lib/python3.7/site-packages/werkzeug/routing.py:794: in compile
    self._build = self._compile_builder(False).__get__(self, None)
.tox/py/lib/python3.7/site-packages/werkzeug/routing.py:952: in _compile_builder
    return self._get_func_code(code, func_ast.name)
.tox/py/lib/python3.7/site-packages/werkzeug/routing.py:859: in _get_func_code
    return locs[name]
E   KeyError: "<builder:'/'>"

@asottile asottile changed the base branch from master to 0.15.x May 15, 2019 01:29
@asottile
Copy link
Contributor Author

Would you retarget to 0.15.x?

Also, this seems to break the tests.

tests/test_routing.py:29: in test_basic_routing
    r.Rule("/bar/", endpoint="bar"),
.tox/py/lib/python3.7/site-packages/werkzeug/routing.py:1347: in __init__
    self.add(rulefactory)
.tox/py/lib/python3.7/site-packages/werkzeug/routing.py:1388: in add
    rule.bind(self)
.tox/py/lib/python3.7/site-packages/werkzeug/routing.py:730: in bind
    self.compile()
.tox/py/lib/python3.7/site-packages/werkzeug/routing.py:794: in compile
    self._build = self._compile_builder(False).__get__(self, None)
.tox/py/lib/python3.7/site-packages/werkzeug/routing.py:952: in _compile_builder
    return self._get_func_code(code, func_ast.name)
.tox/py/lib/python3.7/site-packages/werkzeug/routing.py:859: in _get_func_code
    return locs[name]
E   KeyError: "<builder:'/'>"

lol oops, transposed globs and locs while copying the code 🤦‍♂

@davidism
Copy link
Member

I was trying to spot the difference 😆

@davidism
Copy link
Member

You'll need to git rebase --onto origin/0.15.x master, changing the base here isn't enough.

@asottile
Copy link
Contributor Author

fixed my rebase too -- oops, I'm sick and not thinking super straight

@davidism davidism added this to the 0.15.4 milestone May 15, 2019
@davidism davidism merged commit 9f842ca into pallets:0.15.x May 15, 2019
@davidism
Copy link
Member

Thanks for the quick fix!

@asottile asottile deleted the exec_syntaxerror branch May 15, 2019 01:41
@asottile
Copy link
Contributor Author

No problem! Ya learn some archaic fact every day I guess 😆

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants