Skip to content

Commit

Permalink
Make pyspark shell pythonstartup work under python3
Browse files Browse the repository at this point in the history
This replaces the execfile used for running custom python shell scripts
with explicit open, compile and exec. The reason is to make the
pythonstartup option compatible with python3.
  • Loading branch information
erikselin committed Dec 10, 2015
1 parent 76540b6 commit 46975aa
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 46975aa

Please sign in to comment.