Skip to content

Commit

Permalink
[SPARK-12268][PYSPARK] Make pyspark shell pythonstartup work under py…
Browse files Browse the repository at this point in the history
…thon3

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 apache#10255 from tyro89/pythonstartup-python3.
  • Loading branch information
erikselin authored and JoshRosen committed Jan 13, 2016
1 parent 97e0c7c commit e4e0b3f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion python/pyspark/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,6 @@
# 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 comments on commit e4e0b3f

Please sign in to comment.