Commit cd2a519c authored by Jason R. Coombs's avatar Jason R. Coombs

In sandbox.run_setup, always ensure that __file__ is str. Fixes #712.

parent 6c6f4caa
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment