Skip to content

Commit

Permalink
Update activate_this.py documentation to use runpy instead of exec (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
FredStober committed May 9, 2024
1 parent 4f8034c commit e28dfa7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/virtualenv/activation/python/activate_this.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""
Activate virtualenv for current interpreter:
Use exec(open(this_file).read(), {'__file__': this_file}).
import runpy
runpy.run_path(this_file)
This can be used when you must use an existing Python interpreter, not the virtualenv bin/python.
""" # noqa: D415
Expand All @@ -15,7 +16,7 @@
try:
abs_file = os.path.abspath(__file__)
except NameError as exc:
msg = "You must use exec(open(this_file).read(), {'__file__': this_file})"
msg = "You must use import runpy; runpy.run_path(this_file)"
raise AssertionError(msg) from exc

bin_dir = os.path.dirname(abs_file)
Expand Down

0 comments on commit e28dfa7

Please sign in to comment.