mirror of
https://github.com/zulip/zulip.git
synced 2025-11-21 15:09:34 +00:00
scripts: Fix exec invocation for in-process virtualenv activation.
activate_this.py has always documented that it should be exec()ed with
locals = globals, and in virtualenv 16.0.0 it raises a NameError
otherwise.
As a simplified demonstration of the weird things that can go wrong
when locals ≠ globals:
>>> exec('a = 1; print([a])', {}, {})
[1]
>>> exec('a = 1; print([a for b in [1]])', {}, {})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1, in <module>
File "<string>", line 1, in <listcomp>
NameError: name 'a' is not defined
>>> exec('a = 1; print([a for b in [1]])', {})
[1]
Top-level assignments go into locals, but from inside a new scope like
a list comprehension, they’re read out of globals, which doesn’t work.
Fixes #12030.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
committed by
Tim Abbott
parent
6f2903dd29
commit
d9a1617d00
@@ -393,7 +393,7 @@ def main(options):
|
||||
setup_venvs.main()
|
||||
|
||||
activate_this = "/srv/zulip-py3-venv/bin/activate_this.py"
|
||||
exec(open(activate_this).read(), {}, dict(__file__=activate_this))
|
||||
exec(open(activate_this).read(), dict(__file__=activate_this))
|
||||
|
||||
setup_shell_profile('~/.bash_profile')
|
||||
setup_shell_profile('~/.zprofile')
|
||||
|
||||
Reference in New Issue
Block a user