spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshro...@apache.org
Subject spark git commit: [SPARK-12268][PYSPARK] Make pyspark shell pythonstartup work under python3
Date Wed, 13 Jan 2016 20:22:05 GMT
Repository: spark
Updated Branches:
  refs/heads/master 97e0c7c5a -> e4e0b3f7b


[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.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/e4e0b3f7
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/e4e0b3f7
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/e4e0b3f7

Branch: refs/heads/master
Commit: e4e0b3f7b2945aae5ec7c3d68296010bbc5160cf
Parents: 97e0c7c
Author: Erik Selin <erik.selin@gmail.com>
Authored: Wed Jan 13 12:21:45 2016 -0800
Committer: Josh Rosen <joshrosen@databricks.com>
Committed: Wed Jan 13 12:21:45 2016 -0800

----------------------------------------------------------------------
 python/pyspark/shell.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/e4e0b3f7/python/pyspark/shell.py
----------------------------------------------------------------------
diff --git a/python/pyspark/shell.py b/python/pyspark/shell.py
index 9933129..26cafca 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)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org


Mime
View raw message