summaryrefslogtreecommitdiff
path: root/setuptools/sandbox.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2016-12-18 11:51:19 -0500
committerJason R. Coombs <jaraco@jaraco.com>2016-12-18 11:51:19 -0500
commitcd2a519c6592d90e8658a5e90d8b0342d08b9ae9 (patch)
tree7c0633eed02d450ca25529d78095deb7522d0b00 /setuptools/sandbox.py
parent6c6f4caa4bacce4b719b1e03fb02fdb857b1a135 (diff)
downloadpython-setuptools-git-issue-704.tar.gz
In sandbox.run_setup, always ensure that __file__ is str. Fixes #712.issue-704
Diffstat (limited to 'setuptools/sandbox.py')
-rwxr-xr-xsetuptools/sandbox.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/setuptools/sandbox.py b/setuptools/sandbox.py
index d882d715..817a3afa 100755
--- a/setuptools/sandbox.py
+++ b/setuptools/sandbox.py
@@ -241,8 +241,15 @@ def run_setup(setup_script, args):
working_set.__init__()
working_set.callbacks.append(lambda dist: dist.activate())
+ # __file__ should be a byte string on Python 2 (#712)
+ dunder_file = (
+ setup_script
+ if isinstance(setup_script, str) else
+ setup_script.encode(sys.getfilesystemencoding())
+ )
+
def runner():
- ns = dict(__file__=setup_script, __name__='__main__')
+ ns = dict(__file__=dunder_file, __name__='__main__')
_execfile(setup_script, ns)
DirectorySandbox(setup_dir).run(runner)