Skip to content
Snippets Groups Projects
Commit e4e0b3f7 authored by Erik Selin's avatar Erik Selin Committed by Josh Rosen
Browse files

[SPARK-12268][PYSPARK] Make pyspark shell pythonstartup work under python3

This replaces the `execfile` used for running custom python shell scripts
with explicit open, compile and exec (as recommended by 2to3). The reason
for this change is to make the pythonstartup option compatible with python3.

Author: Erik Selin <erik.selin@gmail.com>

Closes #10255 from tyro89/pythonstartup-python3.
parent 97e0c7c5
No related branches found
No related tags found
No related merge requests found
......@@ -76,4 +76,6 @@ if add_files is not None:
# which allows us to execute the user's PYTHONSTARTUP file:
_pythonstartup = os.environ.get('OLD_PYTHONSTARTUP')
if _pythonstartup and os.path.isfile(_pythonstartup):
execfile(_pythonstartup)
with open(_pythonstartup) as f:
code = compile(f.read(), _pythonstartup, 'exec')
exec(code)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment