aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorErik Selin <erik.selin@gmail.com>2016-01-13 12:21:45 -0800
committerJosh Rosen <joshrosen@databricks.com>2016-01-13 12:21:45 -0800
commite4e0b3f7b2945aae5ec7c3d68296010bbc5160cf (patch)
tree80cbe3aced7a0267a49be99d9973d2dbc447577f /python
parent97e0c7c5af4d002937f9ee679568bb501d8818fc (diff)
downloadspark-e4e0b3f7b2945aae5ec7c3d68296010bbc5160cf.tar.gz
spark-e4e0b3f7b2945aae5ec7c3d68296010bbc5160cf.tar.bz2
spark-e4e0b3f7b2945aae5ec7c3d68296010bbc5160cf.zip
[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.
Diffstat (limited to 'python')
-rw-r--r--python/pyspark/shell.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/python/pyspark/shell.py b/python/pyspark/shell.py
index 99331297c1..26cafca8b8 100644
--- a/python/pyspark/shell.py
+++ b/python/pyspark/shell.py
@@ -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)